bikeshed-now 0.10.0 → 0.11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bikeshed-now",
3
- "version": "0.10.0",
3
+ "version": "0.11.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,14 @@
4
4
  import { readFileSync } from "node:fs";
5
5
  import { basename } from "node:path";
6
6
 
7
- export const CLIENT_NAME = "bikeshed-cli/0.10.0";
7
+ /**
8
+ * This package's version, from the package.json npm ships beside `src/`. Read
9
+ * rather than written here, so `--version` and the client header cannot drift
10
+ * from what was installed.
11
+ */
12
+ export const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
13
+
14
+ export const CLIENT_NAME = `bikeshed-cli/${VERSION}`;
8
15
 
9
16
  /**
10
17
  * Three surfaces, and the split is deliberate rather than untidy.
package/src/index.mjs CHANGED
@@ -10,6 +10,7 @@ import { createInterface } from "node:readline/promises";
10
10
  import { CONFIG_PATH, readConfig, resolveAuth, writeConfig } from "./config.mjs";
11
11
  import {
12
12
  CliError,
13
+ VERSION,
13
14
  callTool,
14
15
  exchangeCode,
15
16
  fetchSkill,
@@ -41,7 +42,7 @@ import {
41
42
  * shell without anybody parsing human-readable output.
42
43
  */
43
44
 
44
- const USAGE = `bikeshed — publish and revise documents
45
+ const USAGE = `bikeshed ${VERSION} — publish and revise documents
45
46
 
46
47
  bikeshed login sign in through your browser (--paste for a token)
47
48
  bikeshed logout sign out (revokes a token from browser sign-in)
@@ -92,7 +93,8 @@ Options
92
93
  --title <text> title for publish or fork (fork default: the original's)
93
94
  --id <id> with publish: the address, /d/<id> (default: from the title)
94
95
  --folder <id> destination folder for publish or fork
95
- --version <v> with fork: the version to copy (default: current)
96
+ --version <v> with fork: the version to copy (default: current);
97
+ on its own, which version of bikeshed this is
96
98
  --parent <id> parent folder for mkdir
97
99
  --limit <n> with list: rows per page (default 20, max 50)
98
100
  --cursor <id> with list: the page after the one that printed it
@@ -847,6 +849,14 @@ async function main() {
847
849
  });
848
850
 
849
851
  const [name, ...rest] = positionals;
852
+ // On its own, --version is about this program; after `fork` it names the
853
+ // version of a document to copy, which is why it is not checked first.
854
+ // Declared as taking a value for fork's sake, it swallows a `--json` that
855
+ // follows it, so that value is read back as the flag it was.
856
+ if (!name && !values.help && (values.version !== undefined || values.v)) {
857
+ out(values.json || values.version === "--json", { version: VERSION }, () => console.log(`bikeshed ${VERSION}`));
858
+ return;
859
+ }
850
860
  if (values.help || !name) {
851
861
  console.log(USAGE);
852
862
  return;