@p11-core/cli 0.0.1 → 0.0.2
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 +17 -7
- package/docs/components.md +2 -2
- package/docs/index.md +2 -2
- package/docs/publishing.md +1 -1
- package/examples/all-components.tsx +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3466,11 +3466,12 @@ var require_commander = __commonJS({
|
|
|
3466
3466
|
});
|
|
3467
3467
|
|
|
3468
3468
|
// src/index.ts
|
|
3469
|
+
import { realpathSync } from "fs";
|
|
3469
3470
|
import { chmod, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from "fs/promises";
|
|
3470
3471
|
import { createRequire } from "module";
|
|
3471
3472
|
import { homedir } from "os";
|
|
3472
3473
|
import path from "path";
|
|
3473
|
-
import { fileURLToPath
|
|
3474
|
+
import { fileURLToPath } from "url";
|
|
3474
3475
|
import process from "process";
|
|
3475
3476
|
import { zipSync } from "fflate";
|
|
3476
3477
|
import * as parser from "@babel/parser";
|
|
@@ -3602,12 +3603,21 @@ var commentableNativeTags = /* @__PURE__ */ new Set([
|
|
|
3602
3603
|
var P11_CODE_SOURCE_LINE_ATTRIBUTE = "data-p11-code-source-line";
|
|
3603
3604
|
var P11_SOURCE_FILE_ATTRIBUTE = "data-p11-source-file";
|
|
3604
3605
|
var P11_SOURCE_LINE_ATTRIBUTE = "data-p11-source-line";
|
|
3605
|
-
if (
|
|
3606
|
+
if (isCliEntrypoint()) {
|
|
3606
3607
|
main().catch((error) => {
|
|
3607
3608
|
console.error(error instanceof Error ? error.message : String(error));
|
|
3608
3609
|
process.exit(1);
|
|
3609
3610
|
});
|
|
3610
3611
|
}
|
|
3612
|
+
function isCliEntrypoint() {
|
|
3613
|
+
if (!process.argv[1]) return false;
|
|
3614
|
+
const modulePath = fileURLToPath(import.meta.url);
|
|
3615
|
+
try {
|
|
3616
|
+
return realpathSync(process.argv[1]) === realpathSync(modulePath);
|
|
3617
|
+
} catch {
|
|
3618
|
+
return path.resolve(process.argv[1]) === modulePath;
|
|
3619
|
+
}
|
|
3620
|
+
}
|
|
3611
3621
|
async function main() {
|
|
3612
3622
|
const program2 = createCliProgram();
|
|
3613
3623
|
if (process.argv.length <= 2) {
|
|
@@ -3620,7 +3630,7 @@ async function main() {
|
|
|
3620
3630
|
}
|
|
3621
3631
|
function createCliProgram() {
|
|
3622
3632
|
const program2 = new Command();
|
|
3623
|
-
program2.name("p11").description("Publish and inspect
|
|
3633
|
+
program2.name("p11").description("Publish and inspect p11 document pages.");
|
|
3624
3634
|
program2.addHelpText(
|
|
3625
3635
|
"after",
|
|
3626
3636
|
`
|
|
@@ -3628,12 +3638,12 @@ function createCliProgram() {
|
|
|
3628
3638
|
Environment:
|
|
3629
3639
|
P11_API_URL Defaults to ${builtDefaultApiUrl}`
|
|
3630
3640
|
);
|
|
3631
|
-
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
|
|
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) => {
|
|
3632
3642
|
await warnIfUpdateAvailable();
|
|
3633
3643
|
await publish(input, normalizePublishOptions(options));
|
|
3634
3644
|
});
|
|
3635
3645
|
allowLegacyParserBehavior(publishCommand);
|
|
3636
|
-
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
|
|
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) => {
|
|
3637
3647
|
await warnIfUpdateAvailable();
|
|
3638
3648
|
await comments(target, normalizeCommentsOptions(options));
|
|
3639
3649
|
});
|
|
@@ -3641,11 +3651,11 @@ Environment:
|
|
|
3641
3651
|
program2.command("history").description("List saved publish read/edit URLs.").option("--json", "Print saved history as JSON.").action(async (options) => {
|
|
3642
3652
|
await history(normalizeHistoryOptions(options));
|
|
3643
3653
|
});
|
|
3644
|
-
const docsCommand = program2.command("docs").description("Print
|
|
3654
|
+
const docsCommand = program2.command("docs").description("Print p11 authoring docs.").argument("[topic]", "Docs topic: components or publishing.").action(async (topic) => {
|
|
3645
3655
|
await docs(topic);
|
|
3646
3656
|
});
|
|
3647
3657
|
allowLegacyParserBehavior(docsCommand);
|
|
3648
|
-
const exampleCommand = program2.command("example").description("Print or write a
|
|
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) => {
|
|
3649
3659
|
await example(name, normalizeExampleOptions(options));
|
|
3650
3660
|
});
|
|
3651
3661
|
allowLegacyParserBehavior(exampleCommand);
|
package/docs/components.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# p11 Components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
p11 documents are React modules that export a default component and import document-safe components from `@p11-core/components`.
|
|
4
4
|
|
|
5
5
|
## Minimal Document
|
|
6
6
|
|
package/docs/index.md
CHANGED
package/docs/publishing.md
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from "@p11-core/components";
|
|
27
27
|
|
|
28
28
|
const figureSrc =
|
|
29
|
-
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 720 240'%3E%3Crect width='720' height='240' fill='%23f8fafc'/%3E%3Cpath d='M80 172h560' stroke='%23d4d4d8' stroke-width='2'/%3E%3Ccircle cx='160' cy='132' r='42' fill='%2318181b'/%3E%3Crect x='260' y='92' width='120' height='80' rx='8' fill='%2352525b'/%3E%3Cpath d='M460 172 540 72l80 100z' fill='%2371717a'/%3E%3Ctext x='80' y='52' font-family='Inter, Arial' font-size='28' font-weight='700' fill='%2318181b'%
|
|
29
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 720 240'%3E%3Crect width='720' height='240' fill='%23f8fafc'/%3E%3Cpath d='M80 172h560' stroke='%23d4d4d8' stroke-width='2'/%3E%3Ccircle cx='160' cy='132' r='42' fill='%2318181b'/%3E%3Crect x='260' y='92' width='120' height='80' rx='8' fill='%2352525b'/%3E%3Cpath d='M460 172 540 72l80 100z' fill='%2371717a'/%3E%3Ctext x='80' y='52' font-family='Inter, Arial' font-size='28' font-weight='700' fill='%2318181b'%3Ep11 document figure%3C/text%3E%3C/svg%3E";
|
|
30
30
|
|
|
31
31
|
export default function All() {
|
|
32
32
|
return (
|
|
@@ -149,7 +149,7 @@ export default function All() {
|
|
|
149
149
|
<Figure>
|
|
150
150
|
<img
|
|
151
151
|
src={figureSrc}
|
|
152
|
-
alt="Abstract
|
|
152
|
+
alt="Abstract p11 document figure with simple geometric marks"
|
|
153
153
|
/>
|
|
154
154
|
<Caption>
|
|
155
155
|
Figure 1. Figure and Caption components keep visual evidence with
|