@devdogsuga/devtools 0.1.26 → 0.1.27

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 (271) hide show
  1. package/README.md +72 -11
  2. package/bin/devtools.mjs +4 -4
  3. package/dist/cli-CZKkNHK5.js +6619 -0
  4. package/dist/failure-log-BBPGejQv.js +256 -0
  5. package/dist/launch.js +267 -281
  6. package/dist/local-env-D8HC2JK_.js +351 -0
  7. package/dist/local-env-DrBCXqD8.js +2 -0
  8. package/dist/menu-CQBsQRgH.js +1684 -0
  9. package/dist/peer-redirect-hooks.js +15 -0
  10. package/dist/peers-RBplwovA.js +229 -0
  11. package/dist/root-C2OmZDwD.js +94 -0
  12. package/dist/stack-Bx-55oi_.js +2 -0
  13. package/dist/stack-BynCgRVS.js +181 -0
  14. package/dist/supabase-project-0knM0mqd.js +426 -0
  15. package/dist/telemetry-C4foD8MD.js +249 -0
  16. package/dist/telemetry.js +2 -148
  17. package/package.json +10 -29
  18. package/bin/devtools-ci-bare.mjs +0 -48
  19. package/bin/devtools-ci.mjs +0 -31
  20. package/dist/args.d.ts +0 -26
  21. package/dist/args.js +0 -78
  22. package/dist/bws/bw.d.ts +0 -18
  23. package/dist/bws/bw.js +0 -70
  24. package/dist/bws/client.d.ts +0 -43
  25. package/dist/bws/client.js +0 -363
  26. package/dist/bws/environments.d.ts +0 -96
  27. package/dist/bws/environments.js +0 -111
  28. package/dist/bws/pace.d.ts +0 -25
  29. package/dist/bws/pace.js +0 -43
  30. package/dist/bws/retry.d.ts +0 -12
  31. package/dist/bws/retry.js +0 -39
  32. package/dist/bws/store.d.ts +0 -1
  33. package/dist/bws/store.js +0 -32
  34. package/dist/bws/token.d.ts +0 -31
  35. package/dist/bws/token.js +0 -88
  36. package/dist/bws/vault.d.ts +0 -29
  37. package/dist/bws/vault.js +0 -200
  38. package/dist/catalog.d.ts +0 -57
  39. package/dist/catalog.js +0 -57
  40. package/dist/cf/build.d.ts +0 -13
  41. package/dist/cf/build.js +0 -65
  42. package/dist/cf/commands.d.ts +0 -1
  43. package/dist/cf/commands.js +0 -172
  44. package/dist/cf/local-env.d.ts +0 -58
  45. package/dist/cf/local-env.js +0 -177
  46. package/dist/ci.d.ts +0 -1
  47. package/dist/ci.js +0 -328
  48. package/dist/cli.d.ts +0 -11
  49. package/dist/cli.js +0 -1094
  50. package/dist/commands.d.ts +0 -261
  51. package/dist/commands.js +0 -1318
  52. package/dist/completions.d.ts +0 -4
  53. package/dist/completions.js +0 -110
  54. package/dist/cron/commands.d.ts +0 -47
  55. package/dist/cron/commands.js +0 -372
  56. package/dist/cron/discovery.d.ts +0 -55
  57. package/dist/cron/discovery.js +0 -85
  58. package/dist/cron/schema.d.ts +0 -45
  59. package/dist/cron/schema.js +0 -35
  60. package/dist/db/config-push.d.ts +0 -8
  61. package/dist/db/config-push.js +0 -11
  62. package/dist/db/connection.d.ts +0 -79
  63. package/dist/db/connection.js +0 -114
  64. package/dist/db/exec.d.ts +0 -1
  65. package/dist/db/exec.js +0 -11
  66. package/dist/db/generate-types.d.ts +0 -1
  67. package/dist/db/generate-types.js +0 -4
  68. package/dist/db/generated-env.d.ts +0 -69
  69. package/dist/db/generated-env.js +0 -113
  70. package/dist/db/introspect.d.ts +0 -1
  71. package/dist/db/introspect.js +0 -122
  72. package/dist/db/local-env.d.ts +0 -65
  73. package/dist/db/local-env.js +0 -23
  74. package/dist/db/new-migration.d.ts +0 -8
  75. package/dist/db/new-migration.js +0 -69
  76. package/dist/db/pooler.d.ts +0 -23
  77. package/dist/db/pooler.js +0 -55
  78. package/dist/db/run.d.ts +0 -68
  79. package/dist/db/run.js +0 -156
  80. package/dist/db/seed-buckets.d.ts +0 -2
  81. package/dist/db/seed-buckets.js +0 -4
  82. package/dist/db/seed-production.d.ts +0 -8
  83. package/dist/db/seed-production.js +0 -79
  84. package/dist/db/seed-roles.d.ts +0 -7
  85. package/dist/db/seed-roles.js +0 -33
  86. package/dist/db/session-refresh.d.ts +0 -43
  87. package/dist/db/session-refresh.js +0 -40
  88. package/dist/deploy/migrations.d.ts +0 -20
  89. package/dist/deploy/migrations.js +0 -68
  90. package/dist/deploy/orphans.d.ts +0 -20
  91. package/dist/deploy/orphans.js +0 -177
  92. package/dist/deploy/preflight.d.ts +0 -53
  93. package/dist/deploy/preflight.js +0 -189
  94. package/dist/deploy/report.d.ts +0 -26
  95. package/dist/deploy/report.js +0 -70
  96. package/dist/deploy/require-planner.d.ts +0 -2
  97. package/dist/deploy/require-planner.js +0 -60
  98. package/dist/deploy/require-token.d.ts +0 -15
  99. package/dist/deploy/require-token.js +0 -78
  100. package/dist/deploy/secrets-file.d.ts +0 -17
  101. package/dist/deploy/secrets-file.js +0 -166
  102. package/dist/deploy/write-env.d.ts +0 -40
  103. package/dist/deploy/write-env.js +0 -395
  104. package/dist/docs/index-pages.d.ts +0 -38
  105. package/dist/docs/index-pages.js +0 -186
  106. package/dist/emails/commands.d.ts +0 -15
  107. package/dist/emails/commands.js +0 -130
  108. package/dist/emails/email-types.d.ts +0 -13
  109. package/dist/emails/email-types.js +0 -1
  110. package/dist/emails/fixtures.d.ts +0 -20
  111. package/dist/emails/fixtures.js +0 -20
  112. package/dist/env/audit.d.ts +0 -206
  113. package/dist/env/audit.js +0 -436
  114. package/dist/env/cloudflare.d.ts +0 -21
  115. package/dist/env/cloudflare.js +0 -61
  116. package/dist/env/commands.d.ts +0 -99
  117. package/dist/env/commands.js +0 -613
  118. package/dist/env/discovery.d.ts +0 -15
  119. package/dist/env/discovery.js +0 -239
  120. package/dist/env/document.d.ts +0 -119
  121. package/dist/env/document.js +0 -323
  122. package/dist/env/example.d.ts +0 -68
  123. package/dist/env/example.js +0 -605
  124. package/dist/env/selection.d.ts +0 -105
  125. package/dist/env/selection.js +0 -228
  126. package/dist/env-entry.d.ts +0 -49
  127. package/dist/env-entry.js +0 -204
  128. package/dist/environment-doctor.d.ts +0 -45
  129. package/dist/environment-doctor.js +0 -429
  130. package/dist/environment.d.ts +0 -92
  131. package/dist/environment.js +0 -185
  132. package/dist/fingerprint.d.ts +0 -10
  133. package/dist/fingerprint.js +0 -18
  134. package/dist/gen/campus-map.d.ts +0 -1
  135. package/dist/gen/campus-map.js +0 -473
  136. package/dist/gen/commands.d.ts +0 -1
  137. package/dist/gen/commands.js +0 -25
  138. package/dist/gen/hypno.d.ts +0 -1
  139. package/dist/gen/hypno.js +0 -134
  140. package/dist/gh/client.d.ts +0 -80
  141. package/dist/gh/client.js +0 -259
  142. package/dist/gh/environments.d.ts +0 -83
  143. package/dist/gh/environments.js +0 -178
  144. package/dist/gh/rulesets/actors.d.ts +0 -14
  145. package/dist/gh/rulesets/actors.js +0 -69
  146. package/dist/gh/rulesets/api.d.ts +0 -15
  147. package/dist/gh/rulesets/api.js +0 -104
  148. package/dist/gh/rulesets/commands.d.ts +0 -3
  149. package/dist/gh/rulesets/commands.js +0 -203
  150. package/dist/gh/rulesets/desired.d.ts +0 -112
  151. package/dist/gh/rulesets/desired.js +0 -271
  152. package/dist/gh/rulesets/diff.d.ts +0 -65
  153. package/dist/gh/rulesets/diff.js +0 -170
  154. package/dist/gh/rulesets/types.d.ts +0 -76
  155. package/dist/gh/rulesets/types.js +0 -13
  156. package/dist/gh/settings/api.d.ts +0 -40
  157. package/dist/gh/settings/api.js +0 -180
  158. package/dist/gh/settings/commands.d.ts +0 -1
  159. package/dist/gh/settings/commands.js +0 -254
  160. package/dist/gh/settings/desired.d.ts +0 -53
  161. package/dist/gh/settings/desired.js +0 -43
  162. package/dist/gh/settings/diff.d.ts +0 -57
  163. package/dist/gh/settings/diff.js +0 -161
  164. package/dist/gh/settings/types.d.ts +0 -92
  165. package/dist/gh/settings/types.js +0 -11
  166. package/dist/gh/settings/workflows.d.ts +0 -41
  167. package/dist/gh/settings/workflows.js +0 -128
  168. package/dist/grantRoot.d.ts +0 -42
  169. package/dist/grantRoot.js +0 -89
  170. package/dist/help.d.ts +0 -18
  171. package/dist/help.js +0 -169
  172. package/dist/images/commands.d.ts +0 -32
  173. package/dist/images/commands.js +0 -231
  174. package/dist/images/events.d.ts +0 -47
  175. package/dist/images/events.js +0 -116
  176. package/dist/images/graphics.d.ts +0 -70
  177. package/dist/images/graphics.js +0 -234
  178. package/dist/images/open-graph-types.d.ts +0 -75
  179. package/dist/images/open-graph-types.js +0 -1
  180. package/dist/images/prompts.d.ts +0 -34
  181. package/dist/images/prompts.js +0 -100
  182. package/dist/images/render.d.ts +0 -21
  183. package/dist/images/render.js +0 -61
  184. package/dist/images/select.d.ts +0 -64
  185. package/dist/images/select.js +0 -96
  186. package/dist/instance.d.ts +0 -69
  187. package/dist/instance.js +0 -102
  188. package/dist/invocation.d.ts +0 -49
  189. package/dist/invocation.js +0 -78
  190. package/dist/launch-ci.d.ts +0 -1
  191. package/dist/launch-ci.js +0 -90
  192. package/dist/launch.d.ts +0 -18
  193. package/dist/menu.d.ts +0 -43
  194. package/dist/menu.js +0 -300
  195. package/dist/moderation.d.ts +0 -70
  196. package/dist/moderation.js +0 -128
  197. package/dist/oauth/browser.d.ts +0 -1
  198. package/dist/oauth/browser.js +0 -13
  199. package/dist/oauth/config.d.ts +0 -24
  200. package/dist/oauth/config.js +0 -24
  201. package/dist/oauth/connect-url.d.ts +0 -17
  202. package/dist/oauth/connect-url.js +0 -23
  203. package/dist/oauth/db.d.ts +0 -37
  204. package/dist/oauth/db.js +0 -108
  205. package/dist/oauth/device.d.ts +0 -93
  206. package/dist/oauth/device.js +0 -198
  207. package/dist/oauth/discovery.d.ts +0 -28
  208. package/dist/oauth/discovery.js +0 -54
  209. package/dist/oauth/env-file.d.ts +0 -6
  210. package/dist/oauth/env-file.js +0 -35
  211. package/dist/oauth/exchange.d.ts +0 -43
  212. package/dist/oauth/exchange.js +0 -93
  213. package/dist/oauth/label.d.ts +0 -1
  214. package/dist/oauth/label.js +0 -25
  215. package/dist/oauth/loopback.d.ts +0 -52
  216. package/dist/oauth/loopback.js +0 -168
  217. package/dist/oauth/pkce.d.ts +0 -6
  218. package/dist/oauth/pkce.js +0 -34
  219. package/dist/oauth/target.d.ts +0 -54
  220. package/dist/oauth/target.js +0 -102
  221. package/dist/oauth/transport.d.ts +0 -41
  222. package/dist/oauth/transport.js +0 -32
  223. package/dist/oauth/wizard.d.ts +0 -40
  224. package/dist/oauth/wizard.js +0 -578
  225. package/dist/persona.d.ts +0 -18
  226. package/dist/persona.js +0 -221
  227. package/dist/pick.d.ts +0 -6
  228. package/dist/pick.js +0 -64
  229. package/dist/pipes.d.ts +0 -1
  230. package/dist/pipes.js +0 -25
  231. package/dist/planner/checks.d.ts +0 -26
  232. package/dist/planner/checks.js +0 -104
  233. package/dist/planner/commands.d.ts +0 -10
  234. package/dist/planner/commands.js +0 -367
  235. package/dist/planner/db.d.ts +0 -15
  236. package/dist/planner/db.js +0 -33
  237. package/dist/planner/role.d.ts +0 -33
  238. package/dist/planner/role.js +0 -68
  239. package/dist/repo/peer-redirect-hooks.d.ts +0 -16
  240. package/dist/repo/peer-redirect-hooks.js +0 -10
  241. package/dist/repo/peer-redirect.d.ts +0 -4
  242. package/dist/repo/peer-redirect.js +0 -26
  243. package/dist/repo/peers.d.ts +0 -39
  244. package/dist/repo/peers.js +0 -139
  245. package/dist/repo/resolve.d.ts +0 -41
  246. package/dist/repo/resolve.js +0 -152
  247. package/dist/repo/root.d.ts +0 -23
  248. package/dist/repo/root.js +0 -91
  249. package/dist/repo/source.d.ts +0 -14
  250. package/dist/repo/source.js +0 -54
  251. package/dist/repo/supabase-project.d.ts +0 -60
  252. package/dist/repo/supabase-project.js +0 -124
  253. package/dist/repo/tsx-loader.d.ts +0 -6
  254. package/dist/repo/tsx-loader.js +0 -41
  255. package/dist/run/pick.d.ts +0 -90
  256. package/dist/run/pick.js +0 -664
  257. package/dist/setup.d.ts +0 -1
  258. package/dist/setup.js +0 -280
  259. package/dist/stack.d.ts +0 -48
  260. package/dist/stack.js +0 -403
  261. package/dist/telemetry.d.ts +0 -59
  262. package/dist/tier.d.ts +0 -40
  263. package/dist/tier.js +0 -96
  264. package/dist/ui.d.ts +0 -40
  265. package/dist/ui.js +0 -71
  266. package/dist/version.d.ts +0 -7
  267. package/dist/version.js +0 -17
  268. package/dist/workers.d.ts +0 -5
  269. package/dist/workers.js +0 -33
  270. package/dist/workflows/commands.d.ts +0 -54
  271. package/dist/workflows/commands.js +0 -763
package/dist/ci.js DELETED
@@ -1,328 +0,0 @@
1
- /**
2
- * `devtools-ci deploy <app|step> [flags]`
3
- *
4
- * The CI entry point. No wizard and no `@clack/prompts`. Commands that create
5
- * the deploy env file run through the bare `ci` package script; commands that
6
- * consume that file run through `ci:env`, which wraps this same entry point in
7
- * `with-env`. Every command runs in GitHub Actions and reports failures by
8
- * exiting non-zero.
9
- *
10
- * ## Why a separate bin
11
- *
12
- * The contributor CLI (`devtools`) prompts interactively and wraps output in
13
- * clack's box-drawing. None of that belongs in a deploy job. This entry point
14
- * never imports clack, so a caller that pipes its stdout is never surprised by
15
- * a banner landing on that stream. `with-env` reports its selected file on
16
- * stderr, leaving the command's stdout protocol intact.
17
- *
18
- * ## The deploy orchestrator
19
- *
20
- * `devtools-ci deploy <app> --tier <staging|production>` replaces the three
21
- * near-identical `cf:deploy:*` shell strings in the app package.json files.
22
- * It runs `require-token`, then the app-specific deploy commands: docs index
23
- * for platform only, then a plain `wrangler deploy` for all three apps.
24
- * Both Next.js apps are on vinext now -- deploy-app.yaml's separate "Build"
25
- * step already ran `vinext build` (`cf:build:$DEPLOY_ENV`), which leaves a
26
- * Wrangler "config redirect" at `.wrangler/deploy/config.json` pointing at
27
- * the generated `dist/server/wrangler.json`; a bare `wrangler deploy` from
28
- * the app dir resolves through that redirect with no `--config` needed.
29
- * Sandbox (plain Worker, wrangler bundles it at deploy time) always used
30
- * this shape, so all three apps now share one deploy step.
31
- *
32
- * Step commands (`write-env`, `secrets-file`, etc.) are still individually
33
- * addressable for jobs that run only one step.
34
- */
35
- import { spawn } from "node:child_process";
36
- import { loadEnvLoad } from "./repo/peers.js";
37
- import { DeployError, say } from "./deploy/report.js";
38
- import { renderWriteEnvReport, runDeployWriteEnv } from "./deploy/write-env.js";
39
- import { runDeploySecretsFile } from "./deploy/secrets-file.js";
40
- import { runDeployOrphans } from "./deploy/orphans.js";
41
- import { runPreflight } from "./deploy/preflight.js";
42
- import { runDeployMigrate, runDeployPlan } from "./deploy/migrations.js";
43
- import { runRequirePlanner } from "./deploy/require-planner.js";
44
- import { runRequireToken } from "./deploy/require-token.js";
45
- import { runDocsIndex } from "./docs/index-pages.js";
46
- import { loadRegistry } from "./env/discovery.js";
47
- import { positionals } from "./args.js";
48
- import { findCiCommand, subcommandCiNames } from "./commands.js";
49
- import { isWorkerApp, workerApps } from "./workers.js";
50
- import { ignoreClosedPipes } from "./pipes.js";
51
- import { captureDevtoolsError, initDevtoolsTelemetry, reportDevtoolsError, reportDevtoolsFailure, } from "./telemetry.js";
52
- function flagValue(rest, flag) {
53
- const index = rest.indexOf(flag);
54
- if (index === -1)
55
- return undefined;
56
- const value = rest[index + 1];
57
- return value && !value.startsWith("--") ? value : undefined;
58
- }
59
- function isApp(value) {
60
- return isWorkerApp(value);
61
- }
62
- /**
63
- * Wrangler's local Hyperdrive emulator wants its binding-specific alias, not
64
- * `DB_URL`. Mirror both of `process.env`'s relevant keys into a scratch
65
- * object so the shared `applyWranglerLocalDatabaseAlias` guard — never
66
- * clobber an alias someone already set — runs against the same values it
67
- * would in-process, then hand back only the alias override for `pnpm()`'s
68
- * env merge (`DB_URL` itself reaches the child already, via the base
69
- * `process.env` spread).
70
- */
71
- async function hyperdriveLocalAliasEnv() {
72
- const { applyWranglerLocalDatabaseAlias, HYPERDRIVE_LOCAL_CONNECTION_ENV } = await loadEnvLoad();
73
- const scratch = {};
74
- const existingAlias = process.env[HYPERDRIVE_LOCAL_CONNECTION_ENV];
75
- if (existingAlias !== undefined) {
76
- scratch[HYPERDRIVE_LOCAL_CONNECTION_ENV] = existingAlias;
77
- }
78
- if (process.env.DB_URL !== undefined)
79
- scratch.DB_URL = process.env.DB_URL;
80
- applyWranglerLocalDatabaseAlias(scratch);
81
- delete scratch.DB_URL;
82
- return scratch;
83
- }
84
- /**
85
- * Runs a command via pnpm, inheriting stdio, returning the exit code.
86
- *
87
- * All orchestrator steps are external processes rather than imported
88
- * functions: `wrangler` (and, for platform, the docs build) own their own
89
- * stdout and must not be wrapped.
90
- */
91
- function pnpm(args, env) {
92
- return new Promise((resolve) => {
93
- const child = spawn("pnpm", args, {
94
- stdio: "inherit",
95
- env: { ...process.env, ...env },
96
- });
97
- child.on("exit", (code) => resolve(code ?? 1));
98
- });
99
- }
100
- /**
101
- * `devtools-ci deploy <app> --tier <staging|production>`
102
- *
103
- * Orchestrates the full deploy for one app:
104
- * 1. `require-token` guard
105
- * 2. Docs index (platform only)
106
- * 3. App deploy via `wrangler deploy`
107
- *
108
- * The `--dry-run` flag prints what would run and exits 0.
109
- */
110
- async function runAppDeploy(app, rest) {
111
- const tier = flagValue(rest, "--tier") ?? process.env.DEPLOY_ENV;
112
- if (!tier) {
113
- throw new DeployError("--tier <staging|production> is required.", [
114
- "Or set DEPLOY_ENV in the environment.",
115
- ]);
116
- }
117
- if (tier !== "staging" && tier !== "production") {
118
- throw new DeployError(`Unknown tier "${tier}".`, [
119
- "Use --tier staging or --tier production.",
120
- ]);
121
- }
122
- const dryRun = rest.includes("--dry-run");
123
- const secretsFile = process.env.DEPLOY_SECRETS_FILE;
124
- const steps = [];
125
- // Platform is the only app with a prestep: it owns the docs site, so its
126
- // deploy re-indexes the (already-built-elsewhere) docs into the remote
127
- // search store before the Worker goes out.
128
- if (app === "platform") {
129
- steps.push({
130
- label: "Index docs",
131
- fn: async () => {
132
- const buildCode = await pnpm(["--filter", "@devdogsuga/docs", "build"]);
133
- if (buildCode !== 0)
134
- return buildCode;
135
- const before = process.exitCode;
136
- process.exitCode = 0;
137
- await runDocsIndex({ target: "remote" });
138
- const code = process.exitCode === 0 ? 0 : 1;
139
- process.exitCode = before;
140
- return code;
141
- },
142
- });
143
- }
144
- // All three apps now share one deploy shape: a bare `wrangler deploy -e
145
- // <tier>` from the app directory. Both Next.js apps' target environment is
146
- // baked in at BUILD time (deploy-app.yaml's separate "Build" step already
147
- // ran `cf:build:$DEPLOY_ENV`, i.e. `vinext build` with
148
- // `CLOUDFLARE_ENV=$tier`), which leaves a Wrangler "config redirect" at
149
- // `.wrangler/deploy/config.json` pointing at `dist/server/wrangler.json`;
150
- // sandbox is a plain Worker with no such redirect and no build step at all.
151
- // `-e` is passed regardless: for the vinext apps, Wrangler cross-checks it
152
- // against the environment the build was tagged with and errors loudly on a
153
- // mismatch, rather than silently deploying the wrong tier.
154
- const deployArgs = [
155
- "--filter",
156
- app,
157
- "exec",
158
- "wrangler",
159
- "deploy",
160
- "-e",
161
- tier,
162
- ];
163
- if (secretsFile)
164
- deployArgs.push("--secrets-file", secretsFile);
165
- // See apps/*/cloudflare/worker.ts's `WorkerEnv` doc: `SENTRY_RELEASE` is
166
- // the deploy's git SHA, minted fresh by CI every run rather than a value
167
- // Bitwarden holds, so it reaches the Worker as a `--var` here rather than
168
- // through `~/env`'s schema or the secrets file above. Absent outside a
169
- // CI-driven deploy.
170
- if (process.env.SENTRY_RELEASE) {
171
- deployArgs.push("--var", `SENTRY_RELEASE:${process.env.SENTRY_RELEASE}`);
172
- }
173
- steps.push({
174
- label: `Deploy ${app} (${tier})`,
175
- // sandbox has no Hyperdrive binding, so the local-database alias is a
176
- // no-op for it; passing it unconditionally keeps this one step shape for
177
- // all three apps rather than branching again just to omit it.
178
- fn: async () => pnpm(deployArgs, await hyperdriveLocalAliasEnv()),
179
- });
180
- if (dryRun) {
181
- say([
182
- `devtools-ci deploy ${app} --tier ${tier} --dry-run`,
183
- ...steps.map((s) => ` ${s.label}`),
184
- ]);
185
- return;
186
- }
187
- // require-token guard: checked inline so the step list above prints on
188
- // --dry-run without requiring the token.
189
- runRequireToken();
190
- for (const step of steps) {
191
- const code = await step.fn();
192
- if (code !== 0) {
193
- // A step is a subprocess (`pnpm … wrangler deploy`) whose output
194
- // already explains itself in the job log; this is only the signal that
195
- // a deploy broke, grouped per app and step.
196
- reportDevtoolsFailure(`devtools-ci deploy ${app}: "${step.label}" failed`, { tier, exitCode: code });
197
- process.exitCode = code;
198
- return;
199
- }
200
- }
201
- }
202
- // ── Deploy dispatch ───────────────────────────────────────────────────────────
203
- async function runDeployCommand(rest) {
204
- const [sub] = positionals(rest);
205
- if (!sub) {
206
- const steps = subcommandCiNames(["deploy"]);
207
- const width = Math.max(...steps.map((name) => name.length)) + 2;
208
- say([
209
- "devtools-ci deploy: which step or app?",
210
- ...steps.map((name) => ` ${name.padEnd(width)}${findCiCommand(["deploy", name]).summary}`),
211
- ]);
212
- process.exitCode = 1;
213
- return;
214
- }
215
- // App orchestrators
216
- if (isApp(sub)) {
217
- await runAppDeploy(sub, rest.slice(1));
218
- return;
219
- }
220
- try {
221
- if (sub === "require-token") {
222
- runRequireToken();
223
- return;
224
- }
225
- if (sub === "require-planner") {
226
- await runRequirePlanner();
227
- return;
228
- }
229
- if (sub === "plan") {
230
- await runDeployPlan(flagValue(rest, "--label"));
231
- return;
232
- }
233
- if (sub === "migrate") {
234
- await runDeployMigrate();
235
- return;
236
- }
237
- if (sub === "preflight") {
238
- await runPreflight();
239
- return;
240
- }
241
- await loadRegistry();
242
- if (sub === "write-env") {
243
- const index = rest.indexOf("--source");
244
- const source = index === -1 ? null : rest[index + 1];
245
- if (index !== -1 && (!source || source.startsWith("--"))) {
246
- throw new DeployError("--source needs a manifest name, e.g. --source supabase.");
247
- }
248
- const result = await runDeployWriteEnv({ source });
249
- say(renderWriteEnvReport(result));
250
- return;
251
- }
252
- if (sub === "secrets-file") {
253
- const app = flagValue(rest, "--app");
254
- if (!app) {
255
- throw new DeployError("--app <name> is required.", [
256
- "It names the workspace app whose manifest declares the Worker's",
257
- `secrets — ${workerApps().join(", ")}.`,
258
- ]);
259
- }
260
- await runDeploySecretsFile({ app });
261
- return;
262
- }
263
- if (sub === "orphans") {
264
- await runDeployOrphans({ prune: rest.includes("--prune") });
265
- return;
266
- }
267
- say([`devtools-ci deploy: unknown subcommand "${sub}".`]);
268
- process.exitCode = 1;
269
- }
270
- catch (err) {
271
- say(err instanceof DeployError
272
- ? [
273
- `devtools-ci deploy ${sub}: ${err.message}`,
274
- ...err.detail.map((line) => ` ${line}`),
275
- ]
276
- : [
277
- `devtools-ci deploy ${sub}: ${err instanceof Error ? err.message : String(err)}`,
278
- ]);
279
- // Caught here, so `launch-ci.ts`'s capture never sees it. Every deploy
280
- // step runs in CI, where a failure is never the reader's typo to fix.
281
- reportDevtoolsError(err);
282
- process.exitCode = 1;
283
- }
284
- }
285
- // ── Entry ─────────────────────────────────────────────────────────────────────
286
- export async function main(argv) {
287
- const [first, ...rest] = argv;
288
- // Same bootstrap point as `cli.ts`'s `main()`: after `argv` is split, before
289
- // any dispatch below. `[first, rest[0]]` names the step (`deploy
290
- // secrets-file`, `deploy platform`, …) as the `command` tag rather than just
291
- // "deploy", which every invocation here would otherwise share.
292
- ignoreClosedPipes();
293
- initDevtoolsTelemetry([first, rest[0]].filter(Boolean).join(" ") || "help");
294
- if (!first || first === "--help" || first === "-h") {
295
- const steps = subcommandCiNames(["deploy"]);
296
- const width = Math.max(...steps.map((name) => name.length)) + 2;
297
- process.stdout.write([
298
- "devtools-ci <command>",
299
- "",
300
- "Commands:",
301
- ` ${"deploy".padEnd(width)}Deploy an app or run a deploy step.`,
302
- "",
303
- "Run `devtools-ci deploy` for the full step list.",
304
- "",
305
- ].join("\n"));
306
- return;
307
- }
308
- if (first === "deploy") {
309
- await runDeployCommand(rest);
310
- return;
311
- }
312
- process.stderr.write(`devtools-ci: unknown command "${first}".\n`);
313
- process.exitCode = 1;
314
- }
315
- // Run only from `src/launch-ci.ts` (via the `devtools-ci` bin) or from a
316
- // bare `run ci` package script for the steps that must not go through
317
- // `with-env`'s replacement at all — see that file's header. Never
318
- // self-invoking here: importing this module must not run anything, so
319
- // `launch-ci.ts` can resolve the deploy tier and enter its environment
320
- // first.
321
- if (import.meta.url === `file://${process.argv[1]}`) {
322
- main(process.argv.slice(2)).catch(async (err) => {
323
- process.stderr.write(`devtools-ci: ${err instanceof Error ? err.message : String(err)}\n`);
324
- // Report BEFORE exiting — see `captureDevtoolsError`'s header.
325
- await captureDevtoolsError(err);
326
- process.exitCode = 1;
327
- });
328
- }
package/dist/cli.d.ts DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * Runs the CLI against an already-resolved argv.
3
- *
4
- * Exported rather than run at import, so `src/launch.ts` can resolve the
5
- * deploy tier and enter its environment BEFORE this module's imports (and the
6
- * commands they pull in) ever see `process.env` — see that file's header. The
7
- * shebang above stays harmless: importing this module runs nothing, only
8
- * `main()` does, and nothing calls it but `launch.ts` and the `import.meta.url`
9
- * guard at the bottom of this file, for a direct `tsx src/cli.ts` run.
10
- */
11
- export declare function main(argv: string[]): Promise<void>;