@famgia/omnify-cli 0.0.110 → 0.0.111
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/dist/cli.js +66 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +63 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +66 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -694,7 +694,9 @@ import {
|
|
|
694
694
|
updateLockFile,
|
|
695
695
|
buildSchemaSnapshots,
|
|
696
696
|
compareSchemasDeep,
|
|
697
|
-
isLockFileV2
|
|
697
|
+
isLockFileV2,
|
|
698
|
+
validateMigrations,
|
|
699
|
+
getMigrationsToRegenerate
|
|
698
700
|
} from "@famgia/omnify-atlas";
|
|
699
701
|
import {
|
|
700
702
|
generateMigrations,
|
|
@@ -1194,6 +1196,68 @@ async function runGenerate(options) {
|
|
|
1194
1196
|
const currentSnapshots = await buildSchemaSnapshots(schemas);
|
|
1195
1197
|
const v2Lock = existingLock && isLockFileV2(existingLock) ? existingLock : null;
|
|
1196
1198
|
const comparison = compareSchemasDeep(currentSnapshots, v2Lock);
|
|
1199
|
+
if (existingLock && config.output.laravel?.migrationsPath) {
|
|
1200
|
+
const migrationsDir = resolve6(rootDir, config.output.laravel.migrationsPath);
|
|
1201
|
+
const migrationValidation = await validateMigrations(existingLock, migrationsDir);
|
|
1202
|
+
if (!migrationValidation.valid) {
|
|
1203
|
+
logger.newline();
|
|
1204
|
+
logger.warn("Migration file issues detected:");
|
|
1205
|
+
if (migrationValidation.missingFiles.length > 0) {
|
|
1206
|
+
logger.error(` Missing files (${migrationValidation.missingFiles.length}):`);
|
|
1207
|
+
for (const file of migrationValidation.missingFiles) {
|
|
1208
|
+
logger.error(` - ${file}`);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
if (migrationValidation.modifiedFiles.length > 0) {
|
|
1212
|
+
logger.warn(` Modified files (${migrationValidation.modifiedFiles.length}):`);
|
|
1213
|
+
for (const file of migrationValidation.modifiedFiles) {
|
|
1214
|
+
logger.warn(` - ${file} (checksum mismatch)`);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
logger.newline();
|
|
1218
|
+
}
|
|
1219
|
+
if ((options.warnStale ?? true) && migrationValidation.staleFiles.length > 0) {
|
|
1220
|
+
logger.newline();
|
|
1221
|
+
logger.warn("\u26A0\uFE0F Stale migrations detected (old timestamp, not in lock file):");
|
|
1222
|
+
for (const file of migrationValidation.staleFiles) {
|
|
1223
|
+
logger.warn(` - ${file}`);
|
|
1224
|
+
}
|
|
1225
|
+
logger.warn(" These may be from merged branches. Review before running migrate.");
|
|
1226
|
+
logger.newline();
|
|
1227
|
+
}
|
|
1228
|
+
if (options.check) {
|
|
1229
|
+
logger.newline();
|
|
1230
|
+
logger.step("CI Check Mode Results:");
|
|
1231
|
+
logger.info(` Schemas: ${schemaCount}`);
|
|
1232
|
+
logger.info(` Tracked migrations: ${migrationValidation.totalTracked}`);
|
|
1233
|
+
logger.info(` Migrations on disk: ${migrationValidation.totalOnDisk}`);
|
|
1234
|
+
logger.info(` Schema changes: ${comparison.changes.length}`);
|
|
1235
|
+
const hasIssues = !migrationValidation.valid || comparison.hasChanges;
|
|
1236
|
+
if (hasIssues) {
|
|
1237
|
+
logger.newline();
|
|
1238
|
+
if (comparison.hasChanges) {
|
|
1239
|
+
logger.error('\u274C Schema changes detected - run "npx omnify generate" to update migrations');
|
|
1240
|
+
}
|
|
1241
|
+
if (migrationValidation.missingFiles.length > 0) {
|
|
1242
|
+
logger.error("\u274C Missing migration files - regenerate or restore from git");
|
|
1243
|
+
}
|
|
1244
|
+
if (migrationValidation.modifiedFiles.length > 0) {
|
|
1245
|
+
logger.warn("\u26A0\uFE0F Modified migration files - may cause inconsistencies");
|
|
1246
|
+
}
|
|
1247
|
+
process.exit(1);
|
|
1248
|
+
} else {
|
|
1249
|
+
logger.success("\u2705 All migrations in sync");
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
if (migrationValidation.missingFiles.length > 0) {
|
|
1254
|
+
const toRegenerate = getMigrationsToRegenerate(existingLock, migrationValidation.missingFiles);
|
|
1255
|
+
if (toRegenerate.length > 0) {
|
|
1256
|
+
logger.info(`Will regenerate ${toRegenerate.length} missing migration(s) with original timestamps.`);
|
|
1257
|
+
logger.warn("Auto-regeneration not yet implemented. Please restore from git or reset migrations.");
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1197
1261
|
const skipMigrations = !comparison.hasChanges && !options.force;
|
|
1198
1262
|
const pluginsHaveGenerators = config.plugins.some((p) => p.generators && p.generators.length > 0);
|
|
1199
1263
|
const hasTypescriptOutput = !!config.output.typescript;
|
|
@@ -1365,7 +1429,7 @@ async function runGenerate(options) {
|
|
|
1365
1429
|
}
|
|
1366
1430
|
}
|
|
1367
1431
|
function registerGenerateCommand(program2) {
|
|
1368
|
-
program2.command("generate").description("Generate Laravel migrations and TypeScript types").option("-v, --verbose", "Show detailed output").option("--migrations-only", "Only generate migrations").option("--types-only", "Only generate TypeScript types").option("-f, --force", "Generate even if no changes detected").action(async (options) => {
|
|
1432
|
+
program2.command("generate").description("Generate Laravel migrations and TypeScript types").option("-v, --verbose", "Show detailed output").option("--migrations-only", "Only generate migrations").option("--types-only", "Only generate TypeScript types").option("-f, --force", "Generate even if no changes detected").option("--check", "CI mode: check if migrations are in sync without generating (exits with code 1 if out of sync)").option("--no-warn-stale", "Disable stale migration warnings").action(async (options) => {
|
|
1369
1433
|
try {
|
|
1370
1434
|
await runGenerate(options);
|
|
1371
1435
|
} catch (error) {
|