@gadicc/loom 1.15.5 → 1.16.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/db/drizzle-config.d.ts +2 -1
- package/db/drizzle-config.js +6 -3
- package/esm/src/cli/migrationEnv.d.ts +16 -0
- package/esm/src/cli/migrationEnv.d.ts.map +1 -0
- package/esm/src/cli/migrationEnv.js +46 -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 +188 -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 +16 -0
- package/script/src/cli/migrationEnv.d.ts.map +1 -0
- package/script/src/cli/migrationEnv.js +49 -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 +189 -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 +4 -2
- package/skills/loom-db/SKILL.md +20 -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,16 @@
|
|
|
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
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=migrationEnv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrationEnv.d.ts","sourceRoot":"","sources":["../../../src/src/cli/migrationEnv.ts"],"names":[],"mappings":"AAAA,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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const DEFAULT_MIGRATION_DATABASE_URL_ENV_NAMES = [
|
|
2
|
+
"MIGRATION_DATABASE_URL_UNPOOLED",
|
|
3
|
+
"MIGRATION_DATABASE_URL",
|
|
4
|
+
"DATABASE_URL_UNPOOLED",
|
|
5
|
+
"DATABASE_URL",
|
|
6
|
+
];
|
|
7
|
+
function isUsableDatabaseUrl(value) {
|
|
8
|
+
return Boolean(value?.trim()) &&
|
|
9
|
+
!/(?:sensitive|redacted)/i.test(value ?? "");
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Resolves and validates the migration database URL without returning or
|
|
13
|
+
* printing the credential itself.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveMigrationEnvironment(env) {
|
|
16
|
+
const envName = DEFAULT_MIGRATION_DATABASE_URL_ENV_NAMES.find((name) => isUsableDatabaseUrl(env[name]));
|
|
17
|
+
if (!envName) {
|
|
18
|
+
throw new Error(`${DEFAULT_MIGRATION_DATABASE_URL_ENV_NAMES.join(" or ")} is not defined with a usable database URL.`);
|
|
19
|
+
}
|
|
20
|
+
const value = env[envName];
|
|
21
|
+
let url;
|
|
22
|
+
try {
|
|
23
|
+
url = new URL(value);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new Error(`${envName} is not a valid URL.`);
|
|
27
|
+
}
|
|
28
|
+
if (url.protocol !== "postgres:" && url.protocol !== "postgresql:") {
|
|
29
|
+
throw new Error(`${envName} must use the postgres or postgresql scheme.`);
|
|
30
|
+
}
|
|
31
|
+
if (!url.username || !url.hostname || !url.pathname.slice(1)) {
|
|
32
|
+
throw new Error(`${envName} must include a database role, hostname, and database name.`);
|
|
33
|
+
}
|
|
34
|
+
const role = decodeURIComponent(url.username);
|
|
35
|
+
const expectedRole = env.LOOM_MIGRATION_DATABASE_ROLE?.trim();
|
|
36
|
+
if (expectedRole && role !== expectedRole) {
|
|
37
|
+
throw new Error(`${envName} uses database role ${role}, but LOOM_MIGRATION_DATABASE_ROLE expects ${expectedRole}.`);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
database: decodeURIComponent(url.pathname.slice(1)),
|
|
41
|
+
direct: !/(?:^|-)pooler(?:\.|$)/i.test(url.hostname),
|
|
42
|
+
envName,
|
|
43
|
+
hostname: url.hostname,
|
|
44
|
+
role,
|
|
45
|
+
};
|
|
46
|
+
}
|
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":"AAqCA,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;AAC1E,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;AACtE,eAAO,MAAM,kCAAkC,yBAAyB,CAAC;AACzE,eAAO,MAAM,mCAAmC,yBAAyB,CAAC;AAI1E,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAAO,CAAC;AAwCtD,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CA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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 } 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,12 @@ 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);
|
|
2781
2793
|
}
|
|
2782
2794
|
function workflowStepStagesVercelProductionDeployment(block) {
|
|
2783
2795
|
return workflowStepUsesVercelCommand(block, "deploy") &&
|
|
@@ -2813,6 +2825,12 @@ function workflowUsesGithubDatabaseUrlSecret(text) {
|
|
|
2813
2825
|
function workflowUsesGithubUnpooledDatabaseUrlSecret(text) {
|
|
2814
2826
|
return /\$\{\{\s*secrets\.DATABASE_URL_UNPOOLED\s*\}\}/.test(text);
|
|
2815
2827
|
}
|
|
2828
|
+
function workflowUsesGithubMigrationDatabaseUrlSecret(text) {
|
|
2829
|
+
return /\$\{\{\s*secrets\.MIGRATION_DATABASE_URL(?:_UNPOOLED)?\s*\}\}/.test(text);
|
|
2830
|
+
}
|
|
2831
|
+
function workflowUsesGithubDatabaseUrlVariable(text) {
|
|
2832
|
+
return /\$\{\{\s*vars\.(?:MIGRATION_)?DATABASE_URL(?:_UNPOOLED)?\s*\}\}/.test(text);
|
|
2833
|
+
}
|
|
2816
2834
|
function getGithubWorkflowJobBlocks(text) {
|
|
2817
2835
|
const lines = normalizeText(text).split("\n");
|
|
2818
2836
|
const jobsIndex = lines.findIndex((line) => /^\s*jobs:\s*(?:#.*)?$/.test(line));
|
|
@@ -2904,8 +2922,10 @@ function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
|
2904
2922
|
return {
|
|
2905
2923
|
jobs,
|
|
2906
2924
|
mainPush: githubWorkflowRunsOnMainPush(normalized),
|
|
2925
|
+
usesGithubDatabaseUrlVariable: workflowUsesGithubDatabaseUrlVariable(normalized),
|
|
2907
2926
|
relativePath,
|
|
2908
2927
|
usesGithubDatabaseUrlSecret: workflowUsesGithubDatabaseUrlSecret(normalized),
|
|
2928
|
+
usesGithubMigrationDatabaseUrlSecret: workflowUsesGithubMigrationDatabaseUrlSecret(normalized),
|
|
2909
2929
|
usesGithubUnpooledDatabaseUrlSecret: workflowUsesGithubUnpooledDatabaseUrlSecret(normalized),
|
|
2910
2930
|
usesOldVercelDeployHook: workflowUsesOldVercelDeployHook(normalized),
|
|
2911
2931
|
};
|
|
@@ -2925,7 +2945,8 @@ function dbMigrationJobHasOrderedStagedRelease(job) {
|
|
|
2925
2945
|
function dbMigrationWorkflowIsValid(workflow) {
|
|
2926
2946
|
return workflow.jobs.some((job) => dbMigrationJobHasOrderedStagedRelease(job) &&
|
|
2927
2947
|
job.promoteStepUsesExplicitScope &&
|
|
2928
|
-
workflow.
|
|
2948
|
+
(workflow.usesGithubMigrationDatabaseUrlSecret ||
|
|
2949
|
+
workflow.usesGithubUnpooledDatabaseUrlSecret));
|
|
2929
2950
|
}
|
|
2930
2951
|
function isJsonObject(value) {
|
|
2931
2952
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -2983,6 +3004,9 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
2983
3004
|
const validMigrationWorkflow = mainPushWorkflows.find(dbMigrationWorkflowIsValid);
|
|
2984
3005
|
const oldDeployHookWorkflows = mainPushWorkflows.filter((inspection) => inspection.usesOldVercelDeployHook);
|
|
2985
3006
|
const duplicatedDatabaseUrlWorkflows = mainPushWorkflows.filter((inspection) => inspection.usesGithubDatabaseUrlSecret);
|
|
3007
|
+
const databaseUrlVariableWorkflows = mainPushWorkflows.filter((inspection) => inspection.usesGithubDatabaseUrlVariable);
|
|
3008
|
+
const legacyUnpooledSecretWorkflows = mainPushWorkflows.filter((inspection) => inspection.usesGithubUnpooledDatabaseUrlSecret &&
|
|
3009
|
+
!inspection.usesGithubMigrationDatabaseUrlSecret);
|
|
2986
3010
|
const vercelCurlWorkflowPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.some((job) => job.vercelCurlStepIndex >= 0)
|
|
2987
3011
|
? [inspection.relativePath]
|
|
2988
3012
|
: []);
|
|
@@ -3018,8 +3042,9 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3018
3042
|
findings.push("DB production migration flow does not restore the untouched pulled env before migrations: " +
|
|
3019
3043
|
migrationWorkflowPaths.join(", "));
|
|
3020
3044
|
}
|
|
3021
|
-
else if (!mainPushWorkflows.some((inspection) => inspection.
|
|
3022
|
-
|
|
3045
|
+
else if (!mainPushWorkflows.some((inspection) => inspection.usesGithubMigrationDatabaseUrlSecret ||
|
|
3046
|
+
inspection.usesGithubUnpooledDatabaseUrlSecret)) {
|
|
3047
|
+
findings.push("DB production migration flow is not ready for Sensitive database variables because it lacks a GitHub migration-secret binding: " +
|
|
3023
3048
|
migrationWorkflowPaths.join(", "));
|
|
3024
3049
|
}
|
|
3025
3050
|
else if (mainPushWorkflows.some((inspection) => inspection.jobs.some((job) => dbMigrationJobHasOrderedStagedRelease(job) &&
|
|
@@ -3031,7 +3056,19 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3031
3056
|
findings.push("DB production migration flow does not order build, staged deploy, migration, and promotion correctly: " +
|
|
3032
3057
|
migrationWorkflowPaths.join(", "));
|
|
3033
3058
|
}
|
|
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
|
|
3059
|
+
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"`.');
|
|
3060
|
+
}
|
|
3061
|
+
if (legacyUnpooledSecretWorkflows.length) {
|
|
3062
|
+
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`: " +
|
|
3063
|
+
legacyUnpooledSecretWorkflows.map((workflow) => workflow.relativePath)
|
|
3064
|
+
.join(", "));
|
|
3065
|
+
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.");
|
|
3066
|
+
}
|
|
3067
|
+
if (databaseUrlVariableWorkflows.length) {
|
|
3068
|
+
warnings.push("DB production migration flow reads a database URL from a readable GitHub Actions variable: " +
|
|
3069
|
+
databaseUrlVariableWorkflows.map((workflow) => workflow.relativePath)
|
|
3070
|
+
.join(", "));
|
|
3071
|
+
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
3072
|
}
|
|
3036
3073
|
if (oldDeployHookWorkflows.length) {
|
|
3037
3074
|
findings.push("DB production migration flow still references a Vercel Deploy Hook: " +
|
|
@@ -3042,7 +3079,7 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3042
3079
|
findings.push("DB production migration flow still reads `secrets.DATABASE_URL` from GitHub: " +
|
|
3043
3080
|
duplicatedDatabaseUrlWorkflows.map((workflow) => workflow.relativePath)
|
|
3044
3081
|
.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 `
|
|
3082
|
+
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
3083
|
}
|
|
3047
3084
|
if (vercelCurlWorkflowPaths.length) {
|
|
3048
3085
|
findings.push("DB production migration flow still uses beta `vercel curl` for smoke checks: " +
|
|
@@ -5424,6 +5461,32 @@ function createGithubReleaseConfigCheckStep(state, context) {
|
|
|
5424
5461
|
suggestions.add(`After confirming no other workflow uses it, run \`gh secret delete ${staleSecret}\`.`);
|
|
5425
5462
|
}
|
|
5426
5463
|
}
|
|
5464
|
+
const hasCanonicalMigrationSecret = environmentSecrets.names.has(GITHUB_MIGRATION_DATABASE_SECRET_NAME);
|
|
5465
|
+
const hasRepositoryCanonicalMigrationSecret = repoSecrets.names.has(GITHUB_MIGRATION_DATABASE_SECRET_NAME);
|
|
5466
|
+
const hasLegacyMigrationSecret = collectionHasName(LEGACY_GITHUB_MIGRATION_DATABASE_SECRET_NAME, environmentSecrets, repoSecrets);
|
|
5467
|
+
if (!hasCanonicalMigrationSecret) {
|
|
5468
|
+
if (hasRepositoryCanonicalMigrationSecret) {
|
|
5469
|
+
warnings.push(`GitHub Actions stores ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} at repository scope instead of the protected ${PRODUCTION_GITHUB_ENVIRONMENT} environment.`);
|
|
5470
|
+
}
|
|
5471
|
+
else if (hasLegacyMigrationSecret) {
|
|
5472
|
+
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.`);
|
|
5473
|
+
}
|
|
5474
|
+
else {
|
|
5475
|
+
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.`);
|
|
5476
|
+
}
|
|
5477
|
+
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.");
|
|
5478
|
+
}
|
|
5479
|
+
if (hasCanonicalMigrationSecret &&
|
|
5480
|
+
findGithubVariableValue(GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME, environmentVariables, repoVariables) === null) {
|
|
5481
|
+
warnings.push(`GitHub Actions has ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} but no ${GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME} metadata variable.`);
|
|
5482
|
+
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.");
|
|
5483
|
+
}
|
|
5484
|
+
for (const name of GITHUB_DATABASE_URL_VARIABLE_NAMES) {
|
|
5485
|
+
if (collectionHasName(name, environmentVariables, repoVariables)) {
|
|
5486
|
+
warnings.push(`GitHub Actions stores database credential ${name} as a readable variable.`);
|
|
5487
|
+
suggestions.add(`Rotate ${name} into the protected ${PRODUCTION_GITHUB_ENVIRONMENT} Environment secret ${GITHUB_MIGRATION_DATABASE_SECRET_NAME}, then delete the readable variable.`);
|
|
5488
|
+
}
|
|
5489
|
+
}
|
|
5427
5490
|
if (collectionHasName("VERCEL_DEPLOY_HOOK", environmentSecrets, repoSecrets) ||
|
|
5428
5491
|
[...STALE_GITHUB_RELEASE_SECRET_NAMES].some((name) => name.startsWith("VERCEL_DEPLOY") &&
|
|
5429
5492
|
collectionHasName(name, environmentSecrets, repoSecrets))) {
|
|
@@ -6014,6 +6077,54 @@ export async function setupVercelNeon(cwd, options = {}) {
|
|
|
6014
6077
|
notes,
|
|
6015
6078
|
};
|
|
6016
6079
|
}
|
|
6080
|
+
/**
|
|
6081
|
+
* Stores an already-provisioned direct migration URL in a protected GitHub
|
|
6082
|
+
* Environment without persisting or printing the credential.
|
|
6083
|
+
*/
|
|
6084
|
+
export async function setupGithubMigrationCredential(cwd, options = {}) {
|
|
6085
|
+
const commandRunner = options.commandRunner ?? defaultCommandRunner;
|
|
6086
|
+
const env = options.env ?? process.env;
|
|
6087
|
+
const environment = options.environment ?? PRODUCTION_GITHUB_ENVIRONMENT;
|
|
6088
|
+
const migration = resolveMigrationEnvironment(env);
|
|
6089
|
+
if (!migration.envName.startsWith("MIGRATION_")) {
|
|
6090
|
+
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.`);
|
|
6091
|
+
}
|
|
6092
|
+
if (!migration.direct) {
|
|
6093
|
+
throw new Error(`${migration.envName} appears pooled. Configure a direct, unpooled migration connection before storing it in GitHub.`);
|
|
6094
|
+
}
|
|
6095
|
+
const githubCli = await detectGithubCliCommand(cwd, commandRunner, env);
|
|
6096
|
+
if (!githubCli.command) {
|
|
6097
|
+
throw new Error("GitHub CLI is not available. Install and authenticate `gh` before running `loom db migrations setup-github`.");
|
|
6098
|
+
}
|
|
6099
|
+
await requireCommand(`Set GitHub ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} secret`, commandRunner, githubCli.command, [
|
|
6100
|
+
"secret",
|
|
6101
|
+
"set",
|
|
6102
|
+
GITHUB_MIGRATION_DATABASE_SECRET_NAME,
|
|
6103
|
+
"--env",
|
|
6104
|
+
environment,
|
|
6105
|
+
], {
|
|
6106
|
+
cwd,
|
|
6107
|
+
env,
|
|
6108
|
+
input: env[migration.envName],
|
|
6109
|
+
stdio: "pipe",
|
|
6110
|
+
});
|
|
6111
|
+
await requireCommand(`Set GitHub ${GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME} variable`, commandRunner, githubCli.command, [
|
|
6112
|
+
"variable",
|
|
6113
|
+
"set",
|
|
6114
|
+
GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME,
|
|
6115
|
+
"--env",
|
|
6116
|
+
environment,
|
|
6117
|
+
"--body",
|
|
6118
|
+
migration.role,
|
|
6119
|
+
], { cwd, env, stdio: "pipe" });
|
|
6120
|
+
return {
|
|
6121
|
+
notes: [
|
|
6122
|
+
`Stored ${GITHUB_MIGRATION_DATABASE_SECRET_NAME} in the protected GitHub \`${environment}\` environment.`,
|
|
6123
|
+
`Recorded migration role ${migration.role} as ${GITHUB_MIGRATION_DATABASE_ROLE_VARIABLE_NAME}.`,
|
|
6124
|
+
"Vercel application database variables were not changed.",
|
|
6125
|
+
],
|
|
6126
|
+
};
|
|
6127
|
+
}
|
|
6017
6128
|
export async function setupGithubVercelRelease(cwd, options = {}) {
|
|
6018
6129
|
const commandRunner = options.commandRunner ?? defaultCommandRunner;
|
|
6019
6130
|
const env = options.env ?? process.env;
|
|
@@ -8476,7 +8587,11 @@ function printHelp({ out }) {
|
|
|
8476
8587
|
out(" db schemas sync Materialize active Loom-managed DB schema blueprints into app-local schema files.");
|
|
8477
8588
|
out(" db neon setup Provision and connect a Vercel-managed Neon database for Production and Preview.");
|
|
8478
8589
|
out(" db neon check Run the DB/Neon network checks registered for the active DB feature.");
|
|
8590
|
+
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials.");
|
|
8591
|
+
out(" db migrations setup-github Store an existing direct migration URL as a protected GitHub Environment secret.");
|
|
8479
8592
|
out(" db release setup-github Create/update GitHub production release config for staged Vercel deploys.");
|
|
8593
|
+
out(" db release prepare-build-env <env> <metadata> <policy> <manifest> Prepare metadata-backed placeholders for an external Vercel build.");
|
|
8594
|
+
out(" db release verify-build-env <output> <manifest> Reject build-only placeholders in a deployable Vercel artifact.");
|
|
8480
8595
|
out(" dev local Enable local Loom development using a managed file: override in pnpm-workspace.yaml.");
|
|
8481
8596
|
out(" dev sync Rebuild the local Loom package and refresh this project's pnpm install when the managed local-dev override is active.");
|
|
8482
8597
|
out(" dev published Remove the managed local-dev override and return to the published dependency.");
|
|
@@ -8505,6 +8620,7 @@ function printHelp({ out }) {
|
|
|
8505
8620
|
out(" --configure-secrets Ask Vercel to prompt securely for missing R2 credentials; never replaces existing credentials.");
|
|
8506
8621
|
out(" --repair Apply declared non-secret Files provider drift; never deletes resources or rotates credentials.");
|
|
8507
8622
|
out(" --token-name <name> Override the Vercel token name for `loom db release setup-github`.");
|
|
8623
|
+
out(" --environment <name> GitHub Environment for migration credential setup (default production).");
|
|
8508
8624
|
out(" --resource <name> Permission resource for API-key integration.");
|
|
8509
8625
|
out(" --action <name> Permission action for API-key integration.");
|
|
8510
8626
|
out(" --allow-query Allow the integration's explicit query credential transport.");
|
|
@@ -9031,14 +9147,39 @@ async function runDbNeon(cwd, command, io, options) {
|
|
|
9031
9147
|
return 1;
|
|
9032
9148
|
}
|
|
9033
9149
|
}
|
|
9034
|
-
async function runDbRelease(cwd, command, io, options) {
|
|
9150
|
+
async function runDbRelease(cwd, command, args, io, options) {
|
|
9035
9151
|
if (!command) {
|
|
9036
9152
|
io.err("Missing release subcommand. Example: `loom db release setup-github`.");
|
|
9037
9153
|
return 1;
|
|
9038
9154
|
}
|
|
9039
9155
|
switch (command) {
|
|
9156
|
+
case "prepare-build-env": {
|
|
9157
|
+
if (args.length !== 4) {
|
|
9158
|
+
io.err("Usage: loom db release prepare-build-env <env-file> <metadata-file> <policy-file> <manifest-file>");
|
|
9159
|
+
return 1;
|
|
9160
|
+
}
|
|
9161
|
+
prepareVercelBuildEnvironment({
|
|
9162
|
+
envFile: resolve(cwd, args[0]),
|
|
9163
|
+
manifestFile: resolve(cwd, args[3]),
|
|
9164
|
+
metadataFile: resolve(cwd, args[1]),
|
|
9165
|
+
policyFile: resolve(cwd, args[2]),
|
|
9166
|
+
}, io);
|
|
9167
|
+
return 0;
|
|
9168
|
+
}
|
|
9169
|
+
case "verify-build-env": {
|
|
9170
|
+
if (args.length !== 2) {
|
|
9171
|
+
io.err("Usage: loom db release verify-build-env <output-directory> <manifest-file>");
|
|
9172
|
+
return 1;
|
|
9173
|
+
}
|
|
9174
|
+
verifyVercelBuildArtifact({
|
|
9175
|
+
manifestFile: resolve(cwd, args[1]),
|
|
9176
|
+
outputDirectory: resolve(cwd, args[0]),
|
|
9177
|
+
}, io);
|
|
9178
|
+
return 0;
|
|
9179
|
+
}
|
|
9040
9180
|
case "setup-github": {
|
|
9041
9181
|
const result = await setupGithubVercelRelease(cwd, {
|
|
9182
|
+
environment: options.environment,
|
|
9042
9183
|
io,
|
|
9043
9184
|
tokenName: options.tokenName,
|
|
9044
9185
|
});
|
|
@@ -9054,6 +9195,39 @@ async function runDbRelease(cwd, command, io, options) {
|
|
|
9054
9195
|
return 1;
|
|
9055
9196
|
}
|
|
9056
9197
|
}
|
|
9198
|
+
async function runDbMigrations(cwd, command, io, options) {
|
|
9199
|
+
if (!command) {
|
|
9200
|
+
io.err("Missing migrations subcommand. Example: `loom db migrations verify-env`.");
|
|
9201
|
+
return 1;
|
|
9202
|
+
}
|
|
9203
|
+
switch (command) {
|
|
9204
|
+
case "setup-github": {
|
|
9205
|
+
const result = await setupGithubMigrationCredential(cwd, {
|
|
9206
|
+
environment: options.environment,
|
|
9207
|
+
});
|
|
9208
|
+
for (const note of result.notes) {
|
|
9209
|
+
io.out(`Note: ${note}`);
|
|
9210
|
+
}
|
|
9211
|
+
io.out("Next step: update the release workflow to bind `secrets.MIGRATION_DATABASE_URL_UNPOOLED`, then run `loom check --production --network`.");
|
|
9212
|
+
return 0;
|
|
9213
|
+
}
|
|
9214
|
+
case "verify-env": {
|
|
9215
|
+
const result = resolveMigrationEnvironment(process.env);
|
|
9216
|
+
io.out(`Migration database environment is usable: ${result.envName} selects role ${result.role} and database ${result.database}.`);
|
|
9217
|
+
if (!result.envName.startsWith("MIGRATION_")) {
|
|
9218
|
+
io.out("Warning: using the gradual-adoption application database fallback; prefer MIGRATION_DATABASE_URL_UNPOOLED after provisioning a dedicated migration credential.");
|
|
9219
|
+
}
|
|
9220
|
+
if (!result.direct) {
|
|
9221
|
+
io.out("Warning: the selected URL appears pooled; migrations should prefer a direct, unpooled connection.");
|
|
9222
|
+
}
|
|
9223
|
+
return 0;
|
|
9224
|
+
}
|
|
9225
|
+
default:
|
|
9226
|
+
io.err(`Unknown migrations subcommand: ${command}`);
|
|
9227
|
+
io.err("Run `loom --help` for usage.");
|
|
9228
|
+
return 1;
|
|
9229
|
+
}
|
|
9230
|
+
}
|
|
9057
9231
|
async function runDb(cwd, command, args, io, options = {}) {
|
|
9058
9232
|
if (!command) {
|
|
9059
9233
|
io.err("Missing db subcommand. Example: `loom db schema-gen`.");
|
|
@@ -9068,8 +9242,10 @@ async function runDb(cwd, command, args, io, options = {}) {
|
|
|
9068
9242
|
return await runDbSchemas(cwd, args[0], io);
|
|
9069
9243
|
case "neon":
|
|
9070
9244
|
return await runDbNeon(cwd, args[0], io, options);
|
|
9245
|
+
case "migrations":
|
|
9246
|
+
return await runDbMigrations(cwd, args[0], io, options);
|
|
9071
9247
|
case "release":
|
|
9072
|
-
return await runDbRelease(cwd, args[0], io, options);
|
|
9248
|
+
return await runDbRelease(cwd, args[0], args.slice(1), io, options);
|
|
9073
9249
|
default:
|
|
9074
9250
|
io.err(`Unknown db subcommand: ${command}`);
|
|
9075
9251
|
io.err("Run `loom --help` for usage.");
|
|
@@ -9215,6 +9391,7 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
9215
9391
|
"cleanup-batch-size": { type: "string" },
|
|
9216
9392
|
"configure-secrets": { type: "boolean" },
|
|
9217
9393
|
cwd: { type: "string" },
|
|
9394
|
+
environment: { type: "string" },
|
|
9218
9395
|
force: { type: "boolean" },
|
|
9219
9396
|
help: { short: "h", type: "boolean" },
|
|
9220
9397
|
jurisdiction: { type: "string" },
|
|
@@ -9317,6 +9494,7 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
9317
9494
|
case "db":
|
|
9318
9495
|
return await runDb(cwd, arg1, [arg2, ...rest].filter(Boolean), io, {
|
|
9319
9496
|
name: parsed.values.name,
|
|
9497
|
+
environment: parsed.values.environment,
|
|
9320
9498
|
noColor: parsed.values["no-color"],
|
|
9321
9499
|
noProgress: parsed.values["no-progress"],
|
|
9322
9500
|
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"}
|