toolaby 1.0.0 → 1.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.
Files changed (3) hide show
  1. package/README.md +4 -3
  2. package/bin.mjs +11 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3,13 +3,14 @@
3
3
  The Toolaby command line. It puts the Wall — sign-in, a Free plan, paid plans, licences and subscriptions — into a Chrome extension you already have, or makes a new one for you.
4
4
 
5
5
  ```sh
6
- npx toolaby login # once: a code to approve in your browser
7
- npx toolaby wire wow--screenzard # in your extension's folder
6
+ npm i -g toolaby # once (or run every command through `npx -y toolaby …`)
7
+ toolaby login # once: a code to approve in your browser
8
+ toolaby wire <tool-id> # in your extension's folder; `toolaby tools` lists your ids
8
9
  ```
9
10
 
10
11
  ## What it does
11
12
 
12
- **`toolaby login`** signs you in. It shows a code and opens the Toolaby dashboard; you approve the code there, and the command is signed in as you from then on. It works the way GitHub's and Stripe's command lines sign in, and only ever acts on your own tools.
13
+ **`toolaby login`** signs you in. It shows a code and opens the Toolaby dashboard; you approve the code there — as the account the dashboard is signed in to — and the command is signed in as that account from then on. It works the way GitHub's and Stripe's command lines sign in, and only ever acts on that account's own tools.
13
14
 
14
15
  **`toolaby wire <tool-id>`**, run in your extension's folder, wires that extension to your tool:
15
16
 
package/bin.mjs CHANGED
@@ -24,10 +24,11 @@ import { spawn } from 'node:child_process';
24
24
  import { wireManifest, WORKER_LINES } from './lib/manifest.js';
25
25
  import { detectProject, CODE_FILES, filesToWrite } from './lib/project.js';
26
26
 
27
- const VERSION = '1.0.0';
27
+ const VERSION = '1.0.2';
28
28
  const CLIENT_ID = 'toolaby-cli';
29
29
  const argv = process.argv.slice(2);
30
- const command = argv.find((a) => !a.startsWith('--')) ?? 'help';
30
+ // `--version` and `--help` are commands of their own; every other command is the first bare word.
31
+ const command = argv.find((a) => ['--version', '-v', '--help', '-h'].includes(a)) ?? argv.find((a) => !a.startsWith('--')) ?? 'help';
31
32
  const rest = argv.filter((a) => a !== command);
32
33
  const positional = rest.filter((a) => !a.startsWith('--'));
33
34
  const opt = (k, d = null) => { const i = rest.indexOf(k); return i >= 0 && rest[i + 1] && !rest[i + 1].startsWith('--') ? rest[i + 1] : d; };
@@ -87,7 +88,7 @@ async function login() {
87
88
  const all = readCredentials();
88
89
  all[wall] = { token, email, at: new Date().toISOString() };
89
90
  writeCredentials(all);
90
- out(`\n\n Signed in${email ? ` as ${email}` : ''}. The session is in ${CREDENTIALS}; \`toolaby logout\` revokes it.\n`);
91
+ out(`\n\n Signed in${email ? ` as ${email}` : ''}.\n`);
91
92
  return token;
92
93
  }
93
94
  const why = poll.json.error;
@@ -158,7 +159,12 @@ async function filesFor(slug, scaffold) {
158
159
  const token = await tokenOrLogin();
159
160
  const res = await api(`/api/cli/wiring/${slug}${scaffold ? '?scaffold=1' : ''}`, { token });
160
161
  if (res.status === 401) { out(' The stored session is no longer valid; signing in again.'); await login(); return filesFor(slug, scaffold); }
161
- if (res.status === 404) fail(res.json.message ?? `No tool "${slug}" in your workspaces.`);
162
+ if (res.status === 404) {
163
+ // Say who the command is: the tool may well exist — in a workspace of another account of theirs.
164
+ const me = await api('/api/cli/me', { token }).catch(() => null);
165
+ const who = me?.ok ? `\n\n You are signed in as ${me.json.email}${me.json.workspaces.length ? ` (workspaces: ${me.json.workspaces.map((w) => w.slug).join(', ')})` : ' (no workspace yet)'}.\n Another account owns it? \`toolaby logout\`, sign in to the dashboard as that account, then run this again.` : '';
166
+ fail(`${res.json.message ?? `No tool "${slug}" in your workspaces.`}${who}`);
167
+ }
162
168
  if (!res.ok) fail(res.json.message ?? `The Wall answered HTTP ${res.status}.`);
163
169
  return res.json;
164
170
  }
@@ -245,4 +251,4 @@ function help() {
245
251
  const commands = { login: async () => { await login(); }, logout, whoami, tools, wire, create, help, '--help': help, '-h': help, '--version': () => out(VERSION), '-v': () => out(VERSION) };
246
252
  const run = commands[command];
247
253
  if (!run) { console.error(`\n Unknown command "${command}".`); help(); process.exit(1); }
248
- run().catch((e) => fail(e.message));
254
+ Promise.resolve().then(run).catch((e) => fail(e.message));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolaby",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "The Toolaby command line: sign in once, then wire any Chrome extension to your tool on the Wall — sign-in, the Free plan, licences and subscriptions — or start a new one.",
5
5
  "type": "module",
6
6
  "bin": { "toolaby": "./bin.mjs" },