@package-broker/cli 0.19.8 → 2.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +12 -0
- package/dist/bin.js.map +1 -0
- package/dist/build-artifacts.d.ts +27 -0
- package/dist/build-artifacts.d.ts.map +1 -0
- package/dist/build-artifacts.js +169 -0
- package/dist/build-artifacts.js.map +1 -0
- package/dist/build-assets.d.ts +36 -0
- package/dist/build-assets.d.ts.map +1 -0
- package/dist/build-assets.js +224 -0
- package/dist/build-assets.js.map +1 -0
- package/dist/build.d.ts +31 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +277 -0
- package/dist/build.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +828 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloudflare/d1-http-executor.d.ts +30 -0
- package/dist/cloudflare/d1-http-executor.d.ts.map +1 -0
- package/dist/cloudflare/d1-http-executor.js +230 -0
- package/dist/cloudflare/d1-http-executor.js.map +1 -0
- package/dist/cloudflare/d1-http-response.d.ts +4 -0
- package/dist/cloudflare/d1-http-response.d.ts.map +1 -0
- package/dist/cloudflare/d1-http-response.js +113 -0
- package/dist/cloudflare/d1-http-response.js.map +1 -0
- package/dist/commands/admin.d.ts +47 -0
- package/dist/commands/admin.d.ts.map +1 -0
- package/dist/commands/admin.js +447 -0
- package/dist/commands/admin.js.map +1 -0
- package/dist/commands/built-manifest.d.ts +13 -0
- package/dist/commands/built-manifest.d.ts.map +1 -0
- package/dist/commands/built-manifest.js +197 -0
- package/dist/commands/built-manifest.js.map +1 -0
- package/dist/commands/cloudflare/api.d.ts +132 -0
- package/dist/commands/cloudflare/api.d.ts.map +1 -0
- package/dist/commands/cloudflare/api.js +502 -0
- package/dist/commands/cloudflare/api.js.map +1 -0
- package/dist/commands/cloudflare/deploy.d.ts +111 -0
- package/dist/commands/cloudflare/deploy.d.ts.map +1 -0
- package/dist/commands/cloudflare/deploy.js +2170 -0
- package/dist/commands/cloudflare/deploy.js.map +1 -0
- package/dist/commands/cloudflare/inventory.d.ts +257 -0
- package/dist/commands/cloudflare/inventory.d.ts.map +1 -0
- package/dist/commands/cloudflare/inventory.js +842 -0
- package/dist/commands/cloudflare/inventory.js.map +1 -0
- package/dist/commands/cloudflare/janitor.d.ts +10 -0
- package/dist/commands/cloudflare/janitor.d.ts.map +1 -0
- package/dist/commands/cloudflare/janitor.js +84 -0
- package/dist/commands/cloudflare/janitor.js.map +1 -0
- package/dist/commands/cloudflare/migrations-check.d.ts +5 -0
- package/dist/commands/cloudflare/migrations-check.d.ts.map +1 -0
- package/dist/commands/cloudflare/migrations-check.js +10 -0
- package/dist/commands/cloudflare/migrations-check.js.map +1 -0
- package/dist/commands/cloudflare/providers-file.d.ts +17 -0
- package/dist/commands/cloudflare/providers-file.d.ts.map +1 -0
- package/dist/commands/cloudflare/providers-file.js +155 -0
- package/dist/commands/cloudflare/providers-file.js.map +1 -0
- package/dist/commands/cloudflare/provision.d.ts +79 -0
- package/dist/commands/cloudflare/provision.d.ts.map +1 -0
- package/dist/commands/cloudflare/provision.js +961 -0
- package/dist/commands/cloudflare/provision.js.map +1 -0
- package/dist/commands/cloudflare/queue-consumer.d.ts +4 -0
- package/dist/commands/cloudflare/queue-consumer.d.ts.map +1 -0
- package/dist/commands/cloudflare/queue-consumer.js +57 -0
- package/dist/commands/cloudflare/queue-consumer.js.map +1 -0
- package/dist/commands/cloudflare/routes.d.ts +3 -0
- package/dist/commands/cloudflare/routes.d.ts.map +1 -0
- package/dist/commands/cloudflare/routes.js +26 -0
- package/dist/commands/cloudflare/routes.js.map +1 -0
- package/dist/commands/cloudflare/setup.d.ts +50 -0
- package/dist/commands/cloudflare/setup.d.ts.map +1 -0
- package/dist/commands/cloudflare/setup.js +836 -0
- package/dist/commands/cloudflare/setup.js.map +1 -0
- package/dist/commands/cloudflare/smoke.d.ts +29 -0
- package/dist/commands/cloudflare/smoke.d.ts.map +1 -0
- package/dist/commands/cloudflare/smoke.js +701 -0
- package/dist/commands/cloudflare/smoke.js.map +1 -0
- package/dist/commands/cloudflare/teardown.d.ts +65 -0
- package/dist/commands/cloudflare/teardown.d.ts.map +1 -0
- package/dist/commands/cloudflare/teardown.js +984 -0
- package/dist/commands/cloudflare/teardown.js.map +1 -0
- package/dist/commands/cloudflare/worker-settings.d.ts +4 -0
- package/dist/commands/cloudflare/worker-settings.d.ts.map +1 -0
- package/dist/commands/cloudflare/worker-settings.js +93 -0
- package/dist/commands/cloudflare/worker-settings.js.map +1 -0
- package/dist/commands/cloudflare/zone.d.ts +3 -0
- package/dist/commands/cloudflare/zone.d.ts.map +1 -0
- package/dist/commands/cloudflare/zone.js +73 -0
- package/dist/commands/cloudflare/zone.js.map +1 -0
- package/dist/commands/cloudflare.d.ts +55 -0
- package/dist/commands/cloudflare.d.ts.map +1 -0
- package/dist/commands/cloudflare.js +393 -0
- package/dist/commands/cloudflare.js.map +1 -0
- package/dist/commands/import-cutover.d.ts +5 -0
- package/dist/commands/import-cutover.d.ts.map +1 -0
- package/dist/commands/import-cutover.js +25 -0
- package/dist/commands/import-cutover.js.map +1 -0
- package/dist/commands/import-private-packagist.d.ts +38 -0
- package/dist/commands/import-private-packagist.d.ts.map +1 -0
- package/dist/commands/import-private-packagist.js +232 -0
- package/dist/commands/import-private-packagist.js.map +1 -0
- package/dist/commands/import-satis.d.ts +11 -0
- package/dist/commands/import-satis.d.ts.map +1 -0
- package/dist/commands/import-satis.js +112 -0
- package/dist/commands/import-satis.js.map +1 -0
- package/dist/commands/import.d.ts +22 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +343 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/openapi-specs.d.ts +4 -0
- package/dist/commands/openapi-specs.d.ts.map +1 -0
- package/dist/commands/openapi-specs.js +94 -0
- package/dist/commands/openapi-specs.js.map +1 -0
- package/dist/commands/openapi.d.ts +12 -0
- package/dist/commands/openapi.d.ts.map +1 -0
- package/dist/commands/openapi.js +44 -0
- package/dist/commands/openapi.js.map +1 -0
- package/dist/commands/source.d.ts +8 -0
- package/dist/commands/source.d.ts.map +1 -0
- package/dist/commands/source.js +61 -0
- package/dist/commands/source.js.map +1 -0
- package/dist/commands/sqlite.d.ts +11 -0
- package/dist/commands/sqlite.d.ts.map +1 -0
- package/dist/commands/sqlite.js +76 -0
- package/dist/commands/sqlite.js.map +1 -0
- package/dist/import/client.d.ts +71 -0
- package/dist/import/client.d.ts.map +1 -0
- package/dist/import/client.js +348 -0
- package/dist/import/client.js.map +1 -0
- package/dist/import/credential-refs.d.ts +2 -0
- package/dist/import/credential-refs.d.ts.map +1 -0
- package/dist/import/credential-refs.js +22 -0
- package/dist/import/credential-refs.js.map +1 -0
- package/dist/import/cutover.d.ts +64 -0
- package/dist/import/cutover.d.ts.map +1 -0
- package/dist/import/cutover.js +544 -0
- package/dist/import/cutover.js.map +1 -0
- package/dist/import/private-packagist/api.d.ts +57 -0
- package/dist/import/private-packagist/api.d.ts.map +1 -0
- package/dist/import/private-packagist/api.js +246 -0
- package/dist/import/private-packagist/api.js.map +1 -0
- package/dist/import/private-packagist/dates.d.ts +30 -0
- package/dist/import/private-packagist/dates.d.ts.map +1 -0
- package/dist/import/private-packagist/dates.js +189 -0
- package/dist/import/private-packagist/dates.js.map +1 -0
- package/dist/import/private-packagist/map.d.ts +48 -0
- package/dist/import/private-packagist/map.d.ts.map +1 -0
- package/dist/import/private-packagist/map.js +162 -0
- package/dist/import/private-packagist/map.js.map +1 -0
- package/dist/import/private-packagist/plan.d.ts +61 -0
- package/dist/import/private-packagist/plan.d.ts.map +1 -0
- package/dist/import/private-packagist/plan.js +936 -0
- package/dist/import/private-packagist/plan.js.map +1 -0
- package/dist/import/private-packagist/snapshot.d.ts +31 -0
- package/dist/import/private-packagist/snapshot.d.ts.map +1 -0
- package/dist/import/private-packagist/snapshot.js +406 -0
- package/dist/import/private-packagist/snapshot.js.map +1 -0
- package/dist/import/satis.d.ts +93 -0
- package/dist/import/satis.d.ts.map +1 -0
- package/dist/import/satis.js +873 -0
- package/dist/import/satis.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -96
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +56 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +137 -0
- package/dist/manifest.js.map +1 -0
- package/dist/migrations-collect.d.ts +6 -0
- package/dist/migrations-collect.d.ts.map +1 -0
- package/dist/migrations-collect.js +39 -0
- package/dist/migrations-collect.js.map +1 -0
- package/dist/prebuilt-expected.json +7 -0
- package/dist/prebuilt.d.ts +27 -0
- package/dist/prebuilt.d.ts.map +1 -0
- package/dist/prebuilt.js +391 -0
- package/dist/prebuilt.js.map +1 -0
- package/package.json +22 -25
- package/README.md +0 -29
- package/dist/__tests__/migrate.test.d.ts +0 -2
- package/dist/__tests__/migrate.test.d.ts.map +0 -1
- package/dist/__tests__/migrate.test.js +0 -116
- package/dist/__tests__/migrate.test.js.map +0 -1
- package/dist/migrate.d.ts +0 -40
- package/dist/migrate.d.ts.map +0 -1
- package/dist/migrate.js +0 -335
- package/dist/migrate.js.map +0 -1
package/dist/cli.js
ADDED
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { parseArgs } from 'node:util';
|
|
3
|
+
import { build, BuildDiagnosticsError } from './build.js';
|
|
4
|
+
import { assertPrebuiltConfiguration } from './prebuilt.js';
|
|
5
|
+
import { runAdminBootstrap, runAdminRebindProvider, runAdminResetLocal, runAdminShowProviderBinding, runGenerateMasterKey, } from './commands/admin.js';
|
|
6
|
+
import { runCloudflareBootstrap, runCloudflareMigrate } from './commands/cloudflare.js';
|
|
7
|
+
import { runCloudflareProvision } from './commands/cloudflare/provision.js';
|
|
8
|
+
import { readProvidersOption } from './commands/cloudflare/providers-file.js';
|
|
9
|
+
import { runCloudflareDeploy } from './commands/cloudflare/deploy.js';
|
|
10
|
+
import { runCloudflareSetup } from './commands/cloudflare/setup.js';
|
|
11
|
+
import { runCloudflareSmoke } from './commands/cloudflare/smoke.js';
|
|
12
|
+
import { runCloudflareTeardown } from './commands/cloudflare/teardown.js';
|
|
13
|
+
import { runCloudflareJanitor } from './commands/cloudflare/janitor.js';
|
|
14
|
+
import { commandEnvelope, failCommand, CloudflareError } from './commands/cloudflare/api.js';
|
|
15
|
+
import { runImport } from './commands/import.js';
|
|
16
|
+
import { runImportCutover } from './commands/import-cutover.js';
|
|
17
|
+
import { runImportSatisPlan } from './commands/import-satis.js';
|
|
18
|
+
import { runImportPrivatePackagistFetch, runImportPrivatePackagistPlan, runImportPrivatePackagistDates, } from './commands/import-private-packagist.js';
|
|
19
|
+
import { runSourceAcceptRemoval } from './commands/source.js';
|
|
20
|
+
import { runOpenApi } from './commands/openapi.js';
|
|
21
|
+
import { runBootstrapSqlite, runMigrateSqlite } from './commands/sqlite.js';
|
|
22
|
+
const USAGE = 'Usage: pb build [--config <file>] [--target cloudflare|node] [--out <dir>]\n' +
|
|
23
|
+
' pb migrate --sqlite <file> [--out <dir> (default .pb/node)] [--dry-run]\n' +
|
|
24
|
+
' pb bootstrap --sqlite <file> --slug <slug> --name <name>\n' +
|
|
25
|
+
' pb cloudflare setup [--workers-paid] [--prebuilt] [--providers <file|none>] --worker-name <slug> --org-slug <slug> --org-name <name> --admin-email <email> [--key-file <path> | --master-key-env <name>] [--token-file <path>] [--non-interactive] [--yes] [--refresh-setup-token] [--json] [--dry-run]\n' +
|
|
26
|
+
' pb cloudflare provision [--prebuilt] --worker-name <slug> [--config <file>] [--environment <slug>] [--jurisdiction eu|default] [--inventory <file>] [--out <dir>] [--adopt-resource <kind:id>] [--abandon-intent <op-id>] [--domain <hostname>] [--yes] [--json] [--dry-run]\n' +
|
|
27
|
+
' pb cloudflare deploy [--workers-paid] [--prebuilt] [--providers <file|none>] --worker-name <slug> [--out <dir>] [--rollout <1..100>] [--domain <hostname>] [--public-url <https-origin>] [--routes <zone:pattern\n...>] [--secret <ENV_NAME>] [--secrets <ENV_NAMES>] [--json] [--dry-run]\n' +
|
|
28
|
+
' pb cloudflare smoke --worker-name <slug> [--project <slug>] [--smoke-token-env <name>] [--deadline-seconds <1..300>] [--no-rollback] [--json] [--dry-run]\n' +
|
|
29
|
+
' pb cloudflare teardown --inventory <file> [--config <file>] [--project <dir>] [--inventory-id <owner_digest> --i-understand-this-deletes] [--json] [--dry-run]\n' +
|
|
30
|
+
' pb cloudflare janitor --repository-id <numeric-id> [--inventory <file>] [--config <file>] [--project <dir>] [--json] [--dry-run]\n' +
|
|
31
|
+
' pb cloudflare migrate [--prebuilt] --database-id <id> [--out <dir> (default .pb/cloudflare)] [--dry-run]\n' +
|
|
32
|
+
' pb cloudflare bootstrap --database-id <id> --slug <slug> --name <name>\n' +
|
|
33
|
+
' pb secrets generate-master-key [--key-version <n> (default 1)]\n' +
|
|
34
|
+
' pb admin bootstrap --email <e> (--sqlite <file> | --cloudflare --database-id <id>) [--token-file <path>]\n' +
|
|
35
|
+
' pb admin reset-local --email <e> (--sqlite <file> | --cloudflare --database-id <id>) [--token-file <path>]\n' +
|
|
36
|
+
' pb admin rebind-provider --provider <id> --confirm <id> --expected-anchor <anchor> --new-anchor <anchor> (--sqlite <file> | --cloudflare --database-id <id>)\n' +
|
|
37
|
+
' pb admin show-provider-binding --provider <id> (--sqlite <file> | --cloudflare --database-id <id>)\n' +
|
|
38
|
+
' pb import cutover-check --project-dir <dir> --old-repository <url> --new-repository <url> --old-auth-env <VAR> --new-auth-env <VAR> [--lock <file>]... [--timeout-seconds <seconds>] [--json]\n' +
|
|
39
|
+
' pb import private-packagist fetch --org <short-name> --snapshot <out.json> [--api-key-file <path>] [--api-secret-file <path>] [--versions] [--require-org-match] (or PP_API_KEY_FILE/PP_API_SECRET_FILE)\n' +
|
|
40
|
+
' pb import private-packagist plan --snapshot <file> --map <file> --out <manifest> --credentials-out <file> [--members <csv>] [--baseline <manifest>] [--mode merge|override] [--include-org-admins] [--runtime workers|node] [--packagist existing:<name>] [--compact-selection --compact-vendor <vendor>...] [--accept-project-widening <slug>...] [--quiet]\n' +
|
|
41
|
+
' pb import private-packagist dates --snapshot <file> --map <file> --baseline <manifest> --out <manifest> [--package <name>...] [--quiet]\n' +
|
|
42
|
+
' pb import satis plan --config <satis.json> --out <manifest> [--project <slug>] [--repository-map <file>] [--credentials <file>] [--baseline <manifest>] [--mode merge|override]\n' +
|
|
43
|
+
' pb import submit --manifest <file> --receipt <file> --principal <label> --broker <origin> [--resume] [--token-file <path>]\n' +
|
|
44
|
+
' pb import status <run> --broker <origin> [--wait | --wait-seconds <0..300>] [--token-file <path>]\n' +
|
|
45
|
+
' pb import credentials <run> --manifest <file> --credentials <map> --broker <origin> [--token-file <path>]\n' +
|
|
46
|
+
' pb import verify <run> --broker <origin> [--wait | --wait-seconds <0..300>] [--token-file <path>]\n' +
|
|
47
|
+
' pb import accept <run> --broker <origin> [--wait | --wait-seconds <0..300>] [--token-file <path>]\n' +
|
|
48
|
+
' pb source accept-removal --url <https-origin> --source <id> (PB_SESSION and PB_CSRF_TOKEN)\n' +
|
|
49
|
+
' pb version\n' +
|
|
50
|
+
'Exit codes: 0 success; 1 error; 2 usage, invalid slug or invalid build configuration; 3 checksum mismatch; 4 migration locked; 5 already bootstrapped with another slug; 6 outcome unknown (response lost after the request was sent)\n' +
|
|
51
|
+
'--providers <file|none>: none removes the definitions; pass a file named none as ./none.\n' +
|
|
52
|
+
'--workers-paid: use the Paid Workers environment variable limit (128; default 64) for cloudflare deploy/setup.\n' +
|
|
53
|
+
'Exit codes for pb cloudflare smoke: 8 concurrent deployment or ownership conflict; 9 smoke failed on an existing deployment; 10 rollback failed or unknown; 11 contract migration blocks rollback; 12 first-deployment smoke failed with no prior release\n' +
|
|
54
|
+
'Exit codes for pb cloudflare teardown/janitor: 0 cleaned or skipped; 1 cleanup failed; 2 invalid inventory, wrong inventory id or missing destructive confirmation; 4 inventory locked; 6 unresolved resource or deletion outcome; 8 ownership conflict. Production confirmation uses identity.owner_digest as --inventory-id. Adopted D1 and R2 resources always require --i-understand-this-deletes; janitor retains them. Inventory schema version 2 records deployment history and lifecycle baselines. Janitor requires run_identity pb-e2e-<repository-id>-<epoch-seconds> (optional run suffix) and a matching worker_name stem; Worker stems may encode both numbers in lowercase base 36 to fit name limits. Both the run and inventory update must be older than 6 hours. Deleting a Worker removes its versions.\n' +
|
|
55
|
+
'Import commands use PB_IMPORT_TOKEN or --token-file. --resume requires the same token (idempotency principal); --principal is only a non-secret receipt label. Approval, apply and accept stay in the UI. Import exit codes: 0 success; 1 API or run failure; 2 local validation; 3 pending UI action or wait timeout; 6 outcome unknown.\n' +
|
|
56
|
+
'Exit codes for pb admin bootstrap/reset-local: 0 success; 1 error; 2 usage, invalid e-mail or existing token file; 5 organization not bootstrapped; 6 already_set_up (bootstrap) or not_found (reset-local); 7 outcome unknown (D1 request sent, no usable response, re-running is safe); 8 admin_role_missing (reset-local); SIGINT or SIGTERM received during a synchronous SQLite batch is handled after the batch returns\n' +
|
|
57
|
+
'Exit codes for pb admin rebind-provider: 0 success; 1 error; 2 usage, --confirm not equal to --provider, or invalid provider or anchor; 5 organization not bootstrapped; 6 anchor_mismatch (no binding with that provider and expected anchor; nothing changed); 7 outcome unknown (D1 response lost; the swap may have applied; a re-run that reports anchor_mismatch means it did or the anchor is wrong)\n' +
|
|
58
|
+
'Exit codes for pb admin show-provider-binding: 0 success; 1 error; 2 usage or invalid provider; 5 organization not bootstrapped; 6 no_binding; nothing is bound for that provider; 7 outcome unknown (D1 response lost, re-running is safe)';
|
|
59
|
+
function parseCliArgs(argv) {
|
|
60
|
+
try {
|
|
61
|
+
return parseArgs({
|
|
62
|
+
args: argv,
|
|
63
|
+
allowPositionals: true,
|
|
64
|
+
options: {
|
|
65
|
+
url: { type: 'string' },
|
|
66
|
+
broker: { type: 'string' },
|
|
67
|
+
'project-dir': { type: 'string' },
|
|
68
|
+
'old-repository': { type: 'string' },
|
|
69
|
+
'new-repository': { type: 'string' },
|
|
70
|
+
'old-auth-env': { type: 'string' },
|
|
71
|
+
'new-auth-env': { type: 'string' },
|
|
72
|
+
'timeout-seconds': { type: 'string' },
|
|
73
|
+
lock: { type: 'string', multiple: true },
|
|
74
|
+
org: { type: 'string' },
|
|
75
|
+
snapshot: { type: 'string' },
|
|
76
|
+
map: { type: 'string' },
|
|
77
|
+
package: { type: 'string', multiple: true },
|
|
78
|
+
'credentials-out': { type: 'string' },
|
|
79
|
+
members: { type: 'string' },
|
|
80
|
+
'include-org-admins': { type: 'boolean' },
|
|
81
|
+
runtime: { type: 'string' },
|
|
82
|
+
packagist: { type: 'string' },
|
|
83
|
+
'compact-selection': { type: 'boolean' },
|
|
84
|
+
'compact-vendor': { type: 'string', multiple: true },
|
|
85
|
+
'accept-project-widening': { type: 'string', multiple: true },
|
|
86
|
+
quiet: { type: 'boolean' },
|
|
87
|
+
'api-key-file': { type: 'string' },
|
|
88
|
+
'api-secret-file': { type: 'string' },
|
|
89
|
+
versions: { type: 'boolean' },
|
|
90
|
+
'require-org-match': { type: 'boolean' },
|
|
91
|
+
manifest: { type: 'string' },
|
|
92
|
+
receipt: { type: 'string' },
|
|
93
|
+
principal: { type: 'string' },
|
|
94
|
+
resume: { type: 'boolean' },
|
|
95
|
+
wait: { type: 'boolean' },
|
|
96
|
+
'wait-seconds': { type: 'string' },
|
|
97
|
+
source: { type: 'string' },
|
|
98
|
+
config: { type: 'string' },
|
|
99
|
+
target: { type: 'string' },
|
|
100
|
+
out: { type: 'string' },
|
|
101
|
+
sqlite: { type: 'string' },
|
|
102
|
+
slug: { type: 'string' },
|
|
103
|
+
name: { type: 'string' },
|
|
104
|
+
'database-id': { type: 'string' },
|
|
105
|
+
email: { type: 'string' },
|
|
106
|
+
provider: { type: 'string' },
|
|
107
|
+
providers: { type: 'string' },
|
|
108
|
+
confirm: { type: 'string' },
|
|
109
|
+
'expected-anchor': { type: 'string' },
|
|
110
|
+
'new-anchor': { type: 'string' },
|
|
111
|
+
cloudflare: { type: 'boolean' },
|
|
112
|
+
prebuilt: { type: 'boolean' },
|
|
113
|
+
'token-file': { type: 'string' },
|
|
114
|
+
'key-file': { type: 'string' },
|
|
115
|
+
'master-key-env': { type: 'string' },
|
|
116
|
+
'org-slug': { type: 'string' },
|
|
117
|
+
'org-name': { type: 'string' },
|
|
118
|
+
'admin-email': { type: 'string' },
|
|
119
|
+
'non-interactive': { type: 'boolean' },
|
|
120
|
+
'refresh-setup-token': { type: 'boolean' },
|
|
121
|
+
migrate: { type: 'string' },
|
|
122
|
+
'key-version': { type: 'string' },
|
|
123
|
+
'dry-run': { type: 'boolean' },
|
|
124
|
+
'worker-name': { type: 'string' },
|
|
125
|
+
environment: { type: 'string' },
|
|
126
|
+
'deployment-id': { type: 'string' },
|
|
127
|
+
inventory: { type: 'string' },
|
|
128
|
+
'inventory-id': { type: 'string' },
|
|
129
|
+
'i-understand-this-deletes': { type: 'boolean' },
|
|
130
|
+
'repository-id': { type: 'string' },
|
|
131
|
+
jurisdiction: { type: 'string' },
|
|
132
|
+
'location-hint': { type: 'string' },
|
|
133
|
+
'adopt-resource': { type: 'string', multiple: true },
|
|
134
|
+
'abandon-intent': { type: 'string' },
|
|
135
|
+
'allow-contract': { type: 'string', multiple: true },
|
|
136
|
+
domain: { type: 'string' },
|
|
137
|
+
rollout: { type: 'string' },
|
|
138
|
+
'public-url': { type: 'string' },
|
|
139
|
+
routes: { type: 'string' },
|
|
140
|
+
secret: { type: 'string', multiple: true },
|
|
141
|
+
secrets: { type: 'string' },
|
|
142
|
+
'workers-paid': { type: 'boolean' },
|
|
143
|
+
yes: { type: 'boolean' },
|
|
144
|
+
json: { type: 'boolean' },
|
|
145
|
+
project: { type: 'string' },
|
|
146
|
+
'smoke-token-env': { type: 'string' },
|
|
147
|
+
'deadline-seconds': { type: 'string' },
|
|
148
|
+
'no-rollback': { type: 'boolean' },
|
|
149
|
+
credentials: { type: 'string' },
|
|
150
|
+
'repository-map': { type: 'string' },
|
|
151
|
+
baseline: { type: 'string' },
|
|
152
|
+
mode: { type: 'string' },
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const ALLOWED_FLAGS = {
|
|
161
|
+
build: ['config', 'target', 'out'],
|
|
162
|
+
migrate: ['sqlite', 'out', 'dry-run'],
|
|
163
|
+
bootstrap: ['sqlite', 'slug', 'name'],
|
|
164
|
+
'cloudflare setup': [
|
|
165
|
+
'providers',
|
|
166
|
+
'prebuilt',
|
|
167
|
+
'worker-name',
|
|
168
|
+
'config',
|
|
169
|
+
'out',
|
|
170
|
+
'environment',
|
|
171
|
+
'deployment-id',
|
|
172
|
+
'inventory',
|
|
173
|
+
'jurisdiction',
|
|
174
|
+
'location-hint',
|
|
175
|
+
'adopt-resource',
|
|
176
|
+
'abandon-intent',
|
|
177
|
+
'domain',
|
|
178
|
+
'public-url',
|
|
179
|
+
'routes',
|
|
180
|
+
'rollout',
|
|
181
|
+
'allow-contract',
|
|
182
|
+
'secret',
|
|
183
|
+
'secrets',
|
|
184
|
+
'workers-paid',
|
|
185
|
+
'org-slug',
|
|
186
|
+
'org-name',
|
|
187
|
+
'admin-email',
|
|
188
|
+
'key-file',
|
|
189
|
+
'master-key-env',
|
|
190
|
+
'token-file',
|
|
191
|
+
'non-interactive',
|
|
192
|
+
'refresh-setup-token',
|
|
193
|
+
'migrate',
|
|
194
|
+
'yes',
|
|
195
|
+
'json',
|
|
196
|
+
'dry-run',
|
|
197
|
+
'project',
|
|
198
|
+
'smoke-token-env',
|
|
199
|
+
'deadline-seconds',
|
|
200
|
+
],
|
|
201
|
+
'cloudflare provision': [
|
|
202
|
+
'prebuilt',
|
|
203
|
+
'worker-name',
|
|
204
|
+
'config',
|
|
205
|
+
'environment',
|
|
206
|
+
'deployment-id',
|
|
207
|
+
'inventory',
|
|
208
|
+
'out',
|
|
209
|
+
'jurisdiction',
|
|
210
|
+
'location-hint',
|
|
211
|
+
'adopt-resource',
|
|
212
|
+
'abandon-intent',
|
|
213
|
+
'domain',
|
|
214
|
+
'yes',
|
|
215
|
+
'json',
|
|
216
|
+
'dry-run',
|
|
217
|
+
],
|
|
218
|
+
'cloudflare deploy': [
|
|
219
|
+
'providers',
|
|
220
|
+
'prebuilt',
|
|
221
|
+
'worker-name',
|
|
222
|
+
'config',
|
|
223
|
+
'environment',
|
|
224
|
+
'deployment-id',
|
|
225
|
+
'inventory',
|
|
226
|
+
'out',
|
|
227
|
+
'jurisdiction',
|
|
228
|
+
'rollout',
|
|
229
|
+
'public-url',
|
|
230
|
+
'routes',
|
|
231
|
+
'domain',
|
|
232
|
+
'secret',
|
|
233
|
+
'secrets',
|
|
234
|
+
'workers-paid',
|
|
235
|
+
'allow-contract',
|
|
236
|
+
'json',
|
|
237
|
+
'dry-run',
|
|
238
|
+
],
|
|
239
|
+
'cloudflare smoke': [
|
|
240
|
+
'worker-name',
|
|
241
|
+
'config',
|
|
242
|
+
'environment',
|
|
243
|
+
'deployment-id',
|
|
244
|
+
'inventory',
|
|
245
|
+
'out',
|
|
246
|
+
'jurisdiction',
|
|
247
|
+
'public-url',
|
|
248
|
+
'project',
|
|
249
|
+
'smoke-token-env',
|
|
250
|
+
'deadline-seconds',
|
|
251
|
+
'no-rollback',
|
|
252
|
+
'json',
|
|
253
|
+
'dry-run',
|
|
254
|
+
],
|
|
255
|
+
'cloudflare migrate': [
|
|
256
|
+
'prebuilt',
|
|
257
|
+
'database-id',
|
|
258
|
+
'out',
|
|
259
|
+
'dry-run',
|
|
260
|
+
'json',
|
|
261
|
+
'worker-name',
|
|
262
|
+
'config',
|
|
263
|
+
'environment',
|
|
264
|
+
'deployment-id',
|
|
265
|
+
'inventory',
|
|
266
|
+
'jurisdiction',
|
|
267
|
+
'allow-contract',
|
|
268
|
+
],
|
|
269
|
+
'cloudflare bootstrap': ['database-id', 'slug', 'name'],
|
|
270
|
+
'cloudflare teardown': [
|
|
271
|
+
'inventory',
|
|
272
|
+
'inventory-id',
|
|
273
|
+
'i-understand-this-deletes',
|
|
274
|
+
'config',
|
|
275
|
+
'project',
|
|
276
|
+
'out',
|
|
277
|
+
'json',
|
|
278
|
+
'dry-run',
|
|
279
|
+
],
|
|
280
|
+
'cloudflare janitor': [
|
|
281
|
+
'repository-id',
|
|
282
|
+
'inventory',
|
|
283
|
+
'config',
|
|
284
|
+
'project',
|
|
285
|
+
'out',
|
|
286
|
+
'json',
|
|
287
|
+
'dry-run',
|
|
288
|
+
],
|
|
289
|
+
'secrets generate-master-key': ['key-version'],
|
|
290
|
+
'admin bootstrap': ['email', 'sqlite', 'cloudflare', 'database-id', 'token-file'],
|
|
291
|
+
'admin reset-local': ['email', 'sqlite', 'cloudflare', 'database-id', 'token-file'],
|
|
292
|
+
'admin rebind-provider': [
|
|
293
|
+
'provider',
|
|
294
|
+
'confirm',
|
|
295
|
+
'expected-anchor',
|
|
296
|
+
'new-anchor',
|
|
297
|
+
'sqlite',
|
|
298
|
+
'cloudflare',
|
|
299
|
+
'database-id',
|
|
300
|
+
],
|
|
301
|
+
'admin show-provider-binding': ['provider', 'sqlite', 'cloudflare', 'database-id'],
|
|
302
|
+
'import cutover-check': [
|
|
303
|
+
'project-dir',
|
|
304
|
+
'old-repository',
|
|
305
|
+
'new-repository',
|
|
306
|
+
'old-auth-env',
|
|
307
|
+
'new-auth-env',
|
|
308
|
+
'timeout-seconds',
|
|
309
|
+
'lock',
|
|
310
|
+
'json',
|
|
311
|
+
],
|
|
312
|
+
'import satis plan': [
|
|
313
|
+
'config',
|
|
314
|
+
'out',
|
|
315
|
+
'project',
|
|
316
|
+
'credentials',
|
|
317
|
+
'repository-map',
|
|
318
|
+
'baseline',
|
|
319
|
+
'mode',
|
|
320
|
+
],
|
|
321
|
+
'import private-packagist plan': [
|
|
322
|
+
'snapshot',
|
|
323
|
+
'map',
|
|
324
|
+
'out',
|
|
325
|
+
'credentials-out',
|
|
326
|
+
'members',
|
|
327
|
+
'baseline',
|
|
328
|
+
'mode',
|
|
329
|
+
'include-org-admins',
|
|
330
|
+
'runtime',
|
|
331
|
+
'packagist',
|
|
332
|
+
'compact-selection',
|
|
333
|
+
'compact-vendor',
|
|
334
|
+
'accept-project-widening',
|
|
335
|
+
'quiet',
|
|
336
|
+
],
|
|
337
|
+
'import private-packagist fetch': [
|
|
338
|
+
'org',
|
|
339
|
+
'snapshot',
|
|
340
|
+
'api-key-file',
|
|
341
|
+
'api-secret-file',
|
|
342
|
+
'versions',
|
|
343
|
+
'require-org-match',
|
|
344
|
+
],
|
|
345
|
+
'import private-packagist dates': ['snapshot', 'map', 'baseline', 'out', 'package', 'quiet'],
|
|
346
|
+
'import submit': ['manifest', 'receipt', 'principal', 'broker', 'resume', 'token-file'],
|
|
347
|
+
'import status': ['broker', 'token-file', 'wait', 'wait-seconds'],
|
|
348
|
+
'import credentials': ['broker', 'token-file', 'manifest', 'credentials'],
|
|
349
|
+
'import verify': ['broker', 'token-file', 'wait', 'wait-seconds'],
|
|
350
|
+
'import accept': ['broker', 'token-file', 'wait', 'wait-seconds'],
|
|
351
|
+
'source accept-removal': ['url', 'source'],
|
|
352
|
+
openapi: ['out'],
|
|
353
|
+
version: [],
|
|
354
|
+
};
|
|
355
|
+
function acceptsInvocation(positionals, flags) {
|
|
356
|
+
const isImportRun = positionals[0] === 'import' &&
|
|
357
|
+
['status', 'credentials', 'verify', 'accept'].includes(positionals[1] ?? '');
|
|
358
|
+
if (isImportRun && positionals.length !== 3)
|
|
359
|
+
return false;
|
|
360
|
+
const allowed = ALLOWED_FLAGS[(isImportRun ? positionals.slice(0, 2) : positionals).join(' ')];
|
|
361
|
+
return allowed !== undefined && flags.every((flag) => allowed.includes(flag));
|
|
362
|
+
}
|
|
363
|
+
function adminTarget(values) {
|
|
364
|
+
const databaseId = values['database-id'];
|
|
365
|
+
if (values.sqlite !== undefined && values.cloudflare !== true && databaseId === undefined) {
|
|
366
|
+
return { kind: 'sqlite', file: values.sqlite };
|
|
367
|
+
}
|
|
368
|
+
if (values.sqlite === undefined && values.cloudflare === true && databaseId !== undefined) {
|
|
369
|
+
return { kind: 'cloudflare', databaseId, env: process.env };
|
|
370
|
+
}
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
export async function run(argv) {
|
|
374
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
375
|
+
console.log(USAGE);
|
|
376
|
+
return 0;
|
|
377
|
+
}
|
|
378
|
+
const parsed = parseCliArgs([...argv]);
|
|
379
|
+
const usageError = () => {
|
|
380
|
+
const cloudflareIndex = argv.findIndex((value, index) => value === 'cloudflare' &&
|
|
381
|
+
['setup', 'provision', 'migrate', 'deploy', 'smoke', 'teardown', 'janitor'].includes(argv[index + 1] ?? ''));
|
|
382
|
+
if (cloudflareIndex >= 0 && argv.includes('--json')) {
|
|
383
|
+
console.log(JSON.stringify(failCommand(commandEnvelope(argv[cloudflareIndex + 1], argv.includes('--dry-run')), new CloudflareError('invalid_input', 2, false, argv[cloudflareIndex + 1])).output));
|
|
384
|
+
}
|
|
385
|
+
else
|
|
386
|
+
console.error(USAGE);
|
|
387
|
+
return 2;
|
|
388
|
+
};
|
|
389
|
+
if (parsed === null)
|
|
390
|
+
return usageError();
|
|
391
|
+
const { positionals, values } = parsed;
|
|
392
|
+
if (!acceptsInvocation(positionals, Object.keys(values))) {
|
|
393
|
+
return usageError();
|
|
394
|
+
}
|
|
395
|
+
const [command, subcommand] = positionals;
|
|
396
|
+
let providers = { kind: 'absent' };
|
|
397
|
+
if (command === 'cloudflare' && (subcommand === 'deploy' || subcommand === 'setup')) {
|
|
398
|
+
try {
|
|
399
|
+
providers = await readProvidersOption(values.providers, undefined, subcommand);
|
|
400
|
+
}
|
|
401
|
+
catch (error) {
|
|
402
|
+
const result = failCommand(commandEnvelope(subcommand, values['dry-run'] ?? false), error);
|
|
403
|
+
if (values.json)
|
|
404
|
+
console.log(JSON.stringify(result.output));
|
|
405
|
+
else
|
|
406
|
+
console.error(result.output.error?.message);
|
|
407
|
+
return result.exitCode;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (command === 'cloudflare' && values.prebuilt) {
|
|
411
|
+
try {
|
|
412
|
+
await assertPrebuiltConfiguration(process.cwd(), values.config);
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
const result = failCommand(commandEnvelope(subcommand, values['dry-run']), error);
|
|
416
|
+
if (values.json)
|
|
417
|
+
console.log(JSON.stringify(result.output));
|
|
418
|
+
else
|
|
419
|
+
console.error(result.output.error?.message);
|
|
420
|
+
return result.exitCode;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
if (command === 'cloudflare' && (subcommand === 'teardown' || subcommand === 'janitor')) {
|
|
424
|
+
const options = {
|
|
425
|
+
env: process.env,
|
|
426
|
+
...(values.config === undefined ? {} : { configPath: values.config }),
|
|
427
|
+
...(values.project === undefined ? {} : { project: values.project }),
|
|
428
|
+
...(values.out === undefined ? {} : { outDir: values.out }),
|
|
429
|
+
dryRun: values['dry-run'] ?? false,
|
|
430
|
+
json: values.json ?? false,
|
|
431
|
+
};
|
|
432
|
+
if (subcommand === 'teardown') {
|
|
433
|
+
if (!values.inventory)
|
|
434
|
+
return usageError();
|
|
435
|
+
return runCloudflareTeardown({
|
|
436
|
+
...options,
|
|
437
|
+
inventory: values.inventory,
|
|
438
|
+
...(values['inventory-id'] === undefined ? {} : { inventoryId: values['inventory-id'] }),
|
|
439
|
+
iUnderstandThisDeletes: values['i-understand-this-deletes'] ?? false,
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
if (!values['repository-id'])
|
|
443
|
+
return usageError();
|
|
444
|
+
return runCloudflareJanitor({
|
|
445
|
+
...options,
|
|
446
|
+
repositoryId: values['repository-id'],
|
|
447
|
+
...(values.inventory === undefined ? {} : { inventory: values.inventory }),
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
if (command === 'source' && subcommand === 'accept-removal') {
|
|
451
|
+
if (!values.url || !values.source)
|
|
452
|
+
return usageError();
|
|
453
|
+
return runSourceAcceptRemoval({
|
|
454
|
+
url: values.url,
|
|
455
|
+
source: values.source,
|
|
456
|
+
env: process.env,
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
if (command === 'openapi')
|
|
460
|
+
return runOpenApi(values.out);
|
|
461
|
+
if (command === 'import' &&
|
|
462
|
+
['submit', 'status', 'credentials', 'verify', 'accept'].includes(subcommand ?? '')) {
|
|
463
|
+
if (!values.broker ||
|
|
464
|
+
(values.wait === true && values['wait-seconds'] !== undefined) ||
|
|
465
|
+
(values['wait-seconds'] !== undefined &&
|
|
466
|
+
!/^(?:0|[1-9][0-9]?|[12][0-9]{2}|300)$/.test(values['wait-seconds'])))
|
|
467
|
+
return usageError();
|
|
468
|
+
return runImport({
|
|
469
|
+
command: subcommand,
|
|
470
|
+
broker: values.broker,
|
|
471
|
+
env: process.env,
|
|
472
|
+
...(positionals[2] === undefined ? {} : { run: positionals[2] }),
|
|
473
|
+
...(values.manifest === undefined ? {} : { manifest: values.manifest }),
|
|
474
|
+
...(values.credentials === undefined ? {} : { credentials: values.credentials }),
|
|
475
|
+
...(values.receipt === undefined ? {} : { receipt: values.receipt }),
|
|
476
|
+
...(values.principal === undefined ? {} : { principal: values.principal }),
|
|
477
|
+
...(values.resume === undefined ? {} : { resume: values.resume }),
|
|
478
|
+
...(values['token-file'] === undefined ? {} : { tokenFile: values['token-file'] }),
|
|
479
|
+
...(values['wait-seconds'] === undefined
|
|
480
|
+
? values.wait
|
|
481
|
+
? { waitSeconds: 300 }
|
|
482
|
+
: {}
|
|
483
|
+
: { waitSeconds: Number(values['wait-seconds']) }),
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
if (command === 'import' && subcommand === 'cutover-check') {
|
|
487
|
+
if (!values['project-dir'] ||
|
|
488
|
+
!values['old-repository'] ||
|
|
489
|
+
!values['new-repository'] ||
|
|
490
|
+
!values['old-auth-env'] ||
|
|
491
|
+
!values['new-auth-env'] ||
|
|
492
|
+
(values['timeout-seconds'] !== undefined && !/^\d+$/.test(values['timeout-seconds'])))
|
|
493
|
+
return usageError();
|
|
494
|
+
return runImportCutover({
|
|
495
|
+
projectDir: values['project-dir'],
|
|
496
|
+
oldRepository: values['old-repository'],
|
|
497
|
+
newRepository: values['new-repository'],
|
|
498
|
+
oldAuthEnv: values['old-auth-env'],
|
|
499
|
+
newAuthEnv: values['new-auth-env'],
|
|
500
|
+
historicLocks: values.lock ?? [],
|
|
501
|
+
timeoutSeconds: values['timeout-seconds'] === undefined ? 1800 : Number(values['timeout-seconds']),
|
|
502
|
+
json: values.json ?? false,
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
if (command === 'import' && subcommand === 'private-packagist') {
|
|
506
|
+
if (positionals[2] === 'dates') {
|
|
507
|
+
if (!values.snapshot || !values.map || !values.baseline || !values.out)
|
|
508
|
+
return usageError();
|
|
509
|
+
return runImportPrivatePackagistDates({
|
|
510
|
+
snapshot: values.snapshot,
|
|
511
|
+
map: values.map,
|
|
512
|
+
baseline: values.baseline,
|
|
513
|
+
out: values.out,
|
|
514
|
+
packages: values.package ?? [],
|
|
515
|
+
quiet: values.quiet ?? false,
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
if (positionals[2] === 'plan') {
|
|
519
|
+
if (!values.snapshot ||
|
|
520
|
+
!values.map ||
|
|
521
|
+
!values.out ||
|
|
522
|
+
!values['credentials-out'] ||
|
|
523
|
+
(values.mode !== undefined && values.mode !== 'merge' && values.mode !== 'override') ||
|
|
524
|
+
(values.runtime !== undefined && values.runtime !== 'workers' && values.runtime !== 'node'))
|
|
525
|
+
return usageError();
|
|
526
|
+
return runImportPrivatePackagistPlan({
|
|
527
|
+
snapshot: values.snapshot,
|
|
528
|
+
map: values.map,
|
|
529
|
+
out: values.out,
|
|
530
|
+
credentialsOut: values['credentials-out'],
|
|
531
|
+
...(values.members === undefined ? {} : { members: values.members }),
|
|
532
|
+
...(values.baseline === undefined ? {} : { baseline: values.baseline }),
|
|
533
|
+
...(values.mode === undefined ? {} : { mode: values.mode }),
|
|
534
|
+
...(values.runtime === undefined ? {} : { runtime: values.runtime }),
|
|
535
|
+
...(values.packagist === undefined ? {} : { packagist: values.packagist }),
|
|
536
|
+
includeOrgAdmins: values['include-org-admins'] ?? false,
|
|
537
|
+
compactSelection: values['compact-selection'] ?? false,
|
|
538
|
+
compactVendors: values['compact-vendor'] ?? [],
|
|
539
|
+
acceptProjectWidening: values['accept-project-widening'] ?? [],
|
|
540
|
+
quiet: values.quiet ?? false,
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
if (!values.org || !values.snapshot)
|
|
544
|
+
return usageError();
|
|
545
|
+
return runImportPrivatePackagistFetch({
|
|
546
|
+
org: values.org,
|
|
547
|
+
snapshot: values.snapshot,
|
|
548
|
+
env: process.env,
|
|
549
|
+
...(values['api-key-file'] === undefined ? {} : { apiKeyFile: values['api-key-file'] }),
|
|
550
|
+
...(values['api-secret-file'] === undefined
|
|
551
|
+
? {}
|
|
552
|
+
: { apiSecretFile: values['api-secret-file'] }),
|
|
553
|
+
versions: values.versions ?? false,
|
|
554
|
+
requireOrgMatch: values['require-org-match'] ?? false,
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
if (command === 'import' && subcommand === 'satis') {
|
|
558
|
+
const { config, out, mode } = values;
|
|
559
|
+
if (config === undefined ||
|
|
560
|
+
out === undefined ||
|
|
561
|
+
(mode !== undefined && mode !== 'merge' && mode !== 'override')) {
|
|
562
|
+
return usageError();
|
|
563
|
+
}
|
|
564
|
+
return runImportSatisPlan({
|
|
565
|
+
config,
|
|
566
|
+
out,
|
|
567
|
+
...(values.project === undefined ? {} : { project: values.project }),
|
|
568
|
+
...(values.credentials === undefined ? {} : { credentials: values.credentials }),
|
|
569
|
+
...(values['repository-map'] === undefined
|
|
570
|
+
? {}
|
|
571
|
+
: { repositoryMap: values['repository-map'] }),
|
|
572
|
+
...(values.baseline === undefined ? {} : { baseline: values.baseline }),
|
|
573
|
+
...(mode === undefined ? {} : { mode }),
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
if (command === 'cloudflare' && subcommand === 'setup') {
|
|
577
|
+
if ((values.migrate !== undefined && !['true', 'false'].includes(values.migrate)) ||
|
|
578
|
+
(values.jurisdiction !== undefined && !['eu', 'default'].includes(values.jurisdiction)))
|
|
579
|
+
return usageError();
|
|
580
|
+
return runCloudflareSetup({
|
|
581
|
+
providers,
|
|
582
|
+
...(values['workers-paid'] === undefined ? {} : { workersPaid: values['workers-paid'] }),
|
|
583
|
+
prebuilt: values.prebuilt ?? false,
|
|
584
|
+
workerName: values['worker-name'] ?? '',
|
|
585
|
+
env: process.env,
|
|
586
|
+
...(values.config === undefined ? {} : { configPath: values.config }),
|
|
587
|
+
...(values.out === undefined ? {} : { outDir: values.out }),
|
|
588
|
+
...(values.environment === undefined ? {} : { environment: values.environment }),
|
|
589
|
+
...(values['deployment-id'] === undefined ? {} : { deploymentId: values['deployment-id'] }),
|
|
590
|
+
...(values.inventory === undefined ? {} : { inventory: values.inventory }),
|
|
591
|
+
...(values.jurisdiction === undefined
|
|
592
|
+
? {}
|
|
593
|
+
: { jurisdiction: values.jurisdiction }),
|
|
594
|
+
...(values['location-hint'] === undefined ? {} : { locationHint: values['location-hint'] }),
|
|
595
|
+
...(values['adopt-resource'] === undefined
|
|
596
|
+
? {}
|
|
597
|
+
: { adoptResource: values['adopt-resource'] }),
|
|
598
|
+
...(values['abandon-intent'] === undefined
|
|
599
|
+
? {}
|
|
600
|
+
: { abandonIntent: values['abandon-intent'] }),
|
|
601
|
+
...(values.domain === undefined ? {} : { domain: values.domain }),
|
|
602
|
+
...(values['public-url'] === undefined ? {} : { publicUrl: values['public-url'] }),
|
|
603
|
+
...(values.routes === undefined ? {} : { routes: values.routes }),
|
|
604
|
+
...(values.rollout === undefined ? {} : { rollout: Number(values.rollout) }),
|
|
605
|
+
...(values['allow-contract'] === undefined
|
|
606
|
+
? {}
|
|
607
|
+
: { allowContract: values['allow-contract'] }),
|
|
608
|
+
...(values.secret === undefined ? {} : { secret: values.secret }),
|
|
609
|
+
...(values.secrets === undefined ? {} : { secrets: values.secrets }),
|
|
610
|
+
...(values['org-slug'] === undefined ? {} : { orgSlug: values['org-slug'] }),
|
|
611
|
+
...(values['org-name'] === undefined ? {} : { orgName: values['org-name'] }),
|
|
612
|
+
...(values['admin-email'] === undefined ? {} : { adminEmail: values['admin-email'] }),
|
|
613
|
+
...(values['key-file'] === undefined ? {} : { keyFile: values['key-file'] }),
|
|
614
|
+
...(values['master-key-env'] === undefined ? {} : { masterKeyEnv: values['master-key-env'] }),
|
|
615
|
+
...(values['token-file'] === undefined ? {} : { tokenFile: values['token-file'] }),
|
|
616
|
+
...(values.project === undefined ? {} : { smokeProject: values.project }),
|
|
617
|
+
...(values['smoke-token-env'] === undefined
|
|
618
|
+
? {}
|
|
619
|
+
: { smokeTokenEnv: values['smoke-token-env'] }),
|
|
620
|
+
...(values['deadline-seconds'] === undefined
|
|
621
|
+
? {}
|
|
622
|
+
: { deadlineSeconds: Number(values['deadline-seconds']) }),
|
|
623
|
+
migrate: values.migrate !== 'false',
|
|
624
|
+
nonInteractive: values['non-interactive'] ?? false,
|
|
625
|
+
refreshSetupToken: values['refresh-setup-token'] ?? false,
|
|
626
|
+
yes: values.yes ?? false,
|
|
627
|
+
json: values.json ?? false,
|
|
628
|
+
dryRun: values['dry-run'] ?? false,
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
if (command === 'cloudflare' && subcommand === 'smoke') {
|
|
632
|
+
if (!values['worker-name'] ||
|
|
633
|
+
(values.jurisdiction !== undefined && !['eu', 'default'].includes(values.jurisdiction)) ||
|
|
634
|
+
(values['deadline-seconds'] !== undefined &&
|
|
635
|
+
!/^(?:[1-9]|[1-9][0-9]|[12][0-9]{2}|300)$/.test(values['deadline-seconds'])))
|
|
636
|
+
return usageError();
|
|
637
|
+
return runCloudflareSmoke({
|
|
638
|
+
workerName: values['worker-name'],
|
|
639
|
+
env: process.env,
|
|
640
|
+
...(values.config === undefined ? {} : { configPath: values.config }),
|
|
641
|
+
...(values.out === undefined ? {} : { outDir: values.out }),
|
|
642
|
+
...(values.environment === undefined ? {} : { environment: values.environment }),
|
|
643
|
+
...(values['deployment-id'] === undefined ? {} : { deploymentId: values['deployment-id'] }),
|
|
644
|
+
...(values.inventory === undefined ? {} : { inventory: values.inventory }),
|
|
645
|
+
...(values.jurisdiction === undefined
|
|
646
|
+
? {}
|
|
647
|
+
: { jurisdiction: values.jurisdiction }),
|
|
648
|
+
...(values['public-url'] === undefined ? {} : { publicUrl: values['public-url'] }),
|
|
649
|
+
...(values.project === undefined ? {} : { project: values.project }),
|
|
650
|
+
...(values['smoke-token-env'] === undefined
|
|
651
|
+
? {}
|
|
652
|
+
: { smokeTokenEnv: values['smoke-token-env'] }),
|
|
653
|
+
...(values['deadline-seconds'] === undefined
|
|
654
|
+
? {}
|
|
655
|
+
: { deadlineSeconds: Number(values['deadline-seconds']) }),
|
|
656
|
+
noRollback: values['no-rollback'] ?? false,
|
|
657
|
+
json: values.json ?? false,
|
|
658
|
+
dryRun: values['dry-run'] ?? false,
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
if (command === 'cloudflare' && subcommand === 'deploy') {
|
|
662
|
+
if (!values['worker-name'] ||
|
|
663
|
+
(values.jurisdiction !== undefined && !['eu', 'default'].includes(values.jurisdiction)) ||
|
|
664
|
+
(values.rollout !== undefined && !/^(?:[1-9]|[1-9][0-9]|100)$/.test(values.rollout)))
|
|
665
|
+
return usageError();
|
|
666
|
+
return runCloudflareDeploy({
|
|
667
|
+
providers,
|
|
668
|
+
...(values['workers-paid'] === undefined ? {} : { workersPaid: values['workers-paid'] }),
|
|
669
|
+
prebuilt: values.prebuilt ?? false,
|
|
670
|
+
workerName: values['worker-name'],
|
|
671
|
+
env: process.env,
|
|
672
|
+
...(values.config === undefined ? {} : { configPath: values.config }),
|
|
673
|
+
...(values.out === undefined ? {} : { outDir: values.out }),
|
|
674
|
+
...(values.environment === undefined ? {} : { environment: values.environment }),
|
|
675
|
+
...(values['deployment-id'] === undefined ? {} : { deploymentId: values['deployment-id'] }),
|
|
676
|
+
...(values.inventory === undefined ? {} : { inventory: values.inventory }),
|
|
677
|
+
...(values.jurisdiction === undefined
|
|
678
|
+
? {}
|
|
679
|
+
: { jurisdiction: values.jurisdiction }),
|
|
680
|
+
...(values.rollout === undefined ? {} : { rollout: Number(values.rollout) }),
|
|
681
|
+
...(values['public-url'] === undefined ? {} : { publicUrl: values['public-url'] }),
|
|
682
|
+
...(values.domain === undefined ? {} : { domain: values.domain }),
|
|
683
|
+
...(values.routes === undefined ? {} : { routes: values.routes }),
|
|
684
|
+
...(values.secret === undefined ? {} : { secret: values.secret }),
|
|
685
|
+
...(values.secrets === undefined ? {} : { secrets: values.secrets }),
|
|
686
|
+
...(values['allow-contract'] === undefined
|
|
687
|
+
? {}
|
|
688
|
+
: { allowContract: values['allow-contract'] }),
|
|
689
|
+
json: values.json ?? false,
|
|
690
|
+
dryRun: values['dry-run'] ?? false,
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
if (command === 'cloudflare' && subcommand === 'provision') {
|
|
694
|
+
if (!values['worker-name'] ||
|
|
695
|
+
(values.jurisdiction !== undefined && !['eu', 'default'].includes(values.jurisdiction)))
|
|
696
|
+
return usageError();
|
|
697
|
+
return runCloudflareProvision({
|
|
698
|
+
prebuilt: values.prebuilt ?? false,
|
|
699
|
+
workerName: values['worker-name'],
|
|
700
|
+
env: process.env,
|
|
701
|
+
...(values.config === undefined ? {} : { configPath: values.config }),
|
|
702
|
+
...(values.out === undefined ? {} : { outDir: values.out }),
|
|
703
|
+
...(values.environment === undefined ? {} : { environment: values.environment }),
|
|
704
|
+
...(values['deployment-id'] === undefined ? {} : { deploymentId: values['deployment-id'] }),
|
|
705
|
+
...(values.inventory === undefined ? {} : { inventory: values.inventory }),
|
|
706
|
+
...(values.jurisdiction === undefined
|
|
707
|
+
? {}
|
|
708
|
+
: { jurisdiction: values.jurisdiction }),
|
|
709
|
+
...(values['location-hint'] === undefined ? {} : { locationHint: values['location-hint'] }),
|
|
710
|
+
...(values['adopt-resource'] === undefined
|
|
711
|
+
? {}
|
|
712
|
+
: { adoptResource: values['adopt-resource'] }),
|
|
713
|
+
...(values['abandon-intent'] === undefined
|
|
714
|
+
? {}
|
|
715
|
+
: { abandonIntent: values['abandon-intent'] }),
|
|
716
|
+
...(values.domain === undefined ? {} : { domain: values.domain }),
|
|
717
|
+
yes: values.yes ?? false,
|
|
718
|
+
json: values.json ?? false,
|
|
719
|
+
dryRun: values['dry-run'] ?? false,
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
if (command === 'cloudflare') {
|
|
723
|
+
if (subcommand === 'migrate' && (values['database-id'] || values['worker-name'])) {
|
|
724
|
+
if (values.jurisdiction !== undefined && !['eu', 'default'].includes(values.jurisdiction))
|
|
725
|
+
return usageError();
|
|
726
|
+
return runCloudflareMigrate({
|
|
727
|
+
prebuilt: values.prebuilt ?? false,
|
|
728
|
+
...(values['database-id'] === undefined ? {} : { databaseId: values['database-id'] }),
|
|
729
|
+
...(values['worker-name'] === undefined ? {} : { workerName: values['worker-name'] }),
|
|
730
|
+
...(values.config === undefined ? {} : { configPath: values.config }),
|
|
731
|
+
...(values.environment === undefined ? {} : { environment: values.environment }),
|
|
732
|
+
...(values['deployment-id'] === undefined ? {} : { deploymentId: values['deployment-id'] }),
|
|
733
|
+
...(values.inventory === undefined ? {} : { inventory: values.inventory }),
|
|
734
|
+
...(values.jurisdiction === undefined
|
|
735
|
+
? {}
|
|
736
|
+
: { jurisdiction: values.jurisdiction }),
|
|
737
|
+
...(values['allow-contract'] === undefined
|
|
738
|
+
? {}
|
|
739
|
+
: { allowContract: values['allow-contract'] }),
|
|
740
|
+
json: values.json ?? false,
|
|
741
|
+
outDir: values.out || (values.prebuilt ? '.pb/prebuilt/cloudflare' : '.pb/cloudflare'),
|
|
742
|
+
dryRun: values['dry-run'] ?? false,
|
|
743
|
+
env: process.env,
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
if (subcommand === 'bootstrap' && values['database-id'] && values.slug && values.name) {
|
|
747
|
+
return runCloudflareBootstrap({
|
|
748
|
+
databaseId: values['database-id'],
|
|
749
|
+
slug: values.slug,
|
|
750
|
+
name: values.name,
|
|
751
|
+
env: process.env,
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (command === 'secrets' && subcommand === 'generate-master-key') {
|
|
756
|
+
return runGenerateMasterKey({ keyVersion: values['key-version'] });
|
|
757
|
+
}
|
|
758
|
+
if (command === 'admin' && (subcommand === 'bootstrap' || subcommand === 'reset-local')) {
|
|
759
|
+
const target = adminTarget(values);
|
|
760
|
+
if (values.email !== undefined && target !== null) {
|
|
761
|
+
const options = { email: values.email, target, tokenFile: values['token-file'] };
|
|
762
|
+
return subcommand === 'bootstrap' ? runAdminBootstrap(options) : runAdminResetLocal(options);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
if (command === 'admin' && subcommand === 'rebind-provider') {
|
|
766
|
+
const target = adminTarget(values);
|
|
767
|
+
const { provider, confirm } = values;
|
|
768
|
+
const expectedAnchor = values['expected-anchor'];
|
|
769
|
+
const newAnchor = values['new-anchor'];
|
|
770
|
+
if (target !== null &&
|
|
771
|
+
provider !== undefined &&
|
|
772
|
+
confirm !== undefined &&
|
|
773
|
+
expectedAnchor !== undefined &&
|
|
774
|
+
newAnchor !== undefined) {
|
|
775
|
+
return runAdminRebindProvider({ provider, confirm, expectedAnchor, newAnchor, target });
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
if (command === 'admin' && subcommand === 'show-provider-binding') {
|
|
779
|
+
const target = adminTarget(values);
|
|
780
|
+
const { provider } = values;
|
|
781
|
+
if (target !== null && provider !== undefined) {
|
|
782
|
+
return runAdminShowProviderBinding({ provider, target });
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (command === 'migrate' && values.sqlite) {
|
|
786
|
+
return runMigrateSqlite({
|
|
787
|
+
file: values.sqlite,
|
|
788
|
+
outDir: values.out || '.pb/node',
|
|
789
|
+
dryRun: values['dry-run'] ?? false,
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
if (command === 'bootstrap' && values.sqlite && values.slug && values.name) {
|
|
793
|
+
return runBootstrapSqlite({ file: values.sqlite, slug: values.slug, name: values.name });
|
|
794
|
+
}
|
|
795
|
+
if (command === 'version') {
|
|
796
|
+
const pkg = createRequire(import.meta.url)('../package.json');
|
|
797
|
+
console.log(pkg.version);
|
|
798
|
+
return 0;
|
|
799
|
+
}
|
|
800
|
+
if (command === 'build') {
|
|
801
|
+
const target = values.target;
|
|
802
|
+
if (target !== undefined && target !== 'cloudflare' && target !== 'node') {
|
|
803
|
+
console.error(`unknown target "${target}"`);
|
|
804
|
+
return 2;
|
|
805
|
+
}
|
|
806
|
+
let result;
|
|
807
|
+
try {
|
|
808
|
+
result = await build({
|
|
809
|
+
configPath: values.config ?? 'broker.config.ts',
|
|
810
|
+
...(target === undefined ? {} : { target: target }),
|
|
811
|
+
...(values.out === undefined ? {} : { outDir: values.out }),
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
catch (error) {
|
|
815
|
+
if (!(error instanceof BuildDiagnosticsError))
|
|
816
|
+
throw error;
|
|
817
|
+
for (const problem of error.problems) {
|
|
818
|
+
console.error(`error: ${problem}`.replace(/[\r\n]+/g, ' '));
|
|
819
|
+
}
|
|
820
|
+
return 2;
|
|
821
|
+
}
|
|
822
|
+
console.log(`manifest: ${result.manifestJson}`);
|
|
823
|
+
console.log(`bundle: ${result.bundle}`);
|
|
824
|
+
return 0;
|
|
825
|
+
}
|
|
826
|
+
return usageError();
|
|
827
|
+
}
|
|
828
|
+
//# sourceMappingURL=cli.js.map
|