bikeshed-now 0.2.0 → 0.3.0

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/README.md CHANGED
@@ -34,6 +34,16 @@ Publishing identical bytes is a no-op: the bundle is hashed, and a matching hash
34
34
  mints no new version. So `update` is safe in a loop, in CI, or after a change you
35
35
  are not sure you made.
36
36
 
37
+ The address comes from the title. To choose it, pass `--id`:
38
+
39
+ ```bash
40
+ bikeshed publish platform.md --id 01-platform
41
+ # published 01-platform v1 — https://<deployment>/d/01-platform
42
+ ```
43
+
44
+ If the id is taken, the document is still published, at the id plus a few
45
+ random characters, and the CLI says so on stderr.
46
+
37
47
  `bikeshed --help` lists the rest — listing documents, folders, and installing the
38
48
  agent skills a deployment serves.
39
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bikeshed-now",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Publish and revise documents on a Bikeshed deployment from the terminal.",
package/src/client.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  import { readFileSync } from "node:fs";
5
5
  import { basename } from "node:path";
6
6
 
7
- export const CLIENT_NAME = "bikeshed-cli/0.2.0";
7
+ export const CLIENT_NAME = "bikeshed-cli/0.3.0";
8
8
 
9
9
  /**
10
10
  * Two surfaces, and the split is deliberate rather than untidy.
@@ -80,11 +80,12 @@ export async function callTool(origin, token, name, args = {}) {
80
80
  }
81
81
 
82
82
  /** Upload a file as a NEW document, exactly as the browser uploader does. */
83
- export async function uploadFile(origin, token, path, { title, folder } = {}) {
83
+ export async function uploadFile(origin, token, path, { title, folder, id } = {}) {
84
84
  const bytes = readFileSync(path);
85
85
  const params = new URLSearchParams({ filename: basename(path) });
86
86
  if (title) params.set("title", title);
87
87
  if (folder) params.set("folderId", folder);
88
+ if (id) params.set("id", id);
88
89
 
89
90
  const res = await fetch(`${origin}/publish?${params}`, {
90
91
  method: "POST",
package/src/index.mjs CHANGED
@@ -49,6 +49,7 @@ Skills
49
49
  Options
50
50
  --json machine-readable output
51
51
  --title <text> title for publish
52
+ --id <id> with publish: the address, /d/<id> (default: from the title)
52
53
  --folder <id> destination folder for publish
53
54
  --parent <id> parent folder for mkdir
54
55
  --limit <n> with list: rows per page (default 20, max 50)
@@ -144,6 +145,7 @@ async function list(flags) {
144
145
 
145
146
  async function publish(flags, [path]) {
146
147
  if (!path) fail("usage: bikeshed publish <file>");
148
+ if (flags.id === true) fail("usage: bikeshed publish <file> --id <id>");
147
149
  const { origin, token } = resolveAuth(flags);
148
150
  const file = resolve(path);
149
151
 
@@ -151,7 +153,14 @@ async function publish(flags, [path]) {
151
153
  const result = await uploadFile(origin, token, file, {
152
154
  title: flags.title,
153
155
  folder: flags.folder,
156
+ id: flags.id,
154
157
  });
158
+ // A taken id still publishes, under a suffix. Said on stderr so `--json`
159
+ // stays parseable; "not available" also covers a deployment too old to
160
+ // know the parameter, which ignores it.
161
+ if (flags.id && result.docId !== flags.id) {
162
+ console.error(`${flags.id} was not available; published at ${result.docId}`);
163
+ }
155
164
  // The address is in the human line already; `--json` carried only the id, so
156
165
  // anything reading it had to know how to build a URL out of a docId.
157
166
  out(flags.json, { ...result, url: result.url ?? `${origin}/d/${result.docId}` }, () =>
@@ -391,6 +400,7 @@ async function main() {
391
400
  all: { type: "boolean", default: false },
392
401
  help: { type: "boolean", default: false },
393
402
  title: { type: "string" },
403
+ id: { type: "string" },
394
404
  folder: { type: "string" },
395
405
  parent: { type: "string" },
396
406
  origin: { type: "string" },