@famgia/omnify-cli 0.0.143 → 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/index.cjs
CHANGED
|
@@ -141,7 +141,8 @@ async function resolveConfig(userConfig, configPath) {
|
|
|
141
141
|
plugins,
|
|
142
142
|
verbose: userConfig.verbose ?? false,
|
|
143
143
|
lockFilePath: userConfig.lockFilePath ?? ".omnify.lock",
|
|
144
|
-
...userConfig.locale && { locale: userConfig.locale }
|
|
144
|
+
...userConfig.locale && { locale: userConfig.locale },
|
|
145
|
+
...userConfig.additionalSchemaPaths && { additionalSchemaPaths: userConfig.additionalSchemaPaths }
|
|
145
146
|
};
|
|
146
147
|
return result;
|
|
147
148
|
}
|
|
@@ -744,6 +745,7 @@ function registerInitCommand(program) {
|
|
|
744
745
|
}
|
|
745
746
|
|
|
746
747
|
// src/commands/validate.ts
|
|
748
|
+
var import_node_fs4 = require("fs");
|
|
747
749
|
var import_node_path4 = require("path");
|
|
748
750
|
var import_omnify_core3 = require("@famgia/omnify-core");
|
|
749
751
|
async function runValidate(options) {
|
|
@@ -758,14 +760,38 @@ async function runValidate(options) {
|
|
|
758
760
|
const schemaPath = (0, import_node_path4.resolve)(rootDir, config.schemasDir);
|
|
759
761
|
logger.step(`Loading schemas from ${schemaPath}`);
|
|
760
762
|
logger.timing("Schema load start");
|
|
761
|
-
|
|
762
|
-
|
|
763
|
+
let schemas = await (0, import_omnify_core3.loadSchemas)(schemaPath);
|
|
764
|
+
logger.debug(`Found ${Object.keys(schemas).length} schema(s) in main directory`);
|
|
765
|
+
const additionalPaths = config.additionalSchemaPaths ?? [];
|
|
766
|
+
let hasPackageSchemas = false;
|
|
767
|
+
if (additionalPaths.length > 0) {
|
|
768
|
+
logger.step(`Loading schemas from ${additionalPaths.length} additional path(s)`);
|
|
769
|
+
for (const entry of additionalPaths) {
|
|
770
|
+
const absolutePath = (0, import_node_path4.resolve)(rootDir, entry.path);
|
|
771
|
+
logger.debug(` Checking: ${entry.path} \u2192 ${absolutePath}`);
|
|
772
|
+
if ((0, import_node_fs4.existsSync)(absolutePath)) {
|
|
773
|
+
const packageSchemas = await (0, import_omnify_core3.loadSchemas)(absolutePath, { skipPartialResolution: true });
|
|
774
|
+
const count = Object.keys(packageSchemas).filter((k) => !k.startsWith("__partial__")).length;
|
|
775
|
+
const partialCount = Object.keys(packageSchemas).filter((k) => k.startsWith("__partial__")).length;
|
|
776
|
+
const nsInfo = entry.namespace ? ` [${entry.namespace}]` : "";
|
|
777
|
+
logger.info(` \u2022 ${entry.path}${nsInfo}: ${count} schema(s)${partialCount > 0 ? ` + ${partialCount} partial(s)` : ""}`);
|
|
778
|
+
schemas = { ...packageSchemas, ...schemas };
|
|
779
|
+
hasPackageSchemas = true;
|
|
780
|
+
} else {
|
|
781
|
+
logger.warn(` \u2022 ${entry.path}: directory not found (skipped)`);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (hasPackageSchemas) {
|
|
786
|
+
schemas = (0, import_omnify_core3.mergePartialSchemas)(schemas);
|
|
787
|
+
}
|
|
763
788
|
logger.timing("Schemas loaded");
|
|
789
|
+
const schemaCount = Object.keys(schemas).length;
|
|
764
790
|
if (schemaCount === 0) {
|
|
765
791
|
logger.warn("No schema files found");
|
|
766
792
|
return;
|
|
767
793
|
}
|
|
768
|
-
logger.debug(`
|
|
794
|
+
logger.debug(`Total: ${schemaCount} schema(s)`);
|
|
769
795
|
logger.step("Validating schemas...");
|
|
770
796
|
logger.timing("Validation start");
|
|
771
797
|
const result = (0, import_omnify_core3.validateSchemas)(schemas);
|
|
@@ -801,6 +827,7 @@ function registerValidateCommand(program) {
|
|
|
801
827
|
}
|
|
802
828
|
|
|
803
829
|
// src/commands/diff.ts
|
|
830
|
+
var import_node_fs5 = require("fs");
|
|
804
831
|
var import_node_path5 = require("path");
|
|
805
832
|
var import_omnify_core4 = require("@famgia/omnify-core");
|
|
806
833
|
|
|
@@ -838,13 +865,37 @@ async function runDiff(options) {
|
|
|
838
865
|
requireDevUrl(config);
|
|
839
866
|
const schemaPath = (0, import_node_path5.resolve)(rootDir, config.schemasDir);
|
|
840
867
|
logger.step(`Loading schemas from ${schemaPath}`);
|
|
841
|
-
|
|
868
|
+
let schemas = await (0, import_omnify_core4.loadSchemas)(schemaPath);
|
|
869
|
+
logger.debug(`Found ${Object.keys(schemas).length} schema(s) in main directory`);
|
|
870
|
+
const additionalPaths = config.additionalSchemaPaths ?? [];
|
|
871
|
+
let hasPackageSchemas = false;
|
|
872
|
+
if (additionalPaths.length > 0) {
|
|
873
|
+
logger.step(`Loading schemas from ${additionalPaths.length} additional path(s)`);
|
|
874
|
+
for (const entry of additionalPaths) {
|
|
875
|
+
const absolutePath = (0, import_node_path5.resolve)(rootDir, entry.path);
|
|
876
|
+
logger.debug(` Checking: ${entry.path} \u2192 ${absolutePath}`);
|
|
877
|
+
if ((0, import_node_fs5.existsSync)(absolutePath)) {
|
|
878
|
+
const packageSchemas = await (0, import_omnify_core4.loadSchemas)(absolutePath, { skipPartialResolution: true });
|
|
879
|
+
const count = Object.keys(packageSchemas).filter((k) => !k.startsWith("__partial__")).length;
|
|
880
|
+
const partialCount = Object.keys(packageSchemas).filter((k) => k.startsWith("__partial__")).length;
|
|
881
|
+
const nsInfo = entry.namespace ? ` [${entry.namespace}]` : "";
|
|
882
|
+
logger.info(` \u2022 ${entry.path}${nsInfo}: ${count} schema(s)${partialCount > 0 ? ` + ${partialCount} partial(s)` : ""}`);
|
|
883
|
+
schemas = { ...packageSchemas, ...schemas };
|
|
884
|
+
hasPackageSchemas = true;
|
|
885
|
+
} else {
|
|
886
|
+
logger.warn(` \u2022 ${entry.path}: directory not found (skipped)`);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
if (hasPackageSchemas) {
|
|
891
|
+
schemas = (0, import_omnify_core4.mergePartialSchemas)(schemas);
|
|
892
|
+
}
|
|
842
893
|
const schemaCount = Object.keys(schemas).length;
|
|
843
894
|
if (schemaCount === 0) {
|
|
844
895
|
logger.warn("No schema files found");
|
|
845
896
|
return;
|
|
846
897
|
}
|
|
847
|
-
logger.debug(`
|
|
898
|
+
logger.debug(`Total: ${schemaCount} schema(s)`);
|
|
848
899
|
logger.step("Validating schemas...");
|
|
849
900
|
const validationResult = (0, import_omnify_core4.validateSchemas)(schemas);
|
|
850
901
|
if (!validationResult.valid) {
|
|
@@ -902,7 +953,7 @@ function registerDiffCommand(program) {
|
|
|
902
953
|
}
|
|
903
954
|
|
|
904
955
|
// src/commands/generate.ts
|
|
905
|
-
var
|
|
956
|
+
var import_node_fs7 = require("fs");
|
|
906
957
|
var import_node_path7 = require("path");
|
|
907
958
|
var import_omnify_core5 = require("@famgia/omnify-core");
|
|
908
959
|
var import_omnify_atlas2 = require("@famgia/omnify-atlas");
|
|
@@ -910,7 +961,7 @@ var import_omnify_laravel = require("@famgia/omnify-laravel");
|
|
|
910
961
|
var import_omnify_typescript = require("@famgia/omnify-typescript");
|
|
911
962
|
|
|
912
963
|
// src/guides/index.ts
|
|
913
|
-
var
|
|
964
|
+
var import_node_fs6 = require("fs");
|
|
914
965
|
var import_node_path6 = require("path");
|
|
915
966
|
var import_node_url = require("url");
|
|
916
967
|
var CLAUDE_MD = `# Omnify Project
|
|
@@ -975,19 +1026,19 @@ function copyOmnifyGuides(rootDir) {
|
|
|
975
1026
|
for (const pkgPath of omnifyPkgPaths) {
|
|
976
1027
|
if (pkgPath.includes("*")) {
|
|
977
1028
|
const parentDir = (0, import_node_path6.dirname)((0, import_node_path6.dirname)(pkgPath));
|
|
978
|
-
if ((0,
|
|
979
|
-
const entries = (0,
|
|
1029
|
+
if ((0, import_node_fs6.existsSync)(parentDir)) {
|
|
1030
|
+
const entries = (0, import_node_fs6.readdirSync)(parentDir);
|
|
980
1031
|
for (const entry of entries) {
|
|
981
1032
|
if (entry.startsWith("@famgia+omnify@")) {
|
|
982
1033
|
const testPath = (0, import_node_path6.join)(parentDir, entry, "node_modules", "@famgia", "omnify", "stubs", "ai-guides", "omnify");
|
|
983
|
-
if ((0,
|
|
1034
|
+
if ((0, import_node_fs6.existsSync)(testPath)) {
|
|
984
1035
|
stubsDir = testPath;
|
|
985
1036
|
break;
|
|
986
1037
|
}
|
|
987
1038
|
}
|
|
988
1039
|
}
|
|
989
1040
|
}
|
|
990
|
-
} else if ((0,
|
|
1041
|
+
} else if ((0, import_node_fs6.existsSync)(pkgPath)) {
|
|
991
1042
|
stubsDir = pkgPath;
|
|
992
1043
|
break;
|
|
993
1044
|
}
|
|
@@ -996,7 +1047,7 @@ function copyOmnifyGuides(rootDir) {
|
|
|
996
1047
|
try {
|
|
997
1048
|
const omnifyPath = (0, import_node_path6.dirname)(require.resolve("@famgia/omnify/package.json", { paths: [rootDir] }));
|
|
998
1049
|
const testPath = (0, import_node_path6.join)(omnifyPath, "stubs", "ai-guides", "omnify");
|
|
999
|
-
if ((0,
|
|
1050
|
+
if ((0, import_node_fs6.existsSync)(testPath)) {
|
|
1000
1051
|
stubsDir = testPath;
|
|
1001
1052
|
}
|
|
1002
1053
|
} catch {
|
|
@@ -1006,13 +1057,13 @@ function copyOmnifyGuides(rootDir) {
|
|
|
1006
1057
|
return 0;
|
|
1007
1058
|
}
|
|
1008
1059
|
const destDir = (0, import_node_path6.resolve)(rootDir, ".claude", "omnify", "guides", "omnify");
|
|
1009
|
-
(0,
|
|
1010
|
-
const files = (0,
|
|
1060
|
+
(0, import_node_fs6.mkdirSync)(destDir, { recursive: true });
|
|
1061
|
+
const files = (0, import_node_fs6.readdirSync)(stubsDir).filter((f) => f.endsWith(".stub"));
|
|
1011
1062
|
for (const file of files) {
|
|
1012
1063
|
const srcPath = (0, import_node_path6.join)(stubsDir, file);
|
|
1013
1064
|
const destPath = (0, import_node_path6.join)(destDir, file.replace(".stub", ""));
|
|
1014
|
-
const content = (0,
|
|
1015
|
-
(0,
|
|
1065
|
+
const content = (0, import_node_fs6.readFileSync)(srcPath, "utf8");
|
|
1066
|
+
(0, import_node_fs6.writeFileSync)(destPath, content);
|
|
1016
1067
|
filesWritten++;
|
|
1017
1068
|
}
|
|
1018
1069
|
return filesWritten;
|
|
@@ -1020,8 +1071,8 @@ function copyOmnifyGuides(rootDir) {
|
|
|
1020
1071
|
function generateAIGuides(rootDir, _plugins) {
|
|
1021
1072
|
let filesWritten = 0;
|
|
1022
1073
|
const claudeMdPath = (0, import_node_path6.resolve)(rootDir, "CLAUDE.md");
|
|
1023
|
-
if (!(0,
|
|
1024
|
-
(0,
|
|
1074
|
+
if (!(0, import_node_fs6.existsSync)(claudeMdPath)) {
|
|
1075
|
+
(0, import_node_fs6.writeFileSync)(claudeMdPath, CLAUDE_MD);
|
|
1025
1076
|
filesWritten++;
|
|
1026
1077
|
}
|
|
1027
1078
|
filesWritten += copyOmnifyGuides(rootDir);
|
|
@@ -1029,37 +1080,16 @@ function generateAIGuides(rootDir, _plugins) {
|
|
|
1029
1080
|
}
|
|
1030
1081
|
|
|
1031
1082
|
// src/commands/generate.ts
|
|
1032
|
-
async function loadRegisteredSchemaPaths(rootDir) {
|
|
1033
|
-
const schemaPathsFile = (0, import_node_path7.resolve)(rootDir, "storage/omnify/schema-paths.json");
|
|
1034
|
-
logger.debug(`Checking for registered schema paths at: ${schemaPathsFile}`);
|
|
1035
|
-
if (!(0, import_node_fs5.existsSync)(schemaPathsFile)) {
|
|
1036
|
-
logger.debug("No registered schema paths file found");
|
|
1037
|
-
return [];
|
|
1038
|
-
}
|
|
1039
|
-
try {
|
|
1040
|
-
const content = (0, import_node_fs5.readFileSync)(schemaPathsFile, "utf-8");
|
|
1041
|
-
const data = JSON.parse(content);
|
|
1042
|
-
if (!data.paths || data.paths.length === 0) {
|
|
1043
|
-
logger.debug("No paths defined in schema-paths.json");
|
|
1044
|
-
return [];
|
|
1045
|
-
}
|
|
1046
|
-
logger.debug(`Found ${data.paths.length} registered schema path(s) in schema-paths.json`);
|
|
1047
|
-
return data.paths;
|
|
1048
|
-
} catch (error) {
|
|
1049
|
-
logger.warn(`Could not read schema-paths.json: ${error.message}`);
|
|
1050
|
-
return [];
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
1083
|
function hasPluginGenerators(plugins) {
|
|
1054
1084
|
return plugins.some((p) => p.generators && p.generators.length > 0);
|
|
1055
1085
|
}
|
|
1056
1086
|
function getExistingMigrationTables(migrationsDir) {
|
|
1057
1087
|
const existingTables = /* @__PURE__ */ new Set();
|
|
1058
|
-
if (!(0,
|
|
1088
|
+
if (!(0, import_node_fs7.existsSync)(migrationsDir)) {
|
|
1059
1089
|
return existingTables;
|
|
1060
1090
|
}
|
|
1061
1091
|
try {
|
|
1062
|
-
const files = (0,
|
|
1092
|
+
const files = (0, import_node_fs7.readdirSync)(migrationsDir);
|
|
1063
1093
|
const createMigrationPattern = /^\d{4}_\d{2}_\d{2}_\d{6}_create_(.+)_table\.php$/;
|
|
1064
1094
|
for (const file of files) {
|
|
1065
1095
|
const match = file.match(createMigrationPattern);
|
|
@@ -1250,15 +1280,15 @@ function writeGeneratorOutputs(outputs, rootDir) {
|
|
|
1250
1280
|
for (const output of outputs) {
|
|
1251
1281
|
const filePath = (0, import_node_path7.resolve)(rootDir, output.path);
|
|
1252
1282
|
const dir = (0, import_node_path7.dirname)(filePath);
|
|
1253
|
-
if (!(0,
|
|
1254
|
-
(0,
|
|
1283
|
+
if (!(0, import_node_fs7.existsSync)(dir)) {
|
|
1284
|
+
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
1255
1285
|
logger.debug(`Created directory: ${dir}`);
|
|
1256
1286
|
}
|
|
1257
|
-
if (output.skipIfExists && (0,
|
|
1287
|
+
if (output.skipIfExists && (0, import_node_fs7.existsSync)(filePath)) {
|
|
1258
1288
|
logger.debug(`Skipped (exists): ${output.path}`);
|
|
1259
1289
|
continue;
|
|
1260
1290
|
}
|
|
1261
|
-
(0,
|
|
1291
|
+
(0, import_node_fs7.writeFileSync)(filePath, output.content);
|
|
1262
1292
|
logger.debug(`Created: ${output.path}`);
|
|
1263
1293
|
if (output.type === "migration") counts.migrations++;
|
|
1264
1294
|
else if (output.type === "type") counts.types++;
|
|
@@ -1315,8 +1345,8 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1315
1345
|
if (!options.typesOnly && config.output.laravel) {
|
|
1316
1346
|
logger.step("Generating Laravel migrations...");
|
|
1317
1347
|
const migrationsDir = (0, import_node_path7.resolve)(rootDir, config.output.laravel.migrationsPath);
|
|
1318
|
-
if (!(0,
|
|
1319
|
-
(0,
|
|
1348
|
+
if (!(0, import_node_fs7.existsSync)(migrationsDir)) {
|
|
1349
|
+
(0, import_node_fs7.mkdirSync)(migrationsDir, { recursive: true });
|
|
1320
1350
|
logger.debug(`Created directory: ${migrationsDir}`);
|
|
1321
1351
|
}
|
|
1322
1352
|
const addedSchemaNames = new Set(
|
|
@@ -1338,7 +1368,7 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1338
1368
|
continue;
|
|
1339
1369
|
}
|
|
1340
1370
|
const filePath = (0, import_node_path7.resolve)(migrationsDir, migration.fileName);
|
|
1341
|
-
(0,
|
|
1371
|
+
(0, import_node_fs7.writeFileSync)(filePath, migration.content);
|
|
1342
1372
|
logger.debug(`Created: ${migration.fileName}`);
|
|
1343
1373
|
migrationsGenerated++;
|
|
1344
1374
|
}
|
|
@@ -1347,7 +1377,7 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1347
1377
|
const alterMigrations = (0, import_omnify_laravel.generateMigrationsFromChanges)(alterChanges);
|
|
1348
1378
|
for (const migration of alterMigrations) {
|
|
1349
1379
|
const filePath = (0, import_node_path7.resolve)(migrationsDir, migration.fileName);
|
|
1350
|
-
(0,
|
|
1380
|
+
(0, import_node_fs7.writeFileSync)(filePath, migration.content);
|
|
1351
1381
|
logger.debug(`Created: ${migration.fileName}`);
|
|
1352
1382
|
migrationsGenerated++;
|
|
1353
1383
|
}
|
|
@@ -1360,11 +1390,11 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1360
1390
|
const baseModelsPath = config.output.laravel.baseModelsPath ?? `${modelsPath}/OmnifyBase`;
|
|
1361
1391
|
const modelsDir = (0, import_node_path7.resolve)(rootDir, modelsPath);
|
|
1362
1392
|
const baseModelsDir = (0, import_node_path7.resolve)(rootDir, baseModelsPath);
|
|
1363
|
-
if (!(0,
|
|
1364
|
-
(0,
|
|
1393
|
+
if (!(0, import_node_fs7.existsSync)(modelsDir)) {
|
|
1394
|
+
(0, import_node_fs7.mkdirSync)(modelsDir, { recursive: true });
|
|
1365
1395
|
}
|
|
1366
|
-
if (!(0,
|
|
1367
|
-
(0,
|
|
1396
|
+
if (!(0, import_node_fs7.existsSync)(baseModelsDir)) {
|
|
1397
|
+
(0, import_node_fs7.mkdirSync)(baseModelsDir, { recursive: true });
|
|
1368
1398
|
}
|
|
1369
1399
|
const providersPath = config.output.laravel.providersPath ?? "app/Providers";
|
|
1370
1400
|
const models = (0, import_omnify_laravel.generateModels)(schemas, {
|
|
@@ -1376,14 +1406,14 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1376
1406
|
for (const model of models) {
|
|
1377
1407
|
const filePath = (0, import_node_path7.resolve)(rootDir, (0, import_omnify_laravel.getModelPath)(model));
|
|
1378
1408
|
const fileDir = (0, import_node_path7.dirname)(filePath);
|
|
1379
|
-
if (!(0,
|
|
1380
|
-
(0,
|
|
1409
|
+
if (!(0, import_node_fs7.existsSync)(fileDir)) {
|
|
1410
|
+
(0, import_node_fs7.mkdirSync)(fileDir, { recursive: true });
|
|
1381
1411
|
}
|
|
1382
|
-
if (!model.overwrite && (0,
|
|
1412
|
+
if (!model.overwrite && (0, import_node_fs7.existsSync)(filePath)) {
|
|
1383
1413
|
logger.debug(`Skipped (exists): ${(0, import_omnify_laravel.getModelPath)(model)}`);
|
|
1384
1414
|
continue;
|
|
1385
1415
|
}
|
|
1386
|
-
(0,
|
|
1416
|
+
(0, import_node_fs7.writeFileSync)(filePath, model.content);
|
|
1387
1417
|
logger.debug(`Created: ${(0, import_omnify_laravel.getModelPath)(model)}`);
|
|
1388
1418
|
modelsGenerated++;
|
|
1389
1419
|
}
|
|
@@ -1393,8 +1423,8 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1393
1423
|
logger.step("Generating Laravel factories...");
|
|
1394
1424
|
const factoriesPath = config.output.laravel.factoriesPath;
|
|
1395
1425
|
const factoriesDir = (0, import_node_path7.resolve)(rootDir, factoriesPath);
|
|
1396
|
-
if (!(0,
|
|
1397
|
-
(0,
|
|
1426
|
+
if (!(0, import_node_fs7.existsSync)(factoriesDir)) {
|
|
1427
|
+
(0, import_node_fs7.mkdirSync)(factoriesDir, { recursive: true });
|
|
1398
1428
|
}
|
|
1399
1429
|
const factories = (0, import_omnify_laravel.generateFactories)(schemas, {
|
|
1400
1430
|
factoryPath: factoriesPath
|
|
@@ -1402,14 +1432,14 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1402
1432
|
for (const factory of factories) {
|
|
1403
1433
|
const filePath = (0, import_node_path7.resolve)(rootDir, (0, import_omnify_laravel.getFactoryPath)(factory));
|
|
1404
1434
|
const fileDir = (0, import_node_path7.dirname)(filePath);
|
|
1405
|
-
if (!(0,
|
|
1406
|
-
(0,
|
|
1435
|
+
if (!(0, import_node_fs7.existsSync)(fileDir)) {
|
|
1436
|
+
(0, import_node_fs7.mkdirSync)(fileDir, { recursive: true });
|
|
1407
1437
|
}
|
|
1408
|
-
if (!factory.overwrite && (0,
|
|
1438
|
+
if (!factory.overwrite && (0, import_node_fs7.existsSync)(filePath)) {
|
|
1409
1439
|
logger.debug(`Skipped (exists): ${(0, import_omnify_laravel.getFactoryPath)(factory)}`);
|
|
1410
1440
|
continue;
|
|
1411
1441
|
}
|
|
1412
|
-
(0,
|
|
1442
|
+
(0, import_node_fs7.writeFileSync)(filePath, factory.content);
|
|
1413
1443
|
logger.debug(`Created: ${(0, import_omnify_laravel.getFactoryPath)(factory)}`);
|
|
1414
1444
|
factoriesGenerated++;
|
|
1415
1445
|
}
|
|
@@ -1422,12 +1452,12 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1422
1452
|
const schemasDir = (0, import_node_path7.resolve)(basePath, tsConfig.schemasDir ?? "schemas");
|
|
1423
1453
|
const enumDir = (0, import_node_path7.resolve)(basePath, tsConfig.enumDir ?? "enum");
|
|
1424
1454
|
const enumImportPrefix = (0, import_node_path7.relative)(schemasDir, enumDir).replace(/\\/g, "/");
|
|
1425
|
-
if (!(0,
|
|
1426
|
-
(0,
|
|
1455
|
+
if (!(0, import_node_fs7.existsSync)(schemasDir)) {
|
|
1456
|
+
(0, import_node_fs7.mkdirSync)(schemasDir, { recursive: true });
|
|
1427
1457
|
logger.debug(`Created directory: ${schemasDir}`);
|
|
1428
1458
|
}
|
|
1429
|
-
if (!(0,
|
|
1430
|
-
(0,
|
|
1459
|
+
if (!(0, import_node_fs7.existsSync)(enumDir)) {
|
|
1460
|
+
(0, import_node_fs7.mkdirSync)(enumDir, { recursive: true });
|
|
1431
1461
|
logger.debug(`Created directory: ${enumDir}`);
|
|
1432
1462
|
}
|
|
1433
1463
|
const isMultiLocale = config.locale && config.locale.locales && config.locale.locales.length > 1;
|
|
@@ -1444,14 +1474,14 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1444
1474
|
const outputDir = file.category === "enum" ? enumDir : schemasDir;
|
|
1445
1475
|
const filePath = (0, import_node_path7.resolve)(outputDir, file.filePath);
|
|
1446
1476
|
const fileDir = (0, import_node_path7.dirname)(filePath);
|
|
1447
|
-
if (!(0,
|
|
1448
|
-
(0,
|
|
1477
|
+
if (!(0, import_node_fs7.existsSync)(fileDir)) {
|
|
1478
|
+
(0, import_node_fs7.mkdirSync)(fileDir, { recursive: true });
|
|
1449
1479
|
}
|
|
1450
|
-
if (!file.overwrite && (0,
|
|
1480
|
+
if (!file.overwrite && (0, import_node_fs7.existsSync)(filePath)) {
|
|
1451
1481
|
logger.debug(`Skipped (exists): ${file.filePath}`);
|
|
1452
1482
|
continue;
|
|
1453
1483
|
}
|
|
1454
|
-
(0,
|
|
1484
|
+
(0, import_node_fs7.writeFileSync)(filePath, file.content);
|
|
1455
1485
|
logger.debug(`Created: ${file.filePath}`);
|
|
1456
1486
|
typesGenerated++;
|
|
1457
1487
|
}
|
|
@@ -1484,18 +1514,19 @@ async function runGenerate(options) {
|
|
|
1484
1514
|
logger.step(`Loading schemas from ${schemaPath}`);
|
|
1485
1515
|
let schemas = await (0, import_omnify_core5.loadSchemas)(schemaPath);
|
|
1486
1516
|
logger.debug(`Found ${Object.keys(schemas).length} schema(s) in main directory`);
|
|
1487
|
-
const additionalPaths =
|
|
1517
|
+
const additionalPaths = config.additionalSchemaPaths ?? [];
|
|
1488
1518
|
let hasPackageSchemas = false;
|
|
1489
1519
|
if (additionalPaths.length > 0) {
|
|
1490
|
-
logger.step(`Loading schemas from ${additionalPaths.length}
|
|
1520
|
+
logger.step(`Loading schemas from ${additionalPaths.length} additional path(s)`);
|
|
1491
1521
|
for (const entry of additionalPaths) {
|
|
1492
1522
|
const absolutePath = (0, import_node_path7.resolve)(rootDir, entry.path);
|
|
1493
1523
|
logger.debug(` Checking: ${entry.path} \u2192 ${absolutePath}`);
|
|
1494
|
-
if ((0,
|
|
1524
|
+
if ((0, import_node_fs7.existsSync)(absolutePath)) {
|
|
1495
1525
|
const packageSchemas = await (0, import_omnify_core5.loadSchemas)(absolutePath, { skipPartialResolution: true });
|
|
1496
1526
|
const count = Object.keys(packageSchemas).filter((k) => !k.startsWith("__partial__")).length;
|
|
1497
1527
|
const partialCount = Object.keys(packageSchemas).filter((k) => k.startsWith("__partial__")).length;
|
|
1498
|
-
|
|
1528
|
+
const nsInfo = entry.namespace ? ` [${entry.namespace}]` : "";
|
|
1529
|
+
logger.info(` \u2022 ${entry.path}${nsInfo}: ${count} schema(s)${partialCount > 0 ? ` + ${partialCount} partial(s)` : ""}`);
|
|
1499
1530
|
schemas = { ...packageSchemas, ...schemas };
|
|
1500
1531
|
hasPackageSchemas = true;
|
|
1501
1532
|
} else {
|
|
@@ -1704,12 +1735,12 @@ async function runGenerate(options) {
|
|
|
1704
1735
|
const schemasDir2 = (0, import_node_path7.resolve)(basePath2, tsConfig2.schemasDir ?? "schemas");
|
|
1705
1736
|
const enumDir2 = (0, import_node_path7.resolve)(basePath2, tsConfig2.enumDir ?? "enum");
|
|
1706
1737
|
const enumImportPrefix2 = (0, import_node_path7.relative)(schemasDir2, enumDir2).replace(/\\/g, "/");
|
|
1707
|
-
if (!(0,
|
|
1708
|
-
(0,
|
|
1738
|
+
if (!(0, import_node_fs7.existsSync)(schemasDir2)) {
|
|
1739
|
+
(0, import_node_fs7.mkdirSync)(schemasDir2, { recursive: true });
|
|
1709
1740
|
logger.debug(`Created directory: ${schemasDir2}`);
|
|
1710
1741
|
}
|
|
1711
|
-
if (!(0,
|
|
1712
|
-
(0,
|
|
1742
|
+
if (!(0, import_node_fs7.existsSync)(enumDir2)) {
|
|
1743
|
+
(0, import_node_fs7.mkdirSync)(enumDir2, { recursive: true });
|
|
1713
1744
|
logger.debug(`Created directory: ${enumDir2}`);
|
|
1714
1745
|
}
|
|
1715
1746
|
const isMultiLocale = config.locale && config.locale.locales && config.locale.locales.length > 1;
|
|
@@ -1726,14 +1757,14 @@ async function runGenerate(options) {
|
|
|
1726
1757
|
const outputDir2 = file.category === "enum" ? enumDir2 : schemasDir2;
|
|
1727
1758
|
const filePath = (0, import_node_path7.resolve)(outputDir2, file.filePath);
|
|
1728
1759
|
const fileDir = (0, import_node_path7.dirname)(filePath);
|
|
1729
|
-
if (!(0,
|
|
1730
|
-
(0,
|
|
1760
|
+
if (!(0, import_node_fs7.existsSync)(fileDir)) {
|
|
1761
|
+
(0, import_node_fs7.mkdirSync)(fileDir, { recursive: true });
|
|
1731
1762
|
}
|
|
1732
|
-
if (!file.overwrite && (0,
|
|
1763
|
+
if (!file.overwrite && (0, import_node_fs7.existsSync)(filePath)) {
|
|
1733
1764
|
logger.debug(`Skipped (exists): ${file.filePath}`);
|
|
1734
1765
|
continue;
|
|
1735
1766
|
}
|
|
1736
|
-
(0,
|
|
1767
|
+
(0, import_node_fs7.writeFileSync)(filePath, file.content);
|
|
1737
1768
|
logger.debug(`Created: ${file.filePath}`);
|
|
1738
1769
|
typesGenerated++;
|
|
1739
1770
|
}
|