@m-kopa/launchpad-cli 0.65.0 → 0.67.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 +21 -0
- package/dist/bundle/upload.d.ts +4 -0
- package/dist/bundle/upload.d.ts.map +1 -1
- package/dist/cli.js +710 -137
- package/dist/commands/deploy.d.ts +15 -4
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/init.d.ts +2 -2
- 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/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 +43 -7
- package/skills/launchpad-deploy-status/SKILL.md +1 -1
- package/skills/launchpad-destroy/SKILL.md +1 -1
- package/skills/launchpad-identity/SKILL.md +135 -38
- 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.67.0";
|
|
23
23
|
|
|
24
24
|
// src/config.ts
|
|
25
25
|
import { readFileSync } from "node:fs";
|
|
@@ -2744,13 +2744,6 @@ var ManifestSchema = z2.object({
|
|
|
2744
2744
|
});
|
|
2745
2745
|
}
|
|
2746
2746
|
}
|
|
2747
|
-
if (isContainer && m.auth === "gateway") {
|
|
2748
|
-
ctx.addIssue({
|
|
2749
|
-
code: z2.ZodIssueCode.custom,
|
|
2750
|
-
path: ["auth"],
|
|
2751
|
-
message: "auth: gateway is only supported for pages-app shapes (static/react/react+api); container apps stay on Cloudflare Access (ADR 0016)."
|
|
2752
|
-
});
|
|
2753
|
-
}
|
|
2754
2747
|
if (isContainer && m.containers === undefined) {
|
|
2755
2748
|
ctx.addIssue({
|
|
2756
2749
|
code: z2.ZodIssueCode.custom,
|
|
@@ -3472,13 +3465,6 @@ var SpecSchema = z3.object({
|
|
|
3472
3465
|
message: "build is not allowed when appType is 'container' (container build lives in the Dockerfile)"
|
|
3473
3466
|
});
|
|
3474
3467
|
}
|
|
3475
|
-
if (isContainer && s.auth === "gateway") {
|
|
3476
|
-
ctx.addIssue({
|
|
3477
|
-
code: z3.ZodIssueCode.custom,
|
|
3478
|
-
path: ["auth"],
|
|
3479
|
-
message: "auth: gateway is only supported for pages-app shapes (static/react/react+api); container apps stay on Cloudflare Access (ADR 0016)."
|
|
3480
|
-
});
|
|
3481
|
-
}
|
|
3482
3468
|
if (!isContainer && s.fronted_by_concierge === true) {
|
|
3483
3469
|
ctx.addIssue({
|
|
3484
3470
|
code: z3.ZodIssueCode.custom,
|
|
@@ -3754,10 +3740,17 @@ function validateDeploymentCapability(manifest) {
|
|
|
3754
3740
|
className: containerClassName(view.appName),
|
|
3755
3741
|
bindingName,
|
|
3756
3742
|
dockerfilePathFromContainerDirectory: `../${container.image.slice(2)}`,
|
|
3757
|
-
environmentNames
|
|
3743
|
+
environmentNames,
|
|
3744
|
+
authMode: deploymentAuthMode(manifest)
|
|
3758
3745
|
}
|
|
3759
3746
|
};
|
|
3760
3747
|
}
|
|
3748
|
+
function deploymentAuthMode(manifest) {
|
|
3749
|
+
if (manifest.apiVersion === "launchpad.m-kopa.us/v2") {
|
|
3750
|
+
return manifest.spec.auth === "gateway" ? "gateway" : "access";
|
|
3751
|
+
}
|
|
3752
|
+
return manifest.auth === "gateway" ? "gateway" : "access";
|
|
3753
|
+
}
|
|
3761
3754
|
function containerClassName(containerName) {
|
|
3762
3755
|
return `AppContainer${containerName.split("-").map(capitalise).join("")}`;
|
|
3763
3756
|
}
|
|
@@ -3832,8 +3825,12 @@ function emit(capability) {
|
|
|
3832
3825
|
const app = JSON.stringify(capability.appName);
|
|
3833
3826
|
const className = capability.className;
|
|
3834
3827
|
const bindingName = capability.bindingName;
|
|
3828
|
+
const healthcheckPath = JSON.stringify(capability.container.healthcheck);
|
|
3829
|
+
const isGateway = capability.authMode === "gateway";
|
|
3835
3830
|
const environmentFields = capability.environmentNames.map((name) => ` ${name}: string;`);
|
|
3836
3831
|
const environmentValues = capability.environmentNames.map((name) => ` ${name}: this.env.${name} ?? "",`);
|
|
3832
|
+
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
|
+
const monitorEnvField = isGateway ? [" MONITOR_SHARED_SECRET: string;"] : [];
|
|
3837
3834
|
const lines = [
|
|
3838
3835
|
"/**",
|
|
3839
3836
|
" * Auto-generated by @m-kopa/launchpad-engine.",
|
|
@@ -3843,17 +3840,19 @@ function emit(capability) {
|
|
|
3843
3840
|
"import {",
|
|
3844
3841
|
" AccessJwtVerificationError,",
|
|
3845
3842
|
" createJwksCache,",
|
|
3846
|
-
" parseAccessJwtFromHeaders,",
|
|
3843
|
+
isGateway ? " parseGatewayAssertionFromHeaders," : " parseAccessJwtFromHeaders,",
|
|
3847
3844
|
" verifyAccessJwt,",
|
|
3845
|
+
...isGateway ? [] : [" verifyJwt,"],
|
|
3848
3846
|
" type User,",
|
|
3847
|
+
...isGateway ? [] : [" type VerifiedPrincipal,"],
|
|
3849
3848
|
'} from "@m-kopa/platform-auth";',
|
|
3850
3849
|
"",
|
|
3851
3850
|
"type Env = {",
|
|
3852
3851
|
` ${bindingName}: DurableObjectNamespace<${className}>;`,
|
|
3853
3852
|
" BINDINGS_PROXY_SECRET: string;",
|
|
3854
|
-
|
|
3855
|
-
" CF_ACCESS_TEAM_DOMAIN: string;",
|
|
3853
|
+
...envAuthFields,
|
|
3856
3854
|
" LAUNCHPAD_DEPLOYMENT_SHA: string;",
|
|
3855
|
+
...isGateway ? monitorEnvField : [" MONITOR_CLIENT_ID: string;"],
|
|
3857
3856
|
...environmentFields,
|
|
3858
3857
|
"};",
|
|
3859
3858
|
"",
|
|
@@ -3865,10 +3864,44 @@ function emit(capability) {
|
|
|
3865
3864
|
"",
|
|
3866
3865
|
"let jwksCache: ReturnType<typeof createJwksCache> | null = null;",
|
|
3867
3866
|
"",
|
|
3867
|
+
...isGateway ? [
|
|
3868
|
+
"/**",
|
|
3869
|
+
" * AIO-811 / ADR 0057 amendment 2: this Worker runs inside the chain",
|
|
3870
|
+
" * gateway -> router -> container Worker, so a live fetch of the",
|
|
3871
|
+
" * gateway's own JWKS URL is a subrequest back to the originating",
|
|
3872
|
+
" * gateway and Cloudflare loop protection can reject it. Try the live",
|
|
3873
|
+
" * fetch first; on a throw or non-2xx fall back to the deploy-time",
|
|
3874
|
+
" * snapshot (GATEWAY_JWKS_JSON). With no snapshot the original failure",
|
|
3875
|
+
" * is surfaced so verification still fails closed.",
|
|
3876
|
+
" */",
|
|
3877
|
+
"async function jwksFetch(",
|
|
3878
|
+
" env: Env,",
|
|
3879
|
+
" input: Parameters<typeof fetch>[0],",
|
|
3880
|
+
" init?: Parameters<typeof fetch>[1],",
|
|
3881
|
+
"): Promise<Response> {",
|
|
3882
|
+
" let failure: unknown;",
|
|
3883
|
+
" try {",
|
|
3884
|
+
" const live = await fetch(input, init);",
|
|
3885
|
+
" if (live.ok) return live;",
|
|
3886
|
+
" failure = live;",
|
|
3887
|
+
" } catch (error) {",
|
|
3888
|
+
" failure = error;",
|
|
3889
|
+
" }",
|
|
3890
|
+
' if (typeof env.GATEWAY_JWKS_JSON === "string" && env.GATEWAY_JWKS_JSON.length > 0) {',
|
|
3891
|
+
" return new Response(env.GATEWAY_JWKS_JSON, {",
|
|
3892
|
+
' headers: { "content-type": "application/json" },',
|
|
3893
|
+
" });",
|
|
3894
|
+
" }",
|
|
3895
|
+
" if (failure instanceof Response) return failure;",
|
|
3896
|
+
" throw failure;",
|
|
3897
|
+
"}",
|
|
3898
|
+
""
|
|
3899
|
+
] : [],
|
|
3868
3900
|
"function jwks(env: Env): ReturnType<typeof createJwksCache> {",
|
|
3869
3901
|
" if (jwksCache === null) {",
|
|
3870
3902
|
" jwksCache = createJwksCache(",
|
|
3871
|
-
" `https://${env.CF_ACCESS_TEAM_DOMAIN}/cdn-cgi/access/certs`,",
|
|
3903
|
+
isGateway ? " env.GATEWAY_JWKS_URL," : " `https://${env.CF_ACCESS_TEAM_DOMAIN}/cdn-cgi/access/certs`,",
|
|
3904
|
+
...isGateway ? [" { fetchFn: (input, init) => jwksFetch(env, input, init) },"] : [],
|
|
3872
3905
|
" );",
|
|
3873
3906
|
" }",
|
|
3874
3907
|
" return jwksCache;",
|
|
@@ -3896,29 +3929,59 @@ function emit(capability) {
|
|
|
3896
3929
|
" return difference === 0;",
|
|
3897
3930
|
"}",
|
|
3898
3931
|
"",
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
"
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
"
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
"
|
|
3921
|
-
|
|
3932
|
+
...isGateway ? [
|
|
3933
|
+
"async function authenticate(request: Request, env: Env): Promise<User | Response> {",
|
|
3934
|
+
" if (!env.GATEWAY_ISSUER || !env.GATEWAY_AUD || !env.GATEWAY_JWKS_URL) {",
|
|
3935
|
+
' return unauthenticated("auth_unconfigured");',
|
|
3936
|
+
" }",
|
|
3937
|
+
" const token = parseGatewayAssertionFromHeaders(request.headers);",
|
|
3938
|
+
" if (token === null) {",
|
|
3939
|
+
' return unauthenticated("gateway_assertion_missing");',
|
|
3940
|
+
" }",
|
|
3941
|
+
" try {",
|
|
3942
|
+
" // verifyAccessJwt is a generic RS256-against-issuer/audience/JWKS",
|
|
3943
|
+
" // check; a gateway-fronted container verifies the Entra-OIDC",
|
|
3944
|
+
" // gateway's assertion (ADR 0057) with the SAME verifier used for",
|
|
3945
|
+
" // Cf Access JWTs, against the GATEWAY_* values instead.",
|
|
3946
|
+
" return await verifyAccessJwt(token, {",
|
|
3947
|
+
" teamDomain: env.GATEWAY_ISSUER,",
|
|
3948
|
+
" audience: env.GATEWAY_AUD,",
|
|
3949
|
+
" jwks: jwks(env),",
|
|
3950
|
+
" clockTolerance: 30,",
|
|
3951
|
+
" });",
|
|
3952
|
+
" } catch (error) {",
|
|
3953
|
+
" if (error instanceof AccessJwtVerificationError) {",
|
|
3954
|
+
" return unauthenticated(error.code);",
|
|
3955
|
+
" }",
|
|
3956
|
+
' console.error(JSON.stringify({ event: "container_runtime_error", kind: "gateway_assertion_verification_failed" }));',
|
|
3957
|
+
' return unauthenticated("gateway_assertion_verification_failed");',
|
|
3958
|
+
" }",
|
|
3959
|
+
"}"
|
|
3960
|
+
] : [
|
|
3961
|
+
"async function authenticate(request: Request, env: Env): Promise<User | Response> {",
|
|
3962
|
+
" if (!env.CF_ACCESS_TEAM_DOMAIN || !env.CF_ACCESS_AUD) {",
|
|
3963
|
+
' return unauthenticated("auth_unconfigured");',
|
|
3964
|
+
" }",
|
|
3965
|
+
" const token = parseAccessJwtFromHeaders(request.headers);",
|
|
3966
|
+
" if (token === null) {",
|
|
3967
|
+
' return unauthenticated("access_jwt_missing");',
|
|
3968
|
+
" }",
|
|
3969
|
+
" try {",
|
|
3970
|
+
" return await verifyAccessJwt(token, {",
|
|
3971
|
+
" teamDomain: `https://${env.CF_ACCESS_TEAM_DOMAIN}`,",
|
|
3972
|
+
" audience: env.CF_ACCESS_AUD,",
|
|
3973
|
+
" jwks: jwks(env),",
|
|
3974
|
+
" clockTolerance: 30,",
|
|
3975
|
+
" });",
|
|
3976
|
+
" } catch (error) {",
|
|
3977
|
+
" if (error instanceof AccessJwtVerificationError) {",
|
|
3978
|
+
" return unauthenticated(error.code);",
|
|
3979
|
+
" }",
|
|
3980
|
+
' console.error(JSON.stringify({ event: "container_runtime_error", kind: "access_jwt_verification_failed" }));',
|
|
3981
|
+
' return unauthenticated("access_jwt_verification_failed");',
|
|
3982
|
+
" }",
|
|
3983
|
+
"}"
|
|
3984
|
+
],
|
|
3922
3985
|
"",
|
|
3923
3986
|
"function forwardedRequest(",
|
|
3924
3987
|
" request: Request,",
|
|
@@ -3955,6 +4018,173 @@ function emit(capability) {
|
|
|
3955
4018
|
" });",
|
|
3956
4019
|
"}",
|
|
3957
4020
|
"",
|
|
4021
|
+
"/**",
|
|
4022
|
+
" * Build the machine-only health-probe request dispatched to the",
|
|
4023
|
+
" * container DO. Deliberately NOT `forwardedRequest`: it carries no",
|
|
4024
|
+
" * inbound header (no auth, no user identity, no bindings-proxy",
|
|
4025
|
+
" * secret/url) and targets the manifest-declared healthcheck path,",
|
|
4026
|
+
" * never the Worker's own reserved `GET /health` liveness route.",
|
|
4027
|
+
" */",
|
|
4028
|
+
"function buildHealthDispatchRequest(",
|
|
4029
|
+
" origin: string,",
|
|
4030
|
+
" requestId: string,",
|
|
4031
|
+
"): Request {",
|
|
4032
|
+
" const headers = new Headers();",
|
|
4033
|
+
' headers.set("X-Request-ID", requestId);',
|
|
4034
|
+
` return new Request(origin + ${healthcheckPath}, {`,
|
|
4035
|
+
' method: "GET",',
|
|
4036
|
+
" headers,",
|
|
4037
|
+
' redirect: "manual",',
|
|
4038
|
+
" });",
|
|
4039
|
+
"}",
|
|
4040
|
+
"",
|
|
4041
|
+
"function healthDenied(code: string): Response {",
|
|
4042
|
+
" return Response.json(",
|
|
4043
|
+
' { error: "health_unavailable", code },',
|
|
4044
|
+
' { status: 404, headers: { "cache-control": "no-store" } },',
|
|
4045
|
+
" );",
|
|
4046
|
+
"}",
|
|
4047
|
+
"",
|
|
4048
|
+
...isGateway ? [
|
|
4049
|
+
"/**",
|
|
4050
|
+
" * `GET /__platform/health/container` — AIO-269 T8. A gateway-",
|
|
4051
|
+
" * fronted app has no Access app and no public hostname (ADR",
|
|
4052
|
+
" * 0057), so there is no Access service-token surface for the",
|
|
4053
|
+
" * monitor to present a credential to. Instead this trusts a",
|
|
4054
|
+
" * shared secret (`MONITOR_SHARED_SECRET`) carried in",
|
|
4055
|
+
" * `X-Launchpad-Monitor-Secret` — safe ONLY because this Worker",
|
|
4056
|
+
" * is reachable exclusively via launchpad-container-router's",
|
|
4057
|
+
" * per-app service binding (never a public hostname), and the",
|
|
4058
|
+
" * monitor is the only caller with a binding to that router.",
|
|
4059
|
+
" * Missing configuration, a missing header, and a mismatched",
|
|
4060
|
+
" * secret all fail closed with no container fetch, same as the",
|
|
4061
|
+
" * Access-mode path below. The container's response body is",
|
|
4062
|
+
" * never forwarded; the reply is a fixed, redacted, `no-store`",
|
|
4063
|
+
" * JSON body.",
|
|
4064
|
+
" */",
|
|
4065
|
+
"async function handleContainerHealth(",
|
|
4066
|
+
" request: Request,",
|
|
4067
|
+
" env: Env,",
|
|
4068
|
+
" requestId: string,",
|
|
4069
|
+
"): Promise<Response> {",
|
|
4070
|
+
' if (request.method !== "GET") {',
|
|
4071
|
+
' return healthDenied("method_not_allowed");',
|
|
4072
|
+
" }",
|
|
4073
|
+
" if (!env.MONITOR_SHARED_SECRET) {",
|
|
4074
|
+
' return healthDenied("monitor_unconfigured");',
|
|
4075
|
+
" }",
|
|
4076
|
+
' const presented = request.headers.get("x-launchpad-monitor-secret");',
|
|
4077
|
+
" if (!presented || !(await secretsEqual(presented, env.MONITOR_SHARED_SECRET))) {",
|
|
4078
|
+
' return healthDenied("monitor_secret_mismatch");',
|
|
4079
|
+
" }",
|
|
4080
|
+
" const url = new URL(request.url);",
|
|
4081
|
+
" const dispatchRequest = buildHealthDispatchRequest(url.origin, requestId);",
|
|
4082
|
+
" const start = Date.now();",
|
|
4083
|
+
" let containerResponse: Response;",
|
|
4084
|
+
" try {",
|
|
4085
|
+
` const id = env.${bindingName}.idFromName("singleton");`,
|
|
4086
|
+
` containerResponse = await env.${bindingName}.get(id).fetch(dispatchRequest);`,
|
|
4087
|
+
" } catch {",
|
|
4088
|
+
" return Response.json(",
|
|
4089
|
+
" {",
|
|
4090
|
+
' outcome: "error",',
|
|
4091
|
+
" workload_status: null,",
|
|
4092
|
+
" deployment_sha: env.LAUNCHPAD_DEPLOYMENT_SHA,",
|
|
4093
|
+
" request_id: requestId,",
|
|
4094
|
+
" duration_ms: Math.min(Date.now() - start, 30_000),",
|
|
4095
|
+
" },",
|
|
4096
|
+
' { status: 200, headers: { "cache-control": "no-store" } },',
|
|
4097
|
+
" );",
|
|
4098
|
+
" }",
|
|
4099
|
+
" return Response.json(",
|
|
4100
|
+
" {",
|
|
4101
|
+
' outcome: containerResponse.ok ? "healthy" : "unhealthy",',
|
|
4102
|
+
" workload_status: containerResponse.status,",
|
|
4103
|
+
" deployment_sha: env.LAUNCHPAD_DEPLOYMENT_SHA,",
|
|
4104
|
+
" request_id: requestId,",
|
|
4105
|
+
" duration_ms: Math.min(Date.now() - start, 30_000),",
|
|
4106
|
+
" },",
|
|
4107
|
+
' { status: 200, headers: { "cache-control": "no-store" } },',
|
|
4108
|
+
" );",
|
|
4109
|
+
"}"
|
|
4110
|
+
] : [
|
|
4111
|
+
"/**",
|
|
4112
|
+
" * `GET /__platform/health/container` — machine-only. Gated on",
|
|
4113
|
+
" * `verifyJwt` returning a service principal whose `commonName`",
|
|
4114
|
+
" * matches the configured monitor client ID. Anonymous callers,",
|
|
4115
|
+
" * human JWTs, wrong service principals, non-GET methods, and a",
|
|
4116
|
+
" * missing monitor-client-ID configuration all fail closed with no",
|
|
4117
|
+
" * container fetch. The container's response body is never",
|
|
4118
|
+
" * forwarded; the reply is a fixed, redacted, `no-store` JSON body.",
|
|
4119
|
+
" */",
|
|
4120
|
+
"async function handleContainerHealth(",
|
|
4121
|
+
" request: Request,",
|
|
4122
|
+
" env: Env,",
|
|
4123
|
+
" requestId: string,",
|
|
4124
|
+
"): Promise<Response> {",
|
|
4125
|
+
' if (request.method !== "GET") {',
|
|
4126
|
+
' return healthDenied("method_not_allowed");',
|
|
4127
|
+
" }",
|
|
4128
|
+
" if (!env.MONITOR_CLIENT_ID || !env.CF_ACCESS_TEAM_DOMAIN || !env.CF_ACCESS_AUD) {",
|
|
4129
|
+
' return healthDenied("monitor_unconfigured");',
|
|
4130
|
+
" }",
|
|
4131
|
+
" const token = parseAccessJwtFromHeaders(request.headers);",
|
|
4132
|
+
" if (token === null) {",
|
|
4133
|
+
' return healthDenied("access_jwt_missing");',
|
|
4134
|
+
" }",
|
|
4135
|
+
" let principal: VerifiedPrincipal;",
|
|
4136
|
+
" try {",
|
|
4137
|
+
" principal = await verifyJwt(token, {",
|
|
4138
|
+
" teamDomain: `https://${env.CF_ACCESS_TEAM_DOMAIN}`,",
|
|
4139
|
+
" audience: env.CF_ACCESS_AUD,",
|
|
4140
|
+
" jwks: jwks(env),",
|
|
4141
|
+
" clockTolerance: 30,",
|
|
4142
|
+
" });",
|
|
4143
|
+
" } catch (error) {",
|
|
4144
|
+
" if (error instanceof AccessJwtVerificationError) {",
|
|
4145
|
+
" return healthDenied(error.code);",
|
|
4146
|
+
" }",
|
|
4147
|
+
' console.error(JSON.stringify({ event: "container_runtime_error", kind: "monitor_jwt_verification_failed" }));',
|
|
4148
|
+
' return healthDenied("monitor_jwt_verification_failed");',
|
|
4149
|
+
" }",
|
|
4150
|
+
' if (principal.kind !== "service") {',
|
|
4151
|
+
' return healthDenied("human_identity_not_allowed");',
|
|
4152
|
+
" }",
|
|
4153
|
+
" if (principal.principal.commonName !== env.MONITOR_CLIENT_ID) {",
|
|
4154
|
+
' return healthDenied("monitor_identity_mismatch");',
|
|
4155
|
+
" }",
|
|
4156
|
+
" const url = new URL(request.url);",
|
|
4157
|
+
" const dispatchRequest = buildHealthDispatchRequest(url.origin, requestId);",
|
|
4158
|
+
" const start = Date.now();",
|
|
4159
|
+
" let containerResponse: Response;",
|
|
4160
|
+
" try {",
|
|
4161
|
+
` const id = env.${bindingName}.idFromName("singleton");`,
|
|
4162
|
+
` containerResponse = await env.${bindingName}.get(id).fetch(dispatchRequest);`,
|
|
4163
|
+
" } catch {",
|
|
4164
|
+
" return Response.json(",
|
|
4165
|
+
" {",
|
|
4166
|
+
' outcome: "error",',
|
|
4167
|
+
" workload_status: null,",
|
|
4168
|
+
" deployment_sha: env.LAUNCHPAD_DEPLOYMENT_SHA,",
|
|
4169
|
+
" request_id: requestId,",
|
|
4170
|
+
" duration_ms: Math.min(Date.now() - start, 30_000),",
|
|
4171
|
+
" },",
|
|
4172
|
+
' { status: 200, headers: { "cache-control": "no-store" } },',
|
|
4173
|
+
" );",
|
|
4174
|
+
" }",
|
|
4175
|
+
" return Response.json(",
|
|
4176
|
+
" {",
|
|
4177
|
+
' outcome: containerResponse.ok ? "healthy" : "unhealthy",',
|
|
4178
|
+
" workload_status: containerResponse.status,",
|
|
4179
|
+
" deployment_sha: env.LAUNCHPAD_DEPLOYMENT_SHA,",
|
|
4180
|
+
" request_id: requestId,",
|
|
4181
|
+
" duration_ms: Math.min(Date.now() - start, 30_000),",
|
|
4182
|
+
" },",
|
|
4183
|
+
' { status: 200, headers: { "cache-control": "no-store" } },',
|
|
4184
|
+
" );",
|
|
4185
|
+
"}"
|
|
4186
|
+
],
|
|
4187
|
+
"",
|
|
3958
4188
|
"function runtimeEvent(",
|
|
3959
4189
|
" env: Env,",
|
|
3960
4190
|
" requestId: string,",
|
|
@@ -3993,6 +4223,11 @@ function emit(capability) {
|
|
|
3993
4223
|
' runtimeEvent(env, requestId, response.status, "bindings_unknown");',
|
|
3994
4224
|
" return response;",
|
|
3995
4225
|
" }",
|
|
4226
|
+
' if (url.pathname === "/__platform/health/container") {',
|
|
4227
|
+
" const response = await handleContainerHealth(request, env, requestId);",
|
|
4228
|
+
' runtimeEvent(env, requestId, response.status, "container_health_probe");',
|
|
4229
|
+
" return response;",
|
|
4230
|
+
" }",
|
|
3996
4231
|
" const identity = await authenticate(request, env);",
|
|
3997
4232
|
" if (identity instanceof Response) {",
|
|
3998
4233
|
' runtimeEvent(env, requestId, identity.status, "authentication_failed");',
|
|
@@ -4033,6 +4268,8 @@ function generateWranglerToml(manifest) {
|
|
|
4033
4268
|
}
|
|
4034
4269
|
function emit2(capability) {
|
|
4035
4270
|
const maxInstances = capability.container.max_instances ?? 1;
|
|
4271
|
+
const isGateway = capability.authMode === "gateway";
|
|
4272
|
+
const authVars = isGateway ? ['GATEWAY_ISSUER = ""', 'GATEWAY_AUD = ""', 'GATEWAY_JWKS_URL = ""'] : ['CF_ACCESS_AUD = ""', 'CF_ACCESS_TEAM_DOMAIN = ""'];
|
|
4036
4273
|
return [
|
|
4037
4274
|
"# Auto-generated by @m-kopa/launchpad-engine. Do not edit by hand.",
|
|
4038
4275
|
`# Source: launchpad.yaml (apiVersion: ${capability.apiVersion})`,
|
|
@@ -4042,14 +4279,14 @@ function emit2(capability) {
|
|
|
4042
4279
|
'main = "worker/index.ts"',
|
|
4043
4280
|
`compatibility_date = "${DEFAULT_COMPATIBILITY_DATE}"`,
|
|
4044
4281
|
`compatibility_flags = [${DEFAULT_COMPATIBILITY_FLAGS.map((flag) => `"${flag}"`).join(", ")}]`,
|
|
4282
|
+
...isGateway ? ["workers_dev = false"] : [],
|
|
4045
4283
|
"",
|
|
4046
4284
|
"[observability]",
|
|
4047
4285
|
"enabled = true",
|
|
4048
4286
|
"head_sampling_rate = 1.0",
|
|
4049
4287
|
"",
|
|
4050
4288
|
"[vars]",
|
|
4051
|
-
|
|
4052
|
-
'CF_ACCESS_TEAM_DOMAIN = ""',
|
|
4289
|
+
...authVars,
|
|
4053
4290
|
'LAUNCHPAD_DEPLOYMENT_SHA = ""',
|
|
4054
4291
|
"",
|
|
4055
4292
|
"[[containers]]",
|
|
@@ -4093,6 +4330,10 @@ function generateGithubDeployWorkflow(manifest) {
|
|
|
4093
4330
|
return { kind: "ok", content: emit3(result.capability), warnings: [] };
|
|
4094
4331
|
}
|
|
4095
4332
|
function emit3(capability) {
|
|
4333
|
+
const isGateway = capability.authMode === "gateway";
|
|
4334
|
+
const authVarNames = isGateway ? ["GATEWAY_ISSUER", "GATEWAY_AUD", "GATEWAY_JWKS_URL"] : ["CF_ACCESS_AUD", "CF_ACCESS_TEAM_DOMAIN"];
|
|
4335
|
+
const authVarEnvLines = authVarNames.map((name) => ` ${name}: \${{ vars.${name} }}`);
|
|
4336
|
+
const authVarWranglerFlags = authVarNames.map((name) => ` --var "${name}:\${${name}}" \\`);
|
|
4096
4337
|
const lines = [
|
|
4097
4338
|
"# Auto-generated by @m-kopa/launchpad-engine. Do not edit by hand.",
|
|
4098
4339
|
`# Source: launchpad.yaml (apiVersion: ${capability.apiVersion})`,
|
|
@@ -4181,29 +4422,22 @@ function emit3(capability) {
|
|
|
4181
4422
|
" cache: npm",
|
|
4182
4423
|
" cache-dependency-path: |",
|
|
4183
4424
|
" container/package-lock.json",
|
|
4184
|
-
" container/backend/package-lock.json",
|
|
4185
4425
|
"",
|
|
4186
4426
|
" - name: Install frozen Worker dependencies",
|
|
4187
4427
|
" working-directory: container",
|
|
4188
4428
|
" run: npm ci --ignore-scripts",
|
|
4189
4429
|
"",
|
|
4190
|
-
" - name: Install frozen workload dependencies",
|
|
4191
|
-
" working-directory: container/backend",
|
|
4192
|
-
" run: npm ci --ignore-scripts",
|
|
4193
|
-
"",
|
|
4194
4430
|
" - name: Verify required deployment inputs",
|
|
4195
4431
|
" env:",
|
|
4196
4432
|
" CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}",
|
|
4197
4433
|
" CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}",
|
|
4198
|
-
|
|
4199
|
-
" CF_ACCESS_TEAM_DOMAIN: ${{ vars.CF_ACCESS_TEAM_DOMAIN }}",
|
|
4434
|
+
...authVarEnvLines,
|
|
4200
4435
|
" BINDINGS_PROXY_SECRET: ${{ secrets.BINDINGS_PROXY_SECRET }}",
|
|
4201
|
-
"
|
|
4202
|
-
" CF_ACCESS_TEAM_DOMAIN: ${{ vars.CF_ACCESS_TEAM_DOMAIN }}",
|
|
4436
|
+
...isGateway ? [" MONITOR_SHARED_SECRET: ${{ secrets.MONITOR_SHARED_SECRET }}"] : [],
|
|
4203
4437
|
...capability.environmentNames.map((name) => ` ${name}: \${{ secrets.${name} }}`),
|
|
4204
4438
|
" run: |",
|
|
4205
4439
|
" set -euo pipefail",
|
|
4206
|
-
|
|
4440
|
+
` for name in CLOUDFLARE_API_TOKEN CLOUDFLARE_ACCOUNT_ID BINDINGS_PROXY_SECRET${isGateway ? " MONITOR_SHARED_SECRET" : ""} ${authVarNames.join(" ")}; do`,
|
|
4207
4441
|
' if [ -z "${!name:-}" ]; then',
|
|
4208
4442
|
' echo "Required deployment input $name is empty" >&2',
|
|
4209
4443
|
" exit 1",
|
|
@@ -4216,37 +4450,213 @@ function emit3(capability) {
|
|
|
4216
4450
|
" fi"
|
|
4217
4451
|
]),
|
|
4218
4452
|
"",
|
|
4219
|
-
" - name: Deploy Worker
|
|
4453
|
+
" - name: Deploy Worker, container image and secrets",
|
|
4220
4454
|
" working-directory: container",
|
|
4221
4455
|
" env:",
|
|
4222
4456
|
" CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}",
|
|
4223
4457
|
" CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}",
|
|
4458
|
+
...authVarEnvLines,
|
|
4459
|
+
...secretNames(capability).map((name) => ` ${name}: \${{ secrets.${name} }}`),
|
|
4224
4460
|
" run: |",
|
|
4461
|
+
" set -euo pipefail",
|
|
4462
|
+
...isGateway ? [
|
|
4463
|
+
' GATEWAY_JWKS_JSON="$(curl -fsS --max-time 20 "$GATEWAY_JWKS_URL")"',
|
|
4464
|
+
` printf '%s' "$GATEWAY_JWKS_JSON" | jq -e '.keys | length > 0' > /dev/null`,
|
|
4465
|
+
" export GATEWAY_JWKS_JSON"
|
|
4466
|
+
] : [],
|
|
4467
|
+
' secrets_file="$(mktemp "${RUNNER_TEMP}/launchpad-secrets.XXXXXX")"',
|
|
4468
|
+
` trap 'rm -f "$secrets_file"' EXIT`,
|
|
4469
|
+
` jq -n '${secretsJqFilter(capability)}' > "$secrets_file"`,
|
|
4225
4470
|
" npx --no-install wrangler deploy \\",
|
|
4226
4471
|
' --message "launchpad:${GITHUB_SHA}" \\',
|
|
4227
4472
|
' --tag "launchpad-deployment-sha:${GITHUB_SHA}" \\',
|
|
4228
|
-
|
|
4229
|
-
' --var "
|
|
4230
|
-
' --
|
|
4231
|
-
""
|
|
4232
|
-
...secretSteps(capability)
|
|
4473
|
+
...authVarWranglerFlags,
|
|
4474
|
+
' --var "LAUNCHPAD_DEPLOYMENT_SHA:${GITHUB_SHA}" \\',
|
|
4475
|
+
' --secrets-file "$secrets_file"',
|
|
4476
|
+
""
|
|
4233
4477
|
];
|
|
4234
4478
|
return lines.join(`
|
|
4235
4479
|
`);
|
|
4236
4480
|
}
|
|
4237
|
-
function
|
|
4238
|
-
return ["BINDINGS_PROXY_SECRET", ...capability.environmentNames]
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4481
|
+
function secretNames(capability) {
|
|
4482
|
+
return capability.authMode === "gateway" ? ["BINDINGS_PROXY_SECRET", "MONITOR_SHARED_SECRET", ...capability.environmentNames] : ["BINDINGS_PROXY_SECRET", ...capability.environmentNames];
|
|
4483
|
+
}
|
|
4484
|
+
function secretsJqFilter(capability) {
|
|
4485
|
+
const names = capability.authMode === "gateway" ? [...secretNames(capability), "GATEWAY_JWKS_JSON"] : secretNames(capability);
|
|
4486
|
+
return `{${names.map((name) => `${name}: env.${name}`).join(", ")}}`;
|
|
4487
|
+
}
|
|
4488
|
+
// ../launchpad-engine/dist/per-app-lock.js
|
|
4489
|
+
var PER_APP_LOCK_HCL = `# This file is maintained automatically by "terraform init".
|
|
4490
|
+
# Manual edits may be lost in future updates.
|
|
4491
|
+
|
|
4492
|
+
provider "registry.terraform.io/cloudflare/cloudflare" {
|
|
4493
|
+
version = "5.19.1"
|
|
4494
|
+
constraints = "~> 5.19"
|
|
4495
|
+
hashes = [
|
|
4496
|
+
"h1:HkKPMZ/n+QiExkRUSLjGMTGnuIaph+k932LiTp7CKZM=",
|
|
4497
|
+
"h1:mopYISyLkUVUwMjJbuPenxIUVDrna1/7ACB1hfMfciU=",
|
|
4498
|
+
"zh:0651618000db705564dab5a25322b9d76ea54b7dd78931ed3565497b559babeb",
|
|
4499
|
+
"zh:1a7847e9479fb6d21a65ef933ffae1416b1e4b44ca940c0d6c50fc4248cc4a0d",
|
|
4500
|
+
"zh:5597cee5854131045eb9f201ae3a70b59c51955d31a647d9616863c746d902cb",
|
|
4501
|
+
"zh:580786830d93e35b957754fd4c62d4681a3b19abc28b757e41acba26455663b1",
|
|
4502
|
+
"zh:83c4bdfb0e74fd50e56fff3c461d76c1c1ec61af3f679e4de1aa70b5ed05a09f",
|
|
4503
|
+
"zh:abb4d1052cee61d80f9cb51e5421e3c118312403afb7104b98bd7e310ac736ee",
|
|
4504
|
+
"zh:b0aeeb3d66ea4d719989875e778c477065ba941e3a76e9a8caacc3be08208dd9",
|
|
4505
|
+
"zh:e43b4b2dfcec1ce2115f5a5c86042d432deb49bee8eae103eb56d97ea02e2e3b",
|
|
4506
|
+
"zh:f809ab383cca0a5f83072981c64208cbd7fa67e986a86ee02dd2c82333221e32",
|
|
4507
|
+
]
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4510
|
+
provider "registry.terraform.io/hashicorp/azurerm" {
|
|
4511
|
+
version = "4.76.0"
|
|
4512
|
+
constraints = "~> 4.0"
|
|
4513
|
+
hashes = [
|
|
4514
|
+
"h1:4VD01UBYjsa3w7zeEBKnDtwClwpsPw6Dk+V9evhiKqU=",
|
|
4515
|
+
"h1:bOzo55MQgsvQ+KRwrWM5q+waapuMZ3AGIkK5ZIOe+JU=",
|
|
4516
|
+
"zh:07bb3a087abca8bd14cc28e3d3d4abb71e0ed711ecec65e7c0a2f1a97b948cf4",
|
|
4517
|
+
"zh:0fa6640b5d6c0b0fe0b7fa25cebc0091b7dda2efd83ec0347c5a50dfce0957bc",
|
|
4518
|
+
"zh:3c8618c8a5ab07fadfcb53ecf614f7b99e25bb6c407cf0af703a6b0647d4461d",
|
|
4519
|
+
"zh:5f23fdda6ff290bc99b25b68f612bf67fbb503b04b1e38664e66d3204a51e99e",
|
|
4520
|
+
"zh:68e6794cbe5e3b021657035c2465767b8296beed6c9acc8a9e032c4b90ba5746",
|
|
4521
|
+
"zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
|
|
4522
|
+
"zh:8a51dad112248d3fdfb19cdd65a182bd6a37e7fb7f1af801ab72a962813b5188",
|
|
4523
|
+
"zh:945ff59c36de8c2128487f4ae0838655feef7c869112430ffa24ea69ff483b76",
|
|
4524
|
+
"zh:b7306af0ecc8ad78771c17e0e911dd7a561251e4255ffe80516f0654a53f42bb",
|
|
4525
|
+
"zh:c584de4858fc4ece330f1986f371acd235a5444e9b14ecea177779b1214539e0",
|
|
4526
|
+
"zh:daa3675af21f8cdf330532af0b420287388f62ac57eaf0bd4c48e732d1052f35",
|
|
4527
|
+
"zh:e76d972712b48a689f8deae41a3ad796c31d8b3798074d66c6f68e2b3b0aaa1f",
|
|
4528
|
+
]
|
|
4249
4529
|
}
|
|
4530
|
+
|
|
4531
|
+
provider "registry.terraform.io/hashicorp/time" {
|
|
4532
|
+
version = "0.14.0"
|
|
4533
|
+
constraints = "~> 0.13"
|
|
4534
|
+
hashes = [
|
|
4535
|
+
"h1:/hlxsUpuN/lvPTNL9+NyVGsOyRsK5NsxwFMsj5CdOp4=",
|
|
4536
|
+
"h1:4EThC3ocCFiFPMZQSUvSGSxoJqBcGWxMcFYmL67uS7Y=",
|
|
4537
|
+
"zh:12abfd6b800e4d7fa6db7310dec8ffd440b31993861ef188c7ed5260b3073937",
|
|
4538
|
+
"zh:23005521e800bb19e1597bf755c5f70d675d30b685d4255001ed5fa47d9df3f1",
|
|
4539
|
+
"zh:2fea249b582ae97cd1cc10385187ea50993bb47c28cc5df0305e57ceaabf0a10",
|
|
4540
|
+
"zh:322018d3b987b7aad08697178029a2bb667bed699e88328f0c89c52a2fd41341",
|
|
4541
|
+
"zh:32a08e98fce2d273cb9b2c89d6c54727cc9f0a32e15bfd896be4e02cc6b48f95",
|
|
4542
|
+
"zh:3db89aabd0e619616bd4b0f8b373a7586dfe60feffcea12a84a0bdbc445714b3",
|
|
4543
|
+
"zh:7488f56c81d742dc020f29063626c8f07ca188aa97be61e7307e8d62397020a2",
|
|
4544
|
+
"zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
|
|
4545
|
+
"zh:7cb4067f2e7559b13f7562ef722f948950901eb37834873e98360ab28f66e9d7",
|
|
4546
|
+
"zh:9d552c8345f61e1b7db8e725144981345f18ac1014d58d6f5ddf0928a195fffb",
|
|
4547
|
+
"zh:a8e69fb6b97fc9d86fb19a9f4d42abe33c4a68e700b15387ce2e17d2b9934bed",
|
|
4548
|
+
"zh:aeeb900eb8dd0f790c60ea5c0e0c8d42bd6e4a54f391681d4decca15b544394b",
|
|
4549
|
+
"zh:c239c619101a8c95e1f14061eb973c57a8d15fa0e68878ced5bbd76858ee5b79",
|
|
4550
|
+
]
|
|
4551
|
+
}
|
|
4552
|
+
`;
|
|
4553
|
+
|
|
4554
|
+
// ../launchpad-engine/dist/per-app-container-lock.js
|
|
4555
|
+
var PER_APP_CONTAINER_LOCK_HCL = `# This file is maintained automatically by "terraform init".
|
|
4556
|
+
# Manual edits may be lost in future updates.
|
|
4557
|
+
|
|
4558
|
+
provider "registry.terraform.io/cloudflare/cloudflare" {
|
|
4559
|
+
version = "5.19.1"
|
|
4560
|
+
constraints = "~> 5.19"
|
|
4561
|
+
hashes = [
|
|
4562
|
+
"h1:HkKPMZ/n+QiExkRUSLjGMTGnuIaph+k932LiTp7CKZM=",
|
|
4563
|
+
"h1:mopYISyLkUVUwMjJbuPenxIUVDrna1/7ACB1hfMfciU=",
|
|
4564
|
+
"zh:0651618000db705564dab5a25322b9d76ea54b7dd78931ed3565497b559babeb",
|
|
4565
|
+
"zh:1a7847e9479fb6d21a65ef933ffae1416b1e4b44ca940c0d6c50fc4248cc4a0d",
|
|
4566
|
+
"zh:5597cee5854131045eb9f201ae3a70b59c51955d31a647d9616863c746d902cb",
|
|
4567
|
+
"zh:580786830d93e35b957754fd4c62d4681a3b19abc28b757e41acba26455663b1",
|
|
4568
|
+
"zh:83c4bdfb0e74fd50e56fff3c461d76c1c1ec61af3f679e4de1aa70b5ed05a09f",
|
|
4569
|
+
"zh:abb4d1052cee61d80f9cb51e5421e3c118312403afb7104b98bd7e310ac736ee",
|
|
4570
|
+
"zh:b0aeeb3d66ea4d719989875e778c477065ba941e3a76e9a8caacc3be08208dd9",
|
|
4571
|
+
"zh:e43b4b2dfcec1ce2115f5a5c86042d432deb49bee8eae103eb56d97ea02e2e3b",
|
|
4572
|
+
"zh:f809ab383cca0a5f83072981c64208cbd7fa67e986a86ee02dd2c82333221e32",
|
|
4573
|
+
]
|
|
4574
|
+
}
|
|
4575
|
+
|
|
4576
|
+
provider "registry.terraform.io/hashicorp/random" {
|
|
4577
|
+
version = "3.9.0"
|
|
4578
|
+
constraints = "~> 3.6"
|
|
4579
|
+
hashes = [
|
|
4580
|
+
"h1:OO+IuvQJSPmWdN8AyyIEvPJbLvDQpgX/zbktoa9KsJE=",
|
|
4581
|
+
"h1:UlBuNVuCGJ39tTv2c5gz2NRZnQbXfbIWbTzWcth5o74=",
|
|
4582
|
+
"zh:161ad0bd9a75768c82f53fb6e7172a9d8be2d4889b012645a34795031aaf1bf1",
|
|
4583
|
+
"zh:19dc9a5b17729725ccfc4f45b0500af0ee5bc6b6b160c7adb8f2bf617d2c80ea",
|
|
4584
|
+
"zh:269eda8fe42daa7974d5a34d166c3ba9defe80cde86c01e4dadcfdf2e1f05e5f",
|
|
4585
|
+
"zh:373f7c65566f8f2cc7f45d698654feb9d988996957e1266a69ca00c52d6d16d0",
|
|
4586
|
+
"zh:5599d16804c41c83009ec621b6d6b6f74e102f5827678a4750f8809055546b61",
|
|
4587
|
+
"zh:583be0440469a22bff70dcfa56593b01566860b29607437264adb51060cf46fc",
|
|
4588
|
+
"zh:5f211d8ec3f2e1f414870d9584bfe26e6995560ef81c748f8447a48164767398",
|
|
4589
|
+
"zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
|
|
4590
|
+
"zh:7b547fd16216761ef86efc3ed516ac5ac0c5c42b7c7eb24a08cef2d93f69ed5e",
|
|
4591
|
+
"zh:7e7c0679daf2a382151d05068c8c3f0dae6b7b7dccf818827b73dd08638df2ef",
|
|
4592
|
+
"zh:8089dec888a8038b9b4fb23b3df7e1057293dbc5b60b42cc47ff690d69d4b61b",
|
|
4593
|
+
"zh:c51f15a031edfd6f23ce8ced3446ca7f8d8d647e2499890d7d5d10d5016d7257",
|
|
4594
|
+
"zh:c94784f005708890dc6895afd53636ec00ec1e430b15d41e5aebfb1d4b39bd04",
|
|
4595
|
+
]
|
|
4596
|
+
}
|
|
4597
|
+
|
|
4598
|
+
provider "registry.terraform.io/hashicorp/time" {
|
|
4599
|
+
version = "0.14.0"
|
|
4600
|
+
constraints = "~> 0.13"
|
|
4601
|
+
hashes = [
|
|
4602
|
+
"h1:/hlxsUpuN/lvPTNL9+NyVGsOyRsK5NsxwFMsj5CdOp4=",
|
|
4603
|
+
"h1:4EThC3ocCFiFPMZQSUvSGSxoJqBcGWxMcFYmL67uS7Y=",
|
|
4604
|
+
"zh:12abfd6b800e4d7fa6db7310dec8ffd440b31993861ef188c7ed5260b3073937",
|
|
4605
|
+
"zh:23005521e800bb19e1597bf755c5f70d675d30b685d4255001ed5fa47d9df3f1",
|
|
4606
|
+
"zh:2fea249b582ae97cd1cc10385187ea50993bb47c28cc5df0305e57ceaabf0a10",
|
|
4607
|
+
"zh:322018d3b987b7aad08697178029a2bb667bed699e88328f0c89c52a2fd41341",
|
|
4608
|
+
"zh:32a08e98fce2d273cb9b2c89d6c54727cc9f0a32e15bfd896be4e02cc6b48f95",
|
|
4609
|
+
"zh:3db89aabd0e619616bd4b0f8b373a7586dfe60feffcea12a84a0bdbc445714b3",
|
|
4610
|
+
"zh:7488f56c81d742dc020f29063626c8f07ca188aa97be61e7307e8d62397020a2",
|
|
4611
|
+
"zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
|
|
4612
|
+
"zh:7cb4067f2e7559b13f7562ef722f948950901eb37834873e98360ab28f66e9d7",
|
|
4613
|
+
"zh:9d552c8345f61e1b7db8e725144981345f18ac1014d58d6f5ddf0928a195fffb",
|
|
4614
|
+
"zh:a8e69fb6b97fc9d86fb19a9f4d42abe33c4a68e700b15387ce2e17d2b9934bed",
|
|
4615
|
+
"zh:aeeb900eb8dd0f790c60ea5c0e0c8d42bd6e4a54f391681d4decca15b544394b",
|
|
4616
|
+
"zh:c239c619101a8c95e1f14061eb973c57a8d15fa0e68878ced5bbd76858ee5b79",
|
|
4617
|
+
]
|
|
4618
|
+
}
|
|
4619
|
+
|
|
4620
|
+
provider "registry.terraform.io/integrations/github" {
|
|
4621
|
+
version = "6.12.1"
|
|
4622
|
+
constraints = "~> 6.0"
|
|
4623
|
+
hashes = [
|
|
4624
|
+
"h1:bGz4LIep/7PVrqy6P8cTYbAJpdxXGrupUJjkCczlzIs=",
|
|
4625
|
+
"h1:hHOwf554tYL9pQS2uRPbaAGSXRbbBJ/+HtQAoT9mtuA=",
|
|
4626
|
+
"zh:3e1a4081ecb9518fdf0074db83c16ad00dc81ffe8249a6e3cf1894e947e28df6",
|
|
4627
|
+
"zh:4cb8224b7f530795b674ac044675f6b22a7c9154f55eb9f76c5af6c7534056a4",
|
|
4628
|
+
"zh:560bc08637926191f6871a89e986022ca67c70afda5bebca34b5216e6fac69c9",
|
|
4629
|
+
"zh:5a70b5d2ac650c5c9819a1875411ebda229d0fcc6c9f57f9d751852ca3cd77ac",
|
|
4630
|
+
"zh:8668d93bd4dc2ffa2545e1473af600a925d479b16033a71a4498a16f3b683c0c",
|
|
4631
|
+
"zh:86eacc6059fd057948e178b665ba5cce74bd5488a9e1035734e60ff5ef1b6f8f",
|
|
4632
|
+
"zh:a329fac98881d8dfc211a9bdc0ec6f2948f0b0c2704d1b6cbe5307403c7ad1b2",
|
|
4633
|
+
"zh:dadd44abab3c52b9d572955afaef1658790e17ea355ee22b58996d81d28e02d8",
|
|
4634
|
+
"zh:de9f455ef342cc38fb76bce844bfcd376fb81a4b9f9bc2fae023ff99efdf1338",
|
|
4635
|
+
"zh:f8c6d2e8351b334491790358574e0a30a7c6d7f5b80f7daf32a7c0f3e9b1ab19",
|
|
4636
|
+
"zh:fab41971a3edee04ab6eceaeab4eeb9a2b2f38a2af3b06eda93e2117b64994be",
|
|
4637
|
+
"zh:fb1279b566dd9c8c117b2e4e0cc8344413b8fc8f2a3e24be22a9b2610551777b",
|
|
4638
|
+
"zh:fbd1fee2c9df3aa19cf8851ce134dea6e45ea01cb85695c1726670c285797e25",
|
|
4639
|
+
"zh:fe79d2a861fb9af420fa5bd7f02c031b2a0a3edf5dbc46022c8ecc7a33cf2b6d",
|
|
4640
|
+
]
|
|
4641
|
+
}
|
|
4642
|
+
`;
|
|
4643
|
+
var PER_APP_CONTAINER_GATEWAY_LOCK_HCL = (() => {
|
|
4644
|
+
const marker = 'provider "registry.terraform.io/hashicorp/azurerm" {';
|
|
4645
|
+
const start = PER_APP_LOCK_HCL.indexOf(marker);
|
|
4646
|
+
const end = PER_APP_LOCK_HCL.indexOf(`
|
|
4647
|
+
}
|
|
4648
|
+
`, start) + 3;
|
|
4649
|
+
if (start < 0 || end < 3)
|
|
4650
|
+
throw new Error("azurerm block missing from the pages lock");
|
|
4651
|
+
const azurerm = PER_APP_LOCK_HCL.slice(start, end);
|
|
4652
|
+
const before = 'provider "registry.terraform.io/hashicorp/random" {';
|
|
4653
|
+
const at = PER_APP_CONTAINER_LOCK_HCL.indexOf(before);
|
|
4654
|
+
if (at < 0)
|
|
4655
|
+
throw new Error("random block missing from the container lock");
|
|
4656
|
+
return PER_APP_CONTAINER_LOCK_HCL.slice(0, at) + azurerm + `
|
|
4657
|
+
` + PER_APP_CONTAINER_LOCK_HCL.slice(at);
|
|
4658
|
+
})();
|
|
4659
|
+
|
|
4250
4660
|
// ../launchpad-engine/dist/per-app-workspace.js
|
|
4251
4661
|
var CF_ACCOUNT_ID = "c07cb17c9f742e8144c4828b3693ca65";
|
|
4252
4662
|
var R2_S3_ENDPOINT = `https://${CF_ACCOUNT_ID}.r2.cloudflarestorage.com`;
|
|
@@ -5936,7 +6346,7 @@ async function runStatus(args, io) {
|
|
|
5936
6346
|
};
|
|
5937
6347
|
}
|
|
5938
6348
|
}
|
|
5939
|
-
emit4(output, parsed.json, io);
|
|
6349
|
+
emit4(output, parsed.json, io, lifecycle?.containerRedeploy);
|
|
5940
6350
|
return 0;
|
|
5941
6351
|
}
|
|
5942
6352
|
let localYaml = null;
|
|
@@ -6013,7 +6423,7 @@ async function runStatus(args, io) {
|
|
|
6013
6423
|
}),
|
|
6014
6424
|
...lifecycle?.statusPageUrl !== undefined ? { statusPageUrl: lifecycle.statusPageUrl } : {}
|
|
6015
6425
|
};
|
|
6016
|
-
emit4(out, parsed.json, io);
|
|
6426
|
+
emit4(out, parsed.json, io, lifecycle?.containerRedeploy);
|
|
6017
6427
|
return 0;
|
|
6018
6428
|
}
|
|
6019
6429
|
if (local === null) {
|
|
@@ -6030,7 +6440,7 @@ async function runStatus(args, io) {
|
|
|
6030
6440
|
}),
|
|
6031
6441
|
...lifecycle?.statusPageUrl !== undefined ? { statusPageUrl: lifecycle.statusPageUrl } : {}
|
|
6032
6442
|
};
|
|
6033
|
-
emit4(out, parsed.json, io);
|
|
6443
|
+
emit4(out, parsed.json, io, lifecycle?.containerRedeploy);
|
|
6034
6444
|
if (parsed.strict) {
|
|
6035
6445
|
if (deployment?.liveDeployment?.buildStatus === "failure" || deployment?.v2?.state === "refused") {
|
|
6036
6446
|
io.err(`launchpad status: --strict: live build FAILED ` + `(drift not evaluated — no local launchpad.yaml here).`);
|
|
@@ -6068,7 +6478,7 @@ async function runStatus(args, io) {
|
|
|
6068
6478
|
...standingExceptions !== null ? { standingExceptions } : {}
|
|
6069
6479
|
})
|
|
6070
6480
|
};
|
|
6071
|
-
emit4(out, parsed.json, io);
|
|
6481
|
+
emit4(out, parsed.json, io, lifecycle?.containerRedeploy);
|
|
6072
6482
|
return 0;
|
|
6073
6483
|
}
|
|
6074
6484
|
const localGroups = await resolveStatusGroups({
|
|
@@ -6131,7 +6541,7 @@ async function runStatus(args, io) {
|
|
|
6131
6541
|
...groupIssues.length === 0 ? {} : { groupIssues },
|
|
6132
6542
|
...lifecycle?.statusPageUrl !== undefined ? { statusPageUrl: lifecycle.statusPageUrl } : {}
|
|
6133
6543
|
};
|
|
6134
|
-
emit4(result, parsed.json, io);
|
|
6544
|
+
emit4(result, parsed.json, io, lifecycle?.containerRedeploy);
|
|
6135
6545
|
if (parsed.strict && (result.state === "drift" || accessDrift?.inSync === false || groupIssues.length > 0)) {
|
|
6136
6546
|
return 1;
|
|
6137
6547
|
}
|
|
@@ -6380,7 +6790,14 @@ function lifecycleOutput(slug, lc) {
|
|
|
6380
6790
|
...lc.statusPageUrl !== undefined ? { statusPageUrl: lc.statusPageUrl } : {}
|
|
6381
6791
|
};
|
|
6382
6792
|
}
|
|
6383
|
-
function
|
|
6793
|
+
function containerRedeployLine(view) {
|
|
6794
|
+
if (view.state === "failed") {
|
|
6795
|
+
return `Container redeploy: failed at ${view.stage ?? "unknown"}` + (view.message ? ` — ${view.message}` : "") + ` (attempt ${view.attemptId}, ${view.at})`;
|
|
6796
|
+
}
|
|
6797
|
+
return `Container redeploy: ${view.state} (attempt ${view.attemptId})`;
|
|
6798
|
+
}
|
|
6799
|
+
function emit4(base, asJson, io, containerRedeploy) {
|
|
6800
|
+
const out = containerRedeploy === undefined ? base : { ...base, containerRedeploy };
|
|
6384
6801
|
if (asJson) {
|
|
6385
6802
|
io.out(JSON.stringify(out, null, 2));
|
|
6386
6803
|
return;
|
|
@@ -6388,6 +6805,8 @@ function emit4(out, asJson, io) {
|
|
|
6388
6805
|
if (out.statusPageUrl !== undefined) {
|
|
6389
6806
|
io.out(`Status page: ${out.statusPageUrl}`);
|
|
6390
6807
|
}
|
|
6808
|
+
if (containerRedeploy !== undefined)
|
|
6809
|
+
io.out(containerRedeployLine(containerRedeploy));
|
|
6391
6810
|
switch (out.state) {
|
|
6392
6811
|
case "provisioning":
|
|
6393
6812
|
io.out(`${out.slug}: provisioning (stage: ${out.stage ?? "starting"})` + (out.submissionId ? ` — submission ${out.submissionId}` : ""));
|
|
@@ -8649,7 +9068,8 @@ var PLATFORM_ENV_NAMES = new Set([
|
|
|
8649
9068
|
"CF_ACCESS_AUD",
|
|
8650
9069
|
"JWKS_URL"
|
|
8651
9070
|
]);
|
|
8652
|
-
|
|
9071
|
+
var PLATFORM_ENV_PREFIXES = ["GATEWAY_", "CF_ACCESS_"];
|
|
9072
|
+
function dispatchManifest(manifest, wrangler = {}) {
|
|
8653
9073
|
const v2 = manifest.apiVersion === "launchpad.m-kopa.us/v2";
|
|
8654
9074
|
const source = v2 ? manifest.spec : manifest;
|
|
8655
9075
|
const appType = v2 ? manifest.spec.appType : manifest.deployment.type;
|
|
@@ -8658,8 +9078,9 @@ function dispatchManifest(manifest, wranglerD1) {
|
|
|
8658
9078
|
}
|
|
8659
9079
|
if (!v2)
|
|
8660
9080
|
assertConvertibleV1(manifest);
|
|
8661
|
-
const d1 = d1Binding(v2 ? manifest.spec.bindings?.d1 : pagesTargetD1(manifest),
|
|
8662
|
-
const
|
|
9081
|
+
const d1 = d1Binding(v2 ? manifest.spec.bindings?.d1 : pagesTargetD1(manifest), wrangler.d1);
|
|
9082
|
+
const manifestEnv = v2 ? manifest.spec.env_vars : plainTextEnv(manifest.production_env);
|
|
9083
|
+
const plainEnv = withWranglerVars(manifestEnv, wrangler.vars ?? {}, d1);
|
|
8663
9084
|
const envVars = { ...plainEnv, ...secretEnv(source.secrets, plainEnv) };
|
|
8664
9085
|
const spec = v2 ? { ...manifest.spec, secrets: undefined } : {
|
|
8665
9086
|
appType,
|
|
@@ -8717,6 +9138,31 @@ function d1Binding(declared, wranglerD1) {
|
|
|
8717
9138
|
}
|
|
8718
9139
|
return declared ?? wranglerD1;
|
|
8719
9140
|
}
|
|
9141
|
+
function withWranglerVars(env, vars, d1) {
|
|
9142
|
+
const entries = Object.entries(vars);
|
|
9143
|
+
if (entries.length === 0)
|
|
9144
|
+
return env;
|
|
9145
|
+
const out = { ...env };
|
|
9146
|
+
for (const [name, value] of entries) {
|
|
9147
|
+
if (isPlatformEnvName(name)) {
|
|
9148
|
+
throw new Error(`The wrangler var ${name} is set by the platform on dispatch apps. Rename it before converting.`);
|
|
9149
|
+
}
|
|
9150
|
+
if (/_(TOKEN|SECRET)$/.test(name)) {
|
|
9151
|
+
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.`);
|
|
9152
|
+
}
|
|
9153
|
+
if (name === d1)
|
|
9154
|
+
throw new Error(`The wrangler var ${name} has the same name as the D1 binding. Rename one of them.`);
|
|
9155
|
+
const existing = out[name];
|
|
9156
|
+
if (existing !== undefined && !(existing.type === "plain_text" && existing.value === value)) {
|
|
9157
|
+
throw new Error(`The wrangler var ${name} differs from the ${name} environment variable in launchpad.yaml. Keep one value.`);
|
|
9158
|
+
}
|
|
9159
|
+
out[name] = { type: "plain_text", value };
|
|
9160
|
+
}
|
|
9161
|
+
return out;
|
|
9162
|
+
}
|
|
9163
|
+
function isPlatformEnvName(name) {
|
|
9164
|
+
return PLATFORM_ENV_NAMES.has(name) || PLATFORM_ENV_PREFIXES.some((prefix) => name.startsWith(prefix));
|
|
9165
|
+
}
|
|
8720
9166
|
function plainTextEnv(env) {
|
|
8721
9167
|
if (env === undefined)
|
|
8722
9168
|
return;
|
|
@@ -8755,19 +9201,36 @@ var ALLOWED_KEYS = new Set([
|
|
|
8755
9201
|
"compatibility_date",
|
|
8756
9202
|
"compatibility_flags",
|
|
8757
9203
|
"pages_build_output_dir",
|
|
8758
|
-
"d1_databases"
|
|
9204
|
+
"d1_databases",
|
|
9205
|
+
"vars"
|
|
8759
9206
|
]);
|
|
8760
9207
|
var PLATFORM_FLAGS = new Set(["nodejs_compat"]);
|
|
8761
9208
|
|
|
8762
9209
|
class UnsupportedWranglerConfigError extends Error {
|
|
8763
9210
|
}
|
|
8764
|
-
function
|
|
9211
|
+
function wranglerRuntime(file, text) {
|
|
8765
9212
|
const toml = file.endsWith(".toml");
|
|
8766
9213
|
const config = toml ? readToml(file, text) : readJsonc(file, text);
|
|
8767
9214
|
for (const key of Object.keys(config)) {
|
|
8768
9215
|
if (!ALLOWED_KEYS.has(key) && (toml || key !== "$schema"))
|
|
8769
9216
|
throw unsupportedKey(file, key);
|
|
8770
9217
|
}
|
|
9218
|
+
const vars = config.vars === undefined ? {} : plainVars(file, config.vars);
|
|
9219
|
+
const d1 = d1Binding2(file, config);
|
|
9220
|
+
return d1 === undefined ? { vars } : { d1, vars };
|
|
9221
|
+
}
|
|
9222
|
+
function plainVars(file, value) {
|
|
9223
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
9224
|
+
throw new UnsupportedWranglerConfigError(`${file} sets \`vars\` to something other than a table`);
|
|
9225
|
+
}
|
|
9226
|
+
for (const [name, item] of Object.entries(value)) {
|
|
9227
|
+
if (typeof item !== "string") {
|
|
9228
|
+
throw new UnsupportedWranglerConfigError(`${file} sets \`vars.${name}\` to something other than a string; dispatch env vars are plain strings`);
|
|
9229
|
+
}
|
|
9230
|
+
}
|
|
9231
|
+
return value;
|
|
9232
|
+
}
|
|
9233
|
+
function d1Binding2(file, config) {
|
|
8771
9234
|
if (config.compatibility_flags !== undefined) {
|
|
8772
9235
|
const extra = asArray(file, "compatibility_flags", config.compatibility_flags).find((flag) => !PLATFORM_FLAGS.has(String(flag)));
|
|
8773
9236
|
if (extra !== undefined) {
|
|
@@ -8820,8 +9283,9 @@ function readToml(file, text) {
|
|
|
8820
9283
|
let table = config;
|
|
8821
9284
|
for (const line of logicalTomlLines(text)) {
|
|
8822
9285
|
if (line.startsWith("[")) {
|
|
8823
|
-
table =
|
|
8824
|
-
|
|
9286
|
+
table = openTable(file, line, config, databases);
|
|
9287
|
+
} else if (table === config.vars) {
|
|
9288
|
+
assignVar(file, table, line);
|
|
8825
9289
|
} else {
|
|
8826
9290
|
assign(file, table, line, table === config);
|
|
8827
9291
|
}
|
|
@@ -8832,20 +9296,55 @@ function readToml(file, text) {
|
|
|
8832
9296
|
throw new UnsupportedWranglerConfigError(`${file} declares d1_databases twice`);
|
|
8833
9297
|
return { ...config, d1_databases: databases };
|
|
8834
9298
|
}
|
|
8835
|
-
function
|
|
9299
|
+
function openTable(file, line, config, databases) {
|
|
8836
9300
|
const name = /^\[\[?\s*([^\]]*?)\s*\]\]?$/.exec(line)?.[1] ?? line;
|
|
8837
|
-
if (
|
|
8838
|
-
|
|
8839
|
-
|
|
9301
|
+
if (line.startsWith("[[") && name === "d1_databases") {
|
|
9302
|
+
const table = {};
|
|
9303
|
+
databases.push(table);
|
|
9304
|
+
return table;
|
|
9305
|
+
}
|
|
9306
|
+
if (!line.startsWith("[[") && name === "vars")
|
|
9307
|
+
return varsTable(config);
|
|
9308
|
+
throw unsupportedKey(file, topKey(name));
|
|
9309
|
+
}
|
|
9310
|
+
function varsTable(config) {
|
|
9311
|
+
config.vars ??= {};
|
|
9312
|
+
return config.vars;
|
|
8840
9313
|
}
|
|
8841
9314
|
function assign(file, table, line, topLevel) {
|
|
9315
|
+
const [, key, value] = tomlAssignment(file, line);
|
|
9316
|
+
if (topLevel && key.includes(".")) {
|
|
9317
|
+
const [head, name, ...rest] = key.split(".");
|
|
9318
|
+
if (head !== "vars" || rest.length > 0)
|
|
9319
|
+
throw unsupportedKey(file, topKey(key));
|
|
9320
|
+
assignVar(file, varsTable(table), `${name} = ${value}`);
|
|
9321
|
+
return;
|
|
9322
|
+
}
|
|
9323
|
+
table[topKey(key)] = tomlValue(value.trim());
|
|
9324
|
+
}
|
|
9325
|
+
function assignVar(file, vars, line) {
|
|
9326
|
+
const [, key, value] = tomlAssignment(file, line);
|
|
9327
|
+
const quoted = /^"((?:[^"\\]|\\.)*)"$|^'([^']*)'$/.exec(value.trim());
|
|
9328
|
+
const text = quoted === null ? null : quoted[1] === undefined ? quoted[2] : basicString(file, key, quoted[1]);
|
|
9329
|
+
vars[key.replace(/"/g, "").trim()] = text;
|
|
9330
|
+
}
|
|
9331
|
+
var TOML_ESCAPES = { b: "\b", t: "\t", n: `
|
|
9332
|
+
`, f: "\f", r: "\r", '"': '"', "\\": "\\" };
|
|
9333
|
+
function basicString(file, key, raw) {
|
|
9334
|
+
return raw.replace(/\\(u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|.)/g, (escape, code) => {
|
|
9335
|
+
const point = code.length > 1 ? parseInt(code.slice(1), 16) : -1;
|
|
9336
|
+
const scalar = point <= 1114111 && (point < 55296 || point > 57343);
|
|
9337
|
+
const decoded = code.length > 1 ? scalar ? String.fromCodePoint(point) : undefined : TOML_ESCAPES[code];
|
|
9338
|
+
if (decoded === undefined)
|
|
9339
|
+
throw new UnsupportedWranglerConfigError(`${file} sets \`vars.${key.trim()}\` with an invalid escape \`${escape}\``);
|
|
9340
|
+
return decoded;
|
|
9341
|
+
});
|
|
9342
|
+
}
|
|
9343
|
+
function tomlAssignment(file, line) {
|
|
8842
9344
|
const assignment = /^([\w\-."]+)\s*=\s*(.*)$/.exec(line);
|
|
8843
9345
|
if (assignment === null)
|
|
8844
9346
|
throw new UnsupportedWranglerConfigError(`${file} could not be read as TOML near \`${line.slice(0, 40)}\``);
|
|
8845
|
-
|
|
8846
|
-
if (topLevel && assignment[1].includes("."))
|
|
8847
|
-
throw unsupportedKey(file, key);
|
|
8848
|
-
table[key] = tomlValue(assignment[2].trim());
|
|
9347
|
+
return [assignment[0], assignment[1], assignment[2]];
|
|
8849
9348
|
}
|
|
8850
9349
|
function topKey(dotted) {
|
|
8851
9350
|
return dotted.split(".")[0].replace(/"/g, "").trim();
|
|
@@ -8942,25 +9441,38 @@ async function runMigrate(args, io) {
|
|
|
8942
9441
|
return 64;
|
|
8943
9442
|
}
|
|
8944
9443
|
try {
|
|
8945
|
-
|
|
8946
|
-
if (result.kind === "already") {
|
|
8947
|
-
io.out("launchpad.yaml already selects Workers dispatch. Run `launchpad deploy`.");
|
|
8948
|
-
} else if (result.kind === "eligible") {
|
|
8949
|
-
io.out(`${result.slug}: eligible for v2 Workers dispatch with gateway authentication. No files changed.`);
|
|
8950
|
-
} else {
|
|
8951
|
-
io.out(`${result.slug}: launchpad.yaml now uses v2 Workers dispatch with gateway authentication.`);
|
|
8952
|
-
io.out(`Audience, owner and application settings are preserved. Original: ${BACKUP_PATH}`);
|
|
8953
|
-
io.out("Run `launchpad deploy`. No Pages project is needed.");
|
|
8954
|
-
const next = secretsNextStep(result.secrets);
|
|
8955
|
-
if (next !== null)
|
|
8956
|
-
io.out(next);
|
|
8957
|
-
}
|
|
9444
|
+
reportMigration(io, await convertToDispatch(process.cwd(), args.includes("--dry-run")));
|
|
8958
9445
|
return 0;
|
|
8959
9446
|
} catch (error) {
|
|
8960
9447
|
io.err(`launchpad migrate: ${error instanceof Error ? error.message : String(error)}`);
|
|
8961
9448
|
return 1;
|
|
8962
9449
|
}
|
|
8963
9450
|
}
|
|
9451
|
+
function reportMigration(io, result) {
|
|
9452
|
+
if (result.kind === "already") {
|
|
9453
|
+
io.out("launchpad.yaml already selects Workers dispatch. Run `launchpad deploy`.");
|
|
9454
|
+
return;
|
|
9455
|
+
}
|
|
9456
|
+
if (result.kind === "eligible") {
|
|
9457
|
+
io.out(`${result.slug}: eligible for v2 Workers dispatch with gateway authentication. No files changed.`);
|
|
9458
|
+
} else {
|
|
9459
|
+
io.out(`${result.slug}: launchpad.yaml now uses v2 Workers dispatch with gateway authentication.`);
|
|
9460
|
+
io.out(`Audience, owner and application settings are preserved. Original: ${BACKUP_PATH}`);
|
|
9461
|
+
io.out("Run `launchpad deploy`. No Pages project is needed.");
|
|
9462
|
+
const next = secretsNextStep(result.secrets);
|
|
9463
|
+
if (next !== null)
|
|
9464
|
+
io.out(next);
|
|
9465
|
+
}
|
|
9466
|
+
const warning = plainSecretWarning(result.plainSecretLike);
|
|
9467
|
+
if (warning !== null)
|
|
9468
|
+
io.err(`warning: ${warning}`);
|
|
9469
|
+
}
|
|
9470
|
+
var SECRET_LIKE_NAME = /SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE|CREDENTIAL|APIKEY|AUTH_CONFIG|(^|_)(API_)?KEY(_|$)/i;
|
|
9471
|
+
function plainSecretWarning(names) {
|
|
9472
|
+
if (names.length === 0)
|
|
9473
|
+
return null;
|
|
9474
|
+
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.";
|
|
9475
|
+
}
|
|
8964
9476
|
var BACKUP_PATH = ".launchpad/manifest-before-dispatch.yaml";
|
|
8965
9477
|
function secretsNextStep(secrets) {
|
|
8966
9478
|
if (secrets.length === 0)
|
|
@@ -8969,33 +9481,37 @@ function secretsNextStep(secrets) {
|
|
|
8969
9481
|
}
|
|
8970
9482
|
async function convertToDispatch(cwd, dryRun) {
|
|
8971
9483
|
const file = path8.join(cwd, "launchpad.yaml");
|
|
8972
|
-
|
|
8973
|
-
throw new Error("launchpad.yaml must be a regular file, not a symlink.");
|
|
9484
|
+
const regularFile = lstatSync4(file).isFile();
|
|
8974
9485
|
const original = readFileSync11(file, "utf8");
|
|
8975
9486
|
const loaded = parseManifestAnyVersion(original, file);
|
|
8976
9487
|
if (loaded.kind !== "ok")
|
|
8977
|
-
throw new
|
|
9488
|
+
throw new InvalidManifestError;
|
|
8978
9489
|
const manifest = loaded.manifest;
|
|
8979
9490
|
if (manifest.apiVersion === "launchpad.m-kopa.us/v2" && manifest.spec.origin === "dispatch")
|
|
8980
9491
|
return { kind: "already" };
|
|
8981
9492
|
const slug = manifest.apiVersion === "launchpad.m-kopa.us/v2" ? manifest.metadata.slug : manifest.metadata.name;
|
|
8982
9493
|
let converted;
|
|
8983
9494
|
try {
|
|
9495
|
+
if (!regularFile)
|
|
9496
|
+
throw new Error("launchpad.yaml must be a regular file, not a symlink.");
|
|
8984
9497
|
converted = convertLocally(cwd, manifest);
|
|
8985
9498
|
} catch (error) {
|
|
8986
|
-
await refuseIfRegistered(slug)
|
|
9499
|
+
if (!await refuseIfRegistered(slug))
|
|
9500
|
+
throw new IneligibleUnconfirmedError(error);
|
|
8987
9501
|
throw error;
|
|
8988
9502
|
}
|
|
8989
9503
|
await assertUnregistered(slug);
|
|
8990
|
-
const
|
|
9504
|
+
const env = Object.entries(converted.spec.env_vars ?? {});
|
|
9505
|
+
const secrets = env.filter(([, value]) => value.type === "secret_text").map(([name]) => name);
|
|
9506
|
+
const plainSecretLike = env.filter(([name, value]) => value.type === "plain_text" && SECRET_LIKE_NAME.test(name)).map(([name]) => name);
|
|
8991
9507
|
if (dryRun)
|
|
8992
|
-
return { kind: "eligible", slug, secrets };
|
|
9508
|
+
return { kind: "eligible", slug, secrets, plainSecretLike };
|
|
8993
9509
|
try {
|
|
8994
9510
|
saveMigration(file, original, converted);
|
|
8995
9511
|
} catch (error) {
|
|
8996
9512
|
throw new MigrationSaveError(error);
|
|
8997
9513
|
}
|
|
8998
|
-
return { kind: "converted", slug, secrets };
|
|
9514
|
+
return { kind: "converted", slug, secrets, plainSecretLike };
|
|
8999
9515
|
}
|
|
9000
9516
|
function convertLocally(cwd, manifest) {
|
|
9001
9517
|
const v2 = manifest.apiVersion === "launchpad.m-kopa.us/v2";
|
|
@@ -9006,9 +9522,11 @@ function convertLocally(cwd, manifest) {
|
|
|
9006
9522
|
async function refuseIfRegistered(slug) {
|
|
9007
9523
|
try {
|
|
9008
9524
|
await assertUnregistered(slug);
|
|
9525
|
+
return true;
|
|
9009
9526
|
} catch (error) {
|
|
9010
|
-
if (error instanceof
|
|
9011
|
-
|
|
9527
|
+
if (error instanceof RegistryUnavailableError)
|
|
9528
|
+
return false;
|
|
9529
|
+
throw error;
|
|
9012
9530
|
}
|
|
9013
9531
|
}
|
|
9014
9532
|
async function assertUnregistered(slug) {
|
|
@@ -9024,6 +9542,18 @@ async function assertUnregistered(slug) {
|
|
|
9024
9542
|
throw new RegisteredAppError;
|
|
9025
9543
|
}
|
|
9026
9544
|
|
|
9545
|
+
class IneligibleUnconfirmedError extends Error {
|
|
9546
|
+
constructor(cause) {
|
|
9547
|
+
super(cause instanceof Error ? cause.message : String(cause));
|
|
9548
|
+
}
|
|
9549
|
+
}
|
|
9550
|
+
|
|
9551
|
+
class InvalidManifestError extends Error {
|
|
9552
|
+
constructor() {
|
|
9553
|
+
super("launchpad.yaml is invalid. Run `launchpad validate` and correct it first.");
|
|
9554
|
+
}
|
|
9555
|
+
}
|
|
9556
|
+
|
|
9027
9557
|
class MigrationSaveError extends Error {
|
|
9028
9558
|
constructor(cause) {
|
|
9029
9559
|
super(`Could not save the converted manifest: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
@@ -9044,10 +9574,14 @@ class RegisteredAppError extends Error {
|
|
|
9044
9574
|
var WRANGLER_FILES = ["wrangler.toml", "wrangler.json", "wrangler.jsonc"];
|
|
9045
9575
|
function inspectRuntime(cwd, appType, appRootDir, build) {
|
|
9046
9576
|
const d1 = new Set;
|
|
9577
|
+
const vars = {};
|
|
9047
9578
|
for (const root of runtimeRoots(cwd, appRootDir, build)) {
|
|
9048
9579
|
assertNoUncompiledCode(root, appType);
|
|
9049
|
-
for (const
|
|
9050
|
-
d1
|
|
9580
|
+
for (const runtime of wranglerRuntimes(cwd, root)) {
|
|
9581
|
+
if (runtime.d1 !== undefined)
|
|
9582
|
+
d1.add(runtime.d1);
|
|
9583
|
+
mergeVars(vars, runtime.vars);
|
|
9584
|
+
}
|
|
9051
9585
|
}
|
|
9052
9586
|
if (d1.size > 1)
|
|
9053
9587
|
throw new Error(`The wrangler configs bind D1 under different names (${[...d1].join(", ")}). Use one name.`);
|
|
@@ -9055,7 +9589,15 @@ function inspectRuntime(cwd, appType, appRootDir, build) {
|
|
|
9055
9589
|
if (binding !== undefined && appType !== "react+api") {
|
|
9056
9590
|
throw new Error("The wrangler config declares a D1 database, which only react+api apps can use on dispatch.");
|
|
9057
9591
|
}
|
|
9058
|
-
return binding;
|
|
9592
|
+
return { ...binding === undefined ? {} : { d1: binding }, vars };
|
|
9593
|
+
}
|
|
9594
|
+
function mergeVars(into, vars) {
|
|
9595
|
+
for (const [name, value] of Object.entries(vars)) {
|
|
9596
|
+
if (into[name] !== undefined && into[name] !== value) {
|
|
9597
|
+
throw new Error(`The wrangler configs set var ${name} to different values. Use one value.`);
|
|
9598
|
+
}
|
|
9599
|
+
into[name] = value;
|
|
9600
|
+
}
|
|
9059
9601
|
}
|
|
9060
9602
|
function runtimeRoots(cwd, appRootDir, build) {
|
|
9061
9603
|
const appRoot = path8.resolve(cwd, appRootDir ?? ".");
|
|
@@ -9078,8 +9620,8 @@ function assertNoUncompiledCode(root, appType) {
|
|
|
9078
9620
|
if (api)
|
|
9079
9621
|
assertWorkerRoutesFit(root);
|
|
9080
9622
|
}
|
|
9081
|
-
function
|
|
9082
|
-
return WRANGLER_FILES.map((name) => path8.join(root, name)).filter((file) => existsSync7(file)).map((file) =>
|
|
9623
|
+
function wranglerRuntimes(cwd, root) {
|
|
9624
|
+
return WRANGLER_FILES.map((name) => path8.join(root, name)).filter((file) => existsSync7(file)).map((file) => wranglerRuntime(path8.relative(cwd, file), readFileSync11(file, "utf8")));
|
|
9083
9625
|
}
|
|
9084
9626
|
function assertWorkerRoutesFit(root) {
|
|
9085
9627
|
const functions = path8.join(root, "functions");
|
|
@@ -9526,14 +10068,19 @@ async function runModelADeploy(args) {
|
|
|
9526
10068
|
let slug;
|
|
9527
10069
|
let appType = "static";
|
|
9528
10070
|
let declaredOrigin;
|
|
9529
|
-
let pagesNote;
|
|
9530
10071
|
try {
|
|
9531
|
-
|
|
10072
|
+
await defaultToDispatch(cwd, manifestPath, io);
|
|
9532
10073
|
} catch (e) {
|
|
9533
10074
|
if (e instanceof UpgradeRequiredError) {
|
|
9534
10075
|
io.err(e.message);
|
|
9535
10076
|
return EXIT_CLI_UPGRADE_REQUIRED;
|
|
9536
10077
|
}
|
|
10078
|
+
if (e instanceof DispatchIneligibleError) {
|
|
10079
|
+
for (const line of e.message.split(`
|
|
10080
|
+
`))
|
|
10081
|
+
io.err(line);
|
|
10082
|
+
return 1;
|
|
10083
|
+
}
|
|
9537
10084
|
io.err(`launchpad deploy: ${describe17(e)}. Nothing was deployed.`);
|
|
9538
10085
|
if (e instanceof UnauthenticatedError)
|
|
9539
10086
|
io.err(" run `launchpad login` to refresh your session.");
|
|
@@ -9607,8 +10154,6 @@ async function runModelADeploy(args) {
|
|
|
9607
10154
|
io.out(`Bundling ${cwd} for ${slug} (Model A) …`);
|
|
9608
10155
|
if (declaredOrigin !== "dispatch" && appType !== "container") {
|
|
9609
10156
|
io.out("Deployment target: Cloudflare Pages, selected by launchpad.yaml.");
|
|
9610
|
-
if (pagesNote !== null)
|
|
9611
|
-
io.out(pagesNote);
|
|
9612
10157
|
}
|
|
9613
10158
|
let cfg;
|
|
9614
10159
|
try {
|
|
@@ -9817,6 +10362,16 @@ async function runModelADeploy(args) {
|
|
|
9817
10362
|
const submissionId = typeof success.submissionId === "string" ? success.submissionId : "(missing)";
|
|
9818
10363
|
const echoedAppType = typeof success.appType === "string" ? success.appType : "(missing)";
|
|
9819
10364
|
const message = typeof success.message === "string" ? success.message : "Bot accepted the upload and started provisioning.";
|
|
10365
|
+
if (success.mode === "container_redeploy") {
|
|
10366
|
+
io.out(`✓ Container redeploy started for ${slug}`);
|
|
10367
|
+
io.out(` submission: ${submissionId}`);
|
|
10368
|
+
io.out("");
|
|
10369
|
+
io.out(message);
|
|
10370
|
+
io.out("");
|
|
10371
|
+
io.out("Next steps:");
|
|
10372
|
+
io.out(` launchpad status ${slug} # watch the redeploy`);
|
|
10373
|
+
return 0;
|
|
10374
|
+
}
|
|
9820
10375
|
io.out(`✓ First-time deploy — provisioning workflow started for ${slug}`);
|
|
9821
10376
|
io.out(` submission: ${submissionId}`);
|
|
9822
10377
|
io.out(` appType: ${echoedAppType}`);
|
|
@@ -9901,24 +10456,39 @@ function isIneligible(e) {
|
|
|
9901
10456
|
return !(e instanceof RegistryUnavailableError || e instanceof MigrationSaveError || e instanceof UpgradeRequiredError || e instanceof UnauthenticatedError);
|
|
9902
10457
|
}
|
|
9903
10458
|
async function defaultToDispatch(cwd, manifestPath, io) {
|
|
9904
|
-
|
|
9905
|
-
|
|
10459
|
+
const fields = originFields(manifestPath);
|
|
10460
|
+
if (!impliesPagesForGateway(fields))
|
|
10461
|
+
return;
|
|
9906
10462
|
try {
|
|
9907
10463
|
const result = await convertToDispatch(cwd, false);
|
|
9908
10464
|
if (result.kind === "converted")
|
|
9909
|
-
reportConversion(io, result.secrets);
|
|
9910
|
-
return null;
|
|
10465
|
+
reportConversion(io, result.secrets, result.plainSecretLike);
|
|
9911
10466
|
} catch (e) {
|
|
9912
|
-
if (e instanceof RegisteredAppError)
|
|
9913
|
-
return
|
|
10467
|
+
if (e instanceof RegisteredAppError || e instanceof InvalidManifestError)
|
|
10468
|
+
return;
|
|
10469
|
+
if (e instanceof IneligibleUnconfirmedError) {
|
|
10470
|
+
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}`);
|
|
10471
|
+
return;
|
|
10472
|
+
}
|
|
9914
10473
|
if (!(e instanceof Error) || !isIneligible(e))
|
|
9915
10474
|
throw e;
|
|
9916
|
-
|
|
10475
|
+
throw new DispatchIneligibleError(describe17(e), fields.v2 === true);
|
|
10476
|
+
}
|
|
10477
|
+
}
|
|
10478
|
+
|
|
10479
|
+
class DispatchIneligibleError extends Error {
|
|
10480
|
+
constructor(reason, v2) {
|
|
10481
|
+
const origin = v2 ? "spec.origin: pages" : "origin: pages";
|
|
10482
|
+
super([
|
|
10483
|
+
`launchpad deploy: this new app cannot move to Workers dispatch, the default for new apps: ${reason}`,
|
|
10484
|
+
" Nothing was deployed. Pages is opt-in for new apps, and new Pages projects fail while the account is at its Pages limit.",
|
|
10485
|
+
` Fix that setting and run \`launchpad deploy\` again, or set \`${origin}\` in launchpad.yaml to choose Pages on purpose.`
|
|
10486
|
+
].join(`
|
|
10487
|
+
`));
|
|
9917
10488
|
}
|
|
9918
10489
|
}
|
|
9919
10490
|
var CONVERTIBLE_APP_TYPES = new Set(["static", "react", "react+api"]);
|
|
9920
|
-
function impliesPagesForGateway(
|
|
9921
|
-
const fields = originFields(manifestPath);
|
|
10491
|
+
function impliesPagesForGateway(fields) {
|
|
9922
10492
|
return CONVERTIBLE_APP_TYPES.has(fields.appType) && fields.origin === undefined && fields.auth === "gateway";
|
|
9923
10493
|
}
|
|
9924
10494
|
function originFields(manifestPath) {
|
|
@@ -9929,16 +10499,19 @@ function originFields(manifestPath) {
|
|
|
9929
10499
|
return {};
|
|
9930
10500
|
}
|
|
9931
10501
|
if (raw.apiVersion === "launchpad.m-kopa.us/v2")
|
|
9932
|
-
return raw.spec
|
|
10502
|
+
return { ...raw.spec, v2: true };
|
|
9933
10503
|
return { origin: raw.origin, auth: raw.auth, appType: raw.deployment?.type };
|
|
9934
10504
|
}
|
|
9935
|
-
function reportConversion(io, secrets) {
|
|
10505
|
+
function reportConversion(io, secrets, plainSecretLike) {
|
|
9936
10506
|
io.out("New apps deploy on Workers dispatch by default, so launchpad.yaml was converted (no Pages project needed).");
|
|
9937
10507
|
io.out(` Audience, owner and build settings are preserved. Original: ${BACKUP_PATH}`);
|
|
9938
10508
|
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.`);
|
|
9939
10509
|
const next = secretsNextStep(secrets);
|
|
9940
10510
|
if (next !== null)
|
|
9941
10511
|
io.out(` ${next}`);
|
|
10512
|
+
const warning = plainSecretWarning(plainSecretLike);
|
|
10513
|
+
if (warning !== null)
|
|
10514
|
+
io.err(` warning: ${warning}`);
|
|
9942
10515
|
}
|
|
9943
10516
|
function declaredOriginOf(isV22, origin) {
|
|
9944
10517
|
if (!isV22)
|
|
@@ -11789,7 +12362,7 @@ function buildManifest(inputs, detected) {
|
|
|
11789
12362
|
catalogue: { listed: false },
|
|
11790
12363
|
access
|
|
11791
12364
|
};
|
|
11792
|
-
const resolvedAuth = inputs.auth ??
|
|
12365
|
+
const resolvedAuth = inputs.auth ?? "gateway";
|
|
11793
12366
|
if (resolvedAuth === "gateway") {
|
|
11794
12367
|
manifest.auth = "gateway";
|
|
11795
12368
|
}
|