run402 4.82.0 → 4.84.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/cli.mjs +1 -1
- package/gitvault-surface.json +1 -1
- package/lib/deploy-v2.mjs +41 -71
- package/lib/doctor-source-scan.mjs +2 -547
- package/lib/doctor.mjs +28 -8
- package/lib/sdk-errors.mjs +7 -0
- package/lib/status.mjs +1 -1
- package/lib/up.mjs +62 -21
- package/lib/up.test.mjs +16 -0
- package/lib/update-check.mjs +11 -6
- package/lib/update-check.test.mjs +18 -5
- package/package.json +1 -1
- package/sdk/dist/actions.d.ts +16 -3
- package/sdk/dist/actions.d.ts.map +1 -1
- package/sdk/dist/config.d.ts +1 -1
- package/sdk/dist/config.d.ts.map +1 -1
- package/sdk/dist/config.js.map +1 -1
- package/sdk/dist/index.d.ts +2 -0
- package/sdk/dist/index.d.ts.map +1 -1
- package/sdk/dist/index.js +2 -0
- package/sdk/dist/index.js.map +1 -1
- package/sdk/dist/namespaces/deploy.d.ts.map +1 -1
- package/sdk/dist/namespaces/deploy.js +2 -1
- package/sdk/dist/namespaces/deploy.js.map +1 -1
- package/sdk/dist/namespaces/deploy.types.d.ts +6 -0
- package/sdk/dist/namespaces/deploy.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/edge-evidence.d.ts +22 -0
- package/sdk/dist/namespaces/edge-evidence.d.ts.map +1 -0
- package/sdk/dist/namespaces/edge-evidence.js +38 -0
- package/sdk/dist/namespaces/edge-evidence.js.map +1 -0
- package/sdk/dist/namespaces/projects.d.ts.map +1 -1
- package/sdk/dist/namespaces/projects.js +9 -7
- package/sdk/dist/namespaces/projects.js.map +1 -1
- package/sdk/dist/node/actions-node.d.ts +18 -0
- package/sdk/dist/node/actions-node.d.ts.map +1 -1
- package/sdk/dist/node/actions-node.js +139 -91
- package/sdk/dist/node/actions-node.js.map +1 -1
- package/sdk/dist/node/app-scope.d.ts +24 -0
- package/sdk/dist/node/app-scope.d.ts.map +1 -0
- package/sdk/dist/node/app-scope.js +47 -0
- package/sdk/dist/node/app-scope.js.map +1 -0
- package/sdk/dist/node/deploy-manifest.d.ts +6 -0
- package/sdk/dist/node/deploy-manifest.d.ts.map +1 -1
- package/sdk/dist/node/deploy-manifest.js +61 -0
- package/sdk/dist/node/deploy-manifest.js.map +1 -1
- package/sdk/dist/node/index.d.ts +6 -1
- package/sdk/dist/node/index.d.ts.map +1 -1
- package/sdk/dist/node/index.js +8 -2
- package/sdk/dist/node/index.js.map +1 -1
- package/sdk/dist/node/manifest-export.d.ts +5 -0
- package/sdk/dist/node/manifest-export.d.ts.map +1 -0
- package/sdk/dist/node/manifest-export.js +78 -0
- package/sdk/dist/node/manifest-export.js.map +1 -0
- package/sdk/dist/node/preflight.d.ts +65 -0
- package/sdk/dist/node/preflight.d.ts.map +1 -0
- package/sdk/dist/node/preflight.js +23 -0
- package/sdk/dist/node/preflight.js.map +1 -0
- package/sdk/dist/node/source-scan.d.ts +73 -0
- package/sdk/dist/node/source-scan.d.ts.map +1 -0
- package/sdk/dist/node/source-scan.js +552 -0
- package/sdk/dist/node/source-scan.js.map +1 -0
- package/sdk/dist/rest-diagnostics.d.ts +15 -0
- package/sdk/dist/rest-diagnostics.d.ts.map +1 -0
- package/sdk/dist/rest-diagnostics.js +19 -0
- package/sdk/dist/rest-diagnostics.js.map +1 -0
package/cli.mjs
CHANGED
|
@@ -134,7 +134,7 @@ Getting started:
|
|
|
134
134
|
run402 init Set up with x402 (Base Sepolia)
|
|
135
135
|
run402 init mpp Set up with MPP (Tempo Moderato)
|
|
136
136
|
run402 tier set prototype Subscribe to a tier
|
|
137
|
-
run402 deploy
|
|
137
|
+
run402 up --name my-app -y Create and deploy this app (explicit destination)
|
|
138
138
|
run402 ci link github --project prj_... --manifest run402.deploy.json
|
|
139
139
|
`;
|
|
140
140
|
|
package/gitvault-surface.json
CHANGED
package/lib/deploy-v2.mjs
CHANGED
|
@@ -32,6 +32,11 @@ import {
|
|
|
32
32
|
loadDeployManifest,
|
|
33
33
|
normalizeDeployManifest,
|
|
34
34
|
normalizeDeployResolveRequest,
|
|
35
|
+
resolveDeploymentTarget,
|
|
36
|
+
resolveApplicationScope,
|
|
37
|
+
scanDeploymentSources,
|
|
38
|
+
serializeDeployManifest,
|
|
39
|
+
describeLocalPreflight,
|
|
35
40
|
} from "#sdk/node";
|
|
36
41
|
import { getSdk } from "./sdk.mjs";
|
|
37
42
|
import { reportSdkError, fail } from "./sdk-errors.mjs";
|
|
@@ -47,8 +52,8 @@ import { sdkStats, printVerboseStats } from "./stats.mjs";
|
|
|
47
52
|
const APPLY_HELP = `run402 deploy apply — Unified deploy primitive (v1.34+)
|
|
48
53
|
|
|
49
54
|
Usage:
|
|
50
|
-
run402 deploy apply --manifest <path> [--project <id>] [--check|--print-spec|--plan|--require-plan <id>] [--no-rehearse] [--quiet|--final-only] [--json]
|
|
51
|
-
run402 deploy apply --spec '<json>' [--project <id>] [--check|--print-spec|--plan|--require-plan <id>] [--no-rehearse] [--quiet|--final-only] [--json]
|
|
55
|
+
run402 deploy apply --manifest <path> [--project <id>] [--check|--print-spec|--print-manifest|--plan|--require-plan <id>] [--no-rehearse] [--quiet|--final-only] [--json]
|
|
56
|
+
run402 deploy apply --spec '<json>' [--project <id>] [--check|--print-spec|--print-manifest|--plan|--require-plan <id>] [--no-rehearse] [--quiet|--final-only] [--json]
|
|
52
57
|
run402 deploy apply --dir <build-output> [--manifest <path>] [--project <id>]
|
|
53
58
|
cat spec.json | run402 deploy apply [--project <id>]
|
|
54
59
|
|
|
@@ -97,7 +102,9 @@ Options:
|
|
|
97
102
|
@run402/astro installed in the project.
|
|
98
103
|
--project <id> Override project_id from the manifest
|
|
99
104
|
--check Validate and normalize locally. No gateway calls or uploads.
|
|
100
|
-
--print-spec
|
|
105
|
+
--print-spec Advanced SDK-native inspection JSON, not authoring input.
|
|
106
|
+
--print-manifest Export snake_case authoring JSON relative to the original manifest
|
|
107
|
+
directory. Unsupported constructs fail; no gateway calls or uploads.
|
|
101
108
|
--plan Ask the gateway for a reviewed plan. No upload or commit.
|
|
102
109
|
--no-rehearse Skip the automatic rehearsal. By default a migration-bearing plan
|
|
103
110
|
against a project with a live release is rehearsed on a contained
|
|
@@ -768,7 +775,7 @@ function parseApplyArgs(args) {
|
|
|
768
775
|
allowDirty: false,
|
|
769
776
|
verbose: false,
|
|
770
777
|
};
|
|
771
|
-
const allowedFlags = ["--manifest", "--spec", "--dir", "--project", "--quiet", "--final-only", "--json", "--allow-warning", "--allow-warnings", "--check", "--print-spec", "--plan", "--no-rehearse", "--require-plan", "--plan-fingerprint", "--allow-dirty", "-v", "--verbose", "--help", "-h"];
|
|
778
|
+
const allowedFlags = ["--manifest", "--spec", "--dir", "--project", "--quiet", "--final-only", "--json", "--allow-warning", "--allow-warnings", "--check", "--print-spec", "--print-manifest", "--plan", "--no-rehearse", "--require-plan", "--plan-fingerprint", "--allow-dirty", "-v", "--verbose", "--help", "-h"];
|
|
772
779
|
|
|
773
780
|
for (let i = 0; i < args.length; i++) {
|
|
774
781
|
const arg = args[i];
|
|
@@ -831,6 +838,7 @@ function parseApplyArgs(args) {
|
|
|
831
838
|
if (arg === "-v" || arg === "--verbose") { opts.verbose = true; continue; }
|
|
832
839
|
if (arg === "--check") { setApplyMode(opts, "check", "--check"); continue; }
|
|
833
840
|
if (arg === "--print-spec") { setApplyMode(opts, "printSpec", "--print-spec"); continue; }
|
|
841
|
+
if (arg === "--print-manifest") { setApplyMode(opts, "printManifest", "--print-manifest"); continue; }
|
|
834
842
|
if (arg === "--plan") { setApplyMode(opts, "plan", "--plan"); continue; }
|
|
835
843
|
if (arg === "--no-rehearse") { opts.noRehearse = true; continue; }
|
|
836
844
|
if (typeof arg === "string" && arg.startsWith("-")) {
|
|
@@ -1159,28 +1167,38 @@ async function applyCmd(args) {
|
|
|
1159
1167
|
});
|
|
1160
1168
|
}
|
|
1161
1169
|
const useGithubActionsOidc = hasGithubActionsOidcEnv();
|
|
1162
|
-
|
|
1163
|
-
if (!opts.project && !manifestProject) {
|
|
1164
|
-
defaultProject = useGithubActionsOidc ? resolveCiProjectId() : resolveProjectId(null);
|
|
1165
|
-
}
|
|
1170
|
+
const defaultProject = "prj_up_preflight_placeholder";
|
|
1166
1171
|
|
|
1167
1172
|
let normalizedManifest;
|
|
1168
1173
|
try {
|
|
1169
1174
|
normalizedManifest = executableManifest
|
|
1170
1175
|
? await loadDeployManifest(manifestPath, {
|
|
1171
|
-
|
|
1176
|
+
|
|
1172
1177
|
...(defaultProject ? { defaultProject } : {}),
|
|
1178
|
+
validateFiles: true,
|
|
1173
1179
|
})
|
|
1174
1180
|
: await normalizeDeployManifest(spec, {
|
|
1175
1181
|
baseDir: manifestPath ? dirname(manifestPath) : process.cwd(),
|
|
1176
|
-
|
|
1182
|
+
|
|
1177
1183
|
...(defaultProject ? { defaultProject } : {}),
|
|
1178
1184
|
});
|
|
1179
1185
|
} catch (err) {
|
|
1180
1186
|
reportSdkError(err);
|
|
1181
1187
|
}
|
|
1182
1188
|
|
|
1189
|
+
const applicationScope = await resolveApplicationScope({ dir: opts.dir, manifest: manifestPath ?? undefined });
|
|
1183
1190
|
const releaseSpec = normalizedManifest.spec;
|
|
1191
|
+
let target;
|
|
1192
|
+
try {
|
|
1193
|
+
target = await resolveDeploymentTarget({
|
|
1194
|
+
appRoot: applicationScope.app_root,
|
|
1195
|
+
manifestPath: manifestPath ?? undefined, projectId: opts.project || undefined, environmentProjectId: process.env.RUN402_PROJECT_ID || undefined,
|
|
1196
|
+
manifestProjectId: manifestProject || (releaseSpec.project === "prj_up_preflight_placeholder" ? undefined : releaseSpec.project),
|
|
1197
|
+
targetKind: isCoreApiTarget() ? "core" : "cloud", apiBase: API,
|
|
1198
|
+
allowUnresolved: opts.mode === "check" || opts.mode === "printSpec" || opts.mode === "printManifest",
|
|
1199
|
+
});
|
|
1200
|
+
if (target.project_id) releaseSpec.project = target.project_id;
|
|
1201
|
+
} catch (err) { reportSdkError(err); }
|
|
1184
1202
|
const idempotencyKey = normalizedManifest.idempotencyKey;
|
|
1185
1203
|
|
|
1186
1204
|
// Filesystem-reference check: every function source, site file / dir and
|
|
@@ -1195,77 +1213,29 @@ async function applyCmd(args) {
|
|
|
1195
1213
|
reportSdkError(err);
|
|
1196
1214
|
}
|
|
1197
1215
|
|
|
1216
|
+
if (process.env.RUN402_DEPLOY_SKIP_SCAN !== "1") {
|
|
1217
|
+
const scan = scanDeploymentSources(releaseSpec, manifestPath ? dirname(manifestPath) : resolve(opts.dir || process.cwd()), opts.dir ? resolve(opts.dir) : undefined);
|
|
1218
|
+
if (scan.errors.length) fail({ code: "R402_AUTH_PREFLIGHT_FAILED", message: "Source scan blocked this application. Fix the reported findings, or explicitly override with RUN402_DEPLOY_SKIP_SCAN=1.", details: scan });
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1198
1221
|
if (opts.mode === "check") {
|
|
1199
1222
|
console.log(JSON.stringify({
|
|
1200
1223
|
ok: true,
|
|
1201
1224
|
mode: "check",
|
|
1202
|
-
project_id:
|
|
1203
|
-
|
|
1225
|
+
project_id: target.project_id,
|
|
1226
|
+
...describeLocalPreflight({ entryPoint: "deploy apply", appRoot: manifestPath ? dirname(manifestPath) : resolve(opts.dir || process.cwd()), manifestPath, authoring: normalizedManifest.manifest, spec: releaseSpec, target, apiBase: API }),
|
|
1204
1227
|
}, null, 2));
|
|
1205
1228
|
return;
|
|
1206
1229
|
}
|
|
1230
|
+
if (opts.mode === "printManifest") {
|
|
1231
|
+
try { console.log(JSON.stringify(serializeDeployManifest(normalizedManifest, manifestPath ? dirname(manifestPath) : process.cwd(), opts.project || process.env.RUN402_PROJECT_ID), null, 2)); } catch (err) { reportSdkError(err); }
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1207
1234
|
if (opts.mode === "printSpec") {
|
|
1208
|
-
console.log(JSON.stringify(releaseSpec, null, 2));
|
|
1235
|
+
console.log(JSON.stringify({ ...releaseSpec, project: target.project_id ?? undefined }, null, 2));
|
|
1209
1236
|
return;
|
|
1210
1237
|
}
|
|
1211
1238
|
|
|
1212
|
-
// Pre-flight source scan (auth-aware-ssr Section 9). Bypass via
|
|
1213
|
-
// RUN402_DEPLOY_SKIP_SCAN=1 — useful for forcing a deploy when
|
|
1214
|
-
// the scanner has a false positive that the operator has confirmed
|
|
1215
|
-
// is fine. Hits with severity `error` fail the deploy.
|
|
1216
|
-
//
|
|
1217
|
-
// Scope: a `--dir` (Astro SSR build) deploy walks that dir —
|
|
1218
|
-
// it IS the artifact. A manifest/spec/stdin deploy scans ONLY the
|
|
1219
|
-
// on-disk source files the manifest actually references, resolved
|
|
1220
|
-
// against the manifest's baseDir. We must NOT walk cwd/src for a
|
|
1221
|
-
// manifest deploy: running from inside an unrelated source tree (e.g.
|
|
1222
|
-
// the gateway monorepo, which legitimately has dozens of `getUser`
|
|
1223
|
-
// references) would otherwise block a deploy of one unrelated HTML file.
|
|
1224
|
-
if (!isNonApplyingMode(opts.mode) && process.env.RUN402_DEPLOY_SKIP_SCAN !== "1") {
|
|
1225
|
-
try {
|
|
1226
|
-
const { scanSourceTree, scanSourceFiles, SCAN_SEVERITY } = await import(
|
|
1227
|
-
"./doctor-source-scan.mjs"
|
|
1228
|
-
);
|
|
1229
|
-
const scannableExt = /\.(?:ts|tsx|js|jsx|mjs|cjs|astro)$/;
|
|
1230
|
-
let findings;
|
|
1231
|
-
if (opts.dir) {
|
|
1232
|
-
const scanRoot = isAbsolute(opts.dir)
|
|
1233
|
-
? opts.dir
|
|
1234
|
-
: resolve(process.cwd(), opts.dir);
|
|
1235
|
-
findings = scanSourceTree(scanRoot, { cwd: process.cwd() });
|
|
1236
|
-
} else {
|
|
1237
|
-
const baseDir = manifestPath ? dirname(manifestPath) : process.cwd();
|
|
1238
|
-
const files = collectManifestSourceFiles(spec ?? normalizedManifest.manifest, baseDir).filter(
|
|
1239
|
-
(p) => scannableExt.test(p) && existsSync(p),
|
|
1240
|
-
);
|
|
1241
|
-
findings = files.length > 0
|
|
1242
|
-
? scanSourceFiles(files, { cwd: process.cwd() })
|
|
1243
|
-
: [];
|
|
1244
|
-
}
|
|
1245
|
-
const errorFindings = findings.filter((f) => f.severity === SCAN_SEVERITY.ERROR);
|
|
1246
|
-
if (errorFindings.length > 0) {
|
|
1247
|
-
const summary = errorFindings.slice(0, 10).map((f) => {
|
|
1248
|
-
const loc = f.line ? `${f.file}:${f.line}` : f.file;
|
|
1249
|
-
return ` ${f.code} ${loc}\n ${f.message}${f.canonical_name ? `\n fix: ${f.canonical_name}` : ""}`;
|
|
1250
|
-
}).join("\n");
|
|
1251
|
-
const more = errorFindings.length > 10 ? `\n ...and ${errorFindings.length - 10} more` : "";
|
|
1252
|
-
fail({
|
|
1253
|
-
code: "R402_AUTH_PREFLIGHT_FAILED",
|
|
1254
|
-
message: `Source scan blocked deploy: ${errorFindings.length} R402_AUTH_* finding(s). Run \`run402 doctor\` for the full list. Bypass with RUN402_DEPLOY_SKIP_SCAN=1 if you're sure.`,
|
|
1255
|
-
details: { findings: errorFindings, summary: `${summary}${more}` },
|
|
1256
|
-
});
|
|
1257
|
-
}
|
|
1258
|
-
} catch (err) {
|
|
1259
|
-
if (err && typeof err === "object" && err.code === "R402_AUTH_PREFLIGHT_FAILED") {
|
|
1260
|
-
throw err;
|
|
1261
|
-
}
|
|
1262
|
-
// Scanner crashed — warn but don't block. The scanner is a safety
|
|
1263
|
-
// net; the deploy should proceed if it can't read the source tree.
|
|
1264
|
-
console.warn(
|
|
1265
|
-
`[deploy] source scan skipped: ${err instanceof Error ? err.message : String(err)}`,
|
|
1266
|
-
);
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
1239
|
|
|
1270
1240
|
let sdkOpts;
|
|
1271
1241
|
const delegateToken = delegateTokenFromEnv();
|
|
@@ -1380,7 +1350,7 @@ async function applyCmd(args) {
|
|
|
1380
1350
|
}
|
|
1381
1351
|
|
|
1382
1352
|
function isNonApplyingMode(mode) {
|
|
1383
|
-
return mode === "check" || mode === "printSpec" || mode === "plan";
|
|
1353
|
+
return mode === "check" || mode === "printSpec" || mode === "printManifest" || mode === "plan";
|
|
1384
1354
|
}
|
|
1385
1355
|
|
|
1386
1356
|
function hasGithubActionsOidcEnv(env = process.env) {
|