@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.
Files changed (253) hide show
  1. package/README.md +44 -0
  2. package/bin/devtools-ci-bare.mjs +48 -0
  3. package/bin/devtools-ci.mjs +17 -0
  4. package/bin/devtools.mjs +27 -0
  5. package/dist/args.d.ts +26 -0
  6. package/dist/args.js +78 -0
  7. package/dist/bws/bw.d.ts +9 -0
  8. package/dist/bws/bw.js +49 -0
  9. package/dist/bws/client.d.ts +43 -0
  10. package/dist/bws/client.js +363 -0
  11. package/dist/bws/environments.d.ts +96 -0
  12. package/dist/bws/environments.js +111 -0
  13. package/dist/bws/pace.d.ts +27 -0
  14. package/dist/bws/pace.js +43 -0
  15. package/dist/bws/retry.d.ts +12 -0
  16. package/dist/bws/retry.js +39 -0
  17. package/dist/bws/store.d.ts +1 -0
  18. package/dist/bws/store.js +32 -0
  19. package/dist/bws/token.d.ts +31 -0
  20. package/dist/bws/token.js +88 -0
  21. package/dist/bws/vault.d.ts +29 -0
  22. package/dist/bws/vault.js +200 -0
  23. package/dist/catalog.d.ts +55 -0
  24. package/dist/catalog.js +81 -0
  25. package/dist/cf/commands.d.ts +1 -0
  26. package/dist/cf/commands.js +182 -0
  27. package/dist/cf/local-env.d.ts +44 -0
  28. package/dist/cf/local-env.js +148 -0
  29. package/dist/ci.d.ts +1 -0
  30. package/dist/ci.js +319 -0
  31. package/dist/cli.d.ts +11 -0
  32. package/dist/cli.js +1077 -0
  33. package/dist/commands.d.ts +255 -0
  34. package/dist/commands.js +1279 -0
  35. package/dist/completions.d.ts +4 -0
  36. package/dist/completions.js +110 -0
  37. package/dist/cron/commands.d.ts +47 -0
  38. package/dist/cron/commands.js +372 -0
  39. package/dist/cron/discovery.d.ts +55 -0
  40. package/dist/cron/discovery.js +85 -0
  41. package/dist/cron/schema.d.ts +45 -0
  42. package/dist/cron/schema.js +35 -0
  43. package/dist/db/config-push.d.ts +8 -0
  44. package/dist/db/config-push.js +11 -0
  45. package/dist/db/connection.d.ts +79 -0
  46. package/dist/db/connection.js +114 -0
  47. package/dist/db/exec.d.ts +1 -0
  48. package/dist/db/exec.js +11 -0
  49. package/dist/db/generate-migration.d.ts +1 -0
  50. package/dist/db/generate-migration.js +67 -0
  51. package/dist/db/generate-types.d.ts +1 -0
  52. package/dist/db/generate-types.js +4 -0
  53. package/dist/db/introspect.d.ts +1 -0
  54. package/dist/db/introspect.js +113 -0
  55. package/dist/db/local-env.d.ts +65 -0
  56. package/dist/db/local-env.js +23 -0
  57. package/dist/db/new-migration.d.ts +1 -0
  58. package/dist/db/new-migration.js +8 -0
  59. package/dist/db/run.d.ts +70 -0
  60. package/dist/db/run.js +158 -0
  61. package/dist/db/seed-buckets.d.ts +2 -0
  62. package/dist/db/seed-buckets.js +4 -0
  63. package/dist/db/seed-production.d.ts +8 -0
  64. package/dist/db/seed-production.js +73 -0
  65. package/dist/db/seed-roles.d.ts +7 -0
  66. package/dist/db/seed-roles.js +31 -0
  67. package/dist/db/session-refresh.d.ts +43 -0
  68. package/dist/db/session-refresh.js +40 -0
  69. package/dist/deploy/migrations.d.ts +20 -0
  70. package/dist/deploy/migrations.js +68 -0
  71. package/dist/deploy/orphans.d.ts +20 -0
  72. package/dist/deploy/orphans.js +177 -0
  73. package/dist/deploy/preflight.d.ts +53 -0
  74. package/dist/deploy/preflight.js +189 -0
  75. package/dist/deploy/report.d.ts +26 -0
  76. package/dist/deploy/report.js +70 -0
  77. package/dist/deploy/require-planner.d.ts +2 -0
  78. package/dist/deploy/require-planner.js +60 -0
  79. package/dist/deploy/require-token.d.ts +15 -0
  80. package/dist/deploy/require-token.js +78 -0
  81. package/dist/deploy/secrets-file.d.ts +17 -0
  82. package/dist/deploy/secrets-file.js +167 -0
  83. package/dist/deploy/write-env.d.ts +40 -0
  84. package/dist/deploy/write-env.js +393 -0
  85. package/dist/docs/index-pages.d.ts +36 -0
  86. package/dist/docs/index-pages.js +184 -0
  87. package/dist/doctor.d.ts +62 -0
  88. package/dist/doctor.js +225 -0
  89. package/dist/emails/commands.d.ts +15 -0
  90. package/dist/emails/commands.js +130 -0
  91. package/dist/emails/email-types.d.ts +13 -0
  92. package/dist/emails/email-types.js +1 -0
  93. package/dist/emails/fixtures.d.ts +20 -0
  94. package/dist/emails/fixtures.js +20 -0
  95. package/dist/env/audit.d.ts +206 -0
  96. package/dist/env/audit.js +436 -0
  97. package/dist/env/cloudflare.d.ts +21 -0
  98. package/dist/env/cloudflare.js +61 -0
  99. package/dist/env/commands.d.ts +99 -0
  100. package/dist/env/commands.js +612 -0
  101. package/dist/env/discovery.d.ts +15 -0
  102. package/dist/env/discovery.js +226 -0
  103. package/dist/env/document.d.ts +119 -0
  104. package/dist/env/document.js +323 -0
  105. package/dist/env/example.d.ts +68 -0
  106. package/dist/env/example.js +603 -0
  107. package/dist/env/selection.d.ts +105 -0
  108. package/dist/env/selection.js +226 -0
  109. package/dist/environment.d.ts +92 -0
  110. package/dist/environment.js +206 -0
  111. package/dist/fingerprint.d.ts +10 -0
  112. package/dist/fingerprint.js +18 -0
  113. package/dist/gen/campus-map.d.ts +1 -0
  114. package/dist/gen/campus-map.js +473 -0
  115. package/dist/gen/commands.d.ts +1 -0
  116. package/dist/gen/commands.js +25 -0
  117. package/dist/gen/hypno.d.ts +1 -0
  118. package/dist/gen/hypno.js +134 -0
  119. package/dist/gh/client.d.ts +80 -0
  120. package/dist/gh/client.js +258 -0
  121. package/dist/gh/environments.d.ts +83 -0
  122. package/dist/gh/environments.js +178 -0
  123. package/dist/gh/rulesets/actors.d.ts +14 -0
  124. package/dist/gh/rulesets/actors.js +68 -0
  125. package/dist/gh/rulesets/api.d.ts +15 -0
  126. package/dist/gh/rulesets/api.js +99 -0
  127. package/dist/gh/rulesets/commands.d.ts +3 -0
  128. package/dist/gh/rulesets/commands.js +203 -0
  129. package/dist/gh/rulesets/desired.d.ts +112 -0
  130. package/dist/gh/rulesets/desired.js +247 -0
  131. package/dist/gh/rulesets/diff.d.ts +65 -0
  132. package/dist/gh/rulesets/diff.js +134 -0
  133. package/dist/gh/rulesets/types.d.ts +76 -0
  134. package/dist/gh/rulesets/types.js +13 -0
  135. package/dist/gh/settings/api.d.ts +40 -0
  136. package/dist/gh/settings/api.js +172 -0
  137. package/dist/gh/settings/commands.d.ts +1 -0
  138. package/dist/gh/settings/commands.js +245 -0
  139. package/dist/gh/settings/desired.d.ts +53 -0
  140. package/dist/gh/settings/desired.js +39 -0
  141. package/dist/gh/settings/diff.d.ts +57 -0
  142. package/dist/gh/settings/diff.js +156 -0
  143. package/dist/gh/settings/types.d.ts +92 -0
  144. package/dist/gh/settings/types.js +11 -0
  145. package/dist/gh/settings/workflows.d.ts +41 -0
  146. package/dist/gh/settings/workflows.js +124 -0
  147. package/dist/grantRoot.d.ts +42 -0
  148. package/dist/grantRoot.js +89 -0
  149. package/dist/help.d.ts +18 -0
  150. package/dist/help.js +169 -0
  151. package/dist/images/commands.d.ts +35 -0
  152. package/dist/images/commands.js +233 -0
  153. package/dist/images/events.d.ts +36 -0
  154. package/dist/images/events.js +152 -0
  155. package/dist/images/graphics.d.ts +70 -0
  156. package/dist/images/graphics.js +233 -0
  157. package/dist/images/open-graph-types.d.ts +75 -0
  158. package/dist/images/open-graph-types.js +1 -0
  159. package/dist/images/prompts.d.ts +34 -0
  160. package/dist/images/prompts.js +100 -0
  161. package/dist/images/render.d.ts +21 -0
  162. package/dist/images/render.js +57 -0
  163. package/dist/images/select.d.ts +64 -0
  164. package/dist/images/select.js +96 -0
  165. package/dist/instance.d.ts +67 -0
  166. package/dist/instance.js +129 -0
  167. package/dist/invocation.d.ts +49 -0
  168. package/dist/invocation.js +78 -0
  169. package/dist/launch-ci.d.ts +1 -0
  170. package/dist/launch-ci.js +86 -0
  171. package/dist/launch.d.ts +29 -0
  172. package/dist/launch.js +371 -0
  173. package/dist/menu.d.ts +31 -0
  174. package/dist/menu.js +277 -0
  175. package/dist/newsletter/commands.d.ts +16 -0
  176. package/dist/newsletter/commands.js +311 -0
  177. package/dist/newsletter/imap.d.ts +17 -0
  178. package/dist/newsletter/imap.js +127 -0
  179. package/dist/newsletter/loopback.d.ts +24 -0
  180. package/dist/newsletter/loopback.js +100 -0
  181. package/dist/newsletter/oauth.d.ts +26 -0
  182. package/dist/newsletter/oauth.js +130 -0
  183. package/dist/newsletter/smtp.d.ts +23 -0
  184. package/dist/newsletter/smtp.js +133 -0
  185. package/dist/oauth/browser.d.ts +1 -0
  186. package/dist/oauth/browser.js +13 -0
  187. package/dist/oauth/config.d.ts +24 -0
  188. package/dist/oauth/config.js +24 -0
  189. package/dist/oauth/connect-url.d.ts +17 -0
  190. package/dist/oauth/connect-url.js +23 -0
  191. package/dist/oauth/db.d.ts +37 -0
  192. package/dist/oauth/db.js +108 -0
  193. package/dist/oauth/device.d.ts +93 -0
  194. package/dist/oauth/device.js +190 -0
  195. package/dist/oauth/discovery.d.ts +28 -0
  196. package/dist/oauth/discovery.js +54 -0
  197. package/dist/oauth/env-file.d.ts +6 -0
  198. package/dist/oauth/env-file.js +35 -0
  199. package/dist/oauth/exchange.d.ts +43 -0
  200. package/dist/oauth/exchange.js +87 -0
  201. package/dist/oauth/label.d.ts +1 -0
  202. package/dist/oauth/label.js +25 -0
  203. package/dist/oauth/loopback.d.ts +52 -0
  204. package/dist/oauth/loopback.js +162 -0
  205. package/dist/oauth/pkce.d.ts +6 -0
  206. package/dist/oauth/pkce.js +34 -0
  207. package/dist/oauth/target.d.ts +54 -0
  208. package/dist/oauth/target.js +102 -0
  209. package/dist/oauth/transport.d.ts +41 -0
  210. package/dist/oauth/transport.js +32 -0
  211. package/dist/oauth/wizard.d.ts +33 -0
  212. package/dist/oauth/wizard.js +571 -0
  213. package/dist/pick.d.ts +6 -0
  214. package/dist/pick.js +64 -0
  215. package/dist/planner/checks.d.ts +26 -0
  216. package/dist/planner/checks.js +104 -0
  217. package/dist/planner/commands.d.ts +10 -0
  218. package/dist/planner/commands.js +367 -0
  219. package/dist/planner/db.d.ts +15 -0
  220. package/dist/planner/db.js +33 -0
  221. package/dist/planner/role.d.ts +33 -0
  222. package/dist/planner/role.js +68 -0
  223. package/dist/repo/peers.d.ts +24 -0
  224. package/dist/repo/peers.js +114 -0
  225. package/dist/repo/preflight.d.ts +109 -0
  226. package/dist/repo/preflight.js +266 -0
  227. package/dist/repo/resolve.d.ts +41 -0
  228. package/dist/repo/resolve.js +152 -0
  229. package/dist/repo/root.d.ts +23 -0
  230. package/dist/repo/root.js +91 -0
  231. package/dist/repo/source.d.ts +14 -0
  232. package/dist/repo/source.js +54 -0
  233. package/dist/repo/tsx-loader.d.ts +6 -0
  234. package/dist/repo/tsx-loader.js +41 -0
  235. package/dist/run/pick.d.ts +60 -0
  236. package/dist/run/pick.js +559 -0
  237. package/dist/setup.d.ts +1 -0
  238. package/dist/setup.js +152 -0
  239. package/dist/stack.d.ts +48 -0
  240. package/dist/stack.js +290 -0
  241. package/dist/telemetry.d.ts +34 -0
  242. package/dist/telemetry.js +93 -0
  243. package/dist/tier.d.ts +40 -0
  244. package/dist/tier.js +93 -0
  245. package/dist/tsconfig.typecheck.tsbuildinfo +1 -0
  246. package/dist/ui.d.ts +25 -0
  247. package/dist/ui.js +51 -0
  248. package/dist/workers.d.ts +5 -0
  249. package/dist/workers.js +35 -0
  250. package/dist/workflows/commands.d.ts +44 -0
  251. package/dist/workflows/commands.js +668 -0
  252. package/env.ts +158 -0
  253. 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));
@@ -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
+ }
@@ -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>;