bikeshed-now 0.10.0 → 0.12.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 +1 -1
- package/src/client.mjs +8 -1
- package/src/index.mjs +22 -17
package/package.json
CHANGED
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
|
-
|
|
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
|
|
@@ -181,15 +183,9 @@ function isCi(value) {
|
|
|
181
183
|
|
|
182
184
|
async function browserLogin(flags) {
|
|
183
185
|
const interactive = Boolean(process.stdin.isTTY);
|
|
186
|
+
// Never asked: --origin, BIKESHED_ORIGIN, the last sign-in, then the default,
|
|
187
|
+
// the same order as every other command. The line below names it.
|
|
184
188
|
let where = resolveAuth(flags).origin;
|
|
185
|
-
if (interactive && !flags.origin) {
|
|
186
|
-
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
187
|
-
try {
|
|
188
|
-
where = (await rl.question(`Deployment [${where}]: `)).trim() || where;
|
|
189
|
-
} finally {
|
|
190
|
-
rl.close();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
189
|
try {
|
|
194
190
|
const url = new URL(where);
|
|
195
191
|
if (url.protocol !== "https:" && url.protocol !== "http:") throw new Error();
|
|
@@ -289,16 +285,17 @@ async function browserLogin(flags) {
|
|
|
289
285
|
);
|
|
290
286
|
}
|
|
291
287
|
|
|
292
|
-
/**
|
|
288
|
+
/**
|
|
289
|
+
* Paste a token made at /account. The flow from before browser sign-in.
|
|
290
|
+
*
|
|
291
|
+
* Only the token is read from stdin. Asking for the deployment first read a
|
|
292
|
+
* piped token as the address, and printed it back inside the /account link.
|
|
293
|
+
*/
|
|
293
294
|
async function pasteLogin(flags) {
|
|
294
|
-
const { origin } = resolveAuth(flags);
|
|
295
|
+
const { origin: where } = resolveAuth(flags);
|
|
295
296
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
296
297
|
try {
|
|
297
|
-
|
|
298
|
-
flags.origin ||
|
|
299
|
-
(await rl.question(`Deployment [${origin}]: `)).trim() ||
|
|
300
|
-
origin;
|
|
301
|
-
console.log(`\nCreate a token at ${where}/account — choose "Command line".`);
|
|
298
|
+
console.log(`Create a token at ${where}/account — choose "Command line".`);
|
|
302
299
|
console.log("It is shown once, so copy it now.\n");
|
|
303
300
|
const token = (await rl.question("Token: ")).trim();
|
|
304
301
|
if (!token) fail("no token given");
|
|
@@ -847,6 +844,14 @@ async function main() {
|
|
|
847
844
|
});
|
|
848
845
|
|
|
849
846
|
const [name, ...rest] = positionals;
|
|
847
|
+
// On its own, --version is about this program; after `fork` it names the
|
|
848
|
+
// version of a document to copy, which is why it is not checked first.
|
|
849
|
+
// Declared as taking a value for fork's sake, it swallows a `--json` that
|
|
850
|
+
// follows it, so that value is read back as the flag it was.
|
|
851
|
+
if (!name && !values.help && (values.version !== undefined || values.v)) {
|
|
852
|
+
out(values.json || values.version === "--json", { version: VERSION }, () => console.log(`bikeshed ${VERSION}`));
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
850
855
|
if (values.help || !name) {
|
|
851
856
|
console.log(USAGE);
|
|
852
857
|
return;
|