@devdogsuga/devtools 0.1.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 +44 -0
- package/bin/devtools-ci-bare.mjs +48 -0
- package/bin/devtools-ci.mjs +17 -0
- package/bin/devtools.mjs +27 -0
- package/dist/args.d.ts +26 -0
- package/dist/args.js +78 -0
- package/dist/bws/bw.d.ts +9 -0
- package/dist/bws/bw.js +49 -0
- package/dist/bws/client.d.ts +43 -0
- package/dist/bws/client.js +363 -0
- package/dist/bws/environments.d.ts +96 -0
- package/dist/bws/environments.js +111 -0
- package/dist/bws/pace.d.ts +27 -0
- package/dist/bws/pace.js +43 -0
- package/dist/bws/retry.d.ts +12 -0
- package/dist/bws/retry.js +39 -0
- package/dist/bws/store.d.ts +1 -0
- package/dist/bws/store.js +32 -0
- package/dist/bws/token.d.ts +31 -0
- package/dist/bws/token.js +88 -0
- package/dist/bws/vault.d.ts +29 -0
- package/dist/bws/vault.js +200 -0
- package/dist/catalog.d.ts +55 -0
- package/dist/catalog.js +81 -0
- package/dist/cf/commands.d.ts +1 -0
- package/dist/cf/commands.js +182 -0
- package/dist/cf/local-env.d.ts +44 -0
- package/dist/cf/local-env.js +148 -0
- package/dist/ci.d.ts +1 -0
- package/dist/ci.js +319 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +1077 -0
- package/dist/commands.d.ts +255 -0
- package/dist/commands.js +1279 -0
- package/dist/completions.d.ts +4 -0
- package/dist/completions.js +110 -0
- package/dist/cron/commands.d.ts +47 -0
- package/dist/cron/commands.js +372 -0
- package/dist/cron/discovery.d.ts +55 -0
- package/dist/cron/discovery.js +85 -0
- package/dist/cron/schema.d.ts +45 -0
- package/dist/cron/schema.js +35 -0
- package/dist/db/config-push.d.ts +8 -0
- package/dist/db/config-push.js +11 -0
- package/dist/db/connection.d.ts +79 -0
- package/dist/db/connection.js +114 -0
- package/dist/db/exec.d.ts +1 -0
- package/dist/db/exec.js +11 -0
- package/dist/db/generate-migration.d.ts +1 -0
- package/dist/db/generate-migration.js +67 -0
- package/dist/db/generate-types.d.ts +1 -0
- package/dist/db/generate-types.js +4 -0
- package/dist/db/introspect.d.ts +1 -0
- package/dist/db/introspect.js +113 -0
- package/dist/db/local-env.d.ts +65 -0
- package/dist/db/local-env.js +23 -0
- package/dist/db/new-migration.d.ts +1 -0
- package/dist/db/new-migration.js +8 -0
- package/dist/db/run.d.ts +70 -0
- package/dist/db/run.js +158 -0
- package/dist/db/seed-buckets.d.ts +2 -0
- package/dist/db/seed-buckets.js +4 -0
- package/dist/db/seed-production.d.ts +8 -0
- package/dist/db/seed-production.js +73 -0
- package/dist/db/seed-roles.d.ts +7 -0
- package/dist/db/seed-roles.js +31 -0
- package/dist/db/session-refresh.d.ts +43 -0
- package/dist/db/session-refresh.js +40 -0
- package/dist/deploy/migrations.d.ts +20 -0
- package/dist/deploy/migrations.js +68 -0
- package/dist/deploy/orphans.d.ts +20 -0
- package/dist/deploy/orphans.js +177 -0
- package/dist/deploy/preflight.d.ts +53 -0
- package/dist/deploy/preflight.js +189 -0
- package/dist/deploy/report.d.ts +26 -0
- package/dist/deploy/report.js +70 -0
- package/dist/deploy/require-planner.d.ts +2 -0
- package/dist/deploy/require-planner.js +60 -0
- package/dist/deploy/require-token.d.ts +15 -0
- package/dist/deploy/require-token.js +78 -0
- package/dist/deploy/secrets-file.d.ts +17 -0
- package/dist/deploy/secrets-file.js +167 -0
- package/dist/deploy/write-env.d.ts +40 -0
- package/dist/deploy/write-env.js +393 -0
- package/dist/docs/index-pages.d.ts +36 -0
- package/dist/docs/index-pages.js +184 -0
- package/dist/doctor.d.ts +62 -0
- package/dist/doctor.js +225 -0
- package/dist/emails/commands.d.ts +15 -0
- package/dist/emails/commands.js +130 -0
- package/dist/emails/email-types.d.ts +13 -0
- package/dist/emails/email-types.js +1 -0
- package/dist/emails/fixtures.d.ts +20 -0
- package/dist/emails/fixtures.js +20 -0
- package/dist/env/audit.d.ts +206 -0
- package/dist/env/audit.js +436 -0
- package/dist/env/cloudflare.d.ts +21 -0
- package/dist/env/cloudflare.js +61 -0
- package/dist/env/commands.d.ts +99 -0
- package/dist/env/commands.js +612 -0
- package/dist/env/discovery.d.ts +15 -0
- package/dist/env/discovery.js +226 -0
- package/dist/env/document.d.ts +119 -0
- package/dist/env/document.js +323 -0
- package/dist/env/example.d.ts +68 -0
- package/dist/env/example.js +603 -0
- package/dist/env/selection.d.ts +105 -0
- package/dist/env/selection.js +226 -0
- package/dist/environment.d.ts +92 -0
- package/dist/environment.js +206 -0
- package/dist/fingerprint.d.ts +10 -0
- package/dist/fingerprint.js +18 -0
- package/dist/gen/campus-map.d.ts +1 -0
- package/dist/gen/campus-map.js +473 -0
- package/dist/gen/commands.d.ts +1 -0
- package/dist/gen/commands.js +25 -0
- package/dist/gen/hypno.d.ts +1 -0
- package/dist/gen/hypno.js +134 -0
- package/dist/gh/client.d.ts +80 -0
- package/dist/gh/client.js +258 -0
- package/dist/gh/environments.d.ts +83 -0
- package/dist/gh/environments.js +178 -0
- package/dist/gh/rulesets/actors.d.ts +14 -0
- package/dist/gh/rulesets/actors.js +68 -0
- package/dist/gh/rulesets/api.d.ts +15 -0
- package/dist/gh/rulesets/api.js +99 -0
- package/dist/gh/rulesets/commands.d.ts +3 -0
- package/dist/gh/rulesets/commands.js +203 -0
- package/dist/gh/rulesets/desired.d.ts +112 -0
- package/dist/gh/rulesets/desired.js +247 -0
- package/dist/gh/rulesets/diff.d.ts +65 -0
- package/dist/gh/rulesets/diff.js +134 -0
- package/dist/gh/rulesets/types.d.ts +76 -0
- package/dist/gh/rulesets/types.js +13 -0
- package/dist/gh/settings/api.d.ts +40 -0
- package/dist/gh/settings/api.js +172 -0
- package/dist/gh/settings/commands.d.ts +1 -0
- package/dist/gh/settings/commands.js +245 -0
- package/dist/gh/settings/desired.d.ts +53 -0
- package/dist/gh/settings/desired.js +39 -0
- package/dist/gh/settings/diff.d.ts +57 -0
- package/dist/gh/settings/diff.js +156 -0
- package/dist/gh/settings/types.d.ts +92 -0
- package/dist/gh/settings/types.js +11 -0
- package/dist/gh/settings/workflows.d.ts +41 -0
- package/dist/gh/settings/workflows.js +124 -0
- package/dist/grantRoot.d.ts +42 -0
- package/dist/grantRoot.js +89 -0
- package/dist/help.d.ts +18 -0
- package/dist/help.js +169 -0
- package/dist/images/commands.d.ts +35 -0
- package/dist/images/commands.js +233 -0
- package/dist/images/events.d.ts +36 -0
- package/dist/images/events.js +152 -0
- package/dist/images/graphics.d.ts +70 -0
- package/dist/images/graphics.js +233 -0
- package/dist/images/open-graph-types.d.ts +75 -0
- package/dist/images/open-graph-types.js +1 -0
- package/dist/images/prompts.d.ts +34 -0
- package/dist/images/prompts.js +100 -0
- package/dist/images/render.d.ts +21 -0
- package/dist/images/render.js +57 -0
- package/dist/images/select.d.ts +64 -0
- package/dist/images/select.js +96 -0
- package/dist/instance.d.ts +67 -0
- package/dist/instance.js +129 -0
- package/dist/invocation.d.ts +49 -0
- package/dist/invocation.js +78 -0
- package/dist/launch-ci.d.ts +1 -0
- package/dist/launch-ci.js +86 -0
- package/dist/launch.d.ts +29 -0
- package/dist/launch.js +371 -0
- package/dist/menu.d.ts +31 -0
- package/dist/menu.js +277 -0
- package/dist/newsletter/commands.d.ts +16 -0
- package/dist/newsletter/commands.js +311 -0
- package/dist/newsletter/imap.d.ts +17 -0
- package/dist/newsletter/imap.js +127 -0
- package/dist/newsletter/loopback.d.ts +24 -0
- package/dist/newsletter/loopback.js +100 -0
- package/dist/newsletter/oauth.d.ts +26 -0
- package/dist/newsletter/oauth.js +130 -0
- package/dist/newsletter/smtp.d.ts +23 -0
- package/dist/newsletter/smtp.js +133 -0
- package/dist/oauth/browser.d.ts +1 -0
- package/dist/oauth/browser.js +13 -0
- package/dist/oauth/config.d.ts +24 -0
- package/dist/oauth/config.js +24 -0
- package/dist/oauth/connect-url.d.ts +17 -0
- package/dist/oauth/connect-url.js +23 -0
- package/dist/oauth/db.d.ts +37 -0
- package/dist/oauth/db.js +108 -0
- package/dist/oauth/device.d.ts +93 -0
- package/dist/oauth/device.js +190 -0
- package/dist/oauth/discovery.d.ts +28 -0
- package/dist/oauth/discovery.js +54 -0
- package/dist/oauth/env-file.d.ts +6 -0
- package/dist/oauth/env-file.js +35 -0
- package/dist/oauth/exchange.d.ts +43 -0
- package/dist/oauth/exchange.js +87 -0
- package/dist/oauth/label.d.ts +1 -0
- package/dist/oauth/label.js +25 -0
- package/dist/oauth/loopback.d.ts +52 -0
- package/dist/oauth/loopback.js +162 -0
- package/dist/oauth/pkce.d.ts +6 -0
- package/dist/oauth/pkce.js +34 -0
- package/dist/oauth/target.d.ts +54 -0
- package/dist/oauth/target.js +102 -0
- package/dist/oauth/transport.d.ts +41 -0
- package/dist/oauth/transport.js +32 -0
- package/dist/oauth/wizard.d.ts +33 -0
- package/dist/oauth/wizard.js +571 -0
- package/dist/pick.d.ts +6 -0
- package/dist/pick.js +64 -0
- package/dist/planner/checks.d.ts +26 -0
- package/dist/planner/checks.js +104 -0
- package/dist/planner/commands.d.ts +10 -0
- package/dist/planner/commands.js +367 -0
- package/dist/planner/db.d.ts +15 -0
- package/dist/planner/db.js +33 -0
- package/dist/planner/role.d.ts +33 -0
- package/dist/planner/role.js +68 -0
- package/dist/repo/peers.d.ts +24 -0
- package/dist/repo/peers.js +114 -0
- package/dist/repo/preflight.d.ts +109 -0
- package/dist/repo/preflight.js +266 -0
- package/dist/repo/resolve.d.ts +41 -0
- package/dist/repo/resolve.js +152 -0
- package/dist/repo/root.d.ts +23 -0
- package/dist/repo/root.js +91 -0
- package/dist/repo/source.d.ts +14 -0
- package/dist/repo/source.js +54 -0
- package/dist/repo/tsx-loader.d.ts +6 -0
- package/dist/repo/tsx-loader.js +41 -0
- package/dist/run/pick.d.ts +60 -0
- package/dist/run/pick.js +559 -0
- package/dist/setup.d.ts +1 -0
- package/dist/setup.js +152 -0
- package/dist/stack.d.ts +48 -0
- package/dist/stack.js +290 -0
- package/dist/telemetry.d.ts +34 -0
- package/dist/telemetry.js +93 -0
- package/dist/tier.d.ts +40 -0
- package/dist/tier.js +93 -0
- package/dist/tsconfig.typecheck.tsbuildinfo +1 -0
- package/dist/ui.d.ts +25 -0
- package/dist/ui.js +51 -0
- package/dist/workers.d.ts +5 -0
- package/dist/workers.js +35 -0
- package/dist/workflows/commands.d.ts +44 -0
- package/dist/workflows/commands.js +668 -0
- package/env.ts +158 -0
- package/package.json +80 -0
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @devdogsuga/devtools
|
|
2
|
+
|
|
3
|
+
Contributor CLI for workspace tasks, runtime infrastructure, generated
|
|
4
|
+
content, configuration, and moderation checks.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pnpm devtools # no arguments: menu of interactive commands
|
|
8
|
+
pnpm devtools db start # boot Supabase on this machine
|
|
9
|
+
pnpm devtools db connect <ref> # or register a hosted project as the remote target
|
|
10
|
+
pnpm devtools db reset # replay migrations, then seeds, then regenerate types
|
|
11
|
+
pnpm devtools cron run # choose a configured route cron
|
|
12
|
+
pnpm devtools workflows run # choose a configured Cloudflare Workflow
|
|
13
|
+
pnpm devtools workflows serve # keep an app-scoped Wrangler runtime open
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The menu is generated from the same command tree the argv parser walks, so
|
|
17
|
+
there is no second list to fall out of step — reach for `--help` at any level
|
|
18
|
+
rather than a table here.
|
|
19
|
+
|
|
20
|
+
## Telemetry disclosure
|
|
21
|
+
|
|
22
|
+
This CLI reports its own crashes to Sentry (see `src/telemetry.ts`), on by
|
|
23
|
+
default, in both `pnpm devtools` and `devtools-ci`:
|
|
24
|
+
|
|
25
|
+
- **What**: uncaught errors only — a captured exception plus a `command` tag
|
|
26
|
+
naming the subcommand that threw (e.g. `db reset`, `deploy platform`).
|
|
27
|
+
Nothing about a successful run is ever sent.
|
|
28
|
+
- **When**: every run, unless `DEVTOOLS_TELEMETRY=0` is set (per-machine or
|
|
29
|
+
per-job opt-out) — or `DEVTOOLS_SENTRY_DSN` is unset, which is the state of
|
|
30
|
+
local development until an operator configures one and the state of every
|
|
31
|
+
environment until the devtools Sentry project exists at all (see the
|
|
32
|
+
committed placeholder in `src/telemetry.ts`). Either condition means no
|
|
33
|
+
`Sentry.init()` call happens: no network request, no console output.
|
|
34
|
+
- **What's scrubbed**: this CLI touches local `.env` files, so every event
|
|
35
|
+
passes through
|
|
36
|
+
`@devdogsuga/telemetry`'s shared scrubbers before it leaves the process —
|
|
37
|
+
file paths reduced to basenames, email addresses redacted, and
|
|
38
|
+
token/secret-shaped values stripped out of messages, breadcrumbs, and
|
|
39
|
+
stack frames. See Backstage's `packages/telemetry/src/scrub.ts` for exactly what each
|
|
40
|
+
scrubber matches.
|
|
41
|
+
|
|
42
|
+
[Command guide](../../docs/toolkit/guides/devtools.md) ·
|
|
43
|
+
[API reference](https://devdogsuga.org/docs/toolkit/reference/api/devtools) ·
|
|
44
|
+
[Quickstart](../../docs/monorepo/guides/quickstart.md)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Entry point for the `devtools-ci-bare` bin: `ci.ts`'s `main()` with no tier
|
|
4
|
+
* resolution and no env-file loading — the counterpart to the old in-repo
|
|
5
|
+
* `"ci": "tsx --conditions=devdogs-source src/ci.ts"` package script.
|
|
6
|
+
*
|
|
7
|
+
* `devtools-ci` (`bin/devtools-ci.mjs` -> `src/launch-ci.ts`) ALWAYS resolves
|
|
8
|
+
* a deploy tier and calls `enterEnvironment` before dispatching to `ci.ts`.
|
|
9
|
+
* That's wrong for two kinds of CI step: `deploy write-env`, which CREATES
|
|
10
|
+
* the env file tier resolution would otherwise insist on reading first (a
|
|
11
|
+
* bootstrap cycle), and the handful of steps that hold one narrow credential
|
|
12
|
+
* via the job's own `env:` block and compose no env file at all (`preflight`,
|
|
13
|
+
* `migrate`, `plan`, `require-planner`, `require-token`, `orphans`). Those
|
|
14
|
+
* steps need `ci.ts`'s `main()` with nothing in front of it.
|
|
15
|
+
*
|
|
16
|
+
* Same technique as `bin/devtools.mjs` and `bin/devtools-ci.mjs` — see
|
|
17
|
+
* `bin/devtools.mjs`'s header — except it imports `dist/ci.js` directly
|
|
18
|
+
* rather than going through a `launch*.ts` wrapper: `ci.ts` has no
|
|
19
|
+
* tier-resolution step to run first, so there is nothing for a wrapper
|
|
20
|
+
* module to do. `dist/ci.js`'s own self-invoke guard
|
|
21
|
+
* (`import.meta.url === file://${process.argv[1]}`) does not fire here —
|
|
22
|
+
* `process.argv[1]` is this bin script, not `dist/ci.js` — so importing it
|
|
23
|
+
* only defines `main`, exactly like `bin/devtools-ci.mjs`'s import of
|
|
24
|
+
* `launch-ci.js` relies on.
|
|
25
|
+
*/
|
|
26
|
+
import { dirname, join } from "node:path";
|
|
27
|
+
import { fileURLToPath } from "node:url";
|
|
28
|
+
|
|
29
|
+
const ciEntry = join(
|
|
30
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
31
|
+
"..",
|
|
32
|
+
"dist",
|
|
33
|
+
"ci.js",
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const { main } = await import(ciEntry);
|
|
37
|
+
try {
|
|
38
|
+
await main(process.argv.slice(2));
|
|
39
|
+
} catch (err) {
|
|
40
|
+
process.stderr.write(
|
|
41
|
+
`devtools-ci-bare: ${err instanceof Error ? err.message : String(err)}\n`,
|
|
42
|
+
);
|
|
43
|
+
const { captureDevtoolsError } = await import(
|
|
44
|
+
join(dirname(fileURLToPath(import.meta.url)), "..", "dist", "telemetry.js")
|
|
45
|
+
);
|
|
46
|
+
await captureDevtoolsError(err);
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Entry point for the `devtools-ci` bin. Same technique as `bin/devtools.mjs`
|
|
4
|
+
* — see that file's header — pointed at `dist/launch-ci.js` instead.
|
|
5
|
+
*/
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
const launchCiEntry = join(
|
|
10
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
11
|
+
"..",
|
|
12
|
+
"dist",
|
|
13
|
+
"launch-ci.js",
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const { launchCi } = await import(launchCiEntry);
|
|
17
|
+
await launchCi(process.argv.slice(2));
|
package/bin/devtools.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Entry point for the `devtools` bin.
|
|
4
|
+
*
|
|
5
|
+
* Ships built JS (see the package's `build` script — `tsc` to `dist/`) and
|
|
6
|
+
* runs it directly with plain `node`: no `tsx` wrapper, no
|
|
7
|
+
* `--conditions=devdogs-source` flag. Those were needed when devtools lived
|
|
8
|
+
* INSIDE the DevDogsUGA workspace and imported sibling `@devdogsuga/*`
|
|
9
|
+
* packages by TypeScript source; published as its own package and run via
|
|
10
|
+
* `pnpm dlx`, none of that applies — every `@devdogsuga/*` import now goes
|
|
11
|
+
* through `src/repo/peers.ts`/`src/repo/source.ts`'s runtime resolution
|
|
12
|
+
* against the TARGET repo instead, and `tsx` is a regular dependency used
|
|
13
|
+
* only programmatically (`src/repo/tsx-loader.ts`) to load that repo's own
|
|
14
|
+
* TypeScript (env manifests, cron contracts, `devdogs-source` packages).
|
|
15
|
+
*/
|
|
16
|
+
import { dirname, join } from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
|
|
19
|
+
const launchEntry = join(
|
|
20
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
21
|
+
"..",
|
|
22
|
+
"dist",
|
|
23
|
+
"launch.js",
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const { launch } = await import(launchEntry);
|
|
27
|
+
await launch(process.argv.slice(2));
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Positional arguments, with flag values excluded.
|
|
3
|
+
*
|
|
4
|
+
* Its own module because of one bug it prevents. The first positional is the
|
|
5
|
+
* subcommand, and `pull`, `push` and `audit` do very different things to live
|
|
6
|
+
* credentials. A naive `filter((a) => !a.startsWith("--"))` reads a flag's
|
|
7
|
+
* VALUE as a positional, so `env --file notes.env audit` fails loudly:
|
|
8
|
+
* `notes.env` is not a subcommand and the command refuses. The quiet version
|
|
9
|
+
* is the one that matters:
|
|
10
|
+
*
|
|
11
|
+
* env --file push audit
|
|
12
|
+
*
|
|
13
|
+
* which runs `push`, writing to Bitwarden and GitHub, when the caller asked
|
|
14
|
+
* for `audit`, which writes nothing at all.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Flags that consume the token after them.
|
|
18
|
+
*
|
|
19
|
+
* `--env` is here even though nothing accepts it any more. It was this CLI's
|
|
20
|
+
* spelling of `--target` until the two vocabularies behind it were merged, and
|
|
21
|
+
* a stale `env push --env staging` in somebody's shell history must not read
|
|
22
|
+
* `staging` as the subcommand. `cli.ts` rejects the flag by name instead,
|
|
23
|
+
* which says what happened.
|
|
24
|
+
*/
|
|
25
|
+
export declare const VALUE_FLAGS: Set<string>;
|
|
26
|
+
export declare function positionals(argv: readonly string[]): string[];
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Positional arguments, with flag values excluded.
|
|
3
|
+
*
|
|
4
|
+
* Its own module because of one bug it prevents. The first positional is the
|
|
5
|
+
* subcommand, and `pull`, `push` and `audit` do very different things to live
|
|
6
|
+
* credentials. A naive `filter((a) => !a.startsWith("--"))` reads a flag's
|
|
7
|
+
* VALUE as a positional, so `env --file notes.env audit` fails loudly:
|
|
8
|
+
* `notes.env` is not a subcommand and the command refuses. The quiet version
|
|
9
|
+
* is the one that matters:
|
|
10
|
+
*
|
|
11
|
+
* env --file push audit
|
|
12
|
+
*
|
|
13
|
+
* which runs `push`, writing to Bitwarden and GitHub, when the caller asked
|
|
14
|
+
* for `audit`, which writes nothing at all.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Flags that consume the token after them.
|
|
18
|
+
*
|
|
19
|
+
* `--env` is here even though nothing accepts it any more. It was this CLI's
|
|
20
|
+
* spelling of `--target` until the two vocabularies behind it were merged, and
|
|
21
|
+
* a stale `env push --env staging` in somebody's shell history must not read
|
|
22
|
+
* `staging` as the subcommand. `cli.ts` rejects the flag by name instead,
|
|
23
|
+
* which says what happened.
|
|
24
|
+
*/
|
|
25
|
+
export const VALUE_FLAGS = new Set([
|
|
26
|
+
"--access-token",
|
|
27
|
+
// `qr`: every value flag, so `qr --out poster.png https://…` still reads
|
|
28
|
+
// the URL as the text and not `poster.png`.
|
|
29
|
+
"--background",
|
|
30
|
+
"--color",
|
|
31
|
+
"--ecl",
|
|
32
|
+
"--format",
|
|
33
|
+
// `images`: so `images --format og page/events` reads `og` as the format and
|
|
34
|
+
// `page/events` as the graphic, not both as graphics.
|
|
35
|
+
"--format",
|
|
36
|
+
"--logo",
|
|
37
|
+
"--logo-padding",
|
|
38
|
+
"--logo-size",
|
|
39
|
+
"--margin",
|
|
40
|
+
"--out",
|
|
41
|
+
"--size",
|
|
42
|
+
"--text",
|
|
43
|
+
"--version",
|
|
44
|
+
"--app",
|
|
45
|
+
"--apps",
|
|
46
|
+
"--base-url",
|
|
47
|
+
"--env",
|
|
48
|
+
"--file",
|
|
49
|
+
"--source",
|
|
50
|
+
"--target",
|
|
51
|
+
"--tier",
|
|
52
|
+
"--cron",
|
|
53
|
+
"--workflow",
|
|
54
|
+
"--params",
|
|
55
|
+
"--port",
|
|
56
|
+
"--preview-url",
|
|
57
|
+
"--db-url",
|
|
58
|
+
"--user",
|
|
59
|
+
"--filter",
|
|
60
|
+
"--shell",
|
|
61
|
+
]);
|
|
62
|
+
export function positionals(argv) {
|
|
63
|
+
const found = [];
|
|
64
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
65
|
+
const arg = argv[i];
|
|
66
|
+
if (!arg.startsWith("-")) {
|
|
67
|
+
found.push(arg);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
// Skip the value, but only if it looks like one. `--file --yes` is a
|
|
71
|
+
// mistake, and swallowing `--yes` would turn it into a silent one.
|
|
72
|
+
const next = argv[i + 1];
|
|
73
|
+
if (VALUE_FLAGS.has(arg) && next !== undefined && !next.startsWith("-")) {
|
|
74
|
+
i += 1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return found;
|
|
78
|
+
}
|
package/dist/bws/bw.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs the Bitwarden CLI with `args`, then exits with its status.
|
|
3
|
+
*
|
|
4
|
+
* Returns a promise that never settles, because every path out of it ends in
|
|
5
|
+
* `process.exit`. That signature is load-bearing rather than pedantic: a
|
|
6
|
+
* `void` return would let the caller carry on and print `outro("Done.")`
|
|
7
|
+
* while `bw login` was still waiting for a master password.
|
|
8
|
+
*/
|
|
9
|
+
export declare function runBw(args: string[]): Promise<never>;
|
package/dist/bws/bw.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pnpm devtools bw …`, the Bitwarden CLI passed through untouched.
|
|
3
|
+
*
|
|
4
|
+
* This is not a command of this CLI wearing a Bitwarden hat. Everything after
|
|
5
|
+
* `bw` goes to the real binary verbatim, and its exit code comes back
|
|
6
|
+
* verbatim, because the thing people actually run is `bw login` and its
|
|
7
|
+
* session handling is Bitwarden's business rather than ours.
|
|
8
|
+
*
|
|
9
|
+
* It exists because `@bitwarden/cli` is a dependency of this package, so the
|
|
10
|
+
* binary sits in devtools' own `node_modules/.bin` and nowhere else. Before
|
|
11
|
+
* this, reaching it meant a root alias (`pnpm bw`) that ran
|
|
12
|
+
* `pnpm --filter @devdogsuga/devtools exec bw`, the last script at the
|
|
13
|
+
* workspace root whose whole job was to reach into this package.
|
|
14
|
+
*
|
|
15
|
+
* ⚠️ `cwd` is deliberately NOT overridden, unlike the pnpm spawn in
|
|
16
|
+
* `run/pick.ts`. pnpm puts this package's `node_modules/.bin` on PATH as a
|
|
17
|
+
* relative entry, so moving the working directory would make `bw` unresolvable
|
|
18
|
+
* from the very place it is installed. Bitwarden does not care where it runs.
|
|
19
|
+
*/
|
|
20
|
+
import { spawn } from "node:child_process";
|
|
21
|
+
/**
|
|
22
|
+
* Runs the Bitwarden CLI with `args`, then exits with its status.
|
|
23
|
+
*
|
|
24
|
+
* Returns a promise that never settles, because every path out of it ends in
|
|
25
|
+
* `process.exit`. That signature is load-bearing rather than pedantic: a
|
|
26
|
+
* `void` return would let the caller carry on and print `outro("Done.")`
|
|
27
|
+
* while `bw login` was still waiting for a master password.
|
|
28
|
+
*/
|
|
29
|
+
export function runBw(args) {
|
|
30
|
+
return new Promise(() => {
|
|
31
|
+
const child = spawn("bw", args, { stdio: "inherit" });
|
|
32
|
+
child.on("error", (err) => {
|
|
33
|
+
// ENOENT here means the dependency is not installed rather than that the
|
|
34
|
+
// user mistyped, so say the thing that fixes it.
|
|
35
|
+
console.error(`bw: ${err.message}\n` +
|
|
36
|
+
"The Bitwarden CLI ships as a devtools dependency — " +
|
|
37
|
+
"run `pnpm install` at the repo root.");
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
child.on("exit", (code, signal) => {
|
|
41
|
+
// Re-raise rather than translating to a number: a Ctrl-C in `bw login`
|
|
42
|
+
// should look to the shell exactly like a Ctrl-C in `bw login`.
|
|
43
|
+
if (signal)
|
|
44
|
+
process.kill(process.pid, signal);
|
|
45
|
+
else
|
|
46
|
+
process.exit(code ?? 1);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare class BwsError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export interface BwsSecret {
|
|
4
|
+
id: string;
|
|
5
|
+
key: string;
|
|
6
|
+
value: string;
|
|
7
|
+
note: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
/**
|
|
10
|
+
* ISO 8601, when this secret last changed.
|
|
11
|
+
*
|
|
12
|
+
* Optional because push and pull do not need it. It is the whole basis of
|
|
13
|
+
* the staleness half of `env audit`, which cannot compare values (GitHub
|
|
14
|
+
* secrets are write-only) and instead asks whether GitHub was updated after
|
|
15
|
+
* this.
|
|
16
|
+
*/
|
|
17
|
+
revisionDate?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Records `--access-token`, before any command runs. */
|
|
20
|
+
export declare function setExplicitAccessToken(token: string | undefined): void;
|
|
21
|
+
/**
|
|
22
|
+
* The access token, found once per process.
|
|
23
|
+
*
|
|
24
|
+
* Memoized as a **promise**, not a value: resolution can prompt, and a single
|
|
25
|
+
* command makes several Secrets Manager calls. Caching the value alone would
|
|
26
|
+
* still let two concurrent calls open two prompts over each other.
|
|
27
|
+
*
|
|
28
|
+
* Whatever the source, the token reaches the SDK as a function argument in
|
|
29
|
+
* this process, never argv, never a child's environment.
|
|
30
|
+
*/
|
|
31
|
+
export declare function accessToken(): Promise<string>;
|
|
32
|
+
/** Resolves a project name to its id. Names are unique within an org. */
|
|
33
|
+
export declare function projectIdFor(name: string): Promise<string>;
|
|
34
|
+
export declare function listSecrets(projectId: string): Promise<BwsSecret[]>;
|
|
35
|
+
export declare function createSecret(projectId: string, key: string, value: string, note: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Takes the whole secret rather than an id: the SDK's update is a full
|
|
38
|
+
* replace (organization, key, project list included), and every caller
|
|
39
|
+
* already holds the listed secret it is updating.
|
|
40
|
+
*/
|
|
41
|
+
export declare function updateSecret(secret: BwsSecret, value: string, note: string): Promise<void>;
|
|
42
|
+
export declare function deleteSecrets(ids: string[]): Promise<void>;
|
|
43
|
+
export declare function byKey(secrets: BwsSecret[]): Map<string, BwsSecret>;
|