@caelo-cms/provisioning 0.12.5 → 0.12.6-rc.1

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 (62) hide show
  1. package/dist/admin-internal.d.ts +1 -1
  2. package/dist/agent-db.js +192 -130
  3. package/dist/cli-routing.d.ts.map +1 -1
  4. package/dist/cli-routing.js +2 -1
  5. package/dist/cli-routing.js.map +1 -1
  6. package/dist/cli.js +15 -1
  7. package/dist/cli.js.map +1 -1
  8. package/dist/gcloud.d.ts +32 -1
  9. package/dist/gcloud.d.ts.map +1 -1
  10. package/dist/gcloud.js +59 -7
  11. package/dist/gcloud.js.map +1 -1
  12. package/dist/infra-contract.d.ts +1 -1
  13. package/dist/infra-contract.d.ts.map +1 -1
  14. package/dist/infra-contract.js +9 -1
  15. package/dist/infra-contract.js.map +1 -1
  16. package/dist/upgrader-iam-preflight.d.ts.map +1 -1
  17. package/dist/upgrader-iam-preflight.js +8 -1
  18. package/dist/upgrader-iam-preflight.js.map +1 -1
  19. package/dist/upgrader-setup.d.ts +19 -0
  20. package/dist/upgrader-setup.d.ts.map +1 -1
  21. package/dist/upgrader-setup.js +78 -56
  22. package/dist/upgrader-setup.js.map +1 -1
  23. package/dist/wizard.d.ts +6 -0
  24. package/dist/wizard.d.ts.map +1 -1
  25. package/dist/wizard.js +4 -0
  26. package/dist/wizard.js.map +1 -1
  27. package/dist/wizards/gcp-billing.d.ts +81 -0
  28. package/dist/wizards/gcp-billing.d.ts.map +1 -0
  29. package/dist/wizards/gcp-billing.js +117 -0
  30. package/dist/wizards/gcp-billing.js.map +1 -0
  31. package/dist/wizards/gcp-firebase.d.ts +2 -0
  32. package/dist/wizards/gcp-firebase.d.ts.map +1 -1
  33. package/dist/wizards/gcp-firebase.js +1 -0
  34. package/dist/wizards/gcp-firebase.js.map +1 -1
  35. package/dist/wizards/gcp-install-job.d.ts +3 -0
  36. package/dist/wizards/gcp-install-job.d.ts.map +1 -1
  37. package/dist/wizards/gcp-install-job.js +5 -1
  38. package/dist/wizards/gcp-install-job.js.map +1 -1
  39. package/dist/wizards/gcp.d.ts +6 -0
  40. package/dist/wizards/gcp.d.ts.map +1 -1
  41. package/dist/wizards/gcp.js +68 -36
  42. package/dist/wizards/gcp.js.map +1 -1
  43. package/package.json +2 -2
  44. package/src/admin-internal.ts +1 -1
  45. package/src/cli-routing.test.ts +1 -1
  46. package/src/cli-routing.ts +2 -1
  47. package/src/cli.ts +16 -1
  48. package/src/gcloud.test.ts +67 -0
  49. package/src/gcloud.ts +78 -11
  50. package/src/infra-contract.test.ts +4 -3
  51. package/src/infra-contract.ts +9 -1
  52. package/src/upgrader-iam-preflight.test.ts +49 -42
  53. package/src/upgrader-iam-preflight.ts +8 -0
  54. package/src/upgrader-job.test.ts +1 -0
  55. package/src/upgrader-setup.test.ts +2 -0
  56. package/src/upgrader-setup.ts +86 -55
  57. package/src/wizard.ts +10 -0
  58. package/src/wizards/gcp-billing.test.ts +260 -0
  59. package/src/wizards/gcp-billing.ts +150 -0
  60. package/src/wizards/gcp-firebase.ts +3 -0
  61. package/src/wizards/gcp-install-job.ts +7 -1
  62. package/src/wizards/gcp.ts +86 -43
@@ -34,7 +34,7 @@ export interface AdminInternalDeps {
34
34
  export interface AdminInternalCall {
35
35
  /** Path under the admin origin, e.g. `/api/internal/owner-reset`. */
36
36
  readonly endpoint: string;
37
- /** Scope the endpoint's `requireInternalAuth` checks. */
37
+ /** Scope the endpoint's `internalAuthRefusal` checks. */
38
38
  readonly scope: string;
39
39
  readonly body: Record<string, unknown>;
40
40
  /** The issue that added the endpoint, named when an older admin answers 404. */
package/dist/agent-db.js CHANGED
@@ -19193,6 +19193,161 @@ function isRlsDenial(error) {
19193
19193
  return false;
19194
19194
  }
19195
19195
 
19196
+ // ../query-api/src/pool-guard.ts
19197
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
19198
+ var POOL_ACQUIRE_TIMEOUT_MS = 1e4;
19199
+ var LONG_TRANSACTIONS = [
19200
+ {
19201
+ holder: "static-generator.build",
19202
+ reason: "a static site build runs in one transaction for as long as the build takes, idle while plugins render and files are written."
19203
+ }
19204
+ ];
19205
+ var LONG_TRANSACTION_ALLOWLIST = new Map(LONG_TRANSACTIONS.map((entry) => [entry.holder, entry]));
19206
+
19207
+ class SerialQueue {
19208
+ #tail = Promise.resolve();
19209
+ run(fn) {
19210
+ const next = this.#tail.then(fn, fn);
19211
+ this.#tail = next.catch(() => {
19212
+ return;
19213
+ });
19214
+ return next;
19215
+ }
19216
+ }
19217
+
19218
+ class NestedPoolCheckoutError extends Error {
19219
+ pool;
19220
+ holder;
19221
+ requester;
19222
+ name = "NestedPoolCheckoutError";
19223
+ constructor(pool, holder, requester) {
19224
+ super(`${requester} asked the ${pool} database pool for a second connection while ${holder} holds a transaction of that pool in the same call chain. ` + "Enough of these at once deadlock the whole pool (issue #1210), so it is refused. Nothing of this call ran. " + `Fix in the code: pass ${holder}'s transaction to the inner work (op.handler(ctx, input, tx)) or move the inner work out of the transaction (transaction: "none").`);
19225
+ this.pool = pool;
19226
+ this.holder = holder;
19227
+ this.requester = requester;
19228
+ }
19229
+ }
19230
+
19231
+ class PoolAcquireTimeoutError extends Error {
19232
+ pool;
19233
+ requester;
19234
+ timeoutMs;
19235
+ name = "PoolAcquireTimeoutError";
19236
+ constructor(pool, requester, timeoutMs) {
19237
+ super(`the ${pool} database pool had no free connection for ${requester} within ${timeoutMs} ms: every connection is busy. ` + `Nothing was changed. Retry in a few seconds (wait about ${Math.round(POOL_BUSY_RETRY_AFTER_MS / 1000)} s, then send the same call again unchanged); ` + "if it keeps happening the admin is overloaded or a request holds its connections \u2014 the server log names it.");
19238
+ this.pool = pool;
19239
+ this.requester = requester;
19240
+ this.timeoutMs = timeoutMs;
19241
+ }
19242
+ }
19243
+ var POOL_BUSY_RETRY_AFTER_MS = 5000;
19244
+ var joining = new AsyncLocalStorage2;
19245
+ function newMarker(holder, root) {
19246
+ return {
19247
+ holder,
19248
+ active: true,
19249
+ tx: null,
19250
+ identity: null,
19251
+ identityOpName: null,
19252
+ root,
19253
+ joined: new SerialQueue,
19254
+ afterEnd: []
19255
+ };
19256
+ }
19257
+
19258
+ class PoolGuard {
19259
+ #stores = {
19260
+ admin: new AsyncLocalStorage2,
19261
+ public: new AsyncLocalStorage2
19262
+ };
19263
+ plan(pool, holder) {
19264
+ const outer = this.held(pool);
19265
+ if (outer === null)
19266
+ return { kind: "own", marker: newMarker(holder, null) };
19267
+ this.assertMayCheckout(pool, holder);
19268
+ return { kind: "join", outer, marker: newMarker(holder, outer.root ?? outer) };
19269
+ }
19270
+ held(pool) {
19271
+ const outer = this.#stores[pool].getStore();
19272
+ return outer?.active ? outer : null;
19273
+ }
19274
+ assertMayCheckout(pool, requester) {
19275
+ const outer = this.held(pool);
19276
+ if (outer === null || joining.getStore() === true)
19277
+ return;
19278
+ throw new NestedPoolCheckoutError(pool, outer.holder, requester);
19279
+ }
19280
+ assertNoHeldTransaction(pool, requester) {
19281
+ const outer = this.held(pool);
19282
+ if (outer !== null)
19283
+ throw new NestedPoolCheckoutError(pool, outer.holder, requester);
19284
+ }
19285
+ async deferUntilEnd(pool, work) {
19286
+ const outer = this.held(pool);
19287
+ if (outer === null) {
19288
+ await work();
19289
+ return false;
19290
+ }
19291
+ (outer.root ?? outer).afterEnd.push(work);
19292
+ return true;
19293
+ }
19294
+ async run(pool, marker, fn) {
19295
+ try {
19296
+ return await this.#stores[pool].run(marker, fn);
19297
+ } finally {
19298
+ marker.active = false;
19299
+ }
19300
+ }
19301
+ }
19302
+ function exemptFromSessionTimeouts(holder) {
19303
+ return LONG_TRANSACTION_ALLOWLIST.has(holder);
19304
+ }
19305
+ async function liftSessionTimeouts(tx) {
19306
+ await tx.execute(sql`SELECT set_config('statement_timeout', '0', true)`);
19307
+ await tx.execute(sql`SELECT set_config('lock_timeout', '0', true)`);
19308
+ await tx.execute(sql`SELECT set_config('idle_in_transaction_session_timeout', '0', true)`);
19309
+ }
19310
+ function detachedRunner(operation, open) {
19311
+ const transaction = (fn) => open(fn);
19312
+ return new Proxy({}, {
19313
+ get(_target, property) {
19314
+ if (property === "transaction")
19315
+ return transaction;
19316
+ if (property === "then")
19317
+ return;
19318
+ throw new Error(`${operation} is a detached operation (transaction: "none") and holds no transaction; it used tx.${String(property)}. Wrap the step in tx.transaction(async (t) => \u2026) or run it as its own operation.`);
19319
+ }
19320
+ });
19321
+ }
19322
+
19323
+ // ../query-api/src/database-trouble.ts
19324
+ var PG_IDLE_IN_TRANSACTION_TIMEOUT = "25P03";
19325
+ function messages(thrown) {
19326
+ const out = [];
19327
+ let current = thrown;
19328
+ for (let depth = 0;depth < 5 && typeof current === "object" && current !== null; depth++) {
19329
+ const message = current.message;
19330
+ if (typeof message === "string")
19331
+ out.push(message);
19332
+ current = current.cause;
19333
+ }
19334
+ return out.join(" | ");
19335
+ }
19336
+ function classifyDatabaseTrouble(thrown) {
19337
+ if (thrown instanceof PoolAcquireTimeoutError)
19338
+ return "pool_wait_timeout";
19339
+ const pg = extractPgFields(thrown);
19340
+ if (pg?.timeout === "statement")
19341
+ return "statement_timeout";
19342
+ if (pg?.timeout === "lock")
19343
+ return "lock_timeout";
19344
+ if (pg?.code === PG_IDLE_IN_TRANSACTION_TIMEOUT)
19345
+ return "idle_in_transaction_timeout";
19346
+ if (/idle-in-transaction timeout/i.test(messages(thrown)))
19347
+ return "idle_in_transaction_timeout";
19348
+ return null;
19349
+ }
19350
+
19196
19351
  // ../query-api/src/operation.ts
19197
19352
  import { appendFileSync, mkdirSync } from "fs";
19198
19353
  import { dirname } from "path";
@@ -19350,133 +19505,6 @@ async function provisionPluginSchemaInTx(tx, caller, opts) {
19350
19505
  };
19351
19506
  }
19352
19507
 
19353
- // ../query-api/src/pool-guard.ts
19354
- import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
19355
- var POOL_ACQUIRE_TIMEOUT_MS = 1e4;
19356
- var LONG_TRANSACTIONS = [
19357
- {
19358
- holder: "static-generator.build",
19359
- reason: "a static site build runs in one transaction for as long as the build takes, idle while plugins render and files are written."
19360
- }
19361
- ];
19362
- var LONG_TRANSACTION_ALLOWLIST = new Map(LONG_TRANSACTIONS.map((entry) => [entry.holder, entry]));
19363
-
19364
- class SerialQueue {
19365
- #tail = Promise.resolve();
19366
- run(fn) {
19367
- const next = this.#tail.then(fn, fn);
19368
- this.#tail = next.catch(() => {
19369
- return;
19370
- });
19371
- return next;
19372
- }
19373
- }
19374
-
19375
- class NestedPoolCheckoutError extends Error {
19376
- pool;
19377
- holder;
19378
- requester;
19379
- name = "NestedPoolCheckoutError";
19380
- constructor(pool, holder, requester) {
19381
- super(`${requester} asked the ${pool} database pool for a second connection while ${holder} holds a transaction of that pool in the same call chain. ` + "Enough of these at once deadlock the whole pool (issue #1210), so it is refused. Nothing of this call ran. " + `Fix in the code: pass ${holder}'s transaction to the inner work (op.handler(ctx, input, tx)) or move the inner work out of the transaction (transaction: "none").`);
19382
- this.pool = pool;
19383
- this.holder = holder;
19384
- this.requester = requester;
19385
- }
19386
- }
19387
-
19388
- class PoolAcquireTimeoutError extends Error {
19389
- pool;
19390
- requester;
19391
- timeoutMs;
19392
- name = "PoolAcquireTimeoutError";
19393
- constructor(pool, requester, timeoutMs) {
19394
- super(`the ${pool} database pool had no free connection for ${requester} within ${timeoutMs} ms: every connection is busy. ` + `Nothing was changed. Retry in a few seconds (wait about ${Math.round(POOL_BUSY_RETRY_AFTER_MS / 1000)} s, then send the same call again unchanged); ` + "if it keeps happening the admin is overloaded or a request holds its connections \u2014 the server log names it.");
19395
- this.pool = pool;
19396
- this.requester = requester;
19397
- this.timeoutMs = timeoutMs;
19398
- }
19399
- }
19400
- var POOL_BUSY_RETRY_AFTER_MS = 5000;
19401
- var joining = new AsyncLocalStorage2;
19402
- function newMarker(holder, root) {
19403
- return {
19404
- holder,
19405
- active: true,
19406
- tx: null,
19407
- identity: null,
19408
- identityOpName: null,
19409
- root,
19410
- joined: new SerialQueue,
19411
- afterEnd: []
19412
- };
19413
- }
19414
-
19415
- class PoolGuard {
19416
- #stores = {
19417
- admin: new AsyncLocalStorage2,
19418
- public: new AsyncLocalStorage2
19419
- };
19420
- plan(pool, holder) {
19421
- const outer = this.held(pool);
19422
- if (outer === null)
19423
- return { kind: "own", marker: newMarker(holder, null) };
19424
- this.assertMayCheckout(pool, holder);
19425
- return { kind: "join", outer, marker: newMarker(holder, outer.root ?? outer) };
19426
- }
19427
- held(pool) {
19428
- const outer = this.#stores[pool].getStore();
19429
- return outer?.active ? outer : null;
19430
- }
19431
- assertMayCheckout(pool, requester) {
19432
- const outer = this.held(pool);
19433
- if (outer === null || joining.getStore() === true)
19434
- return;
19435
- throw new NestedPoolCheckoutError(pool, outer.holder, requester);
19436
- }
19437
- assertNoHeldTransaction(pool, requester) {
19438
- const outer = this.held(pool);
19439
- if (outer !== null)
19440
- throw new NestedPoolCheckoutError(pool, outer.holder, requester);
19441
- }
19442
- async deferUntilEnd(pool, work) {
19443
- const outer = this.held(pool);
19444
- if (outer === null) {
19445
- await work();
19446
- return false;
19447
- }
19448
- (outer.root ?? outer).afterEnd.push(work);
19449
- return true;
19450
- }
19451
- async run(pool, marker, fn) {
19452
- try {
19453
- return await this.#stores[pool].run(marker, fn);
19454
- } finally {
19455
- marker.active = false;
19456
- }
19457
- }
19458
- }
19459
- function exemptFromSessionTimeouts(holder) {
19460
- return LONG_TRANSACTION_ALLOWLIST.has(holder);
19461
- }
19462
- async function liftSessionTimeouts(tx) {
19463
- await tx.execute(sql`SELECT set_config('statement_timeout', '0', true)`);
19464
- await tx.execute(sql`SELECT set_config('lock_timeout', '0', true)`);
19465
- await tx.execute(sql`SELECT set_config('idle_in_transaction_session_timeout', '0', true)`);
19466
- }
19467
- function detachedRunner(operation, open) {
19468
- const transaction = (fn) => open(fn);
19469
- return new Proxy({}, {
19470
- get(_target, property) {
19471
- if (property === "transaction")
19472
- return transaction;
19473
- if (property === "then")
19474
- return;
19475
- throw new Error(`${operation} is a detached operation (transaction: "none") and holds no transaction; it used tx.${String(property)}. Wrap the step in tx.transaction(async (t) => \u2026) or run it as its own operation.`);
19476
- }
19477
- });
19478
- }
19479
-
19480
19508
  // ../query-api/src/pool-pressure.ts
19481
19509
  var BUN_DEFAULT_POOL_MAX = 10;
19482
19510
 
@@ -19668,6 +19696,7 @@ class DatabaseAdapter {
19668
19696
  #acquireTimeoutMs;
19669
19697
  #guard = new PoolGuard;
19670
19698
  #demand;
19699
+ #troubleListeners = new Set;
19671
19700
  #verifyPromise = null;
19672
19701
  #projectionPublisher = null;
19673
19702
  #onStatement;
@@ -19709,9 +19738,42 @@ class DatabaseAdapter {
19709
19738
  if (raw === null)
19710
19739
  throw new AdminDatabaseUnavailableError(holder);
19711
19740
  const plan = this.#guard.plan(pool, holder);
19712
- if (plan.kind === "join")
19713
- return this.#joinHeld(pool, plan.outer, plan.marker, fn);
19714
- const marker = plan.marker;
19741
+ const startedAt = Date.now();
19742
+ try {
19743
+ return plan.kind === "join" ? await this.#joinHeld(pool, plan.outer, plan.marker, fn) : await this.#ownTransaction(pool, raw, holder, plan.marker, fn);
19744
+ } catch (thrown) {
19745
+ this.#reportTrouble(pool, holder, thrown, startedAt);
19746
+ throw thrown;
19747
+ }
19748
+ }
19749
+ onDatabaseTrouble(listener) {
19750
+ this.#troubleListeners.add(listener);
19751
+ return () => {
19752
+ this.#troubleListeners.delete(listener);
19753
+ };
19754
+ }
19755
+ #reportedTrouble = new WeakSet;
19756
+ #reportTrouble(pool, holder, thrown, startedAt) {
19757
+ if (this.#troubleListeners.size === 0)
19758
+ return;
19759
+ if (typeof thrown === "object" && thrown !== null) {
19760
+ if (this.#reportedTrouble.has(thrown))
19761
+ return;
19762
+ this.#reportedTrouble.add(thrown);
19763
+ }
19764
+ const kind = classifyDatabaseTrouble(thrown);
19765
+ if (kind === null)
19766
+ return;
19767
+ const trouble = { kind, pool, holder, elapsedMs: Date.now() - startedAt };
19768
+ for (const listener of this.#troubleListeners) {
19769
+ try {
19770
+ listener(trouble);
19771
+ } catch (e) {
19772
+ console.error("[query-api] a database-trouble listener failed", e);
19773
+ }
19774
+ }
19775
+ }
19776
+ async#ownTransaction(pool, raw, holder, marker, fn) {
19715
19777
  const reserved = await this.#reserve(pool, raw, holder);
19716
19778
  const endHold = this.#demand[pool].beginHold(holder);
19717
19779
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"cli-routing.d.ts","sourceRoot":"","sources":["../src/cli-routing.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,+CAA+C;AAC/C,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAElG;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAkBjG;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED,gGAAgG;AAChG,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,aAAa,EA6GhD,CAAC;AAEF,+EAA+E;AAC/E,wBAAgB,QAAQ,IAAI,MAAM,CAOjC"}
1
+ {"version":3,"file":"cli-routing.d.ts","sourceRoot":"","sources":["../src/cli-routing.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,+CAA+C;AAC/C,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAElG;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAkBjG;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED,gGAAgG;AAChG,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,aAAa,EA6GhD,CAAC;AAEF,+EAA+E;AAC/E,wBAAgB,QAAQ,IAAI,MAAM,CAQjC"}
@@ -141,8 +141,9 @@ export const CLI_COMMANDS = [
141
141
  ];
142
142
  /** The text `cms-provision --help` prints, built from {@link CLI_COMMANDS}. */
143
143
  export function cliUsage() {
144
- return (`Usage: cms-provision [wizard] [--provider <name> --domain <d> [--staging-domain <host>] --owner-email <e> --region <r> [--version x.y.z[-rc.N]] [--scheduler-interval-minutes 1-15]] [--local|--install-job] | <${CLI_COMMANDS.map((c) => c.name).join("|")}> [options]\n` +
144
+ return (`Usage: cms-provision [wizard] [--provider <name> --domain <d> [--staging-domain <host>] --owner-email <e> --region <r> [--billing-account <id>] [--version x.y.z[-rc.N]] [--scheduler-interval-minutes 1-15]] [--local|--install-job] | <${CLI_COMMANDS.map((c) => c.name).join("|")}> [options]\n` +
145
145
  "With several installs on this machine, pick one with --install <install-id or domain> (status, upgrade and backup also take --install all); in a terminal you are asked otherwise.\n" +
146
+ "--billing-account links a new Google Cloud project to that billing account (the id `gcloud billing accounts list` prints); with --non-interactive it is needed when the signed-in account has several open ones.\n" +
146
147
  "--version installs the release it names (otherwise the newest stable one). A release candidate (x.y.z-rc.N) is for test installs only: Caelo's Google Cloud registry keeps its images for 14 days, so installing or upgrading to one there asks for confirmation (--accept-release-candidate in a script).\n" +
147
148
  "Pass --no-wizard with no sub-command to print this usage instead of the wizard.");
148
149
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cli-routing.js","sourceRoot":"","sources":["../src/cli-routing.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAenC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAAuB,EAAE,YAA8B;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/D,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC3B,CAAC;IACD,oEAAoE;IACpE,0EAA0E;IAC1E,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC5C,IAAI,QAAQ,KAAK,CAAC,CA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,EAAE,kBAAkB;QACxB,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,sFAAsF;KAChG;IACD;QACE,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,QAAQ;QACd,OAAO,EACL,8FAA8F;KACjG;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,wFAAwF;QAC9F,OAAO,EACL,mHAAmH;KACtH;IACD;QACE,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,mCAAmC;QACzC,OAAO,EACL,wGAAwG;KAC3G;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,4BAA4B;QAClC,OAAO,EACL,oKAAoK;KACvK;IACD;QACE,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,iEAAiE;QACvE,OAAO,EAAE,mFAAmF;KAC7F;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,4BAA4B;QAClC,OAAO,EAAE,qFAAqF;KAC/F;IACD;QACE,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,EAAE;QACR,OAAO,EACL,0HAA0H;KAC7H;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,0BAA0B;KACpC;CACF,CAAC;AAEF,+EAA+E;AAC/E,MAAM,UAAU,QAAQ;IACtB,OAAO,CACL,mNAAmN,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe;QAC3Q,sLAAsL;QACtL,8SAA8S;QAC9S,iFAAiF,CAClF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"cli-routing.js","sourceRoot":"","sources":["../src/cli-routing.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAenC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAAuB,EAAE,YAA8B;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;I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EAAE,QAAQ;QACd,IAAI,EAAE,4BAA4B;QAClC,OAAO,EAAE,qFAAqF;KAC/F;IACD;QACE,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,EAAE;QACR,OAAO,EACL,0HAA0H;KAC7H;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,0BAA0B;KACpC;CACF,CAAC;AAEF,+EAA+E;AAC/E,MAAM,UAAU,QAAQ;IACtB,OAAO,CACL,4OAA4O,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe;QACpS,sLAAsL;QACtL,oNAAoN;QACpN,8SAA8S;QAC9S,iFAAiF,CAClF,CAAC;AACJ,CAAC"}
package/dist/cli.js CHANGED
@@ -1462,7 +1462,7 @@ async function waitForDomainMappingCert(target) {
1462
1462
  * §11.C — interactive wizard. Loaded lazily so the bare-CLI startup
1463
1463
  * cost stays small (clack + kleur are pulled in only when needed).
1464
1464
  * Reads `--provider`, `--domain`, `--owner-email`, `--project-id`, `--region`,
1465
- * `--scheduler-interval-minutes` (#1140), `--version` and
1465
+ * `--billing-account` (#1580), `--scheduler-interval-minutes` (#1140), `--version` and
1466
1466
  * `--accept-release-candidate` (#1558), `--non-interactive` and the run mode (`--local` / `--install-job`, default:
1467
1467
  * the install job in Cloud Shell, local elsewhere — run-mode.ts) from argv.
1468
1468
  */
@@ -1487,6 +1487,19 @@ async function wizardCommand() {
1487
1487
  console.error("--version needs a release version, e.g. --version 0.12.5-rc.1");
1488
1488
  process.exit(2);
1489
1489
  }
1490
+ const { BILLING_ACCOUNT_FLAG, parseBillingAccountId } = await import("./wizards/gcp-billing.js");
1491
+ const billingArg = arg("billing-account");
1492
+ let billingAccountId;
1493
+ try {
1494
+ if (billingArg === undefined && process.argv.includes(BILLING_ACCOUNT_FLAG)) {
1495
+ throw new Error(`${BILLING_ACCOUNT_FLAG} needs a billing account id, e.g. ${BILLING_ACCOUNT_FLAG} 012345-6789AB-CDEF01`);
1496
+ }
1497
+ billingAccountId = billingArg === undefined ? undefined : parseBillingAccountId(billingArg);
1498
+ }
1499
+ catch (e) {
1500
+ console.error(e.message);
1501
+ process.exit(2);
1502
+ }
1490
1503
  await runWizard({
1491
1504
  ...(schedulerIntervalMinutes !== undefined ? { schedulerIntervalMinutes } : {}),
1492
1505
  runMode: chooseRunMode(process.argv, process.env),
@@ -1501,6 +1514,7 @@ async function wizardCommand() {
1501
1514
  ...(process.argv.includes(ACCEPT_RELEASE_CANDIDATE_FLAG)
1502
1515
  ? { acceptReleaseCandidate: true }
1503
1516
  : {}),
1517
+ ...(billingAccountId !== undefined ? { billingAccountId } : {}),
1504
1518
  });
1505
1519
  }
1506
1520
  // §11.C — flags-only invocations (`--provider gcp --domain …`, the