@gadicc/loom 1.21.1 → 1.21.2
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/README.md +4 -4
- package/esm/src/cli/migrationEnv.d.ts +23 -0
- package/esm/src/cli/migrationEnv.d.ts.map +1 -1
- package/esm/src/cli/migrationEnv.js +76 -1
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +33 -6
- package/package.json +3 -2
- package/script/src/cli/migrationEnv.d.ts +23 -0
- package/script/src/cli/migrationEnv.d.ts.map +1 -1
- package/script/src/cli/migrationEnv.js +111 -1
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +32 -5
- package/skills/loom/SKILL.md +4 -1
- package/skills/loom-db/SKILL.md +5 -2
package/README.md
CHANGED
|
@@ -229,10 +229,10 @@ documented in [`docs/project-tooling.md`](docs/project-tooling.md).
|
|
|
229
229
|
active PWA installs. The DB release-flow check expects Vercel automatic
|
|
230
230
|
production Git deployments to be disabled in `vercel.json` and a GitHub
|
|
231
231
|
Actions workflow to pull Vercel production settings, build, upload a staged
|
|
232
|
-
prebuilt production deployment, run
|
|
233
|
-
`
|
|
234
|
-
`loom check --network` also verifies the required GitHub
|
|
235
|
-
secret/variables when that workflow exists. When
|
|
232
|
+
prebuilt production deployment, run a live migration credential preflight, run
|
|
233
|
+
`db:migrate` against the preserved production environment, then promote the
|
|
234
|
+
staged deployment. `loom check --network` also verifies the required GitHub
|
|
235
|
+
release secret/variables when that workflow exists. When
|
|
236
236
|
`.github/workflows/*.yml|yaml` still contains Loom's obsolete GitHub Packages
|
|
237
237
|
registry/auth setup, `loom check` recommends removing it. The command also
|
|
238
238
|
activates newly discovered npm package skills with a notice, warns when the
|
|
@@ -7,6 +7,18 @@ export type MigrationEnvironmentResolution = {
|
|
|
7
7
|
hostname: string;
|
|
8
8
|
role: string;
|
|
9
9
|
};
|
|
10
|
+
/** Non-secret identity metadata confirmed by a live migration connection. */
|
|
11
|
+
export type MigrationConnectionVerification = MigrationEnvironmentResolution & {
|
|
12
|
+
schema: string;
|
|
13
|
+
};
|
|
14
|
+
type MigrationDatabaseProbeResult = {
|
|
15
|
+
canCreateInSchema: boolean;
|
|
16
|
+
canUseSchema: boolean;
|
|
17
|
+
database: string;
|
|
18
|
+
role: string;
|
|
19
|
+
schema: string | null;
|
|
20
|
+
};
|
|
21
|
+
type MigrationDatabaseProbe = (databaseUrl: string) => Promise<MigrationDatabaseProbeResult>;
|
|
10
22
|
/**
|
|
11
23
|
* Resolves and validates the migration database URL without returning or
|
|
12
24
|
* printing the credential itself.
|
|
@@ -17,5 +29,16 @@ export declare function resolveMigrationEnvironment(env: Record<string, string |
|
|
|
17
29
|
* process values, including a dedicated migration secret, to take precedence.
|
|
18
30
|
*/
|
|
19
31
|
export declare function resolveMigrationEnvironmentFromEnvFile(envFile: string, env: Record<string, string | undefined>): MigrationEnvironmentResolution;
|
|
32
|
+
/**
|
|
33
|
+
* Authenticates with the selected migration URL and verifies that the
|
|
34
|
+
* connection reaches the declared role/database with usable schema access.
|
|
35
|
+
* Credential values and provider error messages are never returned.
|
|
36
|
+
*/
|
|
37
|
+
export declare function verifyMigrationConnection(env: Record<string, string | undefined>, probe?: MigrationDatabaseProbe): Promise<MigrationConnectionVerification>;
|
|
38
|
+
/**
|
|
39
|
+
* Verifies a preserved Vercel pull snapshot with process-level migration
|
|
40
|
+
* credentials layered on top using the same precedence as Drizzle.
|
|
41
|
+
*/
|
|
42
|
+
export declare function verifyMigrationConnectionFromEnvFile(envFile: string, env: Record<string, string | undefined>, probe?: MigrationDatabaseProbe): Promise<MigrationConnectionVerification>;
|
|
20
43
|
export {};
|
|
21
44
|
//# sourceMappingURL=migrationEnv.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationEnv.d.ts","sourceRoot":"","sources":["../../../src/src/cli/migrationEnv.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,wCAAwC,iHA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H,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,kCAGxC;AAiDD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,KAAK,GAAE,sBAA+C,GACrD,OAAO,CAAC,+BAA+B,CAAC,CA0C1C;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,KAAK,GAAE,sBAA+C,4CAGvD"}
|
|
@@ -51,6 +51,81 @@ export function resolveMigrationEnvironment(env) {
|
|
|
51
51
|
* process values, including a dedicated migration secret, to take precedence.
|
|
52
52
|
*/
|
|
53
53
|
export function resolveMigrationEnvironmentFromEnvFile(envFile, env) {
|
|
54
|
+
return resolveMigrationEnvironment(loadMigrationEnvFile(envFile, env));
|
|
55
|
+
}
|
|
56
|
+
function loadMigrationEnvFile(envFile, env) {
|
|
54
57
|
const pulledEnv = parseEnv(readFileSync(envFile, "utf8"));
|
|
55
|
-
return
|
|
58
|
+
return { ...pulledEnv, ...env };
|
|
59
|
+
}
|
|
60
|
+
async function probeMigrationDatabase(databaseUrl) {
|
|
61
|
+
const { default: postgres } = await import("postgres");
|
|
62
|
+
const sql = postgres(databaseUrl, {
|
|
63
|
+
connect_timeout: 5,
|
|
64
|
+
idle_timeout: 1,
|
|
65
|
+
max: 1,
|
|
66
|
+
prepare: false,
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
const rows = await sql.unsafe(`
|
|
70
|
+
select
|
|
71
|
+
current_user::text as "role",
|
|
72
|
+
current_database()::text as "database",
|
|
73
|
+
current_schema()::text as "schema",
|
|
74
|
+
has_schema_privilege(current_user, current_schema(), 'USAGE') as "canUseSchema",
|
|
75
|
+
has_schema_privilege(current_user, current_schema(), 'CREATE') as "canCreateInSchema"
|
|
76
|
+
`);
|
|
77
|
+
if (!rows[0]) {
|
|
78
|
+
throw new Error("Migration database preflight returned no result.");
|
|
79
|
+
}
|
|
80
|
+
return rows[0];
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
await sql.end({ timeout: 1 }).catch(() => undefined);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function databaseErrorCode(error) {
|
|
87
|
+
if (typeof error === "object" && error !== null && "code" in error &&
|
|
88
|
+
typeof error.code === "string" && /^[A-Z0-9_]{2,20}$/.test(error.code)) {
|
|
89
|
+
return error.code;
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Authenticates with the selected migration URL and verifies that the
|
|
95
|
+
* connection reaches the declared role/database with usable schema access.
|
|
96
|
+
* Credential values and provider error messages are never returned.
|
|
97
|
+
*/
|
|
98
|
+
export async function verifyMigrationConnection(env, probe = probeMigrationDatabase) {
|
|
99
|
+
const resolution = resolveMigrationEnvironment(env);
|
|
100
|
+
if (resolution.envName.startsWith("MIGRATION_") && !resolution.direct) {
|
|
101
|
+
throw new Error(`${resolution.envName} must use a direct, unpooled connection.`);
|
|
102
|
+
}
|
|
103
|
+
let connected;
|
|
104
|
+
try {
|
|
105
|
+
connected = await probe(env[resolution.envName]);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const code = databaseErrorCode(error);
|
|
109
|
+
throw new Error(`${resolution.envName} failed the migration database connection preflight${code ? ` (${code})` : ""}. Check the hostname, credential, and network reachability.`);
|
|
110
|
+
}
|
|
111
|
+
if (connected.role !== resolution.role) {
|
|
112
|
+
throw new Error(`${resolution.envName} authenticated as role ${connected.role}, but its URL declares ${resolution.role}.`);
|
|
113
|
+
}
|
|
114
|
+
if (connected.database !== resolution.database) {
|
|
115
|
+
throw new Error(`${resolution.envName} reached database ${connected.database}, but its URL declares ${resolution.database}.`);
|
|
116
|
+
}
|
|
117
|
+
if (!connected.schema) {
|
|
118
|
+
throw new Error(`${resolution.envName} authenticated without a current database schema.`);
|
|
119
|
+
}
|
|
120
|
+
if (!connected.canUseSchema || !connected.canCreateInSchema) {
|
|
121
|
+
throw new Error(`${resolution.envName} role ${connected.role} needs USAGE and CREATE on schema ${connected.schema}.`);
|
|
122
|
+
}
|
|
123
|
+
return { ...resolution, schema: connected.schema };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Verifies a preserved Vercel pull snapshot with process-level migration
|
|
127
|
+
* credentials layered on top using the same precedence as Drizzle.
|
|
128
|
+
*/
|
|
129
|
+
export function verifyMigrationConnectionFromEnvFile(envFile, env, probe = probeMigrationDatabase) {
|
|
130
|
+
return verifyMigrationConnection(loadMigrationEnvFile(envFile, env), probe);
|
|
56
131
|
}
|
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":"AAyCA,OAAO,EAUL,KAAK,cAAc,EAMpB,MAAM,qBAAqB,CAAC;AAE7B,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,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AAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EACrD,OAAO,GAAE,mBAAwB;;;eAMxB,MAAM;gBACL,sBAAsB;;;;GA2GjC;AAuFD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,uBAAuB,EAC9B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,YAoClD;AA0/BD,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;AAymBD,wBAAsB,MAAM,CAC1B,IAAI,MAAwB,EAC5B,EAAE,GAAE,SAGH,mBAuKF"}
|
package/esm/src/cli/mod.js
CHANGED
|
@@ -8,7 +8,7 @@ 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";
|
|
11
|
+
import { resolveMigrationEnvironment, resolveMigrationEnvironmentFromEnvFile, verifyMigrationConnection, verifyMigrationConnectionFromEnvFile, } from "./migrationEnv.js";
|
|
12
12
|
import { prepareVercelBuildEnvironment, verifyVercelBuildArtifact, } from "./vercelBuildEnv.js";
|
|
13
13
|
import { detectProjectTooling, ensureTask, ensureTaskFollowup, ensureTaskPrerequisite, findTaskConflicts, formatTaskInvocation, getTaskCommand, mutateDenoLinks, mutateProjectDependencies, readDenoLinks, readProjectPackageMetadata, readTaskStore, taskInvokes, taskRunsBeforeCommand, } from "./projectTooling.js";
|
|
14
14
|
export const DEFAULT_LOOM_RANGE = "^1.0.0";
|
|
@@ -3193,6 +3193,9 @@ function workflowStepVerifiesMigrationEnvWithPulledSnapshot(block) {
|
|
|
3193
3193
|
/--env-file(?:=|\s+)["']?\$RUNNER_TEMP\/vercel-production\.env["']?/
|
|
3194
3194
|
.test(block);
|
|
3195
3195
|
}
|
|
3196
|
+
function workflowStepVerifiesMigrationConnection(block) {
|
|
3197
|
+
return workflowStepVerifiesMigrationEnv(block) && /(?:^|\s)--connect\b/.test(block);
|
|
3198
|
+
}
|
|
3196
3199
|
function workflowStepStagesVercelProductionDeployment(block) {
|
|
3197
3200
|
return workflowStepUsesVercelCommand(block, "deploy") &&
|
|
3198
3201
|
/\s--prebuilt\b/.test(block) &&
|
|
@@ -3310,6 +3313,7 @@ function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
|
3310
3313
|
hasWorkflowEnvBinding(migrateStep, "DATABASE_URL"),
|
|
3311
3314
|
id: job.id,
|
|
3312
3315
|
metadataStepIndex,
|
|
3316
|
+
migrationVerifyConnects: workflowStepVerifiesMigrationConnection(migrationVerifyStep),
|
|
3313
3317
|
migrationVerifyStepIndex,
|
|
3314
3318
|
migrationVerifyUsesPulledSnapshot: workflowStepVerifiesMigrationEnvWithPulledSnapshot(migrationVerifyStep),
|
|
3315
3319
|
migrateStepIndex,
|
|
@@ -3419,6 +3423,9 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3419
3423
|
!job.migrationVerifyUsesPulledSnapshot
|
|
3420
3424
|
? [inspection.relativePath]
|
|
3421
3425
|
: []));
|
|
3426
|
+
const structuralOnlyMigrationValidationPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.flatMap((job) => job.migrationVerifyStepIndex >= 0 && !job.migrationVerifyConnects
|
|
3427
|
+
? [inspection.relativePath]
|
|
3428
|
+
: []));
|
|
3422
3429
|
const vercelCurlWorkflowPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.some((job) => job.vercelCurlStepIndex >= 0)
|
|
3423
3430
|
? [inspection.relativePath]
|
|
3424
3431
|
: []);
|
|
@@ -3473,7 +3480,12 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3473
3480
|
if (invalidMigrationValidationPaths.length) {
|
|
3474
3481
|
findings.push("DB production migration validation does not load the preserved Vercel production env snapshot: " +
|
|
3475
3482
|
[...new Set(invalidMigrationValidationPaths)].join(", "));
|
|
3476
|
-
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.');
|
|
3483
|
+
suggestions.add('Run `loom db migrations verify-env --connect --env-file "$RUNNER_TEMP/vercel-production.env"` so the optional GitHub migration secret overlays the readable gradual-adoption pull snapshot and proves live access.');
|
|
3484
|
+
}
|
|
3485
|
+
if (structuralOnlyMigrationValidationPaths.length) {
|
|
3486
|
+
warnings.push("DB production migration validation checks URL structure without proving live database access: " +
|
|
3487
|
+
[...new Set(structuralOnlyMigrationValidationPaths)].join(", "));
|
|
3488
|
+
suggestions.add("Add `--connect` to the migration `verify-env` command so a selected override must authenticate and have migration schema access before it supersedes the Vercel integration fallback.");
|
|
3477
3489
|
}
|
|
3478
3490
|
if (legacyUnpooledSecretWorkflows.length) {
|
|
3479
3491
|
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`: " +
|
|
@@ -10466,7 +10478,7 @@ function printHelp({ out }) {
|
|
|
10466
10478
|
out(" db schemas sync Materialize active Loom-managed DB schema blueprints into app-local schema files.");
|
|
10467
10479
|
out(" db neon setup Provision and connect a Vercel-managed Neon database for Production and Preview.");
|
|
10468
10480
|
out(" db neon check Run the DB/Neon network checks registered for the active DB feature.");
|
|
10469
|
-
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials.
|
|
10481
|
+
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials. Add --connect for a live access preflight.");
|
|
10470
10482
|
out(" db migrations setup-github Store an existing direct migration URL as a protected GitHub Environment secret.");
|
|
10471
10483
|
out(" db release setup-github Create/update GitHub production release config for staged Vercel deploys.");
|
|
10472
10484
|
out(" db release prepare-build-env <env> <metadata> <policy> <manifest> Prepare metadata-backed placeholders for an external Vercel build.");
|
|
@@ -10501,6 +10513,7 @@ function printHelp({ out }) {
|
|
|
10501
10513
|
out(" --token-name <name> Override the Vercel token name for `loom db release setup-github`.");
|
|
10502
10514
|
out(" --environment <name> GitHub Environment for migration credential setup (default production).");
|
|
10503
10515
|
out(" --env-file <path> Preserved env snapshot for `db migrations verify-env`; process values take precedence.");
|
|
10516
|
+
out(" --connect Authenticate and check migration database identity and schema privileges.");
|
|
10504
10517
|
out(" --resource <name> Permission resource for API-key integration.");
|
|
10505
10518
|
out(" --action <name> Permission action for API-key integration.");
|
|
10506
10519
|
out(" --allow-query Allow the integration's explicit query credential transport.");
|
|
@@ -11104,9 +11117,18 @@ async function runDbMigrations(cwd, command, io, options) {
|
|
|
11104
11117
|
return 0;
|
|
11105
11118
|
}
|
|
11106
11119
|
case "verify-env": {
|
|
11107
|
-
const
|
|
11108
|
-
?
|
|
11109
|
-
:
|
|
11120
|
+
const envFile = options.envFile
|
|
11121
|
+
? resolve(cwd, options.envFile)
|
|
11122
|
+
: undefined;
|
|
11123
|
+
const connected = options.connect
|
|
11124
|
+
? envFile
|
|
11125
|
+
? await verifyMigrationConnectionFromEnvFile(envFile, process.env)
|
|
11126
|
+
: await verifyMigrationConnection(process.env)
|
|
11127
|
+
: undefined;
|
|
11128
|
+
const result = connected ??
|
|
11129
|
+
(envFile
|
|
11130
|
+
? resolveMigrationEnvironmentFromEnvFile(envFile, process.env)
|
|
11131
|
+
: resolveMigrationEnvironment(process.env));
|
|
11110
11132
|
io.out(`Migration database environment is usable: ${result.envName} selects role ${result.role} and database ${result.database}.`);
|
|
11111
11133
|
if (!result.envName.startsWith("MIGRATION_")) {
|
|
11112
11134
|
io.out("Warning: using the gradual-adoption application database fallback; prefer MIGRATION_DATABASE_URL_UNPOOLED after provisioning a dedicated migration credential.");
|
|
@@ -11114,6 +11136,9 @@ async function runDbMigrations(cwd, command, io, options) {
|
|
|
11114
11136
|
if (!result.direct) {
|
|
11115
11137
|
io.out("Warning: the selected URL appears pooled; migrations should prefer a direct, unpooled connection.");
|
|
11116
11138
|
}
|
|
11139
|
+
if (connected) {
|
|
11140
|
+
io.out(`Migration database connection preflight succeeded: ${connected.envName} authenticated as role ${connected.role} in database ${connected.database} with USAGE and CREATE on schema ${connected.schema}.`);
|
|
11141
|
+
}
|
|
11117
11142
|
return 0;
|
|
11118
11143
|
}
|
|
11119
11144
|
default:
|
|
@@ -11284,6 +11309,7 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
11284
11309
|
"cloudflare-profile": { type: "string" },
|
|
11285
11310
|
"cleanup-batch-size": { type: "string" },
|
|
11286
11311
|
"configure-secrets": { type: "boolean" },
|
|
11312
|
+
connect: { type: "boolean" },
|
|
11287
11313
|
cwd: { type: "string" },
|
|
11288
11314
|
environment: { type: "string" },
|
|
11289
11315
|
"env-file": { type: "string" },
|
|
@@ -11388,6 +11414,7 @@ export async function runCli(args = process.argv.slice(2), io = {
|
|
|
11388
11414
|
return await runEnvCommand(cwd, arg1, [arg2, ...rest].filter((arg) => arg !== undefined), io);
|
|
11389
11415
|
case "db":
|
|
11390
11416
|
return await runDb(cwd, arg1, [arg2, ...rest].filter(Boolean), io, {
|
|
11417
|
+
connect: parsed.values.connect,
|
|
11391
11418
|
name: parsed.values.name,
|
|
11392
11419
|
environment: parsed.values.environment,
|
|
11393
11420
|
envFile: parsed.values["env-file"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadicc/loom",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.2",
|
|
4
4
|
"description": "Deno-first shared helpers for extracting common Next.js app code.",
|
|
5
5
|
"homepage": "https://github.com/gadicc/loom#readme",
|
|
6
6
|
"repository": {
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
},
|
|
232
232
|
"scripts": {},
|
|
233
233
|
"loom": {
|
|
234
|
-
"gitCommit": "
|
|
234
|
+
"gitCommit": "d9d6aa5db5ca8b7a69602b6023b9d0acefe267bd"
|
|
235
235
|
},
|
|
236
236
|
"bin": {
|
|
237
237
|
"loom": "script/bin/loom.js"
|
|
@@ -331,6 +331,7 @@
|
|
|
331
331
|
"@mui/material": "9.2.0",
|
|
332
332
|
"@next/env": "^16.2.10",
|
|
333
333
|
"jsonc-parser": "^3.3.1",
|
|
334
|
+
"postgres": "^3.4.9",
|
|
334
335
|
"react": "19.2.7",
|
|
335
336
|
"react-dom": "19.2.7",
|
|
336
337
|
"tsx": "^4.23.1",
|
|
@@ -7,6 +7,18 @@ export type MigrationEnvironmentResolution = {
|
|
|
7
7
|
hostname: string;
|
|
8
8
|
role: string;
|
|
9
9
|
};
|
|
10
|
+
/** Non-secret identity metadata confirmed by a live migration connection. */
|
|
11
|
+
export type MigrationConnectionVerification = MigrationEnvironmentResolution & {
|
|
12
|
+
schema: string;
|
|
13
|
+
};
|
|
14
|
+
type MigrationDatabaseProbeResult = {
|
|
15
|
+
canCreateInSchema: boolean;
|
|
16
|
+
canUseSchema: boolean;
|
|
17
|
+
database: string;
|
|
18
|
+
role: string;
|
|
19
|
+
schema: string | null;
|
|
20
|
+
};
|
|
21
|
+
type MigrationDatabaseProbe = (databaseUrl: string) => Promise<MigrationDatabaseProbeResult>;
|
|
10
22
|
/**
|
|
11
23
|
* Resolves and validates the migration database URL without returning or
|
|
12
24
|
* printing the credential itself.
|
|
@@ -17,5 +29,16 @@ export declare function resolveMigrationEnvironment(env: Record<string, string |
|
|
|
17
29
|
* process values, including a dedicated migration secret, to take precedence.
|
|
18
30
|
*/
|
|
19
31
|
export declare function resolveMigrationEnvironmentFromEnvFile(envFile: string, env: Record<string, string | undefined>): MigrationEnvironmentResolution;
|
|
32
|
+
/**
|
|
33
|
+
* Authenticates with the selected migration URL and verifies that the
|
|
34
|
+
* connection reaches the declared role/database with usable schema access.
|
|
35
|
+
* Credential values and provider error messages are never returned.
|
|
36
|
+
*/
|
|
37
|
+
export declare function verifyMigrationConnection(env: Record<string, string | undefined>, probe?: MigrationDatabaseProbe): Promise<MigrationConnectionVerification>;
|
|
38
|
+
/**
|
|
39
|
+
* Verifies a preserved Vercel pull snapshot with process-level migration
|
|
40
|
+
* credentials layered on top using the same precedence as Drizzle.
|
|
41
|
+
*/
|
|
42
|
+
export declare function verifyMigrationConnectionFromEnvFile(envFile: string, env: Record<string, string | undefined>, probe?: MigrationDatabaseProbe): Promise<MigrationConnectionVerification>;
|
|
20
43
|
export {};
|
|
21
44
|
//# sourceMappingURL=migrationEnv.d.ts.map
|
|
@@ -1 +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;
|
|
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,G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vD"}
|
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.resolveMigrationEnvironment = resolveMigrationEnvironment;
|
|
4
37
|
exports.resolveMigrationEnvironmentFromEnvFile = resolveMigrationEnvironmentFromEnvFile;
|
|
38
|
+
exports.verifyMigrationConnection = verifyMigrationConnection;
|
|
39
|
+
exports.verifyMigrationConnectionFromEnvFile = verifyMigrationConnectionFromEnvFile;
|
|
5
40
|
const node_fs_1 = require("node:fs");
|
|
6
41
|
const node_util_1 = require("node:util");
|
|
7
42
|
const DEFAULT_MIGRATION_DATABASE_URL_ENV_NAMES = [
|
|
@@ -55,6 +90,81 @@ function resolveMigrationEnvironment(env) {
|
|
|
55
90
|
* process values, including a dedicated migration secret, to take precedence.
|
|
56
91
|
*/
|
|
57
92
|
function resolveMigrationEnvironmentFromEnvFile(envFile, env) {
|
|
93
|
+
return resolveMigrationEnvironment(loadMigrationEnvFile(envFile, env));
|
|
94
|
+
}
|
|
95
|
+
function loadMigrationEnvFile(envFile, env) {
|
|
58
96
|
const pulledEnv = (0, node_util_1.parseEnv)((0, node_fs_1.readFileSync)(envFile, "utf8"));
|
|
59
|
-
return
|
|
97
|
+
return { ...pulledEnv, ...env };
|
|
98
|
+
}
|
|
99
|
+
async function probeMigrationDatabase(databaseUrl) {
|
|
100
|
+
const { default: postgres } = await Promise.resolve().then(() => __importStar(require("postgres")));
|
|
101
|
+
const sql = postgres(databaseUrl, {
|
|
102
|
+
connect_timeout: 5,
|
|
103
|
+
idle_timeout: 1,
|
|
104
|
+
max: 1,
|
|
105
|
+
prepare: false,
|
|
106
|
+
});
|
|
107
|
+
try {
|
|
108
|
+
const rows = await sql.unsafe(`
|
|
109
|
+
select
|
|
110
|
+
current_user::text as "role",
|
|
111
|
+
current_database()::text as "database",
|
|
112
|
+
current_schema()::text as "schema",
|
|
113
|
+
has_schema_privilege(current_user, current_schema(), 'USAGE') as "canUseSchema",
|
|
114
|
+
has_schema_privilege(current_user, current_schema(), 'CREATE') as "canCreateInSchema"
|
|
115
|
+
`);
|
|
116
|
+
if (!rows[0]) {
|
|
117
|
+
throw new Error("Migration database preflight returned no result.");
|
|
118
|
+
}
|
|
119
|
+
return rows[0];
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
await sql.end({ timeout: 1 }).catch(() => undefined);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function databaseErrorCode(error) {
|
|
126
|
+
if (typeof error === "object" && error !== null && "code" in error &&
|
|
127
|
+
typeof error.code === "string" && /^[A-Z0-9_]{2,20}$/.test(error.code)) {
|
|
128
|
+
return error.code;
|
|
129
|
+
}
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Authenticates with the selected migration URL and verifies that the
|
|
134
|
+
* connection reaches the declared role/database with usable schema access.
|
|
135
|
+
* Credential values and provider error messages are never returned.
|
|
136
|
+
*/
|
|
137
|
+
async function verifyMigrationConnection(env, probe = probeMigrationDatabase) {
|
|
138
|
+
const resolution = resolveMigrationEnvironment(env);
|
|
139
|
+
if (resolution.envName.startsWith("MIGRATION_") && !resolution.direct) {
|
|
140
|
+
throw new Error(`${resolution.envName} must use a direct, unpooled connection.`);
|
|
141
|
+
}
|
|
142
|
+
let connected;
|
|
143
|
+
try {
|
|
144
|
+
connected = await probe(env[resolution.envName]);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
const code = databaseErrorCode(error);
|
|
148
|
+
throw new Error(`${resolution.envName} failed the migration database connection preflight${code ? ` (${code})` : ""}. Check the hostname, credential, and network reachability.`);
|
|
149
|
+
}
|
|
150
|
+
if (connected.role !== resolution.role) {
|
|
151
|
+
throw new Error(`${resolution.envName} authenticated as role ${connected.role}, but its URL declares ${resolution.role}.`);
|
|
152
|
+
}
|
|
153
|
+
if (connected.database !== resolution.database) {
|
|
154
|
+
throw new Error(`${resolution.envName} reached database ${connected.database}, but its URL declares ${resolution.database}.`);
|
|
155
|
+
}
|
|
156
|
+
if (!connected.schema) {
|
|
157
|
+
throw new Error(`${resolution.envName} authenticated without a current database schema.`);
|
|
158
|
+
}
|
|
159
|
+
if (!connected.canUseSchema || !connected.canCreateInSchema) {
|
|
160
|
+
throw new Error(`${resolution.envName} role ${connected.role} needs USAGE and CREATE on schema ${connected.schema}.`);
|
|
161
|
+
}
|
|
162
|
+
return { ...resolution, schema: connected.schema };
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Verifies a preserved Vercel pull snapshot with process-level migration
|
|
166
|
+
* credentials layered on top using the same precedence as Drizzle.
|
|
167
|
+
*/
|
|
168
|
+
function verifyMigrationConnectionFromEnvFile(envFile, env, probe = probeMigrationDatabase) {
|
|
169
|
+
return verifyMigrationConnection(loadMigrationEnvFile(envFile, env), probe);
|
|
60
170
|
}
|
|
@@ -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":"AAyCA,OAAO,EAUL,KAAK,cAAc,EAMpB,MAAM,qBAAqB,CAAC;AAE7B,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,MAA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,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,uBAAuB,EAC9B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,YAoClD;AA0/BD,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;AAymBD,wBAAsB,MAAM,CAC1B,IAAI,MAAwB,EAC5B,EAAE,GAAE,SAGH,mBAuKF"}
|
package/script/src/cli/mod.js
CHANGED
|
@@ -3263,6 +3263,9 @@ function workflowStepVerifiesMigrationEnvWithPulledSnapshot(block) {
|
|
|
3263
3263
|
/--env-file(?:=|\s+)["']?\$RUNNER_TEMP\/vercel-production\.env["']?/
|
|
3264
3264
|
.test(block);
|
|
3265
3265
|
}
|
|
3266
|
+
function workflowStepVerifiesMigrationConnection(block) {
|
|
3267
|
+
return workflowStepVerifiesMigrationEnv(block) && /(?:^|\s)--connect\b/.test(block);
|
|
3268
|
+
}
|
|
3266
3269
|
function workflowStepStagesVercelProductionDeployment(block) {
|
|
3267
3270
|
return workflowStepUsesVercelCommand(block, "deploy") &&
|
|
3268
3271
|
/\s--prebuilt\b/.test(block) &&
|
|
@@ -3380,6 +3383,7 @@ function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
|
3380
3383
|
hasWorkflowEnvBinding(migrateStep, "DATABASE_URL"),
|
|
3381
3384
|
id: job.id,
|
|
3382
3385
|
metadataStepIndex,
|
|
3386
|
+
migrationVerifyConnects: workflowStepVerifiesMigrationConnection(migrationVerifyStep),
|
|
3383
3387
|
migrationVerifyStepIndex,
|
|
3384
3388
|
migrationVerifyUsesPulledSnapshot: workflowStepVerifiesMigrationEnvWithPulledSnapshot(migrationVerifyStep),
|
|
3385
3389
|
migrateStepIndex,
|
|
@@ -3489,6 +3493,9 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3489
3493
|
!job.migrationVerifyUsesPulledSnapshot
|
|
3490
3494
|
? [inspection.relativePath]
|
|
3491
3495
|
: []));
|
|
3496
|
+
const structuralOnlyMigrationValidationPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.flatMap((job) => job.migrationVerifyStepIndex >= 0 && !job.migrationVerifyConnects
|
|
3497
|
+
? [inspection.relativePath]
|
|
3498
|
+
: []));
|
|
3492
3499
|
const vercelCurlWorkflowPaths = mainPushWorkflows.flatMap((inspection) => inspection.jobs.some((job) => job.vercelCurlStepIndex >= 0)
|
|
3493
3500
|
? [inspection.relativePath]
|
|
3494
3501
|
: []);
|
|
@@ -3543,7 +3550,12 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3543
3550
|
if (invalidMigrationValidationPaths.length) {
|
|
3544
3551
|
findings.push("DB production migration validation does not load the preserved Vercel production env snapshot: " +
|
|
3545
3552
|
[...new Set(invalidMigrationValidationPaths)].join(", "));
|
|
3546
|
-
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.');
|
|
3553
|
+
suggestions.add('Run `loom db migrations verify-env --connect --env-file "$RUNNER_TEMP/vercel-production.env"` so the optional GitHub migration secret overlays the readable gradual-adoption pull snapshot and proves live access.');
|
|
3554
|
+
}
|
|
3555
|
+
if (structuralOnlyMigrationValidationPaths.length) {
|
|
3556
|
+
warnings.push("DB production migration validation checks URL structure without proving live database access: " +
|
|
3557
|
+
[...new Set(structuralOnlyMigrationValidationPaths)].join(", "));
|
|
3558
|
+
suggestions.add("Add `--connect` to the migration `verify-env` command so a selected override must authenticate and have migration schema access before it supersedes the Vercel integration fallback.");
|
|
3547
3559
|
}
|
|
3548
3560
|
if (legacyUnpooledSecretWorkflows.length) {
|
|
3549
3561
|
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`: " +
|
|
@@ -10536,7 +10548,7 @@ function printHelp({ out }) {
|
|
|
10536
10548
|
out(" db schemas sync Materialize active Loom-managed DB schema blueprints into app-local schema files.");
|
|
10537
10549
|
out(" db neon setup Provision and connect a Vercel-managed Neon database for Production and Preview.");
|
|
10538
10550
|
out(" db neon check Run the DB/Neon network checks registered for the active DB feature.");
|
|
10539
|
-
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials.
|
|
10551
|
+
out(" db migrations verify-env Validate migration URL precedence and role metadata without printing credentials. Add --connect for a live access preflight.");
|
|
10540
10552
|
out(" db migrations setup-github Store an existing direct migration URL as a protected GitHub Environment secret.");
|
|
10541
10553
|
out(" db release setup-github Create/update GitHub production release config for staged Vercel deploys.");
|
|
10542
10554
|
out(" db release prepare-build-env <env> <metadata> <policy> <manifest> Prepare metadata-backed placeholders for an external Vercel build.");
|
|
@@ -10571,6 +10583,7 @@ function printHelp({ out }) {
|
|
|
10571
10583
|
out(" --token-name <name> Override the Vercel token name for `loom db release setup-github`.");
|
|
10572
10584
|
out(" --environment <name> GitHub Environment for migration credential setup (default production).");
|
|
10573
10585
|
out(" --env-file <path> Preserved env snapshot for `db migrations verify-env`; process values take precedence.");
|
|
10586
|
+
out(" --connect Authenticate and check migration database identity and schema privileges.");
|
|
10574
10587
|
out(" --resource <name> Permission resource for API-key integration.");
|
|
10575
10588
|
out(" --action <name> Permission action for API-key integration.");
|
|
10576
10589
|
out(" --allow-query Allow the integration's explicit query credential transport.");
|
|
@@ -11174,9 +11187,18 @@ async function runDbMigrations(cwd, command, io, options) {
|
|
|
11174
11187
|
return 0;
|
|
11175
11188
|
}
|
|
11176
11189
|
case "verify-env": {
|
|
11177
|
-
const
|
|
11178
|
-
? (0,
|
|
11179
|
-
:
|
|
11190
|
+
const envFile = options.envFile
|
|
11191
|
+
? (0, node_path_1.resolve)(cwd, options.envFile)
|
|
11192
|
+
: undefined;
|
|
11193
|
+
const connected = options.connect
|
|
11194
|
+
? envFile
|
|
11195
|
+
? await (0, migrationEnv_js_1.verifyMigrationConnectionFromEnvFile)(envFile, node_process_1.default.env)
|
|
11196
|
+
: await (0, migrationEnv_js_1.verifyMigrationConnection)(node_process_1.default.env)
|
|
11197
|
+
: undefined;
|
|
11198
|
+
const result = connected ??
|
|
11199
|
+
(envFile
|
|
11200
|
+
? (0, migrationEnv_js_1.resolveMigrationEnvironmentFromEnvFile)(envFile, node_process_1.default.env)
|
|
11201
|
+
: (0, migrationEnv_js_1.resolveMigrationEnvironment)(node_process_1.default.env));
|
|
11180
11202
|
io.out(`Migration database environment is usable: ${result.envName} selects role ${result.role} and database ${result.database}.`);
|
|
11181
11203
|
if (!result.envName.startsWith("MIGRATION_")) {
|
|
11182
11204
|
io.out("Warning: using the gradual-adoption application database fallback; prefer MIGRATION_DATABASE_URL_UNPOOLED after provisioning a dedicated migration credential.");
|
|
@@ -11184,6 +11206,9 @@ async function runDbMigrations(cwd, command, io, options) {
|
|
|
11184
11206
|
if (!result.direct) {
|
|
11185
11207
|
io.out("Warning: the selected URL appears pooled; migrations should prefer a direct, unpooled connection.");
|
|
11186
11208
|
}
|
|
11209
|
+
if (connected) {
|
|
11210
|
+
io.out(`Migration database connection preflight succeeded: ${connected.envName} authenticated as role ${connected.role} in database ${connected.database} with USAGE and CREATE on schema ${connected.schema}.`);
|
|
11211
|
+
}
|
|
11187
11212
|
return 0;
|
|
11188
11213
|
}
|
|
11189
11214
|
default:
|
|
@@ -11354,6 +11379,7 @@ async function runCli(args = node_process_1.default.argv.slice(2), io = {
|
|
|
11354
11379
|
"cloudflare-profile": { type: "string" },
|
|
11355
11380
|
"cleanup-batch-size": { type: "string" },
|
|
11356
11381
|
"configure-secrets": { type: "boolean" },
|
|
11382
|
+
connect: { type: "boolean" },
|
|
11357
11383
|
cwd: { type: "string" },
|
|
11358
11384
|
environment: { type: "string" },
|
|
11359
11385
|
"env-file": { type: "string" },
|
|
@@ -11458,6 +11484,7 @@ async function runCli(args = node_process_1.default.argv.slice(2), io = {
|
|
|
11458
11484
|
return await runEnvCommand(cwd, arg1, [arg2, ...rest].filter((arg) => arg !== undefined), io);
|
|
11459
11485
|
case "db":
|
|
11460
11486
|
return await runDb(cwd, arg1, [arg2, ...rest].filter(Boolean), io, {
|
|
11487
|
+
connect: parsed.values.connect,
|
|
11461
11488
|
name: parsed.values.name,
|
|
11462
11489
|
environment: parsed.values.environment,
|
|
11463
11490
|
envFile: parsed.values["env-file"],
|
package/skills/loom/SKILL.md
CHANGED
|
@@ -83,9 +83,12 @@ from the consumer's working directory.
|
|
|
83
83
|
adoption.
|
|
84
84
|
- Validate the migration boundary with
|
|
85
85
|
`loom db migrations verify-env
|
|
86
|
+
--connect
|
|
86
87
|
--env-file "$RUNNER_TEMP/vercel-production.env"`
|
|
87
88
|
so the optional protected migration secret overlays the untouched readable
|
|
88
|
-
pull snapshot instead of replacing that gradual-adoption fallback.
|
|
89
|
+
pull snapshot instead of replacing that gradual-adoption fallback. The live
|
|
90
|
+
probe must authenticate with the selected URL and confirm migration schema
|
|
91
|
+
access before a present override supersedes the fallback.
|
|
89
92
|
|
|
90
93
|
## Re-establishing work context
|
|
91
94
|
|
package/skills/loom-db/SKILL.md
CHANGED
|
@@ -89,11 +89,14 @@ Use this skill when working on the shared DB stack from a consuming app.
|
|
|
89
89
|
`loom db release verify-build-env`; keep only the declarative requirements
|
|
90
90
|
policy app-local.
|
|
91
91
|
- Use
|
|
92
|
-
`loom db migrations verify-env --env-file
|
|
92
|
+
`loom db migrations verify-env --connect --env-file
|
|
93
93
|
"$RUNNER_TEMP/vercel-production.env"`
|
|
94
94
|
before a release migration. It validates the preserved pull snapshot plus any
|
|
95
95
|
process-level migration-secret overlay, including URL precedence, database
|
|
96
|
-
role, and direct-vs-pooled endpoint,
|
|
96
|
+
role, and direct-vs-pooled endpoint, then authenticates with the selected URL
|
|
97
|
+
and checks the target database and schema privileges without printing
|
|
98
|
+
credentials. A present but invalid override must fail instead of silently
|
|
99
|
+
falling back.
|
|
97
100
|
- Once a dedicated direct URL has been provisioned, load it as
|
|
98
101
|
`MIGRATION_DATABASE_URL_UNPOOLED` in the local process and run
|
|
99
102
|
`loom db migrations setup-github`. Loom sends the value to GitHub over stdin,
|