@p11-core/cli 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3519,7 +3519,7 @@ var cliPackageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)),
3519
3519
  var docsTopics = /* @__PURE__ */ new Map([
3520
3520
  ["index", "docs/index.md"],
3521
3521
  ["components", "docs/components.md"],
3522
- ["publishing", "docs/publishing.md"]
3522
+ ["sharing", "docs/sharing.md"]
3523
3523
  ]);
3524
3524
  var exampleFiles = /* @__PURE__ */ new Map([["all-components", "examples/all-components.tsx"]]);
3525
3525
  var allowedDocumentComponents = /* @__PURE__ */ new Set([
@@ -3628,9 +3628,13 @@ async function main() {
3628
3628
  if (!isKnownTopLevelCommand(program2, command)) throw new Error(`Unknown command: ${command}`);
3629
3629
  await program2.parseAsync(process.argv);
3630
3630
  }
3631
- function createCliProgram() {
3631
+ function createCliProgram(options = {}) {
3632
3632
  const program2 = new Command();
3633
- program2.name("p11").description("Publish and inspect p11 document pages.");
3633
+ const warnBeforeAction = options.warnIfUpdateAvailable ?? warnIfUpdateAvailable;
3634
+ program2.name("p11").description("Share and inspect p11 document pages.");
3635
+ program2.hook("preAction", async () => {
3636
+ await warnBeforeAction();
3637
+ });
3634
3638
  program2.addHelpText(
3635
3639
  "after",
3636
3640
  `
@@ -3638,25 +3642,23 @@ function createCliProgram() {
3638
3642
  Environment:
3639
3643
  P11_API_URL Defaults to ${builtDefaultApiUrl}`
3640
3644
  );
3641
- const publishCommand = program2.command("publish").description("Publish a page module.").argument("[page.tsx]").option("--json", "Print the API response as JSON.").option("--edit-url [url]", "Update an existing page using an edit URL or edit id.").option("--api-url [url]", "Override the p11 API URL.").action(async (input, options) => {
3642
- await warnIfUpdateAvailable();
3643
- await publish(input, normalizePublishOptions(options));
3645
+ const shareCommand = program2.command("share").description("Share a review link for a page.").argument("[page.tsx]").option("--json", "Print the API response as JSON.").option("--edit-url [url]", "Share a new version using an edit URL or edit id.").option("--api-url [url]", "Override the p11 API URL.").action(async (input, options2) => {
3646
+ await publish(input, normalizePublishOptions(options2));
3644
3647
  });
3645
- allowLegacyParserBehavior(publishCommand);
3646
- const commentsCommand = program2.command("comments").description("Fetch exported comments for a read/edit URL or id.").argument("[readUrl|editUrl|readId|editId]").option("--json", "Print comments as JSON.").option("--output [file]", "Write comments JSON to a file.").option("--version [n]", "Fetch comments for a specific page version.").option("--api-url [url]", "Override the p11 API URL.").action(async (target, options) => {
3647
- await warnIfUpdateAvailable();
3648
- await comments(target, normalizeCommentsOptions(options));
3648
+ allowLegacyParserBehavior(shareCommand);
3649
+ const commentsCommand = program2.command("comments").description("Fetch exported comments for a read/edit URL or id.").argument("[readUrl|editUrl|readId|editId]").option("--json", "Print comments as JSON.").option("--output [file]", "Write comments JSON to a file.").option("--version [n]", "Fetch comments for a specific page version.").option("--api-url [url]", "Override the p11 API URL.").action(async (target, options2) => {
3650
+ await comments(target, normalizeCommentsOptions(options2));
3649
3651
  });
3650
3652
  allowLegacyParserBehavior(commentsCommand);
3651
- program2.command("history").description("List saved publish read/edit URLs.").option("--json", "Print saved history as JSON.").action(async (options) => {
3652
- await history(normalizeHistoryOptions(options));
3653
+ program2.command("history").description("List saved read/edit links.").option("--json", "Print saved history as JSON.").action(async (options2) => {
3654
+ await history(normalizeHistoryOptions(options2));
3653
3655
  });
3654
- const docsCommand = program2.command("docs").description("Print p11 authoring docs.").argument("[topic]", "Docs topic: components or publishing.").action(async (topic) => {
3656
+ const docsCommand = program2.command("docs").description("Print p11 authoring docs.").argument("[topic]", "Docs topic: components or sharing.").action(async (topic) => {
3655
3657
  await docs(topic);
3656
3658
  });
3657
3659
  allowLegacyParserBehavior(docsCommand);
3658
- const exampleCommand = program2.command("example").description("Print or write a p11 example document.").argument("[name]", "Example name: all-components.").option("--output [file]", "Write the example to a file.").action(async (name, options) => {
3659
- await example(name, normalizeExampleOptions(options));
3660
+ const exampleCommand = program2.command("example").description("Print or write a p11 example document.").argument("[name]", "Example name: all-components.").option("--output [file]", "Write the example to a file.").action(async (name, options2) => {
3661
+ await example(name, normalizeExampleOptions(options2));
3660
3662
  });
3661
3663
  allowLegacyParserBehavior(exampleCommand);
3662
3664
  return program2;
@@ -3697,15 +3699,15 @@ function optionString(value, missingValueMessage) {
3697
3699
  return typeof value === "string" ? value : void 0;
3698
3700
  }
3699
3701
  async function publish(input, options) {
3700
- if (!input) throw new Error("Usage: p11 publish <page.tsx> [--json] [--edit-url URL]");
3702
+ if (!input) throw new Error("Usage: p11 share <page.tsx> [--json] [--edit-url URL]");
3701
3703
  const resolvedInput = path.resolve(input);
3702
3704
  const inputStat = await stat(resolvedInput).catch(() => null);
3703
3705
  if (!inputStat) throw new Error(`Path does not exist: ${input}`);
3704
3706
  if (!inputStat.isFile()) {
3705
- throw new Error("Input must be a .tsx, .jsx, .ts, or .js page module.");
3707
+ throw new Error("Input must be a .tsx, .jsx, .ts, or .js page file.");
3706
3708
  }
3707
3709
  if (!/\.[cm]?[tj]sx?$/.test(resolvedInput)) {
3708
- throw new Error("File input must be a .tsx, .jsx, .ts, or .js page module.");
3710
+ throw new Error("File input must be a .tsx, .jsx, .ts, or .js page file.");
3709
3711
  }
3710
3712
  const cleanupDir = await mkdtemp(path.join(process.cwd(), ".p11-build-"));
3711
3713
  const distDir = path.join(cleanupDir, "dist");
@@ -3728,14 +3730,14 @@ async function publish(input, options) {
3728
3730
  });
3729
3731
  const text = await response.text();
3730
3732
  if (!response.ok) {
3731
- throw new Error(`Publish failed (${response.status}): ${responseErrorMessage(text)}`);
3733
+ throw new Error(`Share failed (${response.status}): ${responseErrorMessage(text)}`);
3732
3734
  }
3733
3735
  const data = JSON.parse(text);
3734
3736
  await appendPublishHistory(data, {
3735
3737
  apiUrl,
3736
3738
  source: resolvedInput
3737
3739
  }).catch((error) => {
3738
- console.error(`Warning: published, but could not save history: ${errorMessage(error)}`);
3740
+ console.error(`Warning: shared, but could not save history: ${errorMessage(error)}`);
3739
3741
  });
3740
3742
  if (options.json) {
3741
3743
  console.log(JSON.stringify(data, null, 2));
@@ -3765,7 +3767,7 @@ async function docs(topic) {
3765
3767
  const normalizedTopic = topic ?? "index";
3766
3768
  const relativePath = docsTopics.get(normalizedTopic);
3767
3769
  if (!relativePath) {
3768
- throw new Error(`Unknown docs topic: ${normalizedTopic}. Available topics: components, publishing`);
3770
+ throw new Error(`Unknown docs topic: ${normalizedTopic}. Available topics: components, sharing`);
3769
3771
  }
3770
3772
  process.stdout.write(await readCliAsset(relativePath));
3771
3773
  }
@@ -3903,7 +3905,7 @@ async function removeStaleHistoryLock(lockDir) {
3903
3905
  }
3904
3906
  function printHistory(entries, limit) {
3905
3907
  if (entries.length === 0) {
3906
- console.log(`No history yet. Publish a document to create ${historyFilePath()}.`);
3908
+ console.log(`No history yet. Share a document to create ${historyFilePath()}.`);
3907
3909
  return;
3908
3910
  }
3909
3911
  const displayEntries = entries.slice(-limit).reverse();
@@ -4432,6 +4434,7 @@ export {
4432
4434
  buildPageModule,
4433
4435
  commentsApiUrlForTarget,
4434
4436
  commentsExportJson,
4437
+ createCliProgram,
4435
4438
  isNewerVersion,
4436
4439
  parseCommentsTarget,
4437
4440
  parseEditId,
@@ -1,6 +1,6 @@
1
1
  # p11 Components
2
2
 
3
- p11 documents are React modules that export a default component and import document-safe components from `@p11-core/components`.
3
+ p11 documents are React files that export a default component and import document-safe components from `@p11-core/components`.
4
4
 
5
5
  ## Minimal Document
6
6
 
@@ -76,7 +76,7 @@ Supported languages include TypeScript, JavaScript, Python, Rust, HTML/XML, CSS,
76
76
 
77
77
  ## Validation
78
78
 
79
- `p11 publish` validates the document before build and upload.
79
+ `p11 share` validates the document before build and upload.
80
80
 
81
81
  Do not import or render app/control components such as:
82
82
 
package/docs/index.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # p11 CLI Docs
2
2
 
3
- p11 publishes reviewable, public-but-unlisted document pages from React document modules.
3
+ p11 shares reviewable, public-but-unlisted document pages from React files.
4
4
 
5
5
  ## Common Commands
6
6
 
7
7
  ```bash
8
- p11 publish <page.tsx>
9
- p11 publish <page.tsx> --edit-url <editUrl>
8
+ p11 share <page.tsx>
9
+ p11 share <page.tsx> --edit-url <editUrl>
10
10
  p11 history
11
11
  p11 comments <readUrl|editUrl|readId|editId>
12
12
  ```
@@ -17,7 +17,7 @@ Add `--json` when scripting or when exact structured fields are needed.
17
17
 
18
18
  ```bash
19
19
  p11 docs components
20
- p11 docs publishing
20
+ p11 docs sharing
21
21
  ```
22
22
 
23
23
  ## Examples
@@ -28,4 +28,4 @@ p11 example all-components
28
28
  p11 example all-components --output ./all-components.tsx
29
29
  ```
30
30
 
31
- Use `p11 publish --help`, `p11 comments --help`, and `p11 history --help` for command-specific flags.
31
+ Use `p11 share --help`, `p11 comments --help`, and `p11 history --help` for command-specific flags.
@@ -1,18 +1,18 @@
1
- # p11 Publishing
1
+ # p11 Sharing
2
2
 
3
- Publish a document module:
3
+ Share a review link for a document:
4
4
 
5
5
  ```bash
6
- p11 publish ./page.tsx
6
+ p11 share ./page.tsx
7
7
  ```
8
8
 
9
- Update an existing document with an edit URL or edit id:
9
+ Share a new version with an edit URL or edit id:
10
10
 
11
11
  ```bash
12
- p11 publish ./page.tsx --edit-url <editUrl>
12
+ p11 share ./page.tsx --edit-url <editUrl>
13
13
  ```
14
14
 
15
- Fetch recent local publish history:
15
+ Fetch recent local share history:
16
16
 
17
17
  ```bash
18
18
  p11 history
@@ -46,7 +46,7 @@ export default function All() {
46
46
  <Quote>
47
47
  The page is intentionally broad: authors can use it to inspect
48
48
  screen layout, print pagination, source-line anchors, tables,
49
- figures, and syntax highlighting in one published document.
49
+ figures, and syntax highlighting in one shared document.
50
50
  </Quote>
51
51
  </Section>
52
52
 
@@ -76,7 +76,7 @@ export default function All() {
76
76
  Unordered lists work for parallel facts and short capabilities.
77
77
  </Text>
78
78
  <List>
79
- <ListItem>Publish static React-authored documents.</ListItem>
79
+ <ListItem>Share static React-authored documents.</ListItem>
80
80
  <ListItem>Allow anonymous comments on text selections.</ListItem>
81
81
  <ListItem>
82
82
  Export comments with source file and line anchors.
@@ -84,8 +84,8 @@ export default function All() {
84
84
  </List>
85
85
  <Text>Ordered lists work for procedural steps.</Text>
86
86
  <List ordered>
87
- <ListItem>Author a document module.</ListItem>
88
- <ListItem>Publish it with the CLI.</ListItem>
87
+ <ListItem>Author a document file.</ListItem>
88
+ <ListItem>Share it with the CLI.</ListItem>
89
89
  <ListItem>
90
90
  Review the screen view and browser print output.
91
91
  </ListItem>
@@ -166,12 +166,12 @@ export default function All() {
166
166
  <Heading>6. TypeScript</Heading>
167
167
  <CodeBlock language="typescript">
168
168
  {code`
169
- type PublishOptions = {
169
+ type ShareOptions = {
170
170
  input: string;
171
171
  comments?: boolean;
172
172
  };
173
173
 
174
- export async function publish(options: PublishOptions) {
174
+ export async function share(options: ShareOptions) {
175
175
  const response = await fetch("/api/pages", {
176
176
  method: "POST",
177
177
  body: JSON.stringify(options)
@@ -307,7 +307,7 @@ export default function All() {
307
307
  <Heading>14. Bash</Heading>
308
308
  <CodeBlock language="bash">
309
309
  {code`
310
- p11 publish ./all-components.tsx
310
+ p11 share ./all-components.tsx
311
311
  p11 comments <readUrl> --version 1
312
312
  `}
313
313
  </CodeBlock>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@p11-core/cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "bin": {