@famgia/omnify-cli 0.0.144 → 0.0.145
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 +121 -90
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +115 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +92 -61
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
|
-
import { existsSync as
|
|
10
|
+
import { existsSync as existsSync12 } from "fs";
|
|
11
11
|
import { resolve as resolve12 } from "path";
|
|
12
12
|
import { Command } from "commander";
|
|
13
13
|
import { OmnifyError as OmnifyError7 } from "@famgia/omnify-core";
|
|
@@ -552,8 +552,9 @@ function registerInitCommand(program2) {
|
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
// src/commands/validate.ts
|
|
555
|
+
import { existsSync as existsSync4 } from "fs";
|
|
555
556
|
import { resolve as resolve4, dirname as dirname2 } from "path";
|
|
556
|
-
import { loadSchemas, validateSchemas, OmnifyError as OmnifyError2 } from "@famgia/omnify-core";
|
|
557
|
+
import { loadSchemas, mergePartialSchemas, validateSchemas, OmnifyError as OmnifyError2 } from "@famgia/omnify-core";
|
|
557
558
|
|
|
558
559
|
// src/config/loader.ts
|
|
559
560
|
import { existsSync as existsSync3 } from "fs";
|
|
@@ -655,7 +656,8 @@ async function resolveConfig(userConfig, configPath2) {
|
|
|
655
656
|
plugins,
|
|
656
657
|
verbose: userConfig.verbose ?? false,
|
|
657
658
|
lockFilePath: userConfig.lockFilePath ?? ".omnify.lock",
|
|
658
|
-
...userConfig.locale && { locale: userConfig.locale }
|
|
659
|
+
...userConfig.locale && { locale: userConfig.locale },
|
|
660
|
+
...userConfig.additionalSchemaPaths && { additionalSchemaPaths: userConfig.additionalSchemaPaths }
|
|
659
661
|
};
|
|
660
662
|
return result;
|
|
661
663
|
}
|
|
@@ -728,14 +730,38 @@ async function runValidate(options) {
|
|
|
728
730
|
const schemaPath = resolve4(rootDir, config.schemasDir);
|
|
729
731
|
logger.step(`Loading schemas from ${schemaPath}`);
|
|
730
732
|
logger.timing("Schema load start");
|
|
731
|
-
|
|
732
|
-
|
|
733
|
+
let schemas = await loadSchemas(schemaPath);
|
|
734
|
+
logger.debug(`Found ${Object.keys(schemas).length} schema(s) in main directory`);
|
|
735
|
+
const additionalPaths = config.additionalSchemaPaths ?? [];
|
|
736
|
+
let hasPackageSchemas = false;
|
|
737
|
+
if (additionalPaths.length > 0) {
|
|
738
|
+
logger.step(`Loading schemas from ${additionalPaths.length} additional path(s)`);
|
|
739
|
+
for (const entry of additionalPaths) {
|
|
740
|
+
const absolutePath = resolve4(rootDir, entry.path);
|
|
741
|
+
logger.debug(` Checking: ${entry.path} \u2192 ${absolutePath}`);
|
|
742
|
+
if (existsSync4(absolutePath)) {
|
|
743
|
+
const packageSchemas = await loadSchemas(absolutePath, { skipPartialResolution: true });
|
|
744
|
+
const count = Object.keys(packageSchemas).filter((k) => !k.startsWith("__partial__")).length;
|
|
745
|
+
const partialCount = Object.keys(packageSchemas).filter((k) => k.startsWith("__partial__")).length;
|
|
746
|
+
const nsInfo = entry.namespace ? ` [${entry.namespace}]` : "";
|
|
747
|
+
logger.info(` \u2022 ${entry.path}${nsInfo}: ${count} schema(s)${partialCount > 0 ? ` + ${partialCount} partial(s)` : ""}`);
|
|
748
|
+
schemas = { ...packageSchemas, ...schemas };
|
|
749
|
+
hasPackageSchemas = true;
|
|
750
|
+
} else {
|
|
751
|
+
logger.warn(` \u2022 ${entry.path}: directory not found (skipped)`);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (hasPackageSchemas) {
|
|
756
|
+
schemas = mergePartialSchemas(schemas);
|
|
757
|
+
}
|
|
733
758
|
logger.timing("Schemas loaded");
|
|
759
|
+
const schemaCount = Object.keys(schemas).length;
|
|
734
760
|
if (schemaCount === 0) {
|
|
735
761
|
logger.warn("No schema files found");
|
|
736
762
|
return;
|
|
737
763
|
}
|
|
738
|
-
logger.debug(`
|
|
764
|
+
logger.debug(`Total: ${schemaCount} schema(s)`);
|
|
739
765
|
logger.step("Validating schemas...");
|
|
740
766
|
logger.timing("Validation start");
|
|
741
767
|
const result = validateSchemas(schemas);
|
|
@@ -771,8 +797,9 @@ function registerValidateCommand(program2) {
|
|
|
771
797
|
}
|
|
772
798
|
|
|
773
799
|
// src/commands/diff.ts
|
|
800
|
+
import { existsSync as existsSync5 } from "fs";
|
|
774
801
|
import { resolve as resolve5, dirname as dirname3 } from "path";
|
|
775
|
-
import { loadSchemas as loadSchemas2, validateSchemas as validateSchemas2, OmnifyError as OmnifyError3 } from "@famgia/omnify-core";
|
|
802
|
+
import { loadSchemas as loadSchemas2, mergePartialSchemas as mergePartialSchemas2, validateSchemas as validateSchemas2, OmnifyError as OmnifyError3 } from "@famgia/omnify-core";
|
|
776
803
|
|
|
777
804
|
// src/operations/diff.ts
|
|
778
805
|
import {
|
|
@@ -811,13 +838,37 @@ async function runDiff(options) {
|
|
|
811
838
|
requireDevUrl(config);
|
|
812
839
|
const schemaPath = resolve5(rootDir, config.schemasDir);
|
|
813
840
|
logger.step(`Loading schemas from ${schemaPath}`);
|
|
814
|
-
|
|
841
|
+
let schemas = await loadSchemas2(schemaPath);
|
|
842
|
+
logger.debug(`Found ${Object.keys(schemas).length} schema(s) in main directory`);
|
|
843
|
+
const additionalPaths = config.additionalSchemaPaths ?? [];
|
|
844
|
+
let hasPackageSchemas = false;
|
|
845
|
+
if (additionalPaths.length > 0) {
|
|
846
|
+
logger.step(`Loading schemas from ${additionalPaths.length} additional path(s)`);
|
|
847
|
+
for (const entry of additionalPaths) {
|
|
848
|
+
const absolutePath = resolve5(rootDir, entry.path);
|
|
849
|
+
logger.debug(` Checking: ${entry.path} \u2192 ${absolutePath}`);
|
|
850
|
+
if (existsSync5(absolutePath)) {
|
|
851
|
+
const packageSchemas = await loadSchemas2(absolutePath, { skipPartialResolution: true });
|
|
852
|
+
const count = Object.keys(packageSchemas).filter((k) => !k.startsWith("__partial__")).length;
|
|
853
|
+
const partialCount = Object.keys(packageSchemas).filter((k) => k.startsWith("__partial__")).length;
|
|
854
|
+
const nsInfo = entry.namespace ? ` [${entry.namespace}]` : "";
|
|
855
|
+
logger.info(` \u2022 ${entry.path}${nsInfo}: ${count} schema(s)${partialCount > 0 ? ` + ${partialCount} partial(s)` : ""}`);
|
|
856
|
+
schemas = { ...packageSchemas, ...schemas };
|
|
857
|
+
hasPackageSchemas = true;
|
|
858
|
+
} else {
|
|
859
|
+
logger.warn(` \u2022 ${entry.path}: directory not found (skipped)`);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
if (hasPackageSchemas) {
|
|
864
|
+
schemas = mergePartialSchemas2(schemas);
|
|
865
|
+
}
|
|
815
866
|
const schemaCount = Object.keys(schemas).length;
|
|
816
867
|
if (schemaCount === 0) {
|
|
817
868
|
logger.warn("No schema files found");
|
|
818
869
|
return;
|
|
819
870
|
}
|
|
820
|
-
logger.debug(`
|
|
871
|
+
logger.debug(`Total: ${schemaCount} schema(s)`);
|
|
821
872
|
logger.step("Validating schemas...");
|
|
822
873
|
const validationResult = validateSchemas2(schemas);
|
|
823
874
|
if (!validationResult.valid) {
|
|
@@ -875,11 +926,11 @@ function registerDiffCommand(program2) {
|
|
|
875
926
|
}
|
|
876
927
|
|
|
877
928
|
// src/commands/generate.ts
|
|
878
|
-
import { existsSync as
|
|
929
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, writeFileSync as writeFileSync4, readdirSync as readdirSync2 } from "fs";
|
|
879
930
|
import { resolve as resolve7, dirname as dirname5, relative } from "path";
|
|
880
931
|
import {
|
|
881
932
|
loadSchemas as loadSchemas3,
|
|
882
|
-
mergePartialSchemas,
|
|
933
|
+
mergePartialSchemas as mergePartialSchemas3,
|
|
883
934
|
validateSchemas as validateSchemas3,
|
|
884
935
|
OmnifyError as OmnifyError4,
|
|
885
936
|
PluginManager,
|
|
@@ -909,7 +960,7 @@ import {
|
|
|
909
960
|
import { generateTypeScript, copyStubs, generateAIGuides as generateTypescriptAIGuides, shouldGenerateAIGuides as shouldGenerateTypescriptAIGuides } from "@famgia/omnify-typescript";
|
|
910
961
|
|
|
911
962
|
// src/guides/index.ts
|
|
912
|
-
import { existsSync as
|
|
963
|
+
import { existsSync as existsSync6, writeFileSync as writeFileSync3, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync2 } from "fs";
|
|
913
964
|
import { resolve as resolve6, dirname as dirname4, join } from "path";
|
|
914
965
|
import "url";
|
|
915
966
|
var CLAUDE_MD = `# Omnify Project
|
|
@@ -974,19 +1025,19 @@ function copyOmnifyGuides(rootDir) {
|
|
|
974
1025
|
for (const pkgPath of omnifyPkgPaths) {
|
|
975
1026
|
if (pkgPath.includes("*")) {
|
|
976
1027
|
const parentDir = dirname4(dirname4(pkgPath));
|
|
977
|
-
if (
|
|
1028
|
+
if (existsSync6(parentDir)) {
|
|
978
1029
|
const entries = readdirSync(parentDir);
|
|
979
1030
|
for (const entry of entries) {
|
|
980
1031
|
if (entry.startsWith("@famgia+omnify@")) {
|
|
981
1032
|
const testPath = join(parentDir, entry, "node_modules", "@famgia", "omnify", "stubs", "ai-guides", "omnify");
|
|
982
|
-
if (
|
|
1033
|
+
if (existsSync6(testPath)) {
|
|
983
1034
|
stubsDir = testPath;
|
|
984
1035
|
break;
|
|
985
1036
|
}
|
|
986
1037
|
}
|
|
987
1038
|
}
|
|
988
1039
|
}
|
|
989
|
-
} else if (
|
|
1040
|
+
} else if (existsSync6(pkgPath)) {
|
|
990
1041
|
stubsDir = pkgPath;
|
|
991
1042
|
break;
|
|
992
1043
|
}
|
|
@@ -995,7 +1046,7 @@ function copyOmnifyGuides(rootDir) {
|
|
|
995
1046
|
try {
|
|
996
1047
|
const omnifyPath = dirname4(__require.resolve("@famgia/omnify/package.json", { paths: [rootDir] }));
|
|
997
1048
|
const testPath = join(omnifyPath, "stubs", "ai-guides", "omnify");
|
|
998
|
-
if (
|
|
1049
|
+
if (existsSync6(testPath)) {
|
|
999
1050
|
stubsDir = testPath;
|
|
1000
1051
|
}
|
|
1001
1052
|
} catch {
|
|
@@ -1019,7 +1070,7 @@ function copyOmnifyGuides(rootDir) {
|
|
|
1019
1070
|
function generateAIGuides(rootDir, _plugins) {
|
|
1020
1071
|
let filesWritten = 0;
|
|
1021
1072
|
const claudeMdPath = resolve6(rootDir, "CLAUDE.md");
|
|
1022
|
-
if (!
|
|
1073
|
+
if (!existsSync6(claudeMdPath)) {
|
|
1023
1074
|
writeFileSync3(claudeMdPath, CLAUDE_MD);
|
|
1024
1075
|
filesWritten++;
|
|
1025
1076
|
}
|
|
@@ -1028,33 +1079,12 @@ function generateAIGuides(rootDir, _plugins) {
|
|
|
1028
1079
|
}
|
|
1029
1080
|
|
|
1030
1081
|
// src/commands/generate.ts
|
|
1031
|
-
async function loadRegisteredSchemaPaths(rootDir) {
|
|
1032
|
-
const schemaPathsFile = resolve7(rootDir, "storage/omnify/schema-paths.json");
|
|
1033
|
-
logger.debug(`Checking for registered schema paths at: ${schemaPathsFile}`);
|
|
1034
|
-
if (!existsSync5(schemaPathsFile)) {
|
|
1035
|
-
logger.debug("No registered schema paths file found");
|
|
1036
|
-
return [];
|
|
1037
|
-
}
|
|
1038
|
-
try {
|
|
1039
|
-
const content = readFileSync3(schemaPathsFile, "utf-8");
|
|
1040
|
-
const data = JSON.parse(content);
|
|
1041
|
-
if (!data.paths || data.paths.length === 0) {
|
|
1042
|
-
logger.debug("No paths defined in schema-paths.json");
|
|
1043
|
-
return [];
|
|
1044
|
-
}
|
|
1045
|
-
logger.debug(`Found ${data.paths.length} registered schema path(s) in schema-paths.json`);
|
|
1046
|
-
return data.paths;
|
|
1047
|
-
} catch (error) {
|
|
1048
|
-
logger.warn(`Could not read schema-paths.json: ${error.message}`);
|
|
1049
|
-
return [];
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
1082
|
function hasPluginGenerators(plugins) {
|
|
1053
1083
|
return plugins.some((p) => p.generators && p.generators.length > 0);
|
|
1054
1084
|
}
|
|
1055
1085
|
function getExistingMigrationTables(migrationsDir) {
|
|
1056
1086
|
const existingTables = /* @__PURE__ */ new Set();
|
|
1057
|
-
if (!
|
|
1087
|
+
if (!existsSync7(migrationsDir)) {
|
|
1058
1088
|
return existingTables;
|
|
1059
1089
|
}
|
|
1060
1090
|
try {
|
|
@@ -1249,11 +1279,11 @@ function writeGeneratorOutputs(outputs, rootDir) {
|
|
|
1249
1279
|
for (const output of outputs) {
|
|
1250
1280
|
const filePath = resolve7(rootDir, output.path);
|
|
1251
1281
|
const dir = dirname5(filePath);
|
|
1252
|
-
if (!
|
|
1282
|
+
if (!existsSync7(dir)) {
|
|
1253
1283
|
mkdirSync3(dir, { recursive: true });
|
|
1254
1284
|
logger.debug(`Created directory: ${dir}`);
|
|
1255
1285
|
}
|
|
1256
|
-
if (output.skipIfExists &&
|
|
1286
|
+
if (output.skipIfExists && existsSync7(filePath)) {
|
|
1257
1287
|
logger.debug(`Skipped (exists): ${output.path}`);
|
|
1258
1288
|
continue;
|
|
1259
1289
|
}
|
|
@@ -1314,7 +1344,7 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1314
1344
|
if (!options.typesOnly && config.output.laravel) {
|
|
1315
1345
|
logger.step("Generating Laravel migrations...");
|
|
1316
1346
|
const migrationsDir = resolve7(rootDir, config.output.laravel.migrationsPath);
|
|
1317
|
-
if (!
|
|
1347
|
+
if (!existsSync7(migrationsDir)) {
|
|
1318
1348
|
mkdirSync3(migrationsDir, { recursive: true });
|
|
1319
1349
|
logger.debug(`Created directory: ${migrationsDir}`);
|
|
1320
1350
|
}
|
|
@@ -1359,10 +1389,10 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1359
1389
|
const baseModelsPath = config.output.laravel.baseModelsPath ?? `${modelsPath}/OmnifyBase`;
|
|
1360
1390
|
const modelsDir = resolve7(rootDir, modelsPath);
|
|
1361
1391
|
const baseModelsDir = resolve7(rootDir, baseModelsPath);
|
|
1362
|
-
if (!
|
|
1392
|
+
if (!existsSync7(modelsDir)) {
|
|
1363
1393
|
mkdirSync3(modelsDir, { recursive: true });
|
|
1364
1394
|
}
|
|
1365
|
-
if (!
|
|
1395
|
+
if (!existsSync7(baseModelsDir)) {
|
|
1366
1396
|
mkdirSync3(baseModelsDir, { recursive: true });
|
|
1367
1397
|
}
|
|
1368
1398
|
const providersPath = config.output.laravel.providersPath ?? "app/Providers";
|
|
@@ -1375,10 +1405,10 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1375
1405
|
for (const model of models) {
|
|
1376
1406
|
const filePath = resolve7(rootDir, getModelPath(model));
|
|
1377
1407
|
const fileDir = dirname5(filePath);
|
|
1378
|
-
if (!
|
|
1408
|
+
if (!existsSync7(fileDir)) {
|
|
1379
1409
|
mkdirSync3(fileDir, { recursive: true });
|
|
1380
1410
|
}
|
|
1381
|
-
if (!model.overwrite &&
|
|
1411
|
+
if (!model.overwrite && existsSync7(filePath)) {
|
|
1382
1412
|
logger.debug(`Skipped (exists): ${getModelPath(model)}`);
|
|
1383
1413
|
continue;
|
|
1384
1414
|
}
|
|
@@ -1392,7 +1422,7 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1392
1422
|
logger.step("Generating Laravel factories...");
|
|
1393
1423
|
const factoriesPath = config.output.laravel.factoriesPath;
|
|
1394
1424
|
const factoriesDir = resolve7(rootDir, factoriesPath);
|
|
1395
|
-
if (!
|
|
1425
|
+
if (!existsSync7(factoriesDir)) {
|
|
1396
1426
|
mkdirSync3(factoriesDir, { recursive: true });
|
|
1397
1427
|
}
|
|
1398
1428
|
const factories = generateFactories(schemas, {
|
|
@@ -1401,10 +1431,10 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1401
1431
|
for (const factory of factories) {
|
|
1402
1432
|
const filePath = resolve7(rootDir, getFactoryPath(factory));
|
|
1403
1433
|
const fileDir = dirname5(filePath);
|
|
1404
|
-
if (!
|
|
1434
|
+
if (!existsSync7(fileDir)) {
|
|
1405
1435
|
mkdirSync3(fileDir, { recursive: true });
|
|
1406
1436
|
}
|
|
1407
|
-
if (!factory.overwrite &&
|
|
1437
|
+
if (!factory.overwrite && existsSync7(filePath)) {
|
|
1408
1438
|
logger.debug(`Skipped (exists): ${getFactoryPath(factory)}`);
|
|
1409
1439
|
continue;
|
|
1410
1440
|
}
|
|
@@ -1421,11 +1451,11 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1421
1451
|
const schemasDir = resolve7(basePath, tsConfig.schemasDir ?? "schemas");
|
|
1422
1452
|
const enumDir = resolve7(basePath, tsConfig.enumDir ?? "enum");
|
|
1423
1453
|
const enumImportPrefix = relative(schemasDir, enumDir).replace(/\\/g, "/");
|
|
1424
|
-
if (!
|
|
1454
|
+
if (!existsSync7(schemasDir)) {
|
|
1425
1455
|
mkdirSync3(schemasDir, { recursive: true });
|
|
1426
1456
|
logger.debug(`Created directory: ${schemasDir}`);
|
|
1427
1457
|
}
|
|
1428
|
-
if (!
|
|
1458
|
+
if (!existsSync7(enumDir)) {
|
|
1429
1459
|
mkdirSync3(enumDir, { recursive: true });
|
|
1430
1460
|
logger.debug(`Created directory: ${enumDir}`);
|
|
1431
1461
|
}
|
|
@@ -1443,10 +1473,10 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1443
1473
|
const outputDir = file.category === "enum" ? enumDir : schemasDir;
|
|
1444
1474
|
const filePath = resolve7(outputDir, file.filePath);
|
|
1445
1475
|
const fileDir = dirname5(filePath);
|
|
1446
|
-
if (!
|
|
1476
|
+
if (!existsSync7(fileDir)) {
|
|
1447
1477
|
mkdirSync3(fileDir, { recursive: true });
|
|
1448
1478
|
}
|
|
1449
|
-
if (!file.overwrite &&
|
|
1479
|
+
if (!file.overwrite && existsSync7(filePath)) {
|
|
1450
1480
|
logger.debug(`Skipped (exists): ${file.filePath}`);
|
|
1451
1481
|
continue;
|
|
1452
1482
|
}
|
|
@@ -1483,18 +1513,19 @@ async function runGenerate(options) {
|
|
|
1483
1513
|
logger.step(`Loading schemas from ${schemaPath}`);
|
|
1484
1514
|
let schemas = await loadSchemas3(schemaPath);
|
|
1485
1515
|
logger.debug(`Found ${Object.keys(schemas).length} schema(s) in main directory`);
|
|
1486
|
-
const additionalPaths =
|
|
1516
|
+
const additionalPaths = config.additionalSchemaPaths ?? [];
|
|
1487
1517
|
let hasPackageSchemas = false;
|
|
1488
1518
|
if (additionalPaths.length > 0) {
|
|
1489
|
-
logger.step(`Loading schemas from ${additionalPaths.length}
|
|
1519
|
+
logger.step(`Loading schemas from ${additionalPaths.length} additional path(s)`);
|
|
1490
1520
|
for (const entry of additionalPaths) {
|
|
1491
1521
|
const absolutePath = resolve7(rootDir, entry.path);
|
|
1492
1522
|
logger.debug(` Checking: ${entry.path} \u2192 ${absolutePath}`);
|
|
1493
|
-
if (
|
|
1523
|
+
if (existsSync7(absolutePath)) {
|
|
1494
1524
|
const packageSchemas = await loadSchemas3(absolutePath, { skipPartialResolution: true });
|
|
1495
1525
|
const count = Object.keys(packageSchemas).filter((k) => !k.startsWith("__partial__")).length;
|
|
1496
1526
|
const partialCount = Object.keys(packageSchemas).filter((k) => k.startsWith("__partial__")).length;
|
|
1497
|
-
|
|
1527
|
+
const nsInfo = entry.namespace ? ` [${entry.namespace}]` : "";
|
|
1528
|
+
logger.info(` \u2022 ${entry.path}${nsInfo}: ${count} schema(s)${partialCount > 0 ? ` + ${partialCount} partial(s)` : ""}`);
|
|
1498
1529
|
schemas = { ...packageSchemas, ...schemas };
|
|
1499
1530
|
hasPackageSchemas = true;
|
|
1500
1531
|
} else {
|
|
@@ -1504,7 +1535,7 @@ async function runGenerate(options) {
|
|
|
1504
1535
|
}
|
|
1505
1536
|
}
|
|
1506
1537
|
if (hasPackageSchemas) {
|
|
1507
|
-
schemas =
|
|
1538
|
+
schemas = mergePartialSchemas3(schemas);
|
|
1508
1539
|
}
|
|
1509
1540
|
const schemaCount = Object.keys(schemas).length;
|
|
1510
1541
|
if (schemaCount === 0) {
|
|
@@ -1703,11 +1734,11 @@ async function runGenerate(options) {
|
|
|
1703
1734
|
const schemasDir2 = resolve7(basePath2, tsConfig2.schemasDir ?? "schemas");
|
|
1704
1735
|
const enumDir2 = resolve7(basePath2, tsConfig2.enumDir ?? "enum");
|
|
1705
1736
|
const enumImportPrefix2 = relative(schemasDir2, enumDir2).replace(/\\/g, "/");
|
|
1706
|
-
if (!
|
|
1737
|
+
if (!existsSync7(schemasDir2)) {
|
|
1707
1738
|
mkdirSync3(schemasDir2, { recursive: true });
|
|
1708
1739
|
logger.debug(`Created directory: ${schemasDir2}`);
|
|
1709
1740
|
}
|
|
1710
|
-
if (!
|
|
1741
|
+
if (!existsSync7(enumDir2)) {
|
|
1711
1742
|
mkdirSync3(enumDir2, { recursive: true });
|
|
1712
1743
|
logger.debug(`Created directory: ${enumDir2}`);
|
|
1713
1744
|
}
|
|
@@ -1725,10 +1756,10 @@ async function runGenerate(options) {
|
|
|
1725
1756
|
const outputDir2 = file.category === "enum" ? enumDir2 : schemasDir2;
|
|
1726
1757
|
const filePath = resolve7(outputDir2, file.filePath);
|
|
1727
1758
|
const fileDir = dirname5(filePath);
|
|
1728
|
-
if (!
|
|
1759
|
+
if (!existsSync7(fileDir)) {
|
|
1729
1760
|
mkdirSync3(fileDir, { recursive: true });
|
|
1730
1761
|
}
|
|
1731
|
-
if (!file.overwrite &&
|
|
1762
|
+
if (!file.overwrite && existsSync7(filePath)) {
|
|
1732
1763
|
logger.debug(`Skipped (exists): ${file.filePath}`);
|
|
1733
1764
|
continue;
|
|
1734
1765
|
}
|
|
@@ -1831,7 +1862,7 @@ function registerGenerateCommand(program2) {
|
|
|
1831
1862
|
}
|
|
1832
1863
|
|
|
1833
1864
|
// src/commands/reset.ts
|
|
1834
|
-
import { existsSync as
|
|
1865
|
+
import { existsSync as existsSync8, readdirSync as readdirSync3, rmSync, statSync } from "fs";
|
|
1835
1866
|
import { resolve as resolve8, dirname as dirname6, join as join2 } from "path";
|
|
1836
1867
|
import { createInterface } from "readline";
|
|
1837
1868
|
async function confirm2(message) {
|
|
@@ -1847,7 +1878,7 @@ async function confirm2(message) {
|
|
|
1847
1878
|
});
|
|
1848
1879
|
}
|
|
1849
1880
|
function countFiles(dir) {
|
|
1850
|
-
if (!
|
|
1881
|
+
if (!existsSync8(dir)) return 0;
|
|
1851
1882
|
let count = 0;
|
|
1852
1883
|
const entries = readdirSync3(dir);
|
|
1853
1884
|
for (const entry of entries) {
|
|
@@ -1862,7 +1893,7 @@ function countFiles(dir) {
|
|
|
1862
1893
|
return count;
|
|
1863
1894
|
}
|
|
1864
1895
|
function deleteDir(dir, verbose) {
|
|
1865
|
-
if (!
|
|
1896
|
+
if (!existsSync8(dir)) return 0;
|
|
1866
1897
|
const count = countFiles(dir);
|
|
1867
1898
|
rmSync(dir, { recursive: true, force: true });
|
|
1868
1899
|
if (verbose) {
|
|
@@ -1871,7 +1902,7 @@ function deleteDir(dir, verbose) {
|
|
|
1871
1902
|
return count;
|
|
1872
1903
|
}
|
|
1873
1904
|
function deleteFilesInDir(dir, pattern, verbose) {
|
|
1874
|
-
if (!
|
|
1905
|
+
if (!existsSync8(dir)) return 0;
|
|
1875
1906
|
let count = 0;
|
|
1876
1907
|
const entries = readdirSync3(dir);
|
|
1877
1908
|
for (const entry of entries) {
|
|
@@ -1902,7 +1933,7 @@ async function runReset(options) {
|
|
|
1902
1933
|
for (const { name, paths: relPaths } of omnifyBasePaths) {
|
|
1903
1934
|
for (const relPath of relPaths) {
|
|
1904
1935
|
const omnifyBasePath = resolve8(rootDir, relPath);
|
|
1905
|
-
if (
|
|
1936
|
+
if (existsSync8(omnifyBasePath)) {
|
|
1906
1937
|
paths.push({ name, path: omnifyBasePath, type: "dir" });
|
|
1907
1938
|
break;
|
|
1908
1939
|
}
|
|
@@ -1914,7 +1945,7 @@ async function runReset(options) {
|
|
|
1914
1945
|
];
|
|
1915
1946
|
for (const relPath of migrationPaths) {
|
|
1916
1947
|
const migrationsPath = resolve8(rootDir, relPath);
|
|
1917
|
-
if (
|
|
1948
|
+
if (existsSync8(migrationsPath)) {
|
|
1918
1949
|
paths.push({
|
|
1919
1950
|
name: "Omnify migrations",
|
|
1920
1951
|
path: migrationsPath,
|
|
@@ -1928,13 +1959,13 @@ async function runReset(options) {
|
|
|
1928
1959
|
if (laravelConfig?.modelsPath) {
|
|
1929
1960
|
const modelsPath = resolve8(rootDir, laravelConfig.modelsPath);
|
|
1930
1961
|
const omnifyBasePath = join2(modelsPath, "OmnifyBase");
|
|
1931
|
-
if (
|
|
1962
|
+
if (existsSync8(omnifyBasePath) && !paths.some((p) => p.path === omnifyBasePath)) {
|
|
1932
1963
|
paths.push({ name: "OmnifyBase models", path: omnifyBasePath, type: "dir" });
|
|
1933
1964
|
}
|
|
1934
1965
|
}
|
|
1935
1966
|
if (laravelConfig?.migrationsPath) {
|
|
1936
1967
|
const migrationsPath = resolve8(rootDir, laravelConfig.migrationsPath);
|
|
1937
|
-
if (
|
|
1968
|
+
if (existsSync8(migrationsPath) && !paths.some((p) => p.path === migrationsPath)) {
|
|
1938
1969
|
paths.push({
|
|
1939
1970
|
name: "Omnify migrations",
|
|
1940
1971
|
path: migrationsPath,
|
|
@@ -1954,45 +1985,45 @@ async function runReset(options) {
|
|
|
1954
1985
|
"src/types/models"
|
|
1955
1986
|
];
|
|
1956
1987
|
let foundTsPath = tsBasePath;
|
|
1957
|
-
if (!foundTsPath || !
|
|
1988
|
+
if (!foundTsPath || !existsSync8(foundTsPath)) {
|
|
1958
1989
|
for (const relPath of commonTsPaths) {
|
|
1959
1990
|
const tsPath = resolve8(rootDir, relPath);
|
|
1960
|
-
if (
|
|
1991
|
+
if (existsSync8(tsPath)) {
|
|
1961
1992
|
foundTsPath = tsPath;
|
|
1962
1993
|
break;
|
|
1963
1994
|
}
|
|
1964
1995
|
}
|
|
1965
1996
|
}
|
|
1966
|
-
if (foundTsPath &&
|
|
1997
|
+
if (foundTsPath && existsSync8(foundTsPath)) {
|
|
1967
1998
|
const autoGeneratedDirs = ["base", "enum", "rules", "hooks", "lib"];
|
|
1968
1999
|
for (const subDir of autoGeneratedDirs) {
|
|
1969
2000
|
const subPath = join2(foundTsPath, subDir);
|
|
1970
|
-
if (
|
|
2001
|
+
if (existsSync8(subPath)) {
|
|
1971
2002
|
paths.push({ name: `TypeScript ${subDir}`, path: subPath, type: "dir" });
|
|
1972
2003
|
}
|
|
1973
2004
|
}
|
|
1974
2005
|
const autoGeneratedFiles = ["common.ts", "index.ts", "i18n.ts"];
|
|
1975
2006
|
for (const fileName of autoGeneratedFiles) {
|
|
1976
2007
|
const filePath = join2(foundTsPath, fileName);
|
|
1977
|
-
if (
|
|
2008
|
+
if (existsSync8(filePath)) {
|
|
1978
2009
|
paths.push({ name: `TypeScript ${fileName}`, path: filePath, type: "file" });
|
|
1979
2010
|
}
|
|
1980
2011
|
}
|
|
1981
2012
|
}
|
|
1982
2013
|
const lockFilePath = resolve8(rootDir, config.lockFilePath);
|
|
1983
|
-
if (
|
|
2014
|
+
if (existsSync8(lockFilePath)) {
|
|
1984
2015
|
paths.push({ name: "Lock file", path: lockFilePath, type: "file" });
|
|
1985
2016
|
}
|
|
1986
2017
|
const versionsDir = resolve8(rootDir, ".omnify-versions");
|
|
1987
|
-
if (
|
|
2018
|
+
if (existsSync8(versionsDir)) {
|
|
1988
2019
|
paths.push({ name: "Version history", path: versionsDir, type: "dir" });
|
|
1989
2020
|
}
|
|
1990
2021
|
const omnifyVersionsDir = resolve8(rootDir, ".omnify/versions");
|
|
1991
|
-
if (
|
|
2022
|
+
if (existsSync8(omnifyVersionsDir)) {
|
|
1992
2023
|
paths.push({ name: "Version history (.omnify/versions)", path: omnifyVersionsDir, type: "dir" });
|
|
1993
2024
|
}
|
|
1994
2025
|
const logsDir = resolve8(rootDir, ".omnify/logs");
|
|
1995
|
-
if (
|
|
2026
|
+
if (existsSync8(logsDir)) {
|
|
1996
2027
|
paths.push({ name: "Logs", path: logsDir, type: "dir" });
|
|
1997
2028
|
}
|
|
1998
2029
|
if (paths.length === 0) {
|
|
@@ -2063,7 +2094,7 @@ function registerResetCommand(program2) {
|
|
|
2063
2094
|
|
|
2064
2095
|
// src/commands/create-project.ts
|
|
2065
2096
|
import { execSync, spawn } from "child_process";
|
|
2066
|
-
import { existsSync as
|
|
2097
|
+
import { existsSync as existsSync9, rmSync as rmSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
2067
2098
|
import { resolve as resolve9 } from "path";
|
|
2068
2099
|
var BOILERPLATE_REPO = "https://github.com/omnifyjp/omnify-laravel-boilerplate.git";
|
|
2069
2100
|
var IS_WINDOWS = process.platform === "win32";
|
|
@@ -2166,8 +2197,8 @@ var GITIGNORE_ENTRIES_TO_REMOVE = [
|
|
|
2166
2197
|
];
|
|
2167
2198
|
function cleanupGitignore(targetDir) {
|
|
2168
2199
|
const gitignorePath = resolve9(targetDir, ".gitignore");
|
|
2169
|
-
if (!
|
|
2170
|
-
const content =
|
|
2200
|
+
if (!existsSync9(gitignorePath)) return;
|
|
2201
|
+
const content = readFileSync3(gitignorePath, "utf-8");
|
|
2171
2202
|
const lines = content.split("\n");
|
|
2172
2203
|
const cleanedLines = lines.filter((line) => {
|
|
2173
2204
|
const trimmed = line.trim();
|
|
@@ -2182,7 +2213,7 @@ function cloneRepo(repo, targetDir) {
|
|
|
2182
2213
|
logger.step(`Cloning boilerplate from ${repo}...`);
|
|
2183
2214
|
execSync(`git clone --depth 1 ${repo} "${targetDir}"`, { stdio: "inherit" });
|
|
2184
2215
|
const gitDir = resolve9(targetDir, ".git");
|
|
2185
|
-
if (
|
|
2216
|
+
if (existsSync9(gitDir)) {
|
|
2186
2217
|
rmSync2(gitDir, { recursive: true, force: true });
|
|
2187
2218
|
}
|
|
2188
2219
|
cleanupGitignore(targetDir);
|
|
@@ -2252,7 +2283,7 @@ async function runCreateProject(projectName, options) {
|
|
|
2252
2283
|
logger.error("Git is not installed. Please install git first.");
|
|
2253
2284
|
process.exit(1);
|
|
2254
2285
|
}
|
|
2255
|
-
if (
|
|
2286
|
+
if (existsSync9(targetDir)) {
|
|
2256
2287
|
logger.error(`Directory "${projectName}" already exists.`);
|
|
2257
2288
|
process.exit(1);
|
|
2258
2289
|
}
|
|
@@ -2278,7 +2309,7 @@ async function runCreateProject(projectName, options) {
|
|
|
2278
2309
|
logger.info(" pnpm run dev");
|
|
2279
2310
|
logger.newline();
|
|
2280
2311
|
} catch (error) {
|
|
2281
|
-
if (!cloneSucceeded &&
|
|
2312
|
+
if (!cloneSucceeded && existsSync9(targetDir)) {
|
|
2282
2313
|
rmSync2(targetDir, { recursive: true, force: true });
|
|
2283
2314
|
} else if (cloneSucceeded) {
|
|
2284
2315
|
logger.newline();
|
|
@@ -2304,7 +2335,7 @@ function registerCreateProjectCommand(program2) {
|
|
|
2304
2335
|
}
|
|
2305
2336
|
|
|
2306
2337
|
// src/commands/deploy.ts
|
|
2307
|
-
import { existsSync as
|
|
2338
|
+
import { existsSync as existsSync10 } from "fs";
|
|
2308
2339
|
import { resolve as resolve10, dirname as dirname7 } from "path";
|
|
2309
2340
|
import { loadSchemas as loadSchemas4, OmnifyError as OmnifyError5 } from "@famgia/omnify-core";
|
|
2310
2341
|
import {
|
|
@@ -2361,7 +2392,7 @@ async function runDeploy(options) {
|
|
|
2361
2392
|
validateConfig(config, rootDir);
|
|
2362
2393
|
const schemasDir = resolve10(rootDir, config.schemasDir);
|
|
2363
2394
|
const chainFilePath = resolve10(rootDir, VERSION_CHAIN_FILE2);
|
|
2364
|
-
if (!
|
|
2395
|
+
if (!existsSync10(schemasDir)) {
|
|
2365
2396
|
throw new OmnifyError5(
|
|
2366
2397
|
`Schemas directory not found: ${schemasDir}`,
|
|
2367
2398
|
"E003",
|
|
@@ -2515,7 +2546,7 @@ function registerDeployCommand(program2) {
|
|
|
2515
2546
|
}
|
|
2516
2547
|
|
|
2517
2548
|
// src/commands/verify.ts
|
|
2518
|
-
import { existsSync as
|
|
2549
|
+
import { existsSync as existsSync11 } from "fs";
|
|
2519
2550
|
import { resolve as resolve11, dirname as dirname8 } from "path";
|
|
2520
2551
|
import { OmnifyError as OmnifyError6 } from "@famgia/omnify-core";
|
|
2521
2552
|
import {
|
|
@@ -2536,7 +2567,7 @@ async function runVerify(options) {
|
|
|
2536
2567
|
validateConfig(config, rootDir);
|
|
2537
2568
|
const schemasDir = resolve11(rootDir, config.schemasDir);
|
|
2538
2569
|
const chainFilePath = resolve11(rootDir, VERSION_CHAIN_FILE3);
|
|
2539
|
-
if (!
|
|
2570
|
+
if (!existsSync11(chainFilePath)) {
|
|
2540
2571
|
if (options.json) {
|
|
2541
2572
|
console.log(JSON.stringify({
|
|
2542
2573
|
valid: true,
|
|
@@ -2717,7 +2748,7 @@ var args = process.argv.slice(2);
|
|
|
2717
2748
|
var firstArg = args[0];
|
|
2718
2749
|
var hasCommand = firstArg !== void 0 && !firstArg.startsWith("-");
|
|
2719
2750
|
var configPath = resolve12(process.cwd(), "omnify.config.ts");
|
|
2720
|
-
var hasConfig =
|
|
2751
|
+
var hasConfig = existsSync12(configPath);
|
|
2721
2752
|
if (!hasCommand && !hasConfig) {
|
|
2722
2753
|
runInit({}).catch((error) => {
|
|
2723
2754
|
if (error instanceof Error) {
|