@addorimprove/prompt 0.2.0 → 0.3.1
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/prompt.js +31 -0
- package/package.json +1 -1
package/dist/prompt.js
CHANGED
|
@@ -108,6 +108,9 @@ class ApiClient {
|
|
|
108
108
|
addVersion(id, body) {
|
|
109
109
|
return this.request("POST", `/docs/${id}/versions`, body);
|
|
110
110
|
}
|
|
111
|
+
setVisibility(id, label, isPublic) {
|
|
112
|
+
return this.request("PATCH", `/docs/${id}/versions/${encodeURIComponent(label)}`, { isPublic });
|
|
113
|
+
}
|
|
111
114
|
deleteCurrentKey() {
|
|
112
115
|
return this.request("DELETE", "/keys/current");
|
|
113
116
|
}
|
|
@@ -515,6 +518,32 @@ ${doc.latest?.content ?? "(no versions)"}`);
|
|
|
515
518
|
const r = await client.addVersion(id, { intent: "branch", parentLabel: parent, content, ...format ? { format } : {} });
|
|
516
519
|
return out(json, r, `Branched → ${r.label}.`);
|
|
517
520
|
}
|
|
521
|
+
case "visibility": {
|
|
522
|
+
const client = requireClient(args.flags);
|
|
523
|
+
if (!client)
|
|
524
|
+
return;
|
|
525
|
+
const id = Number(args.positionals[0]);
|
|
526
|
+
const label = args.positionals[1];
|
|
527
|
+
const state = args.positionals[2];
|
|
528
|
+
if (!Number.isInteger(id) || !label || state !== "public" && state !== "private") {
|
|
529
|
+
console.error("usage: prompt visibility <id> <label> public|private");
|
|
530
|
+
process.exitCode = 1;
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const isPublic = state === "public";
|
|
534
|
+
if (!flags(args, "yes") && !flags(args, "y") && !await confirm(`Set ${id} ${label} → ${state}?`)) {
|
|
535
|
+
console.log("Aborted.");
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
const r = await client.setVisibility(id, label, isPublic);
|
|
539
|
+
if (json) {
|
|
540
|
+
return out(json, r, "");
|
|
541
|
+
}
|
|
542
|
+
console.log(`${id} ${label} → ${r.isPublic ? "public" : "private"}.`);
|
|
543
|
+
if (r.isPublic && r.publicUrl)
|
|
544
|
+
console.log(`Short link: ${r.publicUrl}`);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
518
547
|
case "help":
|
|
519
548
|
default:
|
|
520
549
|
console.log(HELP);
|
|
@@ -538,6 +567,8 @@ Usage: prompt <command> [args] [flags] (or: npx @addorimprove/prompt <command>
|
|
|
538
567
|
new --name <n> [-f file] [--format mdx|html] Create a document
|
|
539
568
|
iterate <id> [--parent label] [-f file] Add a version on the same line
|
|
540
569
|
branch <id> <parentLabel> [-f file] Fork a new line from a version
|
|
570
|
+
visibility <id> <label> public|private Publish/unpublish a version
|
|
571
|
+
On --public, prints a /public/{slug} short link.
|
|
541
572
|
(omit --format to auto-detect mdx/html from content)
|
|
542
573
|
|
|
543
574
|
Global flags: --base-url <url>, --json, -y/--yes
|