@gadicc/loom 1.15.5 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db/drizzle-config.d.ts +2 -1
- package/db/drizzle-config.js +6 -3
- package/esm/src/cli/migrationEnv.d.ts +21 -0
- package/esm/src/cli/migrationEnv.d.ts.map +1 -0
- package/esm/src/cli/migrationEnv.js +56 -0
- package/esm/src/cli/mod.d.ts +12 -0
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +216 -10
- package/esm/src/cli/vercelBuildEnv.d.ts +30 -0
- package/esm/src/cli/vercelBuildEnv.d.ts.map +1 -0
- package/esm/src/cli/vercelBuildEnv.js +186 -0
- package/package.json +2 -2
- package/script/src/cli/migrationEnv.d.ts +21 -0
- package/script/src/cli/migrationEnv.d.ts.map +1 -0
- package/script/src/cli/migrationEnv.js +60 -0
- package/script/src/cli/mod.d.ts +12 -0
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +217 -10
- package/script/src/cli/vercelBuildEnv.d.ts +30 -0
- package/script/src/cli/vercelBuildEnv.d.ts.map +1 -0
- package/script/src/cli/vercelBuildEnv.js +191 -0
- package/skills/loom/SKILL.md +9 -2
- package/skills/loom-db/SKILL.md +23 -9
package/db/drizzle-config.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import type { defineConfig } from "drizzle-kit";
|
|
|
3
3
|
export interface CreateDrizzleConfigOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Override the database URL variable. When omitted, Loom prefers
|
|
6
|
-
* `
|
|
6
|
+
* `MIGRATION_DATABASE_URL_UNPOOLED`, then `MIGRATION_DATABASE_URL`, before
|
|
7
|
+
* the gradual-adoption fallbacks `DATABASE_URL_UNPOOLED` and `DATABASE_URL`.
|
|
7
8
|
*/
|
|
8
9
|
databaseUrlEnvVar?: string;
|
|
9
10
|
/**
|
package/db/drizzle-config.js
CHANGED
|
@@ -6,9 +6,12 @@ export function createDrizzleConfig({
|
|
|
6
6
|
outDir,
|
|
7
7
|
schemaDir,
|
|
8
8
|
}) {
|
|
9
|
-
const databaseUrlEnvVars = databaseUrlEnvVar
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const databaseUrlEnvVars = databaseUrlEnvVar ? [databaseUrlEnvVar] : [
|
|
10
|
+
"MIGRATION_DATABASE_URL_UNPOOLED",
|
|
11
|
+
"MIGRATION_DATABASE_URL",
|
|
12
|
+
"DATABASE_URL_UNPOOLED",
|
|
13
|
+
"DATABASE_URL",
|
|
14
|
+
];
|
|
12
15
|
const resolvedDatabaseUrlEnvVar = databaseUrlEnvVars.find((envName) =>
|
|
13
16
|
process.env[envName]
|
|
14
17
|
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare const DEFAULT_MIGRATION_DATABASE_URL_ENV_NAMES: readonly ["MIGRATION_DATABASE_URL_UNPOOLED", "MIGRATION_DATABASE_URL", "DATABASE_URL_UNPOOLED", "DATABASE_URL"];
|
|
2
|
+
export type MigrationDatabaseUrlEnvName = typeof DEFAULT_MIGRATION_DATABASE_URL_ENV_NAMES[number];
|
|
3
|
+
export type MigrationEnvironmentResolution = {
|
|
4
|
+
database: string;
|
|
5
|
+
direct: boolean;
|
|
6
|
+
envName: MigrationDatabaseUrlEnvName;
|
|
7
|
+
hostname: string;
|
|
8
|
+
role: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Resolves and validates the migration database URL without returning or
|
|
12
|
+
* printing the credential itself.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveMigrationEnvironment(env: Record<string, string | undefined>): MigrationEnvironmentResolution;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves migration metadata from a preserved env snapshot while allowing
|
|
17
|
+
* process values, including a dedicated migration secret, to take precedence.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveMigrationEnvironmentFromEnvFile(envFile: string, env: Record<string, string | undefined>): MigrationEnvironmentResolution;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=migrationEnv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrationEnv.d.ts","sourceRoot":"","sources":["../../../src/src/cli/migrationEnv.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,wCAAwC,iHAKpC,CAAC;AAEX,MAAM,MAAM,2BAA2B,GACrC,OAAO,wCAAwC,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,2BAA2B,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAOF;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,8BAA8B,CA2ChC;AAED;;;GAGG;AACH,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,kCAIxC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { parseEnv } from "node:util";
|
|
3
|
+
const DEFAULT_MIGRATION_DATABASE_URL_ENV_NAMES = [
|
|
4
|
+
"MIGRATION_DATABASE_URL_UNPOOLED",
|
|
5
|
+
"MIGRATION_DATABASE_URL",
|
|
6
|
+
"DATABASE_URL_UNPOOLED",
|
|
7
|
+
"DATABASE_URL",
|
|
8
|
+
];
|
|
9
|
+
function isUsableDatabaseUrl(value) {
|
|
10
|
+
return Boolean(value?.trim()) &&
|
|
11
|
+
!/(?:sensitive|redacted)/i.test(value ?? "");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolves and validates the migration database URL without returning or
|
|
15
|
+
* printing the credential itself.
|
|
16
|
+
*/
|
|
17
|
+
export function resolveMigrationEnvironment(env) {
|
|
18
|
+
const envName = DEFAULT_MIGRATION_DATABASE_URL_ENV_NAMES.find((name) => isUsableDatabaseUrl(env[name]));
|
|
19
|
+
if (!envName) {
|
|
20
|
+
throw new Error(`${DEFAULT_MIGRATION_DATABASE_URL_ENV_NAMES.join(" or ")} is not defined with a usable database URL.`);
|
|
21
|
+
}
|
|
22
|
+
const value = env[envName];
|
|
23
|
+
let url;
|
|
24
|
+
try {
|
|
25
|
+
url = new URL(value);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
throw new Error(`${envName} is not a valid URL.`);
|
|
29
|
+
}
|
|
30
|
+
if (url.protocol !== "postgres:" && url.protocol !== "postgresql:") {
|
|
31
|
+
throw new Error(`${envName} must use the postgres or postgresql scheme.`);
|
|
32
|
+
}
|
|
33
|
+
if (!url.username || !url.hostname || !url.pathname.slice(1)) {
|
|
34
|
+
throw new Error(`${envName} must include a database role, hostname, and database name.`);
|
|
35
|
+
}
|
|
36
|
+
const role = decodeURIComponent(url.username);
|
|
37
|
+
const expectedRole = env.LOOM_MIGRATION_DATABASE_ROLE?.trim();
|
|
38
|
+
if (expectedRole && role !== expectedRole) {
|
|
39
|
+
throw new Error(`${envName} uses database role ${role}, but LOOM_MIGRATION_DATABASE_ROLE expects ${expectedRole}.`);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
database: decodeURIComponent(url.pathname.slice(1)),
|
|
43
|
+
direct: !/(?:^|-)pooler(?:\.|$)/i.test(url.hostname),
|
|
44
|
+
envName,
|
|
45
|
+
hostname: url.hostname,
|
|
46
|
+
role,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolves migration metadata from a preserved env snapshot while allowing
|
|
51
|
+
* process values, including a dedicated migration secret, to take precedence.
|
|
52
|
+
*/
|
|
53
|
+
export function resolveMigrationEnvironmentFromEnvFile(envFile, env) {
|
|
54
|
+
const pulledEnv = parseEnv(readFileSync(envFile, "utf8"));
|
|
55
|
+
return resolveMigrationEnvironment({ ...pulledEnv, ...env });
|
|
56
|
+
}
|
package/esm/src/cli/mod.d.ts
CHANGED
|
@@ -281,6 +281,18 @@ type GithubVercelReleaseSetupOptions = {
|
|
|
281
281
|
io?: CliOutput;
|
|
282
282
|
tokenName?: string;
|
|
283
283
|
};
|
|
284
|
+
type GithubMigrationCredentialSetupOptions = {
|
|
285
|
+
commandRunner?: CommandRunner;
|
|
286
|
+
env?: Record<string, string | undefined>;
|
|
287
|
+
environment?: string;
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* Stores an already-provisioned direct migration URL in a protected GitHub
|
|
291
|
+
* Environment without persisting or printing the credential.
|
|
292
|
+
*/
|
|
293
|
+
export declare function setupGithubMigrationCredential(cwd: string, options?: GithubMigrationCredentialSetupOptions): Promise<{
|
|
294
|
+
notes: string[];
|
|
295
|
+
}>;
|
|
284
296
|
export declare function setupGithubVercelRelease(cwd: string, options?: GithubVercelReleaseSetupOptions): Promise<{
|
|
285
297
|
notes: string[];
|
|
286
298
|
}>;
|
package/esm/src/cli/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"mappings":"AAwCA,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAC9C,eAAO,MAAM,oBAAoB,2DACyB,CAAC;AAC3D,eAAO,MAAM,yBAAyB,uCAAuC,CAAC;AAC9E,eAAO,MAAM,uBAAuB,qCAAqC,CAAC;AAC1E,eAAO,MAAM,8BAA8B,8CACE,CAAC;AAC9C,eAAO,MAAM,4BAA4B,4CACE,CAAC;AAC5C,eAAO,MAAM,+BAA+B,6BAA6B,CAAC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lC;AAED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EACrD,OAAO,GAAE,mBAAwB;;;eAMxB,MAAM;gBACL,sBAAsB;;;;GAyGjC;AAuFD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,uBAAuB,EAC9B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,YAoClD;AAu9BD,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,EAAE,SAAS,EACb,OAAO,GAAE;IACP,aAAa,CAAC,EAAE,aAAa,CAAC;CAC1B,mBAiBP;AA+kBD,wBAAsB,MAAM,CAC1B,IAAI,MAAwB,EAC5B,EAAE,GAAE,SAGH,mBAqKF"}
|
package/esm/src/cli/mod.js
CHANGED
|
@@ -8,6 +8,8 @@ import process from "node:process";
|
|
|
8
8
|
import { parseArgs } from "node:util";
|
|
9
9
|
import { DEFAULT_API_KEY_AUDIT_RETENTION } from "../apiKeys/retention.js";
|
|
10
10
|
import { checkProjectSkills, getProjectSkillStatus, LOOM_EXTERNAL_SKILLS_GITIGNORE_LINE, removeLegacyNextSkillLink, setProjectSkillDisabled, syncExternalProjectSkills, syncInstalledPackageSkills, } from "./projectSkills.js";
|
|
11
|
+
import { resolveMigrationEnvironment, resolveMigrationEnvironmentFromEnvFile, } from "./migrationEnv.js";
|
|
12
|
+
import { prepareVercelBuildEnvironment, verifyVercelBuildArtifact, } from "./vercelBuildEnv.js";
|
|
11
13
|
export const DEFAULT_LOOM_RANGE = "^1.0.0";
|
|
12
14
|
export const LOOM_DEPENDENCY = "@gadicc/loom";
|
|
13
15
|
export const LOOM_MANIFEST_SCHEMA = "https://loom.gadicc.local/project-manifest.schema.json";
|
|
@@ -43,6 +45,15 @@ const REQUIRED_GITHUB_VERCEL_ID_NAMES = [
|
|
|
43
45
|
"VERCEL_ORG_ID",
|
|
44
46
|
"VERCEL_PROJECT_ID",
|
|
45
47
|
];
|
|
48
|
+
const GITHUB_MIGRATION_DATABASE_SECRET_NAME = "MIGRATION_DATABASE_URL_UNPOOLED";
|
|
49
|
+
const GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME = "LOOM_MIGRATION_DATABASE_ROLE";
|
|
50
|
+
const LEGACY_GITHUB_MIGRATION_DATABASE_SECRET_NAME = "DATABASE_URL_UNPOOLED";
|
|
51
|
+
const GITHUB_DATABASE_URL_VARIABLE_NAMES = [
|
|
52
|
+
"DATABASE_URL",
|
|
53
|
+
"DATABASE_URL_UNPOOLED",
|
|
54
|
+
"MIGRATION_DATABASE_URL",
|
|
55
|
+
"MIGRATION_DATABASE_URL_UNPOOLED",
|
|
56
|
+
];
|
|
46
57
|
const STALE_GITHUB_RELEASE_SECRET_NAMES = [
|
|
47
58
|
"DATABASE_URL",
|
|
48
59
|
"VERCEL_DEPLOY_HOOK",
|
|
@@ -2773,11 +2784,20 @@ function workflowStepQueriesVercelProductionEnvMetadata(block) {
|
|
|
2773
2784
|
/\s--format(?:=|\s+)json\b/.test(block);
|
|
2774
2785
|
}
|
|
2775
2786
|
function workflowStepPreparesVercelBuildEnv(block) {
|
|
2776
|
-
return /\bvercel-build-env(?:\.mjs)?\b[\s\S]*\bprepare\b/.test(block)
|
|
2787
|
+
return (/\bvercel-build-env(?:\.mjs)?\b[\s\S]*\bprepare\b/.test(block) ||
|
|
2788
|
+
/\bloom\b[\s\S]*\bdb\s+release\s+prepare-build-env\b/.test(block));
|
|
2777
2789
|
}
|
|
2778
2790
|
function workflowStepVerifiesVercelBuildEnv(block) {
|
|
2779
|
-
return /\bvercel-build-env(?:\.mjs)?\b[\s\S]*\bverify\b/.test(block)
|
|
2780
|
-
/\.vercel\/output\b/.test(block);
|
|
2791
|
+
return (/\bvercel-build-env(?:\.mjs)?\b[\s\S]*\bverify\b/.test(block) ||
|
|
2792
|
+
/\bloom\b[\s\S]*\bdb\s+release\s+verify-build-env\b/.test(block)) && /\.vercel\/output\b/.test(block);
|
|
2793
|
+
}
|
|
2794
|
+
function workflowStepVerifiesMigrationEnv(block) {
|
|
2795
|
+
return /\bloom\b[\s\S]*\bdb\s+migrations\s+verify-env\b/.test(block);
|
|
2796
|
+
}
|
|
2797
|
+
function workflowStepVerifiesMigrationEnvWithPulledSnapshot(block) {
|
|
2798
|
+
return workflowStepVerifiesMigrationEnv(block) &&
|
|
2799
|
+
/--env-file(?:=|\s+)["']?\$RUNNER_TEMP\/vercel-production\.env["']?/
|
|
2800
|
+
.test(block);
|
|
2781
2801
|
}
|
|
2782
2802
|
function workflowStepStagesVercelProductionDeployment(block) {
|
|
2783
2803
|
return workflowStepUsesVercelCommand(block, "deploy") &&
|
|
@@ -2813,6 +2833,12 @@ function workflowUsesGithubDatabaseUrlSecret(text) {
|
|
|
2813
2833
|
function workflowUsesGithubUnpooledDatabaseUrlSecret(text) {
|
|
2814
2834
|
return /\$\{\{\s*secrets\.DATABASE_URL_UNPOOLED\s*\}\}/.test(text);
|
|
2815
2835
|
}
|
|
2836
|
+
function workflowUsesGithubMigrationDatabaseUrlSecret(text) {
|
|
2837
|
+
return /\$\{\{\s*secrets\.MIGRATION_DATABASE_URL(?:_UNPOOLED)?\s*\}\}/.test(text);
|
|
2838
|
+
}
|
|
2839
|
+
function workflowUsesGithubDatabaseUrlVariable(text) {
|
|
2840
|
+
return /\$\{\{\s*vars\.(?:MIGRATION_)?DATABASE_URL(?:_UNPOOLED)?\s*\}\}/.test(text);
|
|
2841
|
+
}
|
|
2816
2842
|
function getGithubWorkflowJobBlocks(text) {
|
|
2817
2843
|
const lines = normalizeText(text).split("\n");
|
|
2818
2844
|
const jobsIndex = lines.findIndex((line) => /^\s*jobs:\s*(?:#.*)?$/.test(line));
|
|
@@ -2868,6 +2894,7 @@ function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
|
2868
2894
|
const metadataStepIndex = job.stepBlocks.findIndex(workflowStepQueriesVercelProductionEnvMetadata);
|
|
2869
2895
|
const prepareBuildEnvStepIndex = job.stepBlocks.findIndex(workflowStepPreparesVercelBuildEnv);
|
|
2870
2896
|
const verifyBuildEnvStepIndex = job.stepBlocks.findIndex(workflowStepVerifiesVercelBuildEnv);
|
|
2897
|
+
const migrationVerifyStepIndex = job.stepBlocks.findIndex(workflowStepVerifiesMigrationEnv);
|
|
2871
2898
|
const stageStepIndex = job.stepBlocks.findIndex(workflowStepStagesVercelProductionDeployment);
|
|
2872
2899
|
const migrateStepIndex = job.stepBlocks.findIndex(workflowStepRunsDbMigrate);
|
|
2873
2900
|
const migrateWithVercelProductionEnvStepIndex = job.stepBlocks.findIndex(workflowStepRunsDbMigrateWithVercelProductionEnv);
|
|
@@ -2876,6 +2903,9 @@ function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
|
2876
2903
|
const migrateStep = migrateStepIndex >= 0
|
|
2877
2904
|
? job.stepBlocks[migrateStepIndex]
|
|
2878
2905
|
: "";
|
|
2906
|
+
const migrationVerifyStep = migrationVerifyStepIndex >= 0
|
|
2907
|
+
? job.stepBlocks[migrationVerifyStepIndex]
|
|
2908
|
+
: "";
|
|
2879
2909
|
const promoteStep = promoteStepIndex >= 0
|
|
2880
2910
|
? job.stepBlocks[promoteStepIndex]
|
|
2881
2911
|
: "";
|
|
@@ -2886,6 +2916,8 @@ function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
|
2886
2916
|
hasWorkflowEnvBinding(migrateStep, "DATABASE_URL"),
|
|
2887
2917
|
id: job.id,
|
|
2888
2918
|
metadataStepIndex,
|
|
2919
|
+
migrationVerifyStepIndex,
|
|
2920
|
+
migrationVerifyUsesPulledSnapshot: workflowStepVerifiesMigrationEnvWithPulledSnapshot(migrationVerifyStep),
|
|
2889
2921
|
migrateStepIndex,
|
|
2890
2922
|
migrateStepRestoresPulledEnv: workflowStepRestoresVercelMigrationEnv(migrateStep),
|
|
2891
2923
|
migrateWithVercelProductionEnvStepIndex,
|
|
@@ -2904,8 +2936,10 @@ function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
|
2904
2936
|
return {
|
|
2905
2937
|
jobs,
|
|
2906
2938
|
mainPush: githubWorkflowRunsOnMainPush(normalized),
|
|
2939
|
+
usesGithubDatabaseUrlVariable: workflowUsesGithubDatabaseUrlVariable(normalized),
|
|
2907
2940
|
relativePath,
|
|
2908
2941
|
usesGithubDatabaseUrlSecret: workflowUsesGithubDatabaseUrlSecret(normalized),
|
|
2942
|
+
usesGithubMigrationDatabaseUrlSecret: workflowUsesGithubMigrationDatabaseUrlSecret(normalized),
|
|
2909
2943
|
usesGithubUnpooledDatabaseUrlSecret: workflowUsesGithubUnpooledDatabaseUrlSecret(normalized),
|
|
2910
2944
|
usesOldVercelDeployHook: workflowUsesOldVercelDeployHook(normalized),
|
|
2911
2945
|
};
|
|
@@ -2925,7 +2959,8 @@ function dbMigrationJobHasOrderedStagedRelease(job) {
|
|
|
2925
2959
|
function dbMigrationWorkflowIsValid(workflow) {
|
|
2926
2960
|
return workflow.jobs.some((job) => dbMigrationJobHasOrderedStagedRelease(job) &&
|
|
2927
2961
|
job.promoteStepUsesExplicitScope &&
|
|
2928
|
-
workflow.
|
|
2962
|
+
(workflow.usesGithubMigrationDatabaseUrlSecret ||
|
|
2963
|
+
workflow.usesGithubUnpooledDatabaseUrlSecret));
|
|
2929
2964
|
}
|
|
2930
2965
|
function isJsonObject(value) {
|
|
2931
2966
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -2983,6 +3018,13 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
2983
3018
|
const validMigrationWorkflow = mainPushWorkflows.find(dbMigrationWorkflowIsValid);
|
|
2984
3019
|
const oldDeployHookWorkflows = mainPushWorkflows.filter((inspection) => inspection.usesOldVercelDeployHook);
|
|
2985
3020
|
const duplicatedDatabaseUrlWorkflows = mainPushWorkflows.filter((inspection) => inspection.usesGithubDatabaseUrlSecret);
|
|
3021
|
+
const databaseUrlVariableWorkflows = mainPushWorkflows.filter((inspection) => inspection.usesGithubDatabaseUrlVariable);
|
|
3022
|
+
const legacyUnpooledSecretWorkflows = mainPushWorkflows.filter((inspection) => inspection.usesGithubUnpooledDatabaseUrlSecret &&
|
|
3023
|
+
!inspection.usesGithubMigrationDatabaseUrlSecret);
|
|
3024
|
+
const invalidMigrationValidationPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.flatMap((job) => job.migrationVerifyStepIndex >= 0 &&
|
|
3025
|
+
!job.migrationVerifyUsesPulledSnapshot
|
|
3026
|
+
? [inspection.relativePath]
|
|
3027
|
+
: []));
|
|
2986
3028
|
const vercelCurlWorkflowPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.some((job) => job.vercelCurlStepIndex >= 0)
|
|
2987
3029
|
? [inspection.relativePath]
|
|
2988
3030
|
: []);
|
|
@@ -3018,8 +3060,9 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3018
3060
|
findings.push("DB production migration flow does not restore the untouched pulled env before migrations: " +
|
|
3019
3061
|
migrationWorkflowPaths.join(", "));
|
|
3020
3062
|
}
|
|
3021
|
-
else if (!mainPushWorkflows.some((inspection) => inspection.
|
|
3022
|
-
|
|
3063
|
+
else if (!mainPushWorkflows.some((inspection) => inspection.usesGithubMigrationDatabaseUrlSecret ||
|
|
3064
|
+
inspection.usesGithubUnpooledDatabaseUrlSecret)) {
|
|
3065
|
+
findings.push("DB production migration flow is not ready for Sensitive database variables because it lacks a GitHub migration-secret binding: " +
|
|
3023
3066
|
migrationWorkflowPaths.join(", "));
|
|
3024
3067
|
}
|
|
3025
3068
|
else if (mainPushWorkflows.some((inspection) => inspection.jobs.some((job) => dbMigrationJobHasOrderedStagedRelease(job) &&
|
|
@@ -3031,7 +3074,24 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3031
3074
|
findings.push("DB production migration flow does not order build, staged deploy, migration, and promotion correctly: " +
|
|
3032
3075
|
migrationWorkflowPaths.join(", "));
|
|
3033
3076
|
}
|
|
3034
|
-
suggestions.add('Add a production GitHub Actions workflow that runs `vercel pull --environment=production --scope "$VERCEL_ORG_ID"`, preserves an untouched migration snapshot, masks usable pulled values, queries `vercel env ls production --format=json`, adds unique placeholders
|
|
3077
|
+
suggestions.add('Add a production GitHub Actions workflow that runs `vercel pull --environment=production --scope "$VERCEL_ORG_ID"`, preserves an untouched migration snapshot, masks usable pulled values, queries `vercel env ls production --format=json`, adds unique build-only placeholders for unreadable Sensitive values, runs `vercel build --prod --scope "$VERCEL_ORG_ID"`, rejects placeholder leakage from `.vercel/output`, stages with `vercel deploy --prebuilt --prod --skip-domain --scope "$VERCEL_ORG_ID"`, restores the migration snapshot with an optional GitHub `MIGRATION_DATABASE_URL_UNPOOLED` override, runs migrations, then runs `vercel promote --scope "$VERCEL_ORG_ID"`.');
|
|
3078
|
+
}
|
|
3079
|
+
if (invalidMigrationValidationPaths.length) {
|
|
3080
|
+
findings.push("DB production migration validation does not load the preserved Vercel production env snapshot: " +
|
|
3081
|
+
[...new Set(invalidMigrationValidationPaths)].join(", "));
|
|
3082
|
+
suggestions.add('Run `loom db migrations verify-env --env-file "$RUNNER_TEMP/vercel-production.env"` so the optional GitHub migration secret overlays the readable gradual-adoption pull snapshot.');
|
|
3083
|
+
}
|
|
3084
|
+
if (legacyUnpooledSecretWorkflows.length) {
|
|
3085
|
+
warnings.push("DB production migration flow still uses the gradual-adoption GitHub secret `DATABASE_URL_UNPOOLED` instead of the migration-scoped `MIGRATION_DATABASE_URL_UNPOOLED`: " +
|
|
3086
|
+
legacyUnpooledSecretWorkflows.map((workflow) => workflow.relativePath)
|
|
3087
|
+
.join(", "));
|
|
3088
|
+
suggestions.add("When rotating the migration credential, store the new direct URL as the protected GitHub Environment secret `MIGRATION_DATABASE_URL_UNPOOLED` and update the workflow binding. The existing `DATABASE_URL_UNPOOLED` flow remains supported during gradual adoption.");
|
|
3089
|
+
}
|
|
3090
|
+
if (databaseUrlVariableWorkflows.length) {
|
|
3091
|
+
warnings.push("DB production migration flow reads a database URL from a readable GitHub Actions variable: " +
|
|
3092
|
+
databaseUrlVariableWorkflows.map((workflow) => workflow.relativePath)
|
|
3093
|
+
.join(", "));
|
|
3094
|
+
suggestions.add("Rotate that credential into the protected GitHub Environment secret `MIGRATION_DATABASE_URL_UNPOOLED`; keep GitHub variables for non-secret IDs and the expected migration role only.");
|
|
3035
3095
|
}
|
|
3036
3096
|
if (oldDeployHookWorkflows.length) {
|
|
3037
3097
|
findings.push("DB production migration flow still references a Vercel Deploy Hook: " +
|
|
@@ -3042,7 +3102,7 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3042
3102
|
findings.push("DB production migration flow still reads `secrets.DATABASE_URL` from GitHub: " +
|
|
3043
3103
|
duplicatedDatabaseUrlWorkflows.map((workflow) => workflow.relativePath)
|
|
3044
3104
|
.join(", "));
|
|
3045
|
-
suggestions.add("Remove the duplicate GitHub `DATABASE_URL`. While Vercel database variables remain readable, migrate with an untouched `vercel pull` snapshot; before making them Sensitive, store only `
|
|
3105
|
+
suggestions.add("Remove the duplicate GitHub `DATABASE_URL`. While Vercel database variables remain readable, migrate with an untouched `vercel pull` snapshot; before making them Sensitive, store only `MIGRATION_DATABASE_URL_UNPOOLED` in the protected GitHub Environment and expose it to the migration step.");
|
|
3046
3106
|
}
|
|
3047
3107
|
if (vercelCurlWorkflowPaths.length) {
|
|
3048
3108
|
findings.push("DB production migration flow still uses beta `vercel curl` for smoke checks: " +
|
|
@@ -5424,6 +5484,32 @@ function createGithubReleaseConfigCheckStep(state, context) {
|
|
|
5424
5484
|
suggestions.add(`After confirming no other workflow uses it, run \`gh secret delete ${staleSecret}\`.`);
|
|
5425
5485
|
}
|
|
5426
5486
|
}
|
|
5487
|
+
const hasCanonicalMigrationSecret = environmentSecrets.names.has(GITHUB_MIGRATION_DATABASE_SECRET_NAME);
|
|
5488
|
+
const hasRepositoryCanonicalMigrationSecret = repoSecrets.names.has(GITHUB_MIGRATION_DATABASE_SECRET_NAME);
|
|
5489
|
+
const hasLegacyMigrationSecret = collectionHasName(LEGACY_GITHUB_MIGRATION_DATABASE_SECRET_NAME, environmentSecrets, repoSecrets);
|
|
5490
|
+
if (!hasCanonicalMigrationSecret) {
|
|
5491
|
+
if (hasRepositoryCanonicalMigrationSecret) {
|
|
5492
|
+
warnings.push(`GitHub Actions stores ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} at repository scope instead of the protected ${PRODUCTION_GITHUB_ENVIRONMENT} environment.`);
|
|
5493
|
+
}
|
|
5494
|
+
else if (hasLegacyMigrationSecret) {
|
|
5495
|
+
warnings.push(`GitHub Actions still uses the gradual-adoption migration secret ${LEGACY_GITHUB_MIGRATION_DATABASE_SECRET_NAME}; rotate into ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} when convenient.`);
|
|
5496
|
+
}
|
|
5497
|
+
else {
|
|
5498
|
+
warnings.push(`GitHub Actions has no dedicated ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} production secret. The existing pulled Vercel URL remains supported while it is readable.`);
|
|
5499
|
+
}
|
|
5500
|
+
suggestions.add("Provision a dedicated direct migration credential, then run `loom db migrations setup-github` to store it without making the Vercel integration variables Sensitive yet.");
|
|
5501
|
+
}
|
|
5502
|
+
if (hasCanonicalMigrationSecret &&
|
|
5503
|
+
findGithubVariableValue(GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME, environmentVariables, repoVariables) === null) {
|
|
5504
|
+
warnings.push(`GitHub Actions has ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} but no ${GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME} metadata variable.`);
|
|
5505
|
+
suggestions.add("Run `loom db migrations setup-github` with the migration URL loaded in the environment so Loom can record the expected non-secret role.");
|
|
5506
|
+
}
|
|
5507
|
+
for (const name of GITHUB_DATABASE_URL_VARIABLE_NAMES) {
|
|
5508
|
+
if (collectionHasName(name, environmentVariables, repoVariables)) {
|
|
5509
|
+
warnings.push(`GitHub Actions stores database credential ${name} as a readable variable.`);
|
|
5510
|
+
suggestions.add(`Rotate ${name} into the protected ${PRODUCTION_GITHUB_ENVIRONMENT} Environment secret ${GITHUB_MIGRATION_DATABASE_SECRET_NAME}, then delete the readable variable.`);
|
|
5511
|
+
}
|
|
5512
|
+
}
|
|
5427
5513
|
if (collectionHasName("VERCEL_DEPLOY_HOOK", environmentSecrets, repoSecrets) ||
|
|
5428
5514
|
[...STALE_GITHUB_RELEASE_SECRET_NAMES].some((name) => name.startsWith("VERCEL_DEPLOY") &&
|
|
5429
5515
|
collectionHasName(name, environmentSecrets, repoSecrets))) {
|
|
@@ -6014,6 +6100,54 @@ export async function setupVercelNeon(cwd, options = {}) {
|
|
|
6014
6100
|
notes,
|
|
6015
6101
|
};
|
|
6016
6102
|
}
|
|
6103
|
+
/**
|
|
6104
|
+
* Stores an already-provisioned direct migration URL in a protected GitHub
|
|
6105
|
+
* Environment without persisting or printing the credential.
|
|
6106
|
+
*/
|
|
6107
|
+
export async function setupGithubMigrationCredential(cwd, options = {}) {
|
|
6108
|
+
const commandRunner = options.commandRunner ?? defaultCommandRunner;
|
|
6109
|
+
const env = options.env ?? process.env;
|
|
6110
|
+
const environment = options.environment ?? PRODUCTION_GITHUB_ENVIRONMENT;
|
|
6111
|
+
const migration = resolveMigrationEnvironment(env);
|
|
6112
|
+
if (!migration.envName.startsWith("MIGRATION_")) {
|
|
6113
|
+
throw new Error(`Load ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} in the process environment before running \`loom db migrations setup-github\`; application database fallbacks are not copied into GitHub.`);
|
|
6114
|
+
}
|
|
6115
|
+
if (!migration.direct) {
|
|
6116
|
+
throw new Error(`${migration.envName} appears pooled. Configure a direct, unpooled migration connection before storing it in GitHub.`);
|
|
6117
|
+
}
|
|
6118
|
+
const githubCli = await detectGithubCliCommand(cwd, commandRunner, env);
|
|
6119
|
+
if (!githubCli.command) {
|
|
6120
|
+
throw new Error("GitHub CLI is not available. Install and authenticate `gh` before running `loom db migrations setup-github`.");
|
|
6121
|
+
}
|
|
6122
|
+
await requireCommand(`Set GitHub ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} secret`, commandRunner, githubCli.command, [
|
|
6123
|
+
"secret",
|
|
6124
|
+
"set",
|
|
6125
|
+
GITHUB_MIGRATION_DATABASE_SECRET_NAME,
|
|
6126
|
+
"--env",
|
|
6127
|
+
environment,
|
|
6128
|
+
], {
|
|
6129
|
+
cwd,
|
|
6130
|
+
env,
|
|
6131
|
+
input: env[migration.envName],
|
|
6132
|
+
stdio: "pipe",
|
|
6133
|
+
});
|
|
6134
|
+
await requireCommand(`Set GitHub ${GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME} variable`, commandRunner, githubCli.command, [
|
|
6135
|
+
"variable",
|
|
6136
|
+
"set",
|
|
6137
|
+
GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME,
|
|
6138
|
+
"--env",
|
|
6139
|
+
environment,
|
|
6140
|
+
"--body",
|
|
6141
|
+
migration.role,
|
|
6142
|
+
], { cwd, env, stdio: "pipe" });
|
|
6143
|
+
return {
|
|
6144
|
+
notes: [
|
|
6145
|
+
`Stored ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} in the protected GitHub \`${environment}\` environment.`,
|
|
6146
|
+
`Recorded migration role ${migration.role} as ${GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME}.`,
|
|
6147
|
+
"Vercel application database variables were not changed.",
|
|
6148
|
+
],
|
|
6149
|
+
};
|
|
6150
|
+
}
|
|
6017
6151
|
export async function setupGithubVercelRelease(cwd, options = {}) {
|
|
6018
6152
|
const commandRunner = options.commandRunner ?? defaultCommandRunner;
|
|
6019
6153
|
const env = options.env ?? process.env;
|
|
@@ -8476,7 +8610,11 @@ function printHelp({ out }) {
|
|
|
8476
8610
|
out(" db schemas sync Materialize active Loom-managed DB schema blueprints into app-local schema files.");
|
|
8477
8611
|
out(" db neon setup Provision and connect a Vercel-managed Neon database for Production and Preview.");
|
|
8478
8612
|
out(" db neon check Run the DB/Neon network checks registered for the active DB feature.");
|
|
8613
|
+
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials. Accepts --env-file <path>.");
|
|
8614
|
+
out(" db migrations setup-github Store an existing direct migration URL as a protected GitHub Environment secret.");
|
|
8479
8615
|
out(" db release setup-github Create/update GitHub production release config for staged Vercel deploys.");
|
|
8616
|
+
out(" db release prepare-build-env <env> <metadata> <policy> <manifest> Prepare metadata-backed placeholders for an external Vercel build.");
|
|
8617
|
+
out(" db release verify-build-env <output> <manifest> Reject build-only placeholders in a deployable Vercel artifact.");
|
|
8480
8618
|
out(" dev local Enable local Loom development using a managed file: override in pnpm-workspace.yaml.");
|
|
8481
8619
|
out(" dev sync Rebuild the local Loom package and refresh this project's pnpm install when the managed local-dev override is active.");
|
|
8482
8620
|
out(" dev published Remove the managed local-dev override and return to the published dependency.");
|
|
@@ -8505,6 +8643,8 @@ function printHelp({ out }) {
|
|
|
8505
8643
|
out(" --configure-secrets Ask Vercel to prompt securely for missing R2 credentials; never replaces existing credentials.");
|
|
8506
8644
|
out(" --repair Apply declared non-secret Files provider drift; never deletes resources or rotates credentials.");
|
|
8507
8645
|
out(" --token-name <name> Override the Vercel token name for `loom db release setup-github`.");
|
|
8646
|
+
out(" --environment <name> GitHub Environment for migration credential setup (default production).");
|
|
8647
|
+
out(" --env-file <path> Preserved env snapshot for `db migrations verify-env`; process values take precedence.");
|
|
8508
8648
|
out(" --resource <name> Permission resource for API-key integration.");
|
|
8509
8649
|
out(" --action <name> Permission action for API-key integration.");
|
|
8510
8650
|
out(" --allow-query Allow the integration's explicit query credential transport.");
|
|
@@ -9031,14 +9171,39 @@ async function runDbNeon(cwd, command, io, options) {
|
|
|
9031
9171
|
return 1;
|
|
9032
9172
|
}
|
|
9033
9173
|
}
|
|
9034
|
-
async function runDbRelease(cwd, command, io, options) {
|
|
9174
|
+
async function runDbRelease(cwd, command, args, io, options) {
|
|
9035
9175
|
if (!command) {
|
|
9036
9176
|
io.err("Missing release subcommand. Example: `loom db release setup-github`.");
|
|
9037
9177
|
return 1;
|
|
9038
9178
|
}
|
|
9039
9179
|
switch (command) {
|
|
9180
|
+
case "prepare-build-env": {
|
|
9181
|
+
if (args.length !== 4) {
|
|
9182
|
+
io.err("Usage: loom db release prepare-build-env <env-file> <metadata-file> <policy-file> <manifest-file>");
|
|
9183
|
+
return 1;
|
|
9184
|
+
}
|
|
9185
|
+
prepareVercelBuildEnvironment({
|
|
9186
|
+
envFile: resolve(cwd, args[0]),
|
|
9187
|
+
manifestFile: resolve(cwd, args[3]),
|
|
9188
|
+
metadataFile: resolve(cwd, args[1]),
|
|
9189
|
+
policyFile: resolve(cwd, args[2]),
|
|
9190
|
+
}, io);
|
|
9191
|
+
return 0;
|
|
9192
|
+
}
|
|
9193
|
+
case "verify-build-env": {
|
|
9194
|
+
if (args.length !== 2) {
|
|
9195
|
+
io.err("Usage: loom db release verify-build-env <output-directory> <manifest-file>");
|
|
9196
|
+
return 1;
|
|
9197
|
+
}
|
|
9198
|
+
verifyVercelBuildArtifact({
|
|
9199
|
+
manifestFile: resolve(cwd, args[1]),
|
|
9200
|
+
outputDirectory: resolve(cwd, args[0]),
|
|
9201
|
+
}, io);
|
|
9202
|
+
return 0;
|
|
9203
|
+
}
|
|
9040
9204
|
case "setup-github": {
|
|
9041
9205
|
const result = await setupGithubVercelRelease(cwd, {
|
|
9206
|
+
environment: options.environment,
|
|
9042
9207
|
io,
|
|
9043
9208
|
tokenName: options.tokenName,
|
|
9044
9209
|
});
|
|
@@ -9054,6 +9219,41 @@ async function runDbRelease(cwd, command, io, options) {
|
|
|
9054
9219
|
return 1;
|
|
9055
9220
|
}
|
|
9056
9221
|
}
|
|
9222
|
+
async function runDbMigrations(cwd, command, io, options) {
|
|
9223
|
+
if (!command) {
|
|
9224
|
+
io.err("Missing migrations subcommand. Example: `loom db migrations verify-env`.");
|
|
9225
|
+
return 1;
|
|
9226
|
+
}
|
|
9227
|
+
switch (command) {
|
|
9228
|
+
case "setup-github": {
|
|
9229
|
+
const result = await setupGithubMigrationCredential(cwd, {
|
|
9230
|
+
environment: options.environment,
|
|
9231
|
+
});
|
|
9232
|
+
for (const note of result.notes) {
|
|
9233
|
+
io.out(`Note: ${note}`);
|
|
9234
|
+
}
|
|
9235
|
+
io.out("Next step: update the release workflow to bind `secrets.MIGRATION_DATABASE_URL_UNPOOLED`, then run `loom check --production --network`.");
|
|
9236
|
+
return 0;
|
|
9237
|
+
}
|
|
9238
|
+
case "verify-env": {
|
|
9239
|
+
const result = options.envFile
|
|
9240
|
+
? resolveMigrationEnvironmentFromEnvFile(resolve(cwd, options.envFile), process.env)
|
|
9241
|
+
: resolveMigrationEnvironment(process.env);
|
|
9242
|
+
io.out(`Migration database environment is usable: ${result.envName} selects role ${result.role} and database ${result.database}.`);
|
|
9243
|
+
if (!result.envName.startsWith("MIGRATION_")) {
|
|
9244
|
+
io.out("Warning: using the gradual-adoption application database fallback; prefer MIGRATION_DATABASE_URL_UNPOOLED after provisioning a dedicated migration credential.");
|
|
9245
|
+
}
|
|
9246
|
+
if (!result.direct) {
|
|
9247
|
+
io.out("Warning: the selected URL appears pooled; migrations should prefer a direct, unpooled connection.");
|
|
9248
|
+
}
|
|
9249
|
+
return 0;
|
|
9250
|
+
}
|
|
9251
|
+
default:
|
|
9252
|
+
io.err(`Unknown migrations subcommand: ${command}`);
|
|
9253
|
+
io.err("Run `loom --help` for usage.");
|
|
9254
|
+
return 1;
|
|
9255
|
+
}
|
|
9256
|
+
}
|
|
9057
9257
|
async function runDb(cwd, command, args, io, options = {}) {
|
|
9058
9258
|
if (!command) {
|
|
9059
9259
|
io.err("Missing db subcommand. Example: `loom db schema-gen`.");
|
|
@@ -9068,8 +9268,10 @@ async function runDb(cwd, command, args, io, options = {}) {
|
|
|
9068
9268
|
return await runDbSchemas(cwd, args[0], io);
|
|
9069
9269
|
case "neon":
|
|
9070
9270
|
return await runDbNeon(cwd, args[0], io, options);
|
|
9271
|
+
case "migrations":
|
|
9272
|
+
return await runDbMigrations(cwd, args[0], io, options);
|
|
9071
9273
|
case "release":
|
|
9072
|
-
return await runDbRelease(cwd, args[0], io, options);
|
|
9274
|
+
return await runDbRelease(cwd, args[0], args.slice(1), io, options);
|
|
9073
9275
|
default:
|
|
9074
9276
|
io.err(`Unknown db subcommand: ${command}`);
|
|
9075
9277
|
io.err("Run `loom --help` for usage.");
|
|
@@ -9215,6 +9417,8 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
9215
9417
|
"cleanup-batch-size": { type: "string" },
|
|
9216
9418
|
"configure-secrets": { type: "boolean" },
|
|
9217
9419
|
cwd: { type: "string" },
|
|
9420
|
+
environment: { type: "string" },
|
|
9421
|
+
"env-file": { type: "string" },
|
|
9218
9422
|
force: { type: "boolean" },
|
|
9219
9423
|
help: { short: "h", type: "boolean" },
|
|
9220
9424
|
jurisdiction: { type: "string" },
|
|
@@ -9317,6 +9521,8 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
9317
9521
|
case "db":
|
|
9318
9522
|
return await runDb(cwd, arg1, [arg2, ...rest].filter(Boolean), io, {
|
|
9319
9523
|
name: parsed.values.name,
|
|
9524
|
+
environment: parsed.values.environment,
|
|
9525
|
+
envFile: parsed.values["env-file"],
|
|
9320
9526
|
noColor: parsed.values["no-color"],
|
|
9321
9527
|
noProgress: parsed.values["no-progress"],
|
|
9322
9528
|
neonAuth: parsed.values["neon-auth"],
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type BuildPlaceholder = {
|
|
2
|
+
key: string;
|
|
3
|
+
marker: string;
|
|
4
|
+
requirement: string;
|
|
5
|
+
};
|
|
6
|
+
type CliOutput = {
|
|
7
|
+
out: (line: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function isUsablePulledValue(value: string | undefined): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Validates required Production variables and fills unreadable Sensitive values
|
|
12
|
+
* with unique build-only placeholders without replacing readable pulled values.
|
|
13
|
+
*/
|
|
14
|
+
export declare function prepareVercelBuildEnvironment({ envFile, manifestFile, metadataFile, policyFile, }: {
|
|
15
|
+
envFile: string;
|
|
16
|
+
manifestFile: string;
|
|
17
|
+
metadataFile: string;
|
|
18
|
+
policyFile: string;
|
|
19
|
+
}, io?: CliOutput): {
|
|
20
|
+
placeholders: BuildPlaceholder[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Rejects a Vercel artifact containing any unique build-only marker.
|
|
24
|
+
*/
|
|
25
|
+
export declare function verifyVercelBuildArtifact({ manifestFile, outputDirectory, }: {
|
|
26
|
+
manifestFile: string;
|
|
27
|
+
outputDirectory: string;
|
|
28
|
+
}, io?: CliOutput): void;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=vercelBuildEnv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercelBuildEnv.d.ts","sourceRoot":"","sources":["../../../src/src/cli/vercelBuildEnv.ts"],"names":[],"mappings":"AAyBA,KAAK,gBAAgB,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAMF,KAAK,SAAS,GAAG;IACf,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,CAAC;AAgBF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,WAG5D;AAmFD;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,EACE,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,UAAU,GACX,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,EACD,EAAE,GAAE,SAAgD;;EAoGrD;AAeD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,EACE,YAAY,EACZ,eAAe,GAChB,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB,EACD,EAAE,GAAE,SAAgD,QAyCrD"}
|