@famgia/omnify-cli 0.0.110 → 0.0.112
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 +163 -39
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +117 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +151 -26
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
2
8
|
|
|
3
9
|
// src/cli.ts
|
|
4
10
|
import { existsSync as existsSync7 } from "fs";
|
|
@@ -679,8 +685,8 @@ function registerDiffCommand(program2) {
|
|
|
679
685
|
}
|
|
680
686
|
|
|
681
687
|
// src/commands/generate.ts
|
|
682
|
-
import { existsSync as existsSync4, mkdirSync as
|
|
683
|
-
import { resolve as resolve6, dirname as
|
|
688
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3, readdirSync as readdirSync2 } from "fs";
|
|
689
|
+
import { resolve as resolve6, dirname as dirname5, relative } from "path";
|
|
684
690
|
import {
|
|
685
691
|
loadSchemas as loadSchemas3,
|
|
686
692
|
validateSchemas as validateSchemas3,
|
|
@@ -694,7 +700,9 @@ import {
|
|
|
694
700
|
updateLockFile,
|
|
695
701
|
buildSchemaSnapshots,
|
|
696
702
|
compareSchemasDeep,
|
|
697
|
-
isLockFileV2
|
|
703
|
+
isLockFileV2,
|
|
704
|
+
validateMigrations,
|
|
705
|
+
getMigrationsToRegenerate
|
|
698
706
|
} from "@famgia/omnify-atlas";
|
|
699
707
|
import {
|
|
700
708
|
generateMigrations,
|
|
@@ -707,8 +715,9 @@ import {
|
|
|
707
715
|
import { generateTypeScript, copyStubs, generateAIGuides as generateTypescriptAIGuides, shouldGenerateAIGuides as shouldGenerateTypescriptAIGuides } from "@famgia/omnify-typescript";
|
|
708
716
|
|
|
709
717
|
// src/guides/index.ts
|
|
710
|
-
import { existsSync as existsSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
711
|
-
import { resolve as resolve5 } from "path";
|
|
718
|
+
import { existsSync as existsSync3, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, readdirSync, readFileSync } from "fs";
|
|
719
|
+
import { resolve as resolve5, dirname as dirname4, join } from "path";
|
|
720
|
+
import "url";
|
|
712
721
|
var CLAUDE_MD = `## Omnify
|
|
713
722
|
|
|
714
723
|
This project uses Omnify for schema-driven code generation.
|
|
@@ -725,6 +734,58 @@ This project uses Omnify for schema-driven code generation.
|
|
|
725
734
|
- \`npx omnify generate\` - Generate code from schemas
|
|
726
735
|
- \`npx omnify validate\` - Validate schemas
|
|
727
736
|
`;
|
|
737
|
+
function copyOmnifyGuides(rootDir) {
|
|
738
|
+
let filesWritten = 0;
|
|
739
|
+
const omnifyPkgPaths = [
|
|
740
|
+
resolve5(rootDir, "node_modules", "@famgia", "omnify", "stubs", "ai-guides", "omnify"),
|
|
741
|
+
resolve5(rootDir, "node_modules", ".pnpm", "@famgia+omnify@*", "node_modules", "@famgia", "omnify", "stubs", "ai-guides", "omnify")
|
|
742
|
+
];
|
|
743
|
+
let stubsDir = null;
|
|
744
|
+
for (const pkgPath of omnifyPkgPaths) {
|
|
745
|
+
if (pkgPath.includes("*")) {
|
|
746
|
+
const parentDir = dirname4(dirname4(pkgPath));
|
|
747
|
+
if (existsSync3(parentDir)) {
|
|
748
|
+
const entries = readdirSync(parentDir);
|
|
749
|
+
for (const entry of entries) {
|
|
750
|
+
if (entry.startsWith("@famgia+omnify@")) {
|
|
751
|
+
const testPath = join(parentDir, entry, "node_modules", "@famgia", "omnify", "stubs", "ai-guides", "omnify");
|
|
752
|
+
if (existsSync3(testPath)) {
|
|
753
|
+
stubsDir = testPath;
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
} else if (existsSync3(pkgPath)) {
|
|
760
|
+
stubsDir = pkgPath;
|
|
761
|
+
break;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
if (!stubsDir) {
|
|
765
|
+
try {
|
|
766
|
+
const omnifyPath = dirname4(__require.resolve("@famgia/omnify/package.json", { paths: [rootDir] }));
|
|
767
|
+
const testPath = join(omnifyPath, "stubs", "ai-guides", "omnify");
|
|
768
|
+
if (existsSync3(testPath)) {
|
|
769
|
+
stubsDir = testPath;
|
|
770
|
+
}
|
|
771
|
+
} catch {
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
if (!stubsDir) {
|
|
775
|
+
return 0;
|
|
776
|
+
}
|
|
777
|
+
const destDir = resolve5(rootDir, ".claude", "omnify", "guides", "omnify");
|
|
778
|
+
mkdirSync2(destDir, { recursive: true });
|
|
779
|
+
const files = readdirSync(stubsDir).filter((f) => f.endsWith(".stub"));
|
|
780
|
+
for (const file of files) {
|
|
781
|
+
const srcPath = join(stubsDir, file);
|
|
782
|
+
const destPath = join(destDir, file.replace(".stub", ""));
|
|
783
|
+
const content = readFileSync(srcPath, "utf8");
|
|
784
|
+
writeFileSync2(destPath, content);
|
|
785
|
+
filesWritten++;
|
|
786
|
+
}
|
|
787
|
+
return filesWritten;
|
|
788
|
+
}
|
|
728
789
|
function generateAIGuides(rootDir, _plugins) {
|
|
729
790
|
let filesWritten = 0;
|
|
730
791
|
const claudeMdPath = resolve5(rootDir, "CLAUDE.md");
|
|
@@ -732,6 +793,7 @@ function generateAIGuides(rootDir, _plugins) {
|
|
|
732
793
|
writeFileSync2(claudeMdPath, CLAUDE_MD);
|
|
733
794
|
filesWritten++;
|
|
734
795
|
}
|
|
796
|
+
filesWritten += copyOmnifyGuides(rootDir);
|
|
735
797
|
return filesWritten;
|
|
736
798
|
}
|
|
737
799
|
|
|
@@ -745,7 +807,7 @@ function getExistingMigrationTables(migrationsDir) {
|
|
|
745
807
|
return existingTables;
|
|
746
808
|
}
|
|
747
809
|
try {
|
|
748
|
-
const files =
|
|
810
|
+
const files = readdirSync2(migrationsDir);
|
|
749
811
|
const createMigrationPattern = /^\d{4}_\d{2}_\d{2}_\d{6}_create_(.+)_table\.php$/;
|
|
750
812
|
for (const file of files) {
|
|
751
813
|
const match = file.match(createMigrationPattern);
|
|
@@ -935,9 +997,9 @@ function writeGeneratorOutputs(outputs, rootDir) {
|
|
|
935
997
|
const counts = { migrations: 0, types: 0, models: 0, factories: 0, other: 0 };
|
|
936
998
|
for (const output of outputs) {
|
|
937
999
|
const filePath = resolve6(rootDir, output.path);
|
|
938
|
-
const dir =
|
|
1000
|
+
const dir = dirname5(filePath);
|
|
939
1001
|
if (!existsSync4(dir)) {
|
|
940
|
-
|
|
1002
|
+
mkdirSync3(dir, { recursive: true });
|
|
941
1003
|
logger.debug(`Created directory: ${dir}`);
|
|
942
1004
|
}
|
|
943
1005
|
if (output.skipIfExists && existsSync4(filePath)) {
|
|
@@ -1002,7 +1064,7 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1002
1064
|
logger.step("Generating Laravel migrations...");
|
|
1003
1065
|
const migrationsDir = resolve6(rootDir, config.output.laravel.migrationsPath);
|
|
1004
1066
|
if (!existsSync4(migrationsDir)) {
|
|
1005
|
-
|
|
1067
|
+
mkdirSync3(migrationsDir, { recursive: true });
|
|
1006
1068
|
logger.debug(`Created directory: ${migrationsDir}`);
|
|
1007
1069
|
}
|
|
1008
1070
|
const addedSchemaNames = new Set(
|
|
@@ -1047,10 +1109,10 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1047
1109
|
const modelsDir = resolve6(rootDir, modelsPath);
|
|
1048
1110
|
const baseModelsDir = resolve6(rootDir, baseModelsPath);
|
|
1049
1111
|
if (!existsSync4(modelsDir)) {
|
|
1050
|
-
|
|
1112
|
+
mkdirSync3(modelsDir, { recursive: true });
|
|
1051
1113
|
}
|
|
1052
1114
|
if (!existsSync4(baseModelsDir)) {
|
|
1053
|
-
|
|
1115
|
+
mkdirSync3(baseModelsDir, { recursive: true });
|
|
1054
1116
|
}
|
|
1055
1117
|
const providersPath = config.output.laravel.providersPath ?? "app/Providers";
|
|
1056
1118
|
const models = generateModels(schemas, {
|
|
@@ -1061,9 +1123,9 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1061
1123
|
});
|
|
1062
1124
|
for (const model of models) {
|
|
1063
1125
|
const filePath = resolve6(rootDir, getModelPath(model));
|
|
1064
|
-
const fileDir =
|
|
1126
|
+
const fileDir = dirname5(filePath);
|
|
1065
1127
|
if (!existsSync4(fileDir)) {
|
|
1066
|
-
|
|
1128
|
+
mkdirSync3(fileDir, { recursive: true });
|
|
1067
1129
|
}
|
|
1068
1130
|
if (!model.overwrite && existsSync4(filePath)) {
|
|
1069
1131
|
logger.debug(`Skipped (exists): ${getModelPath(model)}`);
|
|
@@ -1080,16 +1142,16 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1080
1142
|
const factoriesPath = config.output.laravel.factoriesPath;
|
|
1081
1143
|
const factoriesDir = resolve6(rootDir, factoriesPath);
|
|
1082
1144
|
if (!existsSync4(factoriesDir)) {
|
|
1083
|
-
|
|
1145
|
+
mkdirSync3(factoriesDir, { recursive: true });
|
|
1084
1146
|
}
|
|
1085
1147
|
const factories = generateFactories(schemas, {
|
|
1086
1148
|
factoryPath: factoriesPath
|
|
1087
1149
|
});
|
|
1088
1150
|
for (const factory of factories) {
|
|
1089
1151
|
const filePath = resolve6(rootDir, getFactoryPath(factory));
|
|
1090
|
-
const fileDir =
|
|
1152
|
+
const fileDir = dirname5(filePath);
|
|
1091
1153
|
if (!existsSync4(fileDir)) {
|
|
1092
|
-
|
|
1154
|
+
mkdirSync3(fileDir, { recursive: true });
|
|
1093
1155
|
}
|
|
1094
1156
|
if (!factory.overwrite && existsSync4(filePath)) {
|
|
1095
1157
|
logger.debug(`Skipped (exists): ${getFactoryPath(factory)}`);
|
|
@@ -1109,11 +1171,11 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1109
1171
|
const enumDir = resolve6(basePath, tsConfig.enumDir ?? "enum");
|
|
1110
1172
|
const enumImportPrefix = relative(schemasDir, enumDir).replace(/\\/g, "/");
|
|
1111
1173
|
if (!existsSync4(schemasDir)) {
|
|
1112
|
-
|
|
1174
|
+
mkdirSync3(schemasDir, { recursive: true });
|
|
1113
1175
|
logger.debug(`Created directory: ${schemasDir}`);
|
|
1114
1176
|
}
|
|
1115
1177
|
if (!existsSync4(enumDir)) {
|
|
1116
|
-
|
|
1178
|
+
mkdirSync3(enumDir, { recursive: true });
|
|
1117
1179
|
logger.debug(`Created directory: ${enumDir}`);
|
|
1118
1180
|
}
|
|
1119
1181
|
const isMultiLocale = config.locale && config.locale.locales && config.locale.locales.length > 1;
|
|
@@ -1129,9 +1191,9 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1129
1191
|
for (const file of typeFiles) {
|
|
1130
1192
|
const outputDir = file.category === "enum" ? enumDir : schemasDir;
|
|
1131
1193
|
const filePath = resolve6(outputDir, file.filePath);
|
|
1132
|
-
const fileDir =
|
|
1194
|
+
const fileDir = dirname5(filePath);
|
|
1133
1195
|
if (!existsSync4(fileDir)) {
|
|
1134
|
-
|
|
1196
|
+
mkdirSync3(fileDir, { recursive: true });
|
|
1135
1197
|
}
|
|
1136
1198
|
if (!file.overwrite && existsSync4(filePath)) {
|
|
1137
1199
|
logger.debug(`Skipped (exists): ${file.filePath}`);
|
|
@@ -1157,7 +1219,7 @@ async function runGenerate(options) {
|
|
|
1157
1219
|
logger.header("Generating Outputs");
|
|
1158
1220
|
logger.debug("Loading configuration...");
|
|
1159
1221
|
const { config, configPath: configPath2 } = await loadConfig();
|
|
1160
|
-
const rootDir = configPath2 ?
|
|
1222
|
+
const rootDir = configPath2 ? dirname5(configPath2) : process.cwd();
|
|
1161
1223
|
validateConfig(config, rootDir);
|
|
1162
1224
|
const schemaPath = resolve6(rootDir, config.schemasDir);
|
|
1163
1225
|
logger.step(`Loading schemas from ${schemaPath}`);
|
|
@@ -1194,6 +1256,68 @@ async function runGenerate(options) {
|
|
|
1194
1256
|
const currentSnapshots = await buildSchemaSnapshots(schemas);
|
|
1195
1257
|
const v2Lock = existingLock && isLockFileV2(existingLock) ? existingLock : null;
|
|
1196
1258
|
const comparison = compareSchemasDeep(currentSnapshots, v2Lock);
|
|
1259
|
+
if (existingLock && config.output.laravel?.migrationsPath) {
|
|
1260
|
+
const migrationsDir = resolve6(rootDir, config.output.laravel.migrationsPath);
|
|
1261
|
+
const migrationValidation = await validateMigrations(existingLock, migrationsDir);
|
|
1262
|
+
if (!migrationValidation.valid) {
|
|
1263
|
+
logger.newline();
|
|
1264
|
+
logger.warn("Migration file issues detected:");
|
|
1265
|
+
if (migrationValidation.missingFiles.length > 0) {
|
|
1266
|
+
logger.error(` Missing files (${migrationValidation.missingFiles.length}):`);
|
|
1267
|
+
for (const file of migrationValidation.missingFiles) {
|
|
1268
|
+
logger.error(` - ${file}`);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
if (migrationValidation.modifiedFiles.length > 0) {
|
|
1272
|
+
logger.warn(` Modified files (${migrationValidation.modifiedFiles.length}):`);
|
|
1273
|
+
for (const file of migrationValidation.modifiedFiles) {
|
|
1274
|
+
logger.warn(` - ${file} (checksum mismatch)`);
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
logger.newline();
|
|
1278
|
+
}
|
|
1279
|
+
if ((options.warnStale ?? true) && migrationValidation.staleFiles.length > 0) {
|
|
1280
|
+
logger.newline();
|
|
1281
|
+
logger.warn("\u26A0\uFE0F Stale migrations detected (old timestamp, not in lock file):");
|
|
1282
|
+
for (const file of migrationValidation.staleFiles) {
|
|
1283
|
+
logger.warn(` - ${file}`);
|
|
1284
|
+
}
|
|
1285
|
+
logger.warn(" These may be from merged branches. Review before running migrate.");
|
|
1286
|
+
logger.newline();
|
|
1287
|
+
}
|
|
1288
|
+
if (options.check) {
|
|
1289
|
+
logger.newline();
|
|
1290
|
+
logger.step("CI Check Mode Results:");
|
|
1291
|
+
logger.info(` Schemas: ${schemaCount}`);
|
|
1292
|
+
logger.info(` Tracked migrations: ${migrationValidation.totalTracked}`);
|
|
1293
|
+
logger.info(` Migrations on disk: ${migrationValidation.totalOnDisk}`);
|
|
1294
|
+
logger.info(` Schema changes: ${comparison.changes.length}`);
|
|
1295
|
+
const hasIssues = !migrationValidation.valid || comparison.hasChanges;
|
|
1296
|
+
if (hasIssues) {
|
|
1297
|
+
logger.newline();
|
|
1298
|
+
if (comparison.hasChanges) {
|
|
1299
|
+
logger.error('\u274C Schema changes detected - run "npx omnify generate" to update migrations');
|
|
1300
|
+
}
|
|
1301
|
+
if (migrationValidation.missingFiles.length > 0) {
|
|
1302
|
+
logger.error("\u274C Missing migration files - regenerate or restore from git");
|
|
1303
|
+
}
|
|
1304
|
+
if (migrationValidation.modifiedFiles.length > 0) {
|
|
1305
|
+
logger.warn("\u26A0\uFE0F Modified migration files - may cause inconsistencies");
|
|
1306
|
+
}
|
|
1307
|
+
process.exit(1);
|
|
1308
|
+
} else {
|
|
1309
|
+
logger.success("\u2705 All migrations in sync");
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
if (migrationValidation.missingFiles.length > 0) {
|
|
1314
|
+
const toRegenerate = getMigrationsToRegenerate(existingLock, migrationValidation.missingFiles);
|
|
1315
|
+
if (toRegenerate.length > 0) {
|
|
1316
|
+
logger.info(`Will regenerate ${toRegenerate.length} missing migration(s) with original timestamps.`);
|
|
1317
|
+
logger.warn("Auto-regeneration not yet implemented. Please restore from git or reset migrations.");
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1197
1321
|
const skipMigrations = !comparison.hasChanges && !options.force;
|
|
1198
1322
|
const pluginsHaveGenerators = config.plugins.some((p) => p.generators && p.generators.length > 0);
|
|
1199
1323
|
const hasTypescriptOutput = !!config.output.typescript;
|
|
@@ -1262,11 +1386,11 @@ async function runGenerate(options) {
|
|
|
1262
1386
|
const enumDir2 = resolve6(basePath2, tsConfig2.enumDir ?? "enum");
|
|
1263
1387
|
const enumImportPrefix2 = relative(schemasDir2, enumDir2).replace(/\\/g, "/");
|
|
1264
1388
|
if (!existsSync4(schemasDir2)) {
|
|
1265
|
-
|
|
1389
|
+
mkdirSync3(schemasDir2, { recursive: true });
|
|
1266
1390
|
logger.debug(`Created directory: ${schemasDir2}`);
|
|
1267
1391
|
}
|
|
1268
1392
|
if (!existsSync4(enumDir2)) {
|
|
1269
|
-
|
|
1393
|
+
mkdirSync3(enumDir2, { recursive: true });
|
|
1270
1394
|
logger.debug(`Created directory: ${enumDir2}`);
|
|
1271
1395
|
}
|
|
1272
1396
|
const isMultiLocale = config.locale && config.locale.locales && config.locale.locales.length > 1;
|
|
@@ -1282,9 +1406,9 @@ async function runGenerate(options) {
|
|
|
1282
1406
|
for (const file of typeFiles) {
|
|
1283
1407
|
const outputDir2 = file.category === "enum" ? enumDir2 : schemasDir2;
|
|
1284
1408
|
const filePath = resolve6(outputDir2, file.filePath);
|
|
1285
|
-
const fileDir =
|
|
1409
|
+
const fileDir = dirname5(filePath);
|
|
1286
1410
|
if (!existsSync4(fileDir)) {
|
|
1287
|
-
|
|
1411
|
+
mkdirSync3(fileDir, { recursive: true });
|
|
1288
1412
|
}
|
|
1289
1413
|
if (!file.overwrite && existsSync4(filePath)) {
|
|
1290
1414
|
logger.debug(`Skipped (exists): ${file.filePath}`);
|
|
@@ -1365,7 +1489,7 @@ async function runGenerate(options) {
|
|
|
1365
1489
|
}
|
|
1366
1490
|
}
|
|
1367
1491
|
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) => {
|
|
1492
|
+
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
1493
|
try {
|
|
1370
1494
|
await runGenerate(options);
|
|
1371
1495
|
} catch (error) {
|
|
@@ -1382,8 +1506,8 @@ function registerGenerateCommand(program2) {
|
|
|
1382
1506
|
}
|
|
1383
1507
|
|
|
1384
1508
|
// src/commands/reset.ts
|
|
1385
|
-
import { existsSync as existsSync5, readdirSync as
|
|
1386
|
-
import { resolve as resolve7, dirname as
|
|
1509
|
+
import { existsSync as existsSync5, readdirSync as readdirSync3, rmSync, statSync } from "fs";
|
|
1510
|
+
import { resolve as resolve7, dirname as dirname6, join as join2 } from "path";
|
|
1387
1511
|
import { createInterface } from "readline";
|
|
1388
1512
|
async function confirm2(message) {
|
|
1389
1513
|
const rl = createInterface({
|
|
@@ -1400,9 +1524,9 @@ async function confirm2(message) {
|
|
|
1400
1524
|
function countFiles(dir) {
|
|
1401
1525
|
if (!existsSync5(dir)) return 0;
|
|
1402
1526
|
let count = 0;
|
|
1403
|
-
const entries =
|
|
1527
|
+
const entries = readdirSync3(dir);
|
|
1404
1528
|
for (const entry of entries) {
|
|
1405
|
-
const fullPath =
|
|
1529
|
+
const fullPath = join2(dir, entry);
|
|
1406
1530
|
const stat = statSync(fullPath);
|
|
1407
1531
|
if (stat.isDirectory()) {
|
|
1408
1532
|
count += countFiles(fullPath);
|
|
@@ -1424,9 +1548,9 @@ function deleteDir(dir, verbose) {
|
|
|
1424
1548
|
function deleteFilesInDir(dir, pattern, verbose) {
|
|
1425
1549
|
if (!existsSync5(dir)) return 0;
|
|
1426
1550
|
let count = 0;
|
|
1427
|
-
const entries =
|
|
1551
|
+
const entries = readdirSync3(dir);
|
|
1428
1552
|
for (const entry of entries) {
|
|
1429
|
-
const fullPath =
|
|
1553
|
+
const fullPath = join2(dir, entry);
|
|
1430
1554
|
const stat = statSync(fullPath);
|
|
1431
1555
|
if (stat.isFile() && pattern.test(entry)) {
|
|
1432
1556
|
rmSync(fullPath);
|
|
@@ -1443,7 +1567,7 @@ async function runReset(options) {
|
|
|
1443
1567
|
logger.header("Reset Omnify Generated Files");
|
|
1444
1568
|
logger.debug("Loading configuration...");
|
|
1445
1569
|
const { config, configPath: configPath2 } = await loadConfig();
|
|
1446
|
-
const rootDir = configPath2 ?
|
|
1570
|
+
const rootDir = configPath2 ? dirname6(configPath2) : process.cwd();
|
|
1447
1571
|
const paths = [];
|
|
1448
1572
|
const omnifyBasePaths = [
|
|
1449
1573
|
{ name: "OmnifyBase models", paths: ["app/Models/OmnifyBase", "backend/app/Models/OmnifyBase"] },
|
|
@@ -1478,7 +1602,7 @@ async function runReset(options) {
|
|
|
1478
1602
|
const laravelConfig = config.output.laravel;
|
|
1479
1603
|
if (laravelConfig?.modelsPath) {
|
|
1480
1604
|
const modelsPath = resolve7(rootDir, laravelConfig.modelsPath);
|
|
1481
|
-
const omnifyBasePath =
|
|
1605
|
+
const omnifyBasePath = join2(modelsPath, "OmnifyBase");
|
|
1482
1606
|
if (existsSync5(omnifyBasePath) && !paths.some((p) => p.path === omnifyBasePath)) {
|
|
1483
1607
|
paths.push({ name: "OmnifyBase models", path: omnifyBasePath, type: "dir" });
|
|
1484
1608
|
}
|
|
@@ -1517,14 +1641,14 @@ async function runReset(options) {
|
|
|
1517
1641
|
if (foundTsPath && existsSync5(foundTsPath)) {
|
|
1518
1642
|
const autoGeneratedDirs = ["base", "enum", "rules", "hooks", "lib"];
|
|
1519
1643
|
for (const subDir of autoGeneratedDirs) {
|
|
1520
|
-
const subPath =
|
|
1644
|
+
const subPath = join2(foundTsPath, subDir);
|
|
1521
1645
|
if (existsSync5(subPath)) {
|
|
1522
1646
|
paths.push({ name: `TypeScript ${subDir}`, path: subPath, type: "dir" });
|
|
1523
1647
|
}
|
|
1524
1648
|
}
|
|
1525
1649
|
const autoGeneratedFiles = ["common.ts", "index.ts", "i18n.ts"];
|
|
1526
1650
|
for (const fileName of autoGeneratedFiles) {
|
|
1527
|
-
const filePath =
|
|
1651
|
+
const filePath = join2(foundTsPath, fileName);
|
|
1528
1652
|
if (existsSync5(filePath)) {
|
|
1529
1653
|
paths.push({ name: `TypeScript ${fileName}`, path: filePath, type: "file" });
|
|
1530
1654
|
}
|
|
@@ -1558,7 +1682,7 @@ async function runReset(options) {
|
|
|
1558
1682
|
const count = countFiles(item.path);
|
|
1559
1683
|
logger.info(` \u2022 ${item.name}: ${item.path} (${count} files)`);
|
|
1560
1684
|
} else if (item.type === "files" && item.pattern) {
|
|
1561
|
-
const count =
|
|
1685
|
+
const count = readdirSync3(item.path).filter((f) => item.pattern.test(f)).length;
|
|
1562
1686
|
logger.info(` \u2022 ${item.name}: ${item.path} (${count} files)`);
|
|
1563
1687
|
} else {
|
|
1564
1688
|
logger.info(` \u2022 ${item.name}: ${item.path}`);
|
|
@@ -1614,7 +1738,7 @@ function registerResetCommand(program2) {
|
|
|
1614
1738
|
|
|
1615
1739
|
// src/commands/create-project.ts
|
|
1616
1740
|
import { execSync, spawn } from "child_process";
|
|
1617
|
-
import { existsSync as existsSync6, rmSync as rmSync2, readFileSync, writeFileSync as writeFileSync4 } from "fs";
|
|
1741
|
+
import { existsSync as existsSync6, rmSync as rmSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync4 } from "fs";
|
|
1618
1742
|
import { resolve as resolve8 } from "path";
|
|
1619
1743
|
var BOILERPLATE_REPO = "https://github.com/omnifyjp/omnify-laravel-boilerplate.git";
|
|
1620
1744
|
var IS_WINDOWS = process.platform === "win32";
|
|
@@ -1718,7 +1842,7 @@ var GITIGNORE_ENTRIES_TO_REMOVE = [
|
|
|
1718
1842
|
function cleanupGitignore(targetDir) {
|
|
1719
1843
|
const gitignorePath = resolve8(targetDir, ".gitignore");
|
|
1720
1844
|
if (!existsSync6(gitignorePath)) return;
|
|
1721
|
-
const content =
|
|
1845
|
+
const content = readFileSync2(gitignorePath, "utf-8");
|
|
1722
1846
|
const lines = content.split("\n");
|
|
1723
1847
|
const cleanedLines = lines.filter((line) => {
|
|
1724
1848
|
const trimmed = line.trim();
|