@m-kopa/launchpad-cli 0.66.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/bundle/upload.d.ts +4 -0
- package/dist/bundle/upload.d.ts.map +1 -1
- package/dist/cli.js +293 -72
- package/dist/commands/deploy.d.ts +15 -4
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/migrate.d.ts +15 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/status.d.ts +14 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/deploy/dry-run.d.ts.map +1 -1
- package/dist/http/api-client.d.ts.map +1 -1
- package/dist/http/error-envelope.d.ts +4 -0
- package/dist/http/error-envelope.d.ts.map +1 -1
- package/dist/manifest/migrate-dispatch.d.ts +7 -3
- package/dist/manifest/migrate-dispatch.d.ts.map +1 -1
- package/dist/manifest/wrangler-config.d.ts +9 -2
- package/dist/manifest/wrangler-config.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/skills/launchpad-content-pr/SKILL.md +130 -50
- package/skills/launchpad-deploy/SKILL.md +7 -4
- package/skills/launchpad-deploy-status/SKILL.md +1 -1
- package/skills/launchpad-destroy/SKILL.md +1 -1
- package/skills/launchpad-identity/SKILL.md +125 -39
- package/skills/launchpad-onboard/SKILL.md +3 -2
- package/skills/launchpad-report/SKILL.md +1 -1
- package/skills/launchpad-status/SKILL.md +1 -1
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
19
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
20
20
|
|
|
21
21
|
// src/version.ts
|
|
22
|
-
var CLI_VERSION = "0.
|
|
22
|
+
var CLI_VERSION = "0.68.0";
|
|
23
23
|
|
|
24
24
|
// src/config.ts
|
|
25
25
|
import { readFileSync } from "node:fs";
|
|
@@ -73,7 +73,9 @@ function decodeErrorEnvelope(input, context) {
|
|
|
73
73
|
const endpoint = boundedOptionalString(body.endpoint, "endpoint", omissions) ?? context.endpoint;
|
|
74
74
|
const legacyError = boundedOptionalString(body.error, "error", omissions);
|
|
75
75
|
const code = boundedOptionalString(body.code, "code", omissions) ?? legacyError ?? "api_error";
|
|
76
|
-
const
|
|
76
|
+
const serverMessage = boundedOptionalString(body.message, "message", omissions);
|
|
77
|
+
const reason = boundedOptionalString(body.reason, "reason", omissions);
|
|
78
|
+
const message = serverMessage ?? `bot returned HTTP ${context.status}`;
|
|
77
79
|
const source = boundedOptionalString(body.source, "source", omissions);
|
|
78
80
|
const sourceSha = nullableBoundedString(body.source_sha ?? body.sourceSha, "source_sha", omissions);
|
|
79
81
|
const manifestSha = boundedOptionalString(body.manifest_sha ?? body.manifestSha ?? body.commit_sha ?? body.commitSha, "manifest_sha", omissions);
|
|
@@ -82,6 +84,8 @@ function decodeErrorEnvelope(input, context) {
|
|
|
82
84
|
endpoint,
|
|
83
85
|
code,
|
|
84
86
|
message,
|
|
87
|
+
...serverMessage === undefined ? {} : { serverMessage },
|
|
88
|
+
...reason === undefined ? {} : { reason },
|
|
85
89
|
...legacyError === undefined ? {} : { legacyError },
|
|
86
90
|
...source === undefined ? {} : { source },
|
|
87
91
|
...sourceSha === undefined ? {} : { sourceSha },
|
|
@@ -1149,8 +1153,10 @@ async function apiRaw(cfg, opts, fetcher = fetch) {
|
|
|
1149
1153
|
throw recordedFault(new UnauthenticatedError(`bot returned 401 for ${opts.path}: ${detail} — run \`launchpad login\``));
|
|
1150
1154
|
}
|
|
1151
1155
|
if (res.status === 403) {
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1156
|
+
const envelope = await readErrorEnvelope(res, opts.path);
|
|
1157
|
+
const hint = forbiddenHint(envelope, opts.path);
|
|
1158
|
+
throw recordedFault(new ForbiddenError(`bot returned 403 for ${opts.path}: ${formatErrorEnvelope(envelope)}` + (hint === null ? "" : `
|
|
1159
|
+
${hint}`)));
|
|
1154
1160
|
}
|
|
1155
1161
|
if (res.status === 404) {
|
|
1156
1162
|
const envelope = await readErrorEnvelope(res, opts.path);
|
|
@@ -1225,6 +1231,17 @@ async function readErrorEnvelope(res, endpoint) {
|
|
|
1225
1231
|
omissions: [omission]
|
|
1226
1232
|
};
|
|
1227
1233
|
}
|
|
1234
|
+
var APP_PATH_REGEX = /^\/apps\/([A-Za-z0-9._-]+)\//;
|
|
1235
|
+
function forbiddenHint(envelope, endpoint) {
|
|
1236
|
+
const slug = APP_PATH_REGEX.exec(endpoint)?.[1];
|
|
1237
|
+
if (slug === undefined)
|
|
1238
|
+
return null;
|
|
1239
|
+
const insufficientRole = envelope.reason === "insufficient-role" || envelope.code === "insufficient-role";
|
|
1240
|
+
const bare = envelope.serverMessage === undefined && (envelope.reason === undefined || envelope.reason === "forbidden");
|
|
1241
|
+
if (!insufficientRole && !bare)
|
|
1242
|
+
return null;
|
|
1243
|
+
return `hint: you have no role on app '${slug}' (or this action needs a higher role). ` + `Ask an owner of '${slug}' to run: launchpad add-owner ${slug} <your-email> ` + `(or launchpad grant-editor). Check your roles with: launchpad whoami`;
|
|
1244
|
+
}
|
|
1228
1245
|
async function errorDetail(res, endpoint) {
|
|
1229
1246
|
return formatErrorEnvelope(await readErrorEnvelope(res, endpoint));
|
|
1230
1247
|
}
|
|
@@ -3829,7 +3846,7 @@ function emit(capability) {
|
|
|
3829
3846
|
const isGateway = capability.authMode === "gateway";
|
|
3830
3847
|
const environmentFields = capability.environmentNames.map((name) => ` ${name}: string;`);
|
|
3831
3848
|
const environmentValues = capability.environmentNames.map((name) => ` ${name}: this.env.${name} ?? "",`);
|
|
3832
|
-
const envAuthFields = isGateway ? [" GATEWAY_ISSUER: string;", " GATEWAY_AUD: string;", " GATEWAY_JWKS_URL: string;"] : [" CF_ACCESS_AUD: string;", " CF_ACCESS_TEAM_DOMAIN: string;"];
|
|
3849
|
+
const envAuthFields = isGateway ? [" GATEWAY_ISSUER: string;", " GATEWAY_AUD: string;", " GATEWAY_JWKS_URL: string;", " GATEWAY_JWKS_JSON?: string;"] : [" CF_ACCESS_AUD: string;", " CF_ACCESS_TEAM_DOMAIN: string;"];
|
|
3833
3850
|
const monitorEnvField = isGateway ? [" MONITOR_SHARED_SECRET: string;"] : [];
|
|
3834
3851
|
const lines = [
|
|
3835
3852
|
"/**",
|
|
@@ -3864,10 +3881,44 @@ function emit(capability) {
|
|
|
3864
3881
|
"",
|
|
3865
3882
|
"let jwksCache: ReturnType<typeof createJwksCache> | null = null;",
|
|
3866
3883
|
"",
|
|
3884
|
+
...isGateway ? [
|
|
3885
|
+
"/**",
|
|
3886
|
+
" * AIO-811 / ADR 0057 amendment 2: this Worker runs inside the chain",
|
|
3887
|
+
" * gateway -> router -> container Worker, so a live fetch of the",
|
|
3888
|
+
" * gateway's own JWKS URL is a subrequest back to the originating",
|
|
3889
|
+
" * gateway and Cloudflare loop protection can reject it. Try the live",
|
|
3890
|
+
" * fetch first; on a throw or non-2xx fall back to the deploy-time",
|
|
3891
|
+
" * snapshot (GATEWAY_JWKS_JSON). With no snapshot the original failure",
|
|
3892
|
+
" * is surfaced so verification still fails closed.",
|
|
3893
|
+
" */",
|
|
3894
|
+
"async function jwksFetch(",
|
|
3895
|
+
" env: Env,",
|
|
3896
|
+
" input: Parameters<typeof fetch>[0],",
|
|
3897
|
+
" init?: Parameters<typeof fetch>[1],",
|
|
3898
|
+
"): Promise<Response> {",
|
|
3899
|
+
" let failure: unknown;",
|
|
3900
|
+
" try {",
|
|
3901
|
+
" const live = await fetch(input, init);",
|
|
3902
|
+
" if (live.ok) return live;",
|
|
3903
|
+
" failure = live;",
|
|
3904
|
+
" } catch (error) {",
|
|
3905
|
+
" failure = error;",
|
|
3906
|
+
" }",
|
|
3907
|
+
' if (typeof env.GATEWAY_JWKS_JSON === "string" && env.GATEWAY_JWKS_JSON.length > 0) {',
|
|
3908
|
+
" return new Response(env.GATEWAY_JWKS_JSON, {",
|
|
3909
|
+
' headers: { "content-type": "application/json" },',
|
|
3910
|
+
" });",
|
|
3911
|
+
" }",
|
|
3912
|
+
" if (failure instanceof Response) return failure;",
|
|
3913
|
+
" throw failure;",
|
|
3914
|
+
"}",
|
|
3915
|
+
""
|
|
3916
|
+
] : [],
|
|
3867
3917
|
"function jwks(env: Env): ReturnType<typeof createJwksCache> {",
|
|
3868
3918
|
" if (jwksCache === null) {",
|
|
3869
3919
|
" jwksCache = createJwksCache(",
|
|
3870
3920
|
isGateway ? " env.GATEWAY_JWKS_URL," : " `https://${env.CF_ACCESS_TEAM_DOMAIN}/cdn-cgi/access/certs`,",
|
|
3921
|
+
...isGateway ? [" { fetchFn: (input, init) => jwksFetch(env, input, init) },"] : [],
|
|
3871
3922
|
" );",
|
|
3872
3923
|
" }",
|
|
3873
3924
|
" return jwksCache;",
|
|
@@ -4425,6 +4476,11 @@ function emit3(capability) {
|
|
|
4425
4476
|
...secretNames(capability).map((name) => ` ${name}: \${{ secrets.${name} }}`),
|
|
4426
4477
|
" run: |",
|
|
4427
4478
|
" set -euo pipefail",
|
|
4479
|
+
...isGateway ? [
|
|
4480
|
+
' GATEWAY_JWKS_JSON="$(curl -fsS --max-time 20 "$GATEWAY_JWKS_URL")"',
|
|
4481
|
+
` printf '%s' "$GATEWAY_JWKS_JSON" | jq -e '.keys | length > 0' > /dev/null`,
|
|
4482
|
+
" export GATEWAY_JWKS_JSON"
|
|
4483
|
+
] : [],
|
|
4428
4484
|
' secrets_file="$(mktemp "${RUNNER_TEMP}/launchpad-secrets.XXXXXX")"',
|
|
4429
4485
|
` trap 'rm -f "$secrets_file"' EXIT`,
|
|
4430
4486
|
` jq -n '${secretsJqFilter(capability)}' > "$secrets_file"`,
|
|
@@ -4443,7 +4499,8 @@ function secretNames(capability) {
|
|
|
4443
4499
|
return capability.authMode === "gateway" ? ["BINDINGS_PROXY_SECRET", "MONITOR_SHARED_SECRET", ...capability.environmentNames] : ["BINDINGS_PROXY_SECRET", ...capability.environmentNames];
|
|
4444
4500
|
}
|
|
4445
4501
|
function secretsJqFilter(capability) {
|
|
4446
|
-
|
|
4502
|
+
const names = capability.authMode === "gateway" ? [...secretNames(capability), "GATEWAY_JWKS_JSON"] : secretNames(capability);
|
|
4503
|
+
return `{${names.map((name) => `${name}: env.${name}`).join(", ")}}`;
|
|
4447
4504
|
}
|
|
4448
4505
|
// ../launchpad-engine/dist/per-app-lock.js
|
|
4449
4506
|
var PER_APP_LOCK_HCL = `# This file is maintained automatically by "terraform init".
|
|
@@ -6306,7 +6363,7 @@ async function runStatus(args, io) {
|
|
|
6306
6363
|
};
|
|
6307
6364
|
}
|
|
6308
6365
|
}
|
|
6309
|
-
emit4(output, parsed.json, io);
|
|
6366
|
+
emit4(output, parsed.json, io, lifecycle?.containerRedeploy);
|
|
6310
6367
|
return 0;
|
|
6311
6368
|
}
|
|
6312
6369
|
let localYaml = null;
|
|
@@ -6383,7 +6440,7 @@ async function runStatus(args, io) {
|
|
|
6383
6440
|
}),
|
|
6384
6441
|
...lifecycle?.statusPageUrl !== undefined ? { statusPageUrl: lifecycle.statusPageUrl } : {}
|
|
6385
6442
|
};
|
|
6386
|
-
emit4(out, parsed.json, io);
|
|
6443
|
+
emit4(out, parsed.json, io, lifecycle?.containerRedeploy);
|
|
6387
6444
|
return 0;
|
|
6388
6445
|
}
|
|
6389
6446
|
if (local === null) {
|
|
@@ -6400,7 +6457,7 @@ async function runStatus(args, io) {
|
|
|
6400
6457
|
}),
|
|
6401
6458
|
...lifecycle?.statusPageUrl !== undefined ? { statusPageUrl: lifecycle.statusPageUrl } : {}
|
|
6402
6459
|
};
|
|
6403
|
-
emit4(out, parsed.json, io);
|
|
6460
|
+
emit4(out, parsed.json, io, lifecycle?.containerRedeploy);
|
|
6404
6461
|
if (parsed.strict) {
|
|
6405
6462
|
if (deployment?.liveDeployment?.buildStatus === "failure" || deployment?.v2?.state === "refused") {
|
|
6406
6463
|
io.err(`launchpad status: --strict: live build FAILED ` + `(drift not evaluated — no local launchpad.yaml here).`);
|
|
@@ -6438,7 +6495,7 @@ async function runStatus(args, io) {
|
|
|
6438
6495
|
...standingExceptions !== null ? { standingExceptions } : {}
|
|
6439
6496
|
})
|
|
6440
6497
|
};
|
|
6441
|
-
emit4(out, parsed.json, io);
|
|
6498
|
+
emit4(out, parsed.json, io, lifecycle?.containerRedeploy);
|
|
6442
6499
|
return 0;
|
|
6443
6500
|
}
|
|
6444
6501
|
const localGroups = await resolveStatusGroups({
|
|
@@ -6501,7 +6558,7 @@ async function runStatus(args, io) {
|
|
|
6501
6558
|
...groupIssues.length === 0 ? {} : { groupIssues },
|
|
6502
6559
|
...lifecycle?.statusPageUrl !== undefined ? { statusPageUrl: lifecycle.statusPageUrl } : {}
|
|
6503
6560
|
};
|
|
6504
|
-
emit4(result, parsed.json, io);
|
|
6561
|
+
emit4(result, parsed.json, io, lifecycle?.containerRedeploy);
|
|
6505
6562
|
if (parsed.strict && (result.state === "drift" || accessDrift?.inSync === false || groupIssues.length > 0)) {
|
|
6506
6563
|
return 1;
|
|
6507
6564
|
}
|
|
@@ -6750,7 +6807,14 @@ function lifecycleOutput(slug, lc) {
|
|
|
6750
6807
|
...lc.statusPageUrl !== undefined ? { statusPageUrl: lc.statusPageUrl } : {}
|
|
6751
6808
|
};
|
|
6752
6809
|
}
|
|
6753
|
-
function
|
|
6810
|
+
function containerRedeployLine(view) {
|
|
6811
|
+
if (view.state === "failed") {
|
|
6812
|
+
return `Container redeploy: failed at ${view.stage ?? "unknown"}` + (view.message ? ` — ${view.message}` : "") + ` (attempt ${view.attemptId}, ${view.at})`;
|
|
6813
|
+
}
|
|
6814
|
+
return `Container redeploy: ${view.state} (attempt ${view.attemptId})`;
|
|
6815
|
+
}
|
|
6816
|
+
function emit4(base, asJson, io, containerRedeploy) {
|
|
6817
|
+
const out = containerRedeploy === undefined ? base : { ...base, containerRedeploy };
|
|
6754
6818
|
if (asJson) {
|
|
6755
6819
|
io.out(JSON.stringify(out, null, 2));
|
|
6756
6820
|
return;
|
|
@@ -6758,6 +6822,8 @@ function emit4(out, asJson, io) {
|
|
|
6758
6822
|
if (out.statusPageUrl !== undefined) {
|
|
6759
6823
|
io.out(`Status page: ${out.statusPageUrl}`);
|
|
6760
6824
|
}
|
|
6825
|
+
if (containerRedeploy !== undefined)
|
|
6826
|
+
io.out(containerRedeployLine(containerRedeploy));
|
|
6761
6827
|
switch (out.state) {
|
|
6762
6828
|
case "provisioning":
|
|
6763
6829
|
io.out(`${out.slug}: provisioning (stage: ${out.stage ?? "starting"})` + (out.submissionId ? ` — submission ${out.submissionId}` : ""));
|
|
@@ -8573,11 +8639,11 @@ async function runDeployDryRun(opts, io, deps = {}) {
|
|
|
8573
8639
|
const cfg = deps.config ?? loadConfig();
|
|
8574
8640
|
const fetcher = deps.fetcher ?? fetch;
|
|
8575
8641
|
const manifestPath = resolve8(process.cwd(), opts.file ?? "launchpad.yaml");
|
|
8576
|
-
const loaded =
|
|
8642
|
+
const loaded = loadManifestAnyVersion(manifestPath);
|
|
8577
8643
|
if (loaded.kind !== "ok") {
|
|
8578
8644
|
return renderManifestError2(loaded, opts.json, io);
|
|
8579
8645
|
}
|
|
8580
|
-
const slug = loaded
|
|
8646
|
+
const slug = manifestSlug(loaded);
|
|
8581
8647
|
let manifestSha;
|
|
8582
8648
|
try {
|
|
8583
8649
|
manifestSha = (deps.gitHeadSha ?? defaultGitHeadSha)(process.cwd());
|
|
@@ -8701,10 +8767,11 @@ function renderManifestError2(loaded, json, io) {
|
|
|
8701
8767
|
ok: false,
|
|
8702
8768
|
kind: "schema-error",
|
|
8703
8769
|
path: loaded.path,
|
|
8770
|
+
schema: loaded.schema,
|
|
8704
8771
|
issues: loaded.issues
|
|
8705
8772
|
}));
|
|
8706
8773
|
} else {
|
|
8707
|
-
io.err(`launchpad deploy --dry-run: manifest schema validation
|
|
8774
|
+
io.err(`launchpad deploy --dry-run: manifest failed ${loaded.schema} schema validation (${loaded.path}):`);
|
|
8708
8775
|
for (const issue of loaded.issues) {
|
|
8709
8776
|
io.err(` - ${issue.path}: ${issue.message}`);
|
|
8710
8777
|
}
|
|
@@ -9019,7 +9086,8 @@ var PLATFORM_ENV_NAMES = new Set([
|
|
|
9019
9086
|
"CF_ACCESS_AUD",
|
|
9020
9087
|
"JWKS_URL"
|
|
9021
9088
|
]);
|
|
9022
|
-
|
|
9089
|
+
var PLATFORM_ENV_PREFIXES = ["GATEWAY_", "CF_ACCESS_"];
|
|
9090
|
+
function dispatchManifest(manifest, wrangler = {}) {
|
|
9023
9091
|
const v2 = manifest.apiVersion === "launchpad.m-kopa.us/v2";
|
|
9024
9092
|
const source = v2 ? manifest.spec : manifest;
|
|
9025
9093
|
const appType = v2 ? manifest.spec.appType : manifest.deployment.type;
|
|
@@ -9028,8 +9096,9 @@ function dispatchManifest(manifest, wranglerD1) {
|
|
|
9028
9096
|
}
|
|
9029
9097
|
if (!v2)
|
|
9030
9098
|
assertConvertibleV1(manifest);
|
|
9031
|
-
const d1 = d1Binding(v2 ? manifest.spec.bindings?.d1 : pagesTargetD1(manifest),
|
|
9032
|
-
const
|
|
9099
|
+
const d1 = d1Binding(v2 ? manifest.spec.bindings?.d1 : pagesTargetD1(manifest), wrangler.d1);
|
|
9100
|
+
const manifestEnv = v2 ? manifest.spec.env_vars : plainTextEnv(manifest.production_env);
|
|
9101
|
+
const plainEnv = withWranglerVars(manifestEnv, wrangler.vars ?? {}, d1);
|
|
9033
9102
|
const envVars = { ...plainEnv, ...secretEnv(source.secrets, plainEnv) };
|
|
9034
9103
|
const spec = v2 ? { ...manifest.spec, secrets: undefined } : {
|
|
9035
9104
|
appType,
|
|
@@ -9087,6 +9156,31 @@ function d1Binding(declared, wranglerD1) {
|
|
|
9087
9156
|
}
|
|
9088
9157
|
return declared ?? wranglerD1;
|
|
9089
9158
|
}
|
|
9159
|
+
function withWranglerVars(env, vars, d1) {
|
|
9160
|
+
const entries = Object.entries(vars);
|
|
9161
|
+
if (entries.length === 0)
|
|
9162
|
+
return env;
|
|
9163
|
+
const out = { ...env };
|
|
9164
|
+
for (const [name, value] of entries) {
|
|
9165
|
+
if (isPlatformEnvName(name)) {
|
|
9166
|
+
throw new Error(`The wrangler var ${name} is set by the platform on dispatch apps. Rename it before converting.`);
|
|
9167
|
+
}
|
|
9168
|
+
if (/_(TOKEN|SECRET)$/.test(name)) {
|
|
9169
|
+
throw new Error(`The wrangler var ${name} is named like a secret. Declare it as an \`env-file\` secret in launchpad.yaml and remove it from the wrangler vars.`);
|
|
9170
|
+
}
|
|
9171
|
+
if (name === d1)
|
|
9172
|
+
throw new Error(`The wrangler var ${name} has the same name as the D1 binding. Rename one of them.`);
|
|
9173
|
+
const existing = out[name];
|
|
9174
|
+
if (existing !== undefined && !(existing.type === "plain_text" && existing.value === value)) {
|
|
9175
|
+
throw new Error(`The wrangler var ${name} differs from the ${name} environment variable in launchpad.yaml. Keep one value.`);
|
|
9176
|
+
}
|
|
9177
|
+
out[name] = { type: "plain_text", value };
|
|
9178
|
+
}
|
|
9179
|
+
return out;
|
|
9180
|
+
}
|
|
9181
|
+
function isPlatformEnvName(name) {
|
|
9182
|
+
return PLATFORM_ENV_NAMES.has(name) || PLATFORM_ENV_PREFIXES.some((prefix) => name.startsWith(prefix));
|
|
9183
|
+
}
|
|
9090
9184
|
function plainTextEnv(env) {
|
|
9091
9185
|
if (env === undefined)
|
|
9092
9186
|
return;
|
|
@@ -9125,19 +9219,36 @@ var ALLOWED_KEYS = new Set([
|
|
|
9125
9219
|
"compatibility_date",
|
|
9126
9220
|
"compatibility_flags",
|
|
9127
9221
|
"pages_build_output_dir",
|
|
9128
|
-
"d1_databases"
|
|
9222
|
+
"d1_databases",
|
|
9223
|
+
"vars"
|
|
9129
9224
|
]);
|
|
9130
9225
|
var PLATFORM_FLAGS = new Set(["nodejs_compat"]);
|
|
9131
9226
|
|
|
9132
9227
|
class UnsupportedWranglerConfigError extends Error {
|
|
9133
9228
|
}
|
|
9134
|
-
function
|
|
9229
|
+
function wranglerRuntime(file, text) {
|
|
9135
9230
|
const toml = file.endsWith(".toml");
|
|
9136
9231
|
const config = toml ? readToml(file, text) : readJsonc(file, text);
|
|
9137
9232
|
for (const key of Object.keys(config)) {
|
|
9138
9233
|
if (!ALLOWED_KEYS.has(key) && (toml || key !== "$schema"))
|
|
9139
9234
|
throw unsupportedKey(file, key);
|
|
9140
9235
|
}
|
|
9236
|
+
const vars = config.vars === undefined ? {} : plainVars(file, config.vars);
|
|
9237
|
+
const d1 = d1Binding2(file, config);
|
|
9238
|
+
return d1 === undefined ? { vars } : { d1, vars };
|
|
9239
|
+
}
|
|
9240
|
+
function plainVars(file, value) {
|
|
9241
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
9242
|
+
throw new UnsupportedWranglerConfigError(`${file} sets \`vars\` to something other than a table`);
|
|
9243
|
+
}
|
|
9244
|
+
for (const [name, item] of Object.entries(value)) {
|
|
9245
|
+
if (typeof item !== "string") {
|
|
9246
|
+
throw new UnsupportedWranglerConfigError(`${file} sets \`vars.${name}\` to something other than a string; dispatch env vars are plain strings`);
|
|
9247
|
+
}
|
|
9248
|
+
}
|
|
9249
|
+
return value;
|
|
9250
|
+
}
|
|
9251
|
+
function d1Binding2(file, config) {
|
|
9141
9252
|
if (config.compatibility_flags !== undefined) {
|
|
9142
9253
|
const extra = asArray(file, "compatibility_flags", config.compatibility_flags).find((flag) => !PLATFORM_FLAGS.has(String(flag)));
|
|
9143
9254
|
if (extra !== undefined) {
|
|
@@ -9190,8 +9301,9 @@ function readToml(file, text) {
|
|
|
9190
9301
|
let table = config;
|
|
9191
9302
|
for (const line of logicalTomlLines(text)) {
|
|
9192
9303
|
if (line.startsWith("[")) {
|
|
9193
|
-
table =
|
|
9194
|
-
|
|
9304
|
+
table = openTable(file, line, config, databases);
|
|
9305
|
+
} else if (table === config.vars) {
|
|
9306
|
+
assignVar(file, table, line);
|
|
9195
9307
|
} else {
|
|
9196
9308
|
assign(file, table, line, table === config);
|
|
9197
9309
|
}
|
|
@@ -9202,20 +9314,55 @@ function readToml(file, text) {
|
|
|
9202
9314
|
throw new UnsupportedWranglerConfigError(`${file} declares d1_databases twice`);
|
|
9203
9315
|
return { ...config, d1_databases: databases };
|
|
9204
9316
|
}
|
|
9205
|
-
function
|
|
9317
|
+
function openTable(file, line, config, databases) {
|
|
9206
9318
|
const name = /^\[\[?\s*([^\]]*?)\s*\]\]?$/.exec(line)?.[1] ?? line;
|
|
9207
|
-
if (
|
|
9208
|
-
|
|
9209
|
-
|
|
9319
|
+
if (line.startsWith("[[") && name === "d1_databases") {
|
|
9320
|
+
const table = {};
|
|
9321
|
+
databases.push(table);
|
|
9322
|
+
return table;
|
|
9323
|
+
}
|
|
9324
|
+
if (!line.startsWith("[[") && name === "vars")
|
|
9325
|
+
return varsTable(config);
|
|
9326
|
+
throw unsupportedKey(file, topKey(name));
|
|
9327
|
+
}
|
|
9328
|
+
function varsTable(config) {
|
|
9329
|
+
config.vars ??= {};
|
|
9330
|
+
return config.vars;
|
|
9210
9331
|
}
|
|
9211
9332
|
function assign(file, table, line, topLevel) {
|
|
9333
|
+
const [, key, value] = tomlAssignment(file, line);
|
|
9334
|
+
if (topLevel && key.includes(".")) {
|
|
9335
|
+
const [head, name, ...rest] = key.split(".");
|
|
9336
|
+
if (head !== "vars" || rest.length > 0)
|
|
9337
|
+
throw unsupportedKey(file, topKey(key));
|
|
9338
|
+
assignVar(file, varsTable(table), `${name} = ${value}`);
|
|
9339
|
+
return;
|
|
9340
|
+
}
|
|
9341
|
+
table[topKey(key)] = tomlValue(value.trim());
|
|
9342
|
+
}
|
|
9343
|
+
function assignVar(file, vars, line) {
|
|
9344
|
+
const [, key, value] = tomlAssignment(file, line);
|
|
9345
|
+
const quoted = /^"((?:[^"\\]|\\.)*)"$|^'([^']*)'$/.exec(value.trim());
|
|
9346
|
+
const text = quoted === null ? null : quoted[1] === undefined ? quoted[2] : basicString(file, key, quoted[1]);
|
|
9347
|
+
vars[key.replace(/"/g, "").trim()] = text;
|
|
9348
|
+
}
|
|
9349
|
+
var TOML_ESCAPES = { b: "\b", t: "\t", n: `
|
|
9350
|
+
`, f: "\f", r: "\r", '"': '"', "\\": "\\" };
|
|
9351
|
+
function basicString(file, key, raw) {
|
|
9352
|
+
return raw.replace(/\\(u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|.)/g, (escape, code) => {
|
|
9353
|
+
const point = code.length > 1 ? parseInt(code.slice(1), 16) : -1;
|
|
9354
|
+
const scalar = point <= 1114111 && (point < 55296 || point > 57343);
|
|
9355
|
+
const decoded = code.length > 1 ? scalar ? String.fromCodePoint(point) : undefined : TOML_ESCAPES[code];
|
|
9356
|
+
if (decoded === undefined)
|
|
9357
|
+
throw new UnsupportedWranglerConfigError(`${file} sets \`vars.${key.trim()}\` with an invalid escape \`${escape}\``);
|
|
9358
|
+
return decoded;
|
|
9359
|
+
});
|
|
9360
|
+
}
|
|
9361
|
+
function tomlAssignment(file, line) {
|
|
9212
9362
|
const assignment = /^([\w\-."]+)\s*=\s*(.*)$/.exec(line);
|
|
9213
9363
|
if (assignment === null)
|
|
9214
9364
|
throw new UnsupportedWranglerConfigError(`${file} could not be read as TOML near \`${line.slice(0, 40)}\``);
|
|
9215
|
-
|
|
9216
|
-
if (topLevel && assignment[1].includes("."))
|
|
9217
|
-
throw unsupportedKey(file, key);
|
|
9218
|
-
table[key] = tomlValue(assignment[2].trim());
|
|
9365
|
+
return [assignment[0], assignment[1], assignment[2]];
|
|
9219
9366
|
}
|
|
9220
9367
|
function topKey(dotted) {
|
|
9221
9368
|
return dotted.split(".")[0].replace(/"/g, "").trim();
|
|
@@ -9312,25 +9459,38 @@ async function runMigrate(args, io) {
|
|
|
9312
9459
|
return 64;
|
|
9313
9460
|
}
|
|
9314
9461
|
try {
|
|
9315
|
-
|
|
9316
|
-
if (result.kind === "already") {
|
|
9317
|
-
io.out("launchpad.yaml already selects Workers dispatch. Run `launchpad deploy`.");
|
|
9318
|
-
} else if (result.kind === "eligible") {
|
|
9319
|
-
io.out(`${result.slug}: eligible for v2 Workers dispatch with gateway authentication. No files changed.`);
|
|
9320
|
-
} else {
|
|
9321
|
-
io.out(`${result.slug}: launchpad.yaml now uses v2 Workers dispatch with gateway authentication.`);
|
|
9322
|
-
io.out(`Audience, owner and application settings are preserved. Original: ${BACKUP_PATH}`);
|
|
9323
|
-
io.out("Run `launchpad deploy`. No Pages project is needed.");
|
|
9324
|
-
const next = secretsNextStep(result.secrets);
|
|
9325
|
-
if (next !== null)
|
|
9326
|
-
io.out(next);
|
|
9327
|
-
}
|
|
9462
|
+
reportMigration(io, await convertToDispatch(process.cwd(), args.includes("--dry-run")));
|
|
9328
9463
|
return 0;
|
|
9329
9464
|
} catch (error) {
|
|
9330
9465
|
io.err(`launchpad migrate: ${error instanceof Error ? error.message : String(error)}`);
|
|
9331
9466
|
return 1;
|
|
9332
9467
|
}
|
|
9333
9468
|
}
|
|
9469
|
+
function reportMigration(io, result) {
|
|
9470
|
+
if (result.kind === "already") {
|
|
9471
|
+
io.out("launchpad.yaml already selects Workers dispatch. Run `launchpad deploy`.");
|
|
9472
|
+
return;
|
|
9473
|
+
}
|
|
9474
|
+
if (result.kind === "eligible") {
|
|
9475
|
+
io.out(`${result.slug}: eligible for v2 Workers dispatch with gateway authentication. No files changed.`);
|
|
9476
|
+
} else {
|
|
9477
|
+
io.out(`${result.slug}: launchpad.yaml now uses v2 Workers dispatch with gateway authentication.`);
|
|
9478
|
+
io.out(`Audience, owner and application settings are preserved. Original: ${BACKUP_PATH}`);
|
|
9479
|
+
io.out("Run `launchpad deploy`. No Pages project is needed.");
|
|
9480
|
+
const next = secretsNextStep(result.secrets);
|
|
9481
|
+
if (next !== null)
|
|
9482
|
+
io.out(next);
|
|
9483
|
+
}
|
|
9484
|
+
const warning = plainSecretWarning(result.plainSecretLike);
|
|
9485
|
+
if (warning !== null)
|
|
9486
|
+
io.err(`warning: ${warning}`);
|
|
9487
|
+
}
|
|
9488
|
+
var SECRET_LIKE_NAME = /SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE|CREDENTIAL|APIKEY|AUTH_CONFIG|(^|_)(API_)?KEY(_|$)/i;
|
|
9489
|
+
function plainSecretWarning(names) {
|
|
9490
|
+
if (names.length === 0)
|
|
9491
|
+
return null;
|
|
9492
|
+
return `${names.join(", ")} ${names.length === 1 ? "looks" : "look"} like a secret but carried over as plain text, readable in launchpad.yaml. ` + "If it is one, declare it as an `env-file` secret, set it with `launchpad secrets push`, and rotate it.";
|
|
9493
|
+
}
|
|
9334
9494
|
var BACKUP_PATH = ".launchpad/manifest-before-dispatch.yaml";
|
|
9335
9495
|
function secretsNextStep(secrets) {
|
|
9336
9496
|
if (secrets.length === 0)
|
|
@@ -9339,33 +9499,37 @@ function secretsNextStep(secrets) {
|
|
|
9339
9499
|
}
|
|
9340
9500
|
async function convertToDispatch(cwd, dryRun) {
|
|
9341
9501
|
const file = path8.join(cwd, "launchpad.yaml");
|
|
9342
|
-
|
|
9343
|
-
throw new Error("launchpad.yaml must be a regular file, not a symlink.");
|
|
9502
|
+
const regularFile = lstatSync4(file).isFile();
|
|
9344
9503
|
const original = readFileSync11(file, "utf8");
|
|
9345
9504
|
const loaded = parseManifestAnyVersion(original, file);
|
|
9346
9505
|
if (loaded.kind !== "ok")
|
|
9347
|
-
throw new
|
|
9506
|
+
throw new InvalidManifestError;
|
|
9348
9507
|
const manifest = loaded.manifest;
|
|
9349
9508
|
if (manifest.apiVersion === "launchpad.m-kopa.us/v2" && manifest.spec.origin === "dispatch")
|
|
9350
9509
|
return { kind: "already" };
|
|
9351
9510
|
const slug = manifest.apiVersion === "launchpad.m-kopa.us/v2" ? manifest.metadata.slug : manifest.metadata.name;
|
|
9352
9511
|
let converted;
|
|
9353
9512
|
try {
|
|
9513
|
+
if (!regularFile)
|
|
9514
|
+
throw new Error("launchpad.yaml must be a regular file, not a symlink.");
|
|
9354
9515
|
converted = convertLocally(cwd, manifest);
|
|
9355
9516
|
} catch (error) {
|
|
9356
|
-
await refuseIfRegistered(slug)
|
|
9517
|
+
if (!await refuseIfRegistered(slug))
|
|
9518
|
+
throw new IneligibleUnconfirmedError(error);
|
|
9357
9519
|
throw error;
|
|
9358
9520
|
}
|
|
9359
9521
|
await assertUnregistered(slug);
|
|
9360
|
-
const
|
|
9522
|
+
const env = Object.entries(converted.spec.env_vars ?? {});
|
|
9523
|
+
const secrets = env.filter(([, value]) => value.type === "secret_text").map(([name]) => name);
|
|
9524
|
+
const plainSecretLike = env.filter(([name, value]) => value.type === "plain_text" && SECRET_LIKE_NAME.test(name)).map(([name]) => name);
|
|
9361
9525
|
if (dryRun)
|
|
9362
|
-
return { kind: "eligible", slug, secrets };
|
|
9526
|
+
return { kind: "eligible", slug, secrets, plainSecretLike };
|
|
9363
9527
|
try {
|
|
9364
9528
|
saveMigration(file, original, converted);
|
|
9365
9529
|
} catch (error) {
|
|
9366
9530
|
throw new MigrationSaveError(error);
|
|
9367
9531
|
}
|
|
9368
|
-
return { kind: "converted", slug, secrets };
|
|
9532
|
+
return { kind: "converted", slug, secrets, plainSecretLike };
|
|
9369
9533
|
}
|
|
9370
9534
|
function convertLocally(cwd, manifest) {
|
|
9371
9535
|
const v2 = manifest.apiVersion === "launchpad.m-kopa.us/v2";
|
|
@@ -9376,9 +9540,11 @@ function convertLocally(cwd, manifest) {
|
|
|
9376
9540
|
async function refuseIfRegistered(slug) {
|
|
9377
9541
|
try {
|
|
9378
9542
|
await assertUnregistered(slug);
|
|
9543
|
+
return true;
|
|
9379
9544
|
} catch (error) {
|
|
9380
|
-
if (error instanceof
|
|
9381
|
-
|
|
9545
|
+
if (error instanceof RegistryUnavailableError)
|
|
9546
|
+
return false;
|
|
9547
|
+
throw error;
|
|
9382
9548
|
}
|
|
9383
9549
|
}
|
|
9384
9550
|
async function assertUnregistered(slug) {
|
|
@@ -9394,6 +9560,18 @@ async function assertUnregistered(slug) {
|
|
|
9394
9560
|
throw new RegisteredAppError;
|
|
9395
9561
|
}
|
|
9396
9562
|
|
|
9563
|
+
class IneligibleUnconfirmedError extends Error {
|
|
9564
|
+
constructor(cause) {
|
|
9565
|
+
super(cause instanceof Error ? cause.message : String(cause));
|
|
9566
|
+
}
|
|
9567
|
+
}
|
|
9568
|
+
|
|
9569
|
+
class InvalidManifestError extends Error {
|
|
9570
|
+
constructor() {
|
|
9571
|
+
super("launchpad.yaml is invalid. Run `launchpad validate` and correct it first.");
|
|
9572
|
+
}
|
|
9573
|
+
}
|
|
9574
|
+
|
|
9397
9575
|
class MigrationSaveError extends Error {
|
|
9398
9576
|
constructor(cause) {
|
|
9399
9577
|
super(`Could not save the converted manifest: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
@@ -9414,10 +9592,14 @@ class RegisteredAppError extends Error {
|
|
|
9414
9592
|
var WRANGLER_FILES = ["wrangler.toml", "wrangler.json", "wrangler.jsonc"];
|
|
9415
9593
|
function inspectRuntime(cwd, appType, appRootDir, build) {
|
|
9416
9594
|
const d1 = new Set;
|
|
9595
|
+
const vars = {};
|
|
9417
9596
|
for (const root of runtimeRoots(cwd, appRootDir, build)) {
|
|
9418
9597
|
assertNoUncompiledCode(root, appType);
|
|
9419
|
-
for (const
|
|
9420
|
-
d1
|
|
9598
|
+
for (const runtime of wranglerRuntimes(cwd, root)) {
|
|
9599
|
+
if (runtime.d1 !== undefined)
|
|
9600
|
+
d1.add(runtime.d1);
|
|
9601
|
+
mergeVars(vars, runtime.vars);
|
|
9602
|
+
}
|
|
9421
9603
|
}
|
|
9422
9604
|
if (d1.size > 1)
|
|
9423
9605
|
throw new Error(`The wrangler configs bind D1 under different names (${[...d1].join(", ")}). Use one name.`);
|
|
@@ -9425,7 +9607,15 @@ function inspectRuntime(cwd, appType, appRootDir, build) {
|
|
|
9425
9607
|
if (binding !== undefined && appType !== "react+api") {
|
|
9426
9608
|
throw new Error("The wrangler config declares a D1 database, which only react+api apps can use on dispatch.");
|
|
9427
9609
|
}
|
|
9428
|
-
return binding;
|
|
9610
|
+
return { ...binding === undefined ? {} : { d1: binding }, vars };
|
|
9611
|
+
}
|
|
9612
|
+
function mergeVars(into, vars) {
|
|
9613
|
+
for (const [name, value] of Object.entries(vars)) {
|
|
9614
|
+
if (into[name] !== undefined && into[name] !== value) {
|
|
9615
|
+
throw new Error(`The wrangler configs set var ${name} to different values. Use one value.`);
|
|
9616
|
+
}
|
|
9617
|
+
into[name] = value;
|
|
9618
|
+
}
|
|
9429
9619
|
}
|
|
9430
9620
|
function runtimeRoots(cwd, appRootDir, build) {
|
|
9431
9621
|
const appRoot = path8.resolve(cwd, appRootDir ?? ".");
|
|
@@ -9448,8 +9638,8 @@ function assertNoUncompiledCode(root, appType) {
|
|
|
9448
9638
|
if (api)
|
|
9449
9639
|
assertWorkerRoutesFit(root);
|
|
9450
9640
|
}
|
|
9451
|
-
function
|
|
9452
|
-
return WRANGLER_FILES.map((name) => path8.join(root, name)).filter((file) => existsSync7(file)).map((file) =>
|
|
9641
|
+
function wranglerRuntimes(cwd, root) {
|
|
9642
|
+
return WRANGLER_FILES.map((name) => path8.join(root, name)).filter((file) => existsSync7(file)).map((file) => wranglerRuntime(path8.relative(cwd, file), readFileSync11(file, "utf8")));
|
|
9453
9643
|
}
|
|
9454
9644
|
function assertWorkerRoutesFit(root) {
|
|
9455
9645
|
const functions = path8.join(root, "functions");
|
|
@@ -9896,14 +10086,19 @@ async function runModelADeploy(args) {
|
|
|
9896
10086
|
let slug;
|
|
9897
10087
|
let appType = "static";
|
|
9898
10088
|
let declaredOrigin;
|
|
9899
|
-
let pagesNote;
|
|
9900
10089
|
try {
|
|
9901
|
-
|
|
10090
|
+
await defaultToDispatch(cwd, manifestPath, io);
|
|
9902
10091
|
} catch (e) {
|
|
9903
10092
|
if (e instanceof UpgradeRequiredError) {
|
|
9904
10093
|
io.err(e.message);
|
|
9905
10094
|
return EXIT_CLI_UPGRADE_REQUIRED;
|
|
9906
10095
|
}
|
|
10096
|
+
if (e instanceof DispatchIneligibleError) {
|
|
10097
|
+
for (const line of e.message.split(`
|
|
10098
|
+
`))
|
|
10099
|
+
io.err(line);
|
|
10100
|
+
return 1;
|
|
10101
|
+
}
|
|
9907
10102
|
io.err(`launchpad deploy: ${describe17(e)}. Nothing was deployed.`);
|
|
9908
10103
|
if (e instanceof UnauthenticatedError)
|
|
9909
10104
|
io.err(" run `launchpad login` to refresh your session.");
|
|
@@ -9977,8 +10172,6 @@ async function runModelADeploy(args) {
|
|
|
9977
10172
|
io.out(`Bundling ${cwd} for ${slug} (Model A) …`);
|
|
9978
10173
|
if (declaredOrigin !== "dispatch" && appType !== "container") {
|
|
9979
10174
|
io.out("Deployment target: Cloudflare Pages, selected by launchpad.yaml.");
|
|
9980
|
-
if (pagesNote !== null)
|
|
9981
|
-
io.out(pagesNote);
|
|
9982
10175
|
}
|
|
9983
10176
|
let cfg;
|
|
9984
10177
|
try {
|
|
@@ -10187,6 +10380,16 @@ async function runModelADeploy(args) {
|
|
|
10187
10380
|
const submissionId = typeof success.submissionId === "string" ? success.submissionId : "(missing)";
|
|
10188
10381
|
const echoedAppType = typeof success.appType === "string" ? success.appType : "(missing)";
|
|
10189
10382
|
const message = typeof success.message === "string" ? success.message : "Bot accepted the upload and started provisioning.";
|
|
10383
|
+
if (success.mode === "container_redeploy") {
|
|
10384
|
+
io.out(`✓ Container redeploy started for ${slug}`);
|
|
10385
|
+
io.out(` submission: ${submissionId}`);
|
|
10386
|
+
io.out("");
|
|
10387
|
+
io.out(message);
|
|
10388
|
+
io.out("");
|
|
10389
|
+
io.out("Next steps:");
|
|
10390
|
+
io.out(` launchpad status ${slug} # watch the redeploy`);
|
|
10391
|
+
return 0;
|
|
10392
|
+
}
|
|
10190
10393
|
io.out(`✓ First-time deploy — provisioning workflow started for ${slug}`);
|
|
10191
10394
|
io.out(` submission: ${submissionId}`);
|
|
10192
10395
|
io.out(` appType: ${echoedAppType}`);
|
|
@@ -10271,24 +10474,39 @@ function isIneligible(e) {
|
|
|
10271
10474
|
return !(e instanceof RegistryUnavailableError || e instanceof MigrationSaveError || e instanceof UpgradeRequiredError || e instanceof UnauthenticatedError);
|
|
10272
10475
|
}
|
|
10273
10476
|
async function defaultToDispatch(cwd, manifestPath, io) {
|
|
10274
|
-
|
|
10275
|
-
|
|
10477
|
+
const fields = originFields(manifestPath);
|
|
10478
|
+
if (!impliesPagesForGateway(fields))
|
|
10479
|
+
return;
|
|
10276
10480
|
try {
|
|
10277
10481
|
const result = await convertToDispatch(cwd, false);
|
|
10278
10482
|
if (result.kind === "converted")
|
|
10279
|
-
reportConversion(io, result.secrets);
|
|
10280
|
-
return null;
|
|
10483
|
+
reportConversion(io, result.secrets, result.plainSecretLike);
|
|
10281
10484
|
} catch (e) {
|
|
10282
|
-
if (e instanceof RegisteredAppError)
|
|
10283
|
-
return
|
|
10485
|
+
if (e instanceof RegisteredAppError || e instanceof InvalidManifestError)
|
|
10486
|
+
return;
|
|
10487
|
+
if (e instanceof IneligibleUnconfirmedError) {
|
|
10488
|
+
io.err(`launchpad deploy: warning: could not confirm whether this app is registered, so it stays on Cloudflare Pages. It cannot move to Workers dispatch: ${e.message}`);
|
|
10489
|
+
return;
|
|
10490
|
+
}
|
|
10284
10491
|
if (!(e instanceof Error) || !isIneligible(e))
|
|
10285
10492
|
throw e;
|
|
10286
|
-
|
|
10493
|
+
throw new DispatchIneligibleError(describe17(e), fields.v2 === true);
|
|
10494
|
+
}
|
|
10495
|
+
}
|
|
10496
|
+
|
|
10497
|
+
class DispatchIneligibleError extends Error {
|
|
10498
|
+
constructor(reason, v2) {
|
|
10499
|
+
const origin = v2 ? "spec.origin: pages" : "origin: pages";
|
|
10500
|
+
super([
|
|
10501
|
+
`launchpad deploy: this new app cannot move to Workers dispatch, the default for new apps: ${reason}`,
|
|
10502
|
+
" Nothing was deployed. Pages is opt-in for new apps, and new Pages projects fail while the account is at its Pages limit.",
|
|
10503
|
+
` Fix that setting and run \`launchpad deploy\` again, or set \`${origin}\` in launchpad.yaml to choose Pages on purpose.`
|
|
10504
|
+
].join(`
|
|
10505
|
+
`));
|
|
10287
10506
|
}
|
|
10288
10507
|
}
|
|
10289
10508
|
var CONVERTIBLE_APP_TYPES = new Set(["static", "react", "react+api"]);
|
|
10290
|
-
function impliesPagesForGateway(
|
|
10291
|
-
const fields = originFields(manifestPath);
|
|
10509
|
+
function impliesPagesForGateway(fields) {
|
|
10292
10510
|
return CONVERTIBLE_APP_TYPES.has(fields.appType) && fields.origin === undefined && fields.auth === "gateway";
|
|
10293
10511
|
}
|
|
10294
10512
|
function originFields(manifestPath) {
|
|
@@ -10299,16 +10517,19 @@ function originFields(manifestPath) {
|
|
|
10299
10517
|
return {};
|
|
10300
10518
|
}
|
|
10301
10519
|
if (raw.apiVersion === "launchpad.m-kopa.us/v2")
|
|
10302
|
-
return raw.spec
|
|
10520
|
+
return { ...raw.spec, v2: true };
|
|
10303
10521
|
return { origin: raw.origin, auth: raw.auth, appType: raw.deployment?.type };
|
|
10304
10522
|
}
|
|
10305
|
-
function reportConversion(io, secrets) {
|
|
10523
|
+
function reportConversion(io, secrets, plainSecretLike) {
|
|
10306
10524
|
io.out("New apps deploy on Workers dispatch by default, so launchpad.yaml was converted (no Pages project needed).");
|
|
10307
10525
|
io.out(` Audience, owner and build settings are preserved. Original: ${BACKUP_PATH}`);
|
|
10308
10526
|
io.out(` To stay on Pages instead, restore ${BACKUP_PATH} as launchpad.yaml, set \`origin: pages\` (v1) or \`spec.origin: pages\` (v2) and deploy again.`);
|
|
10309
10527
|
const next = secretsNextStep(secrets);
|
|
10310
10528
|
if (next !== null)
|
|
10311
10529
|
io.out(` ${next}`);
|
|
10530
|
+
const warning = plainSecretWarning(plainSecretLike);
|
|
10531
|
+
if (warning !== null)
|
|
10532
|
+
io.err(` warning: ${warning}`);
|
|
10312
10533
|
}
|
|
10313
10534
|
function declaredOriginOf(isV22, origin) {
|
|
10314
10535
|
if (!isV22)
|