grada-run 0.43.1 → 0.44.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/package.json
CHANGED
|
@@ -323,6 +323,8 @@ async function runDbEnableVectorMain(input = {}) {
|
|
|
323
323
|
const exitCode = outcome.exitCode;
|
|
324
324
|
const stoppedReason = outcome.stoppedReason;
|
|
325
325
|
if (exitCode === 0) {
|
|
326
|
+
// Owner pairs its own start/stop (see migrate.js BUG-202).
|
|
327
|
+
try { s.stop(color.green('pgvector extension enabled.')); } catch { /* already stopped */ }
|
|
326
328
|
console.log(color.green('\n✅ pgvector extension enabled.'));
|
|
327
329
|
try {
|
|
328
330
|
const prismaSchema = path.join(cwd, 'prisma', 'schema.prisma');
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
readFileSafe,
|
|
19
19
|
readTerraformComputeTarget,
|
|
20
20
|
} from '../../utils/resolvers.js';
|
|
21
|
-
import { detectMigrationCommand, isNpmShimCommand, dockerfileStripsNpmShims } from '../../utils/detector.js';
|
|
21
|
+
import { detectMigrationCommand, isNpmShimCommand, dockerfileStripsNpmShims, ormMappedHintSegment } from '../../utils/detector.js';
|
|
22
22
|
import { resolveContainer } from '../../utils/ecs.js';
|
|
23
23
|
import { runEphemeralEcsTask } from '../../utils/ecs-runner.js';
|
|
24
24
|
import { parseTimeoutSeconds } from '../../utils/system.js';
|
|
@@ -336,10 +336,11 @@ async function runDbMigrateMain(input = {}) {
|
|
|
336
336
|
// headless; warn loudly (and proceed) interactively. Fail-open when
|
|
337
337
|
// no Dockerfile is present — nothing to prove breakage against.
|
|
338
338
|
if (isNpmShimCommand(resolvedCmd) && dockerfileStripsNpmShims(readFileSafe(path.join(cwd, 'Dockerfile')))) {
|
|
339
|
+
const ormHint = ormMappedHintSegment(cwd, '--cmd ');
|
|
339
340
|
if (headless) {
|
|
340
341
|
return failCommand({
|
|
341
342
|
message: `\n✖ Refusing to run "${resolvedCmd}": your Dockerfile strips npm/npx from the runner image, so this command would fail with "command not found" inside the task.\n`,
|
|
342
|
-
hint:
|
|
343
|
+
hint: ` Bundle a framework-compiled runner instead and re-run with an explicit node-based command, e.g. --cmd "node ./dist/migrate.cjs". Ensure your Dockerfile builds the bundle and copies it into the runner image${ormHint}.\n`,
|
|
343
344
|
event: 'db_migrate_run',
|
|
344
345
|
telemetry: { projectName, cmd_source: cmdSource, ci_setup: setupCi, error_code: 'NPM_CMD_STRIPPED_RUNNER' },
|
|
345
346
|
errorCode: 'NPM_CMD_STRIPPED_RUNNER',
|
|
@@ -347,7 +348,7 @@ async function runDbMigrateMain(input = {}) {
|
|
|
347
348
|
resultExtra: { cluster, service, region },
|
|
348
349
|
});
|
|
349
350
|
}
|
|
350
|
-
console.log(color.yellow(`⚠️ "${resolvedCmd}" starts with npm/npx but your Dockerfile strips those binaries from the runner image — this will fail with "command not found" unless you switch to a node-based command (e.g. "node ./dist/migrate.cjs"). Ensure your Dockerfile builds the bundle and copies it into the runner image
|
|
351
|
+
console.log(color.yellow(`⚠️ "${resolvedCmd}" starts with npm/npx but your Dockerfile strips those binaries from the runner image — this will fail with "command not found" unless you switch to a node-based command (e.g. "node ./dist/migrate.cjs"). Ensure your Dockerfile builds the bundle and copies it into the runner image.${ormHint}`));
|
|
351
352
|
trackEvent('npm_cmd_stripped_runner', { projectName, cmd_source: cmdSource, ci_setup: setupCi });
|
|
352
353
|
}
|
|
353
354
|
|
|
@@ -526,6 +527,10 @@ async function runDbMigrateMain(input = {}) {
|
|
|
526
527
|
const exitCode = outcome.exitCode;
|
|
527
528
|
const stoppedReason = outcome.stoppedReason;
|
|
528
529
|
if (exitCode === 0) {
|
|
530
|
+
// Owner pairs its own start/stop: the runner usually stops
|
|
531
|
+
// first (idempotent no-op then), but success must never
|
|
532
|
+
// depend on a callee for the spinner lifecycle (BUG-202).
|
|
533
|
+
try { s.stop(color.green('Migration succeeded.')); } catch { /* already stopped */ }
|
|
529
534
|
console.log(color.green('\n✅ Migration succeeded.'));
|
|
530
535
|
await trackSuccess('db_migrate_run', { projectName, cmd_source: cmdSource, ci_setup: false });
|
|
531
536
|
outro(color.green('Done.'));
|
package/src/commands/init.js
CHANGED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
frameworkDefaultPort,
|
|
19
19
|
frameworkUsesStrippedRunner,
|
|
20
20
|
isNpmShimCommand,
|
|
21
|
+
detectOrmMigrationCommand,
|
|
22
|
+
ormMappedHintSegment,
|
|
21
23
|
SUPPORTED_FRAMEWORKS
|
|
22
24
|
} from '../utils/detector.js';
|
|
23
25
|
import { detectProjectCapabilities } from '../utils/capabilities.js';
|
|
@@ -577,17 +579,18 @@ async function mainStackMain(input = {}) {
|
|
|
577
579
|
// gate would fail 100% of deploys. Fail fast headless (re-run with an
|
|
578
580
|
// explicit node command); warn loudly interactively and continue.
|
|
579
581
|
if (migrationGateEnabled && isNpmShimCommand(migrationCmd) && target === 'ecs' && frameworkUsesStrippedRunner(config.framework)) {
|
|
582
|
+
const ormHint = ormMappedHintSegment(dirConfig.targetDir, '--setup-ci-migrate=');
|
|
580
583
|
if (!isInteractive) {
|
|
581
584
|
return failCommand({
|
|
582
585
|
message: `\n✖ Refusing to wire the pre-deploy migration gate with "${migrationCmd}": the generated ${config.framework} Dockerfile strips npm/npx from the runner image, so this command would fail with "command not found" on every deploy.\n`,
|
|
583
|
-
hint:
|
|
586
|
+
hint: ` Re-run with an explicit node-based command, e.g. \`--setup-ci-migrate="node ./dist/migrate.cjs"\`, or wire the gate later with \`grada db migrate --cmd "node ./dist/migrate.cjs" --setup-ci\`. Ensure your Dockerfile builds the bundle and copies it into the runner image${ormHint}.\n`,
|
|
584
587
|
event: 'cli-error',
|
|
585
588
|
telemetry: { step: 'init_setup', cmd_source: migrationCmdSource, error_code: 'NPM_CMD_STRIPPED_RUNNER' },
|
|
586
589
|
errorCode: 'NPM_CMD_STRIPPED_RUNNER',
|
|
587
590
|
reason: 'npm-cmd-stripped-runner',
|
|
588
591
|
});
|
|
589
592
|
}
|
|
590
|
-
console.log(color.yellow(`⚠️ The ${migrationCmdSource} migration command ("${migrationCmd}") starts with npm/npx but the generated ${config.framework} Dockerfile strips those binaries from the runner image — the gate will fail unless you switch to a node-based command (e.g. "node ./dist/migrate.cjs"). Ensure your Dockerfile builds the bundle and copies it into the runner image
|
|
593
|
+
console.log(color.yellow(`⚠️ The ${migrationCmdSource} migration command ("${migrationCmd}") starts with npm/npx but the generated ${config.framework} Dockerfile strips those binaries from the runner image — the gate will fail unless you switch to a node-based command (e.g. "node ./dist/migrate.cjs"). Ensure your Dockerfile builds the bundle and copies it into the runner image.${ormHint}`));
|
|
591
594
|
trackEvent('npm_cmd_stripped_runner', { projectName: dirConfig.actualProjectName, cmd_source: migrationCmdSource, ci_setup: true });
|
|
592
595
|
}
|
|
593
596
|
|
|
@@ -1097,6 +1100,19 @@ async function mainStackMain(input = {}) {
|
|
|
1097
1100
|
}
|
|
1098
1101
|
}
|
|
1099
1102
|
|
|
1103
|
+
// ORM runner matrix: when the gate was auto-wired to a mapped ORM
|
|
1104
|
+
// command, say which one and what the user must guarantee (the
|
|
1105
|
+
// bundle path / production dependency), while the run is fresh.
|
|
1106
|
+
if (migrationGateEnabled && migrationCmdSource === 'detected') {
|
|
1107
|
+
const ormMapped = detectOrmMigrationCommand(dirConfig.targetDir);
|
|
1108
|
+
if (ormMapped && ormMapped.command === migrationCmd) {
|
|
1109
|
+
const ormWarning = ormMapped.orm === 'drizzle'
|
|
1110
|
+
? 'Detected Drizzle ORM. Configured migration gate to use \'node ./dist/migrate.cjs\'. Ensure your build script bundles your migrator to this path.'
|
|
1111
|
+
: 'Detected Prisma. Configured migration gate to run via \'node_modules/prisma/build/index.js\'. Ensure Prisma is in your production dependencies.';
|
|
1112
|
+
log.warn(color.yellow(`⚠️ ${ormWarning}`));
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1100
1116
|
const isGitInitialized = fsSync.existsSync(path.join(dirConfig.targetDir, '.git'));
|
|
1101
1117
|
const needsCd = dirConfig.projectName && dirConfig.projectName !== '.';
|
|
1102
1118
|
const applyStep = needsCd ? `cd ${dirConfig.projectName} && npx --yes grada-run apply` : 'npx --yes grada-run apply';
|
package/src/commands/secrets.js
CHANGED
|
@@ -938,11 +938,17 @@ async function pullSecretsMain(envFilePath, projectName, options = {}) {
|
|
|
938
938
|
abort.code = 'SECRETS_PULL_UNREPRESENTABLE_VALUE';
|
|
939
939
|
throw abort;
|
|
940
940
|
}
|
|
941
|
-
// Skip the write when the
|
|
942
|
-
//
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
941
|
+
// Skip the write when the merge changes nothing semantically.
|
|
942
|
+
// Byte comparison always differs on commented files
|
|
943
|
+
// (serializeEnv emits canonical lines), so compare parsed
|
|
944
|
+
// content instead: same keys + same values means the file —
|
|
945
|
+
// comments and all — already holds exactly this state.
|
|
946
|
+
const localKeys = Object.keys(localSecrets);
|
|
947
|
+
const semanticallyEqual = localExists
|
|
948
|
+
&& localKeys.length === orderedKeys.length
|
|
949
|
+
&& orderedKeys.every((key) => Object.hasOwn(localSecrets, key) && String(localSecrets[key]) === String(merged[key]));
|
|
950
|
+
if (!semanticallyEqual) {
|
|
951
|
+
await fs.writeFile(envPath, serializeEnv(orderedKeys, merged));
|
|
946
952
|
}
|
|
947
953
|
|
|
948
954
|
outro(`Successfully synced ${remoteKeys.length} secrets to ${resolvedFilePath}`);
|
package/src/utils/detector.js
CHANGED
|
@@ -303,6 +303,60 @@ export function analyzeAstroConfig(targetDir) {
|
|
|
303
303
|
// framework markers. Pure: reads files under `cwd`, never throws (malformed
|
|
304
304
|
// or unreadable files fall through to the next marker). Returns the shell
|
|
305
305
|
// command string or null when nothing matches.
|
|
306
|
+
// ORM runner matrix (npx-trap fix): stripped runners have no npm/npx,
|
|
307
|
+
// so marker-detected ORMs map to compiled node commands instead of
|
|
308
|
+
// task-guaranteed-to-fail shims. Returns { command, orm } or null.
|
|
309
|
+
// - Drizzle (dep or config): the prescribed bundle path. The file may
|
|
310
|
+
// not exist until the user builds — callers warn about that.
|
|
311
|
+
// - Prisma v6/v7 (schema or dep): the direct CLI entry. v8 moved the
|
|
312
|
+
// entry (dist/prisma.js) and other majors are unverified, so only
|
|
313
|
+
// 6/7 map; anything else falls through to the npx form (which the
|
|
314
|
+
// stripped-runner guard refuses with a hint).
|
|
315
|
+
export function detectOrmMigrationCommand(cwd = process.cwd()) {
|
|
316
|
+
const readJson = (file) => {
|
|
317
|
+
try {
|
|
318
|
+
return JSON.parse(fsSync.readFileSync(path.join(cwd, file), 'utf-8'));
|
|
319
|
+
} catch {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
const exists = (file) => {
|
|
324
|
+
try {
|
|
325
|
+
return fsSync.existsSync(path.join(cwd, file));
|
|
326
|
+
} catch {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const pkg = readJson('package.json');
|
|
331
|
+
const deps = pkg && typeof pkg === 'object'
|
|
332
|
+
? { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) }
|
|
333
|
+
: {};
|
|
334
|
+
if (deps['drizzle-kit'] || deps['drizzle-orm']
|
|
335
|
+
|| exists('drizzle.config.ts') || exists('drizzle.config.js') || exists('drizzle.config.mjs')) {
|
|
336
|
+
return { command: 'node ./dist/migrate.cjs', orm: 'drizzle' };
|
|
337
|
+
}
|
|
338
|
+
const hasPrismaMarkers = exists(path.join('prisma', 'schema.prisma')) || deps.prisma;
|
|
339
|
+
if (hasPrismaMarkers) {
|
|
340
|
+
const major = /^\D*(\d+)/.exec(String(deps.prisma ?? ''))?.[1];
|
|
341
|
+
if (major === '6' || major === '7') {
|
|
342
|
+
return { command: 'node ./node_modules/prisma/build/index.js migrate deploy', orm: 'prisma' };
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const ORM_DISPLAY_NAMES = { drizzle: 'Drizzle ORM', prisma: 'Prisma' };
|
|
349
|
+
|
|
350
|
+
// Shared refusal-hint sentence naming the mapped ORM command, so the
|
|
351
|
+
// migrate/init guard sites can't skew. Empty when nothing maps.
|
|
352
|
+
// `flagForm` carries the caller's joiner ('--cmd ' vs '--setup-ci-migrate=').
|
|
353
|
+
export function ormMappedHintSegment(cwd, flagForm) {
|
|
354
|
+
const mapped = detectOrmMigrationCommand(cwd);
|
|
355
|
+
if (!mapped) return '';
|
|
356
|
+
const label = ORM_DISPLAY_NAMES[mapped.orm] || mapped.orm;
|
|
357
|
+
return ` Detected ${label} — re-run with ${flagForm}"${mapped.command}" instead`;
|
|
358
|
+
}
|
|
359
|
+
|
|
306
360
|
export function detectMigrationCommand(cwd = process.cwd()) {
|
|
307
361
|
const readJson = (file) => {
|
|
308
362
|
try {
|
|
@@ -337,7 +391,12 @@ export function detectMigrationCommand(cwd = process.cwd()) {
|
|
|
337
391
|
return 'npm run migrate';
|
|
338
392
|
}
|
|
339
393
|
|
|
340
|
-
// 2.
|
|
394
|
+
// 2. ORM matrix: stripped-runner-safe node commands win over shims.
|
|
395
|
+
const ormMapped = detectOrmMigrationCommand(cwd);
|
|
396
|
+
if (ormMapped) return ormMapped.command;
|
|
397
|
+
|
|
398
|
+
// 3. Unmappable Prisma (other majors, unresolvable range): legacy npx
|
|
399
|
+
// form, which the stripped-runner guard refuses with a hint.
|
|
341
400
|
const deps = pkg && typeof pkg === 'object'
|
|
342
401
|
? { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) }
|
|
343
402
|
: {};
|
|
@@ -345,11 +404,6 @@ export function detectMigrationCommand(cwd = process.cwd()) {
|
|
|
345
404
|
return 'npx prisma migrate deploy';
|
|
346
405
|
}
|
|
347
406
|
|
|
348
|
-
// 3. Drizzle: config file in any supported extension.
|
|
349
|
-
if (exists('drizzle.config.ts') || exists('drizzle.config.js') || exists('drizzle.config.mjs')) {
|
|
350
|
-
return 'npx drizzle-kit migrate';
|
|
351
|
-
}
|
|
352
|
-
|
|
353
407
|
// 4. Alembic.
|
|
354
408
|
if (exists('alembic.ini')) {
|
|
355
409
|
return 'alembic upgrade head';
|
|
@@ -40,6 +40,12 @@ resource "aws_rds_cluster" "postgres" {
|
|
|
40
40
|
skip_final_snapshot = true
|
|
41
41
|
storage_encrypted = true
|
|
42
42
|
|
|
43
|
+
# Match the instance engines: 7-day retention with explicit off-peak
|
|
44
|
+
# UTC windows instead of AWS-assigned ones (BUG-203).
|
|
45
|
+
backup_retention_period = 7
|
|
46
|
+
preferred_backup_window = "03:00-04:00"
|
|
47
|
+
preferred_maintenance_window = "sun:04:00-sun:05:00"
|
|
48
|
+
|
|
43
49
|
# grada destroy lifts this only via --allow-data-loss (or a per-run
|
|
44
50
|
# data-loss confirm); grada snapshots the database first unless the
|
|
45
51
|
# flag says the data may go. grada destroy also pre-wakes stopped
|