@alpha.consultings/eloquent-orm.js 1.0.9 → 1.0.11
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/CHANGELOG.md +17 -0
- package/PACKAGE-UPDATE-SUMMARY.md +18 -11
- package/README.md +5 -5
- package/dist/Model.d.ts +1 -1
- package/dist/Model.js +3 -3
- package/dist/cli/commands/cacheClear.js +12 -12
- package/dist/cli/commands/cacheStats.js +12 -12
- package/dist/cli/commands/dbSeed.d.ts +1 -1
- package/dist/cli/commands/dbSeed.js +23 -23
- package/dist/cli/commands/dbSeedBootstrapPrecheck.d.ts +1 -1
- package/dist/cli/commands/dbSeedBootstrapPrecheck.js +2 -2
- package/dist/cli/commands/dbSeedFresh.d.ts +1 -1
- package/dist/cli/commands/dbSeedFresh.js +10 -10
- package/dist/cli/commands/demoScenario.js +11 -11
- package/dist/cli/commands/factoryStatus.js +13 -13
- package/dist/cli/commands/makeController.js +11 -11
- package/dist/cli/commands/makeFactory.js +21 -21
- package/dist/cli/commands/makeMigration.d.ts +1 -1
- package/dist/cli/commands/makeMigration.js +31 -17
- package/dist/cli/commands/makeModel.js +30 -30
- package/dist/cli/commands/makeRegistry.d.ts +5 -8
- package/dist/cli/commands/makeRegistry.js +18 -68
- package/dist/cli/commands/makeScenario.js +49 -43
- package/dist/cli/commands/makeSeed.js +12 -9
- package/dist/cli/commands/makeService.js +10 -10
- package/dist/cli/commands/migrateFresh.d.ts +1 -1
- package/dist/cli/commands/migrateFresh.js +14 -14
- package/dist/cli/commands/migrateReset.d.ts +1 -1
- package/dist/cli/commands/migrateReset.js +4 -4
- package/dist/cli/commands/migrateRollback.d.ts +1 -1
- package/dist/cli/commands/migrateRollback.js +36 -36
- package/dist/cli/commands/migrateRun.d.ts +2 -2
- package/dist/cli/commands/migrateRun.js +34 -34
- package/dist/cli/commands/migrateStatus.d.ts +1 -1
- package/dist/cli/commands/migrateStatus.js +16 -16
- package/dist/cli/eloquent.d.ts +1 -1
- package/dist/cli/eloquent.js +30 -30
- package/dist/cli/utils/ArtifactRoutingReport.d.ts +1 -1
- package/dist/cli/utils/ArtifactRoutingReport.js +3 -3
- package/dist/cli/utils/ArtifactStorage.d.ts +2 -2
- package/dist/cli/utils/ArtifactStorage.js +17 -17
- package/dist/cli/utils/AuditTrail.js +2 -2
- package/dist/cli/utils/CliBootstrapSupport.d.ts +1 -1
- package/dist/cli/utils/CliCommandTargets.d.ts +2 -2
- package/dist/cli/utils/CliCommandTargets.js +2 -2
- package/dist/cli/utils/CliMakeArtifactCommandRegistration.js +15 -15
- package/dist/cli/utils/CliMigrationCommandRegistration.js +29 -29
- package/dist/cli/utils/CliProductionGuards.d.ts +1 -1
- package/dist/cli/utils/CliProductionGuards.js +6 -6
- package/dist/cli/utils/CliScaffoldCommandRegistration.js +13 -13
- package/dist/cli/utils/CliSeedScenarioCommandRegistration.js +23 -23
- package/dist/cli/utils/CliSupportCommandRegistration.js +8 -8
- package/dist/cli/utils/ImportResolver.d.ts +12 -3
- package/dist/cli/utils/ImportResolver.js +76 -17
- package/dist/cli/utils/ModelIntrospector.d.ts +1 -1
- package/dist/cli/utils/ModelIntrospector.js +4 -4
- package/dist/cli/utils/ScaffoldGeneratorSupport.js +2 -2
- package/dist/cli/utils/ScenarioMorphAliasRouting.js +8 -8
- package/dist/cli/utils/SeedBootstrapPrecheck.d.ts +1 -1
- package/dist/cli/utils/SeedBootstrapPrecheck.js +10 -10
- package/dist/cli/utils/TemplateEngine.js +2 -2
- package/dist/cli/utils/factories/Factory.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryDisplay.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryGraph.js +5 -5
- package/dist/cli/utils/factories/FactoryLoader.d.ts +1 -1
- package/dist/cli/utils/factories/FactoryLoader.js +4 -4
- package/dist/cli/utils/factories/FactoryRegistry.d.ts +3 -3
- package/dist/cli/utils/factories/FactoryRegistry.js +10 -10
- package/dist/cli/utils/migrations/MigrationLockStrategy.d.ts +1 -1
- package/dist/cli/utils/migrations/MigrationLockStrategy.js +2 -2
- package/dist/cli/utils/migrations/MigrationTracker.d.ts +2 -2
- package/dist/cli/utils/migrations/MigrationTracker.js +6 -6
- package/dist/cli/utils/migrations/MongoMigrationTracker.js +3 -3
- package/dist/cli/utils/resolveConnectionFlags.d.ts +1 -1
- package/dist/cli/utils/resolveConnectionFlags.js +3 -3
- package/dist/cli/utils/resolveSqlConnectionFlags.d.ts +1 -1
- package/dist/cli/utils/typescript/BaseCommand.d.ts +1 -1
- package/dist/cli/utils/typescript/BaseCommand.js +3 -3
- package/dist/cli/utils/typescript/tsRuntime.js +62 -9
- package/dist/config/database.js +9 -9
- package/dist/core/cache/CacheFallbackManager.d.ts +1 -1
- package/dist/core/cache/CacheManager.d.ts +1 -1
- package/dist/core/cache/CacheManager.js +2 -2
- package/dist/core/cache/CacheRegistry.js +4 -4
- package/dist/core/cache/drivers/FileCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/FileCacheDriver.js +2 -2
- package/dist/core/cache/drivers/MemcachedCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/MemcachedCacheDriver.js +2 -2
- package/dist/core/cache/drivers/MemoryCacheDriver.d.ts +1 -1
- package/dist/core/cache/drivers/MemoryCacheDriver.js +2 -2
- package/dist/core/cache/setupCache.js +12 -12
- package/dist/core/connection/ConnectionFactory.d.ts +2 -2
- package/dist/core/connection/ConnectionFactory.js +9 -9
- package/dist/core/connection/DatabaseConnection.d.ts +2 -2
- package/dist/core/connection/DatabaseConnection.js +4 -4
- package/dist/core/connection/DriverAdapter.d.ts +1 -1
- package/dist/core/connection/DriverAdapter.js +2 -2
- package/dist/core/connection/resolveConnectionName.d.ts +1 -1
- package/dist/core/connection/resolveConnectionName.js +7 -7
- package/dist/core/model/BaseModel.d.ts +29 -29
- package/dist/core/model/BaseModel.js +38 -38
- package/dist/core/model/BaseModelSafeFinderStatics.d.ts +1 -1
- package/dist/core/model/BaseModelSafeFinderStatics.js +19 -19
- package/dist/core/model/CoreModel.d.ts +4 -4
- package/dist/core/model/CoreModel.js +28 -28
- package/dist/core/model/CoreModelPersistenceState.d.ts +1 -1
- package/dist/core/model/CoreModelSafeFinderSupport.d.ts +2 -2
- package/dist/core/model/CoreModelSafeFinderSupport.js +2 -2
- package/dist/core/model/CoreModelValidationEvents.d.ts +2 -2
- package/dist/core/model/CoreModelValidationEvents.js +2 -2
- package/dist/core/model/SafeFinder.d.ts +1 -1
- package/dist/core/model/SafeFinder.js +2 -2
- package/dist/core/orm/mixins/CastsMixin.js +2 -2
- package/dist/core/orm/mixins/HooksMixin.js +8 -8
- package/dist/core/orm/mixins/MorphableMixin.js +4 -4
- package/dist/core/orm/mixins/PivotHelperMixin.js +3 -3
- package/dist/core/orm/mixins/QueryCacheMixin.js +20 -20
- package/dist/core/orm/mixins/ScopeMixin.js +2 -2
- package/dist/core/orm/mixins/SoftDeletesMixin.js +2 -2
- package/dist/core/orm/mixins/utils/HookStore.d.ts +1 -1
- package/dist/core/orm/mixins/utils/HookStore.js +2 -2
- package/dist/core/orm/mixins/utils/modelRegistration.d.ts +1 -1
- package/dist/core/orm/mixins/utils/modelRegistration.js +6 -6
- package/dist/core/orm/relations/BelongsTo.d.ts +1 -1
- package/dist/core/orm/relations/BelongsTo.js +2 -2
- package/dist/core/orm/relations/BelongsToMany.d.ts +1 -1
- package/dist/core/orm/relations/BelongsToMany.js +2 -2
- package/dist/core/orm/relations/HasMany.d.ts +1 -1
- package/dist/core/orm/relations/HasMany.js +2 -2
- package/dist/core/orm/relations/HasOne.d.ts +1 -1
- package/dist/core/orm/relations/HasOne.js +2 -2
- package/dist/core/orm/relations/MorphMany.d.ts +1 -1
- package/dist/core/orm/relations/MorphMany.js +2 -2
- package/dist/core/orm/relations/MorphOne.d.ts +1 -1
- package/dist/core/orm/relations/MorphOne.js +2 -2
- package/dist/core/orm/relations/MorphTo.d.ts +1 -1
- package/dist/core/orm/relations/MorphTo.js +5 -5
- package/dist/core/schema/SchemaBuilder.d.ts +2 -2
- package/dist/core/schema/SchemaBuilder.js +9 -9
- package/dist/core/schema/SchemaValidator.d.ts +1 -1
- package/dist/core/security/AbstractSecurity.d.ts +1 -1
- package/dist/core/security/EnvKeySecurity.d.ts +1 -1
- package/dist/core/security/EnvKeySecurity.js +2 -2
- package/dist/core/security/NoSecurity.d.ts +1 -1
- package/dist/core/security/NoSecurity.js +2 -2
- package/dist/core/security/SecurityFactory.d.ts +1 -1
- package/dist/core/security/SecurityFactory.js +4 -4
- package/dist/core/security/index.d.ts +5 -5
- package/dist/core/security/index.js +5 -5
- package/dist/index.d.ts +10 -10
- package/dist/index.js +30 -30
- package/esm/Factory.mjs +113 -136
- package/esm/Model.mjs +4 -0
- package/esm/index.mjs +23 -28
- package/package.json +14 -5
- package/src/cli/templates/factory.tpl +1 -1
- package/src/cli/templates/seed.tpl +1 -1
|
@@ -7,11 +7,11 @@ exports.makeFactory = makeFactory;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
10
|
+
const PathMap_js_1 = require("../utils/PathMap.js");
|
|
11
|
+
const TemplateEngine_js_1 = require("../utils/TemplateEngine.js");
|
|
12
|
+
const fileWriter_js_1 = require("../utils/fileWriter.js");
|
|
13
|
+
const ModelIntrospector_js_1 = require("../utils/ModelIntrospector.js");
|
|
14
|
+
const ImportResolver_js_1 = require("../utils/ImportResolver.js");
|
|
15
15
|
function ensureDirSync(dir) {
|
|
16
16
|
if (!fs_1.default.existsSync(dir))
|
|
17
17
|
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
@@ -28,7 +28,7 @@ async function makeFactory(factoryName, options = {}) {
|
|
|
28
28
|
: `${factoryName}Factory`;
|
|
29
29
|
const ModelName = options.model ?? factoryName.replace(/Factory$/i, "");
|
|
30
30
|
// Reflect schema using ModelIntrospector.
|
|
31
|
-
const analysisRaw = (await
|
|
31
|
+
const analysisRaw = (await ModelIntrospector_js_1.ModelIntrospector.analyze(ModelName, {
|
|
32
32
|
test: !!options.test,
|
|
33
33
|
}));
|
|
34
34
|
if (!analysisRaw) {
|
|
@@ -59,7 +59,7 @@ async function makeFactory(factoryName, options = {}) {
|
|
|
59
59
|
fakerPath: fakerMap[String(f.type ?? "").toLowerCase()] ?? "lorem.word()",
|
|
60
60
|
}));
|
|
61
61
|
// Load the main factory template and fail early if it is missing.
|
|
62
|
-
const templatePath =
|
|
62
|
+
const templatePath = PathMap_js_1.PathMap.template("factory");
|
|
63
63
|
if (!fs_1.default.existsSync(templatePath)) {
|
|
64
64
|
console.error(chalk_1.default.red(`ERROR: Factory template not found at: ${templatePath}`));
|
|
65
65
|
return;
|
|
@@ -68,10 +68,12 @@ async function makeFactory(factoryName, options = {}) {
|
|
|
68
68
|
// Build relation imports and example usage snippets for template.
|
|
69
69
|
const relationImports = new Set();
|
|
70
70
|
const relationExamples = [];
|
|
71
|
+
const rootDir = PathMap_js_1.PathMap.root;
|
|
72
|
+
const modelImportPath = ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension(options.test ? `../models/${ModelName}` : `../../models/${ModelName}`, rootDir);
|
|
71
73
|
for (const rel of relations) {
|
|
72
74
|
if (rel.target && typeof rel.target === "string") {
|
|
73
75
|
const candidateFactoryName = `${rel.target}Factory`;
|
|
74
|
-
const candidateImportPath = `../factories/${candidateFactoryName}
|
|
76
|
+
const candidateImportPath = ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension(`../factories/${candidateFactoryName}`, rootDir);
|
|
75
77
|
relationImports.add(`import { ${candidateFactoryName} } from "${candidateImportPath}";`);
|
|
76
78
|
}
|
|
77
79
|
const relatedName = String(rel.target ?? "Related");
|
|
@@ -93,9 +95,9 @@ async function makeFactory(factoryName, options = {}) {
|
|
|
93
95
|
relationExamples.push(`// relation ${rel.name} (${String(rel.type)})`);
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
|
-
const factoriesDir =
|
|
98
|
+
const factoriesDir = PathMap_js_1.PathMap.factories(!!options.test);
|
|
97
99
|
const outputPath = path_1.default.join(factoriesDir, `${FactoryName}.ts`);
|
|
98
|
-
const packageImportPath =
|
|
100
|
+
const packageImportPath = ImportResolver_js_1.ImportResolver.publicApiImportPath(outputPath, rootDir);
|
|
99
101
|
const renderData = {
|
|
100
102
|
ModelName,
|
|
101
103
|
FactoryName,
|
|
@@ -105,24 +107,22 @@ async function makeFactory(factoryName, options = {}) {
|
|
|
105
107
|
relationImports: Array.from(relationImports),
|
|
106
108
|
relationExamples,
|
|
107
109
|
features,
|
|
110
|
+
modelImportPath,
|
|
108
111
|
packageImportPath,
|
|
109
112
|
};
|
|
110
|
-
|
|
111
|
-
if (options.test) {
|
|
112
|
-
rendered = rendered.replace(/from \"\.\.\/\.\.\/models\//g, 'from "../models/');
|
|
113
|
-
}
|
|
113
|
+
const rendered = TemplateEngine_js_1.TemplateEngine.render(templateContent, renderData);
|
|
114
114
|
// Write the main factory file using writeFileSafe / overwriteFile.
|
|
115
115
|
ensureDirSync(factoriesDir);
|
|
116
116
|
if (fs_1.default.existsSync(outputPath)) {
|
|
117
117
|
if (shouldOverwrite) {
|
|
118
|
-
(0,
|
|
118
|
+
(0, fileWriter_js_1.overwriteFile)(outputPath, rendered);
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
121
|
console.log(chalk_1.default.yellow(`INFO: Factory file already exists: ${outputPath}. Use overwrite option to replace.`));
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
else {
|
|
125
|
-
(0,
|
|
125
|
+
(0, fileWriter_js_1.writeFileSafe)(outputPath, rendered);
|
|
126
126
|
}
|
|
127
127
|
// Generate pivot factories automatically.
|
|
128
128
|
for (const rel of relations) {
|
|
@@ -132,7 +132,7 @@ async function makeFactory(factoryName, options = {}) {
|
|
|
132
132
|
const pivotTable = rel.pivotTable ??
|
|
133
133
|
[left.toLowerCase(), right.toLowerCase()].sort().join("_") + "_pivot";
|
|
134
134
|
const pivotFactoryName = `${left}${right}PivotFactory`;
|
|
135
|
-
const pivotTemplatePath =
|
|
135
|
+
const pivotTemplatePath = PathMap_js_1.PathMap.template("pivot-factory");
|
|
136
136
|
if (!fs_1.default.existsSync(pivotTemplatePath)) {
|
|
137
137
|
console.warn(chalk_1.default.yellow(`WARN: Pivot template not found at: ${pivotTemplatePath} - skipping pivot ${pivotTable}.`));
|
|
138
138
|
continue;
|
|
@@ -144,7 +144,7 @@ async function makeFactory(factoryName, options = {}) {
|
|
|
144
144
|
? rel.relatedKey
|
|
145
145
|
: `${right.toLowerCase()}_id`;
|
|
146
146
|
const pivotOutputPath = path_1.default.join(factoriesDir, `${pivotFactoryName}.ts`);
|
|
147
|
-
const pivotPackageImportPath =
|
|
147
|
+
const pivotPackageImportPath = ImportResolver_js_1.ImportResolver.publicApiImportPath(pivotOutputPath, rootDir);
|
|
148
148
|
const pivotRenderData = {
|
|
149
149
|
PivotFactoryName: pivotFactoryName,
|
|
150
150
|
pivotTable,
|
|
@@ -152,17 +152,17 @@ async function makeFactory(factoryName, options = {}) {
|
|
|
152
152
|
relatedKey,
|
|
153
153
|
packageImportPath: pivotPackageImportPath,
|
|
154
154
|
};
|
|
155
|
-
const pivotRendered =
|
|
155
|
+
const pivotRendered = TemplateEngine_js_1.TemplateEngine.render(fs_1.default.readFileSync(pivotTemplatePath, "utf8"), pivotRenderData);
|
|
156
156
|
if (fs_1.default.existsSync(pivotOutputPath)) {
|
|
157
157
|
if (shouldOverwrite) {
|
|
158
|
-
(0,
|
|
158
|
+
(0, fileWriter_js_1.overwriteFile)(pivotOutputPath, pivotRendered);
|
|
159
159
|
}
|
|
160
160
|
else {
|
|
161
161
|
console.log(chalk_1.default.yellow(`INFO: Pivot factory already exists: ${pivotOutputPath}`));
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
else {
|
|
165
|
-
(0,
|
|
165
|
+
(0, fileWriter_js_1.writeFileSafe)(pivotOutputPath, pivotRendered);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
}
|
|
@@ -8,13 +8,13 @@ exports.makeMigration = makeMigration;
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
11
|
+
const SchemaBuilder_js_1 = require("../../core/schema/SchemaBuilder.js");
|
|
12
|
+
const PathMap_js_1 = require("../utils/PathMap.js");
|
|
13
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
14
|
+
const TypeScriptCompiler_js_1 = require("../utils/typescript/TypeScriptCompiler.js");
|
|
15
|
+
const ConnectionFactory_js_1 = require("../../core/connection/ConnectionFactory.js");
|
|
16
|
+
const database_js_1 = require("../../config/database.js");
|
|
17
|
+
const tsRuntime_js_1 = require("../utils/typescript/tsRuntime.js");
|
|
18
18
|
function hasSoftDeletesSchema(schema) {
|
|
19
19
|
for (const [name, field] of Object.entries(schema)) {
|
|
20
20
|
if (field.kind === "mixin" && field.name === "SoftDeletes") {
|
|
@@ -169,14 +169,14 @@ async function makeMigration(modelName, options = {}) {
|
|
|
169
169
|
const isTest = options.test === true;
|
|
170
170
|
const forcedConnectionName = options.connectionName;
|
|
171
171
|
const pivotSeparate = options.pivotSeparate === true || modelName.toLowerCase() === "all";
|
|
172
|
-
const modelsDir =
|
|
173
|
-
|
|
172
|
+
const modelsDir = PathMap_js_1.PathMap.models(isTest);
|
|
173
|
+
PathMap_js_1.PathMap.ensureDirs();
|
|
174
174
|
if (!fs_1.default.existsSync(modelsDir)) {
|
|
175
175
|
console.error(chalk_1.default.red(`ERROR: Models folder not found: ${modelsDir}`));
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
178
|
console.log(chalk_1.default.gray(`INFO: Models Path: ${modelsDir}`));
|
|
179
|
-
console.log(chalk_1.default.gray(`INFO: Migrations Root: ${isTest ?
|
|
179
|
+
console.log(chalk_1.default.gray(`INFO: Migrations Root: ${isTest ? PathMap_js_1.PathMap.testMigrations() : PathMap_js_1.PathMap.appMigrations()}`));
|
|
180
180
|
const requestedModelFiles = modelName.toLowerCase() === "all"
|
|
181
181
|
? fs_1.default.readdirSync(modelsDir).filter((f) => f.endsWith(".ts"))
|
|
182
182
|
: [`${pascalCase(modelName)}.ts`];
|
|
@@ -186,6 +186,7 @@ async function makeMigration(modelName, options = {}) {
|
|
|
186
186
|
}
|
|
187
187
|
const loadedModels = [];
|
|
188
188
|
const pendingPivotMigrations = new Map();
|
|
189
|
+
const failedFiles = new Set();
|
|
189
190
|
const timestampSeed = new Date()
|
|
190
191
|
.toISOString()
|
|
191
192
|
.replace(/[-:.TZ]/g, "")
|
|
@@ -202,13 +203,13 @@ async function makeMigration(modelName, options = {}) {
|
|
|
202
203
|
continue;
|
|
203
204
|
}
|
|
204
205
|
try {
|
|
205
|
-
if (!
|
|
206
|
+
if (!TypeScriptCompiler_js_1.TypeScriptCompiler.compile([modelPath])) {
|
|
206
207
|
console.warn(chalk_1.default.yellow(`WARN: Skipping migration due to TS error in ${file}`));
|
|
207
208
|
continue;
|
|
208
209
|
}
|
|
209
210
|
const absModelPath = path_1.default.resolve(modelPath);
|
|
210
211
|
delete require.cache[require.resolve(absModelPath)];
|
|
211
|
-
const modelModule = (0,
|
|
212
|
+
const modelModule = (0, tsRuntime_js_1.loadModule)(absModelPath);
|
|
212
213
|
const modelClassName = path_1.default.basename(file, ".ts");
|
|
213
214
|
const ModelClass = modelModule[modelClassName];
|
|
214
215
|
if (!ModelClass?.schema || !ModelClass?.tableName) {
|
|
@@ -227,6 +228,7 @@ async function makeMigration(modelName, options = {}) {
|
|
|
227
228
|
});
|
|
228
229
|
}
|
|
229
230
|
catch (err) {
|
|
231
|
+
failedFiles.add(file);
|
|
230
232
|
console.error(chalk_1.default.red(`ERROR: Error processing ${file}:`));
|
|
231
233
|
console.error(err instanceof Error ? err.message : err);
|
|
232
234
|
}
|
|
@@ -236,9 +238,9 @@ async function makeMigration(modelName, options = {}) {
|
|
|
236
238
|
: loadedModels;
|
|
237
239
|
for (const { file, modelClassName, ModelClass } of orderedModels) {
|
|
238
240
|
try {
|
|
239
|
-
const resolvedConnectionName = (0,
|
|
241
|
+
const resolvedConnectionName = (0, resolveConnectionName_js_1.resolveConnectionName)(ModelClass, { test: isTest });
|
|
240
242
|
const connectionName = forcedConnectionName ?? resolvedConnectionName;
|
|
241
|
-
const migrationsDir =
|
|
243
|
+
const migrationsDir = PathMap_js_1.PathMap.migrations(isTest, connectionName);
|
|
242
244
|
if (!fs_1.default.existsSync(migrationsDir)) {
|
|
243
245
|
fs_1.default.mkdirSync(migrationsDir, { recursive: true });
|
|
244
246
|
}
|
|
@@ -250,7 +252,7 @@ async function makeMigration(modelName, options = {}) {
|
|
|
250
252
|
const needsBaselineCreate = createFiles.length === 0 && updateFiles.length === 0;
|
|
251
253
|
console.log(chalk_1.default.gray(`INFO: Using connection: ${connectionName}`));
|
|
252
254
|
console.log(chalk_1.default.gray(`INFO: Migrations Path: ${migrationsDir}`));
|
|
253
|
-
const driver =
|
|
255
|
+
const driver = database_js_1.dbConfig.connections[connectionName]?.driver ??
|
|
254
256
|
connectionName;
|
|
255
257
|
const normalizedSchema = normalizedSchemaForMigration(ModelClass);
|
|
256
258
|
if (driver === "mongo") {
|
|
@@ -357,7 +359,7 @@ export async function down(db: { dropCollection(name: string): Promise<void> })
|
|
|
357
359
|
console.warn(chalk_1.default.yellow(`Skipping make:migration for "${connectionName}": unsupported driver "${driver}".`));
|
|
358
360
|
continue;
|
|
359
361
|
}
|
|
360
|
-
const { mainSQL, extraTables, rollbackMainSQL, rollbackExtraTables } = await
|
|
362
|
+
const { mainSQL, extraTables, rollbackMainSQL, rollbackExtraTables } = await SchemaBuilder_js_1.SchemaBuilder.toCreateSQL(ModelClass.tableName, normalizedSchema, driver, !needsBaselineCreate, connectionName, needsBaselineCreate);
|
|
361
363
|
if ((!mainSQL || mainSQL.trim() === "") && extraTables.length === 0) {
|
|
362
364
|
console.log(chalk_1.default.gray("INFO: No new columns or schema changes - skipping."));
|
|
363
365
|
continue;
|
|
@@ -454,6 +456,7 @@ export async function down(db: { query(sql: string): Promise<void> }) {
|
|
|
454
456
|
}
|
|
455
457
|
}
|
|
456
458
|
catch (err) {
|
|
459
|
+
failedFiles.add(file);
|
|
457
460
|
console.error(chalk_1.default.red(`ERROR: Error processing ${file}:`));
|
|
458
461
|
console.error(err instanceof Error ? err.message : err);
|
|
459
462
|
}
|
|
@@ -482,12 +485,23 @@ export async function down(db: { query(sql: string): Promise<void> }) {
|
|
|
482
485
|
console.log(chalk_1.default.green(`OK: Pivot migration saved: ${pivotPath}`));
|
|
483
486
|
}
|
|
484
487
|
try {
|
|
485
|
-
await (0,
|
|
488
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
486
489
|
console.log(chalk_1.default.gray("INFO: All database connections closed.\n"));
|
|
487
490
|
}
|
|
488
491
|
catch {
|
|
489
492
|
console.warn(chalk_1.default.yellow("WARN: Could not close DB connections cleanly."));
|
|
490
493
|
}
|
|
494
|
+
if (failedFiles.size > 0) {
|
|
495
|
+
const failureSummary = `ERROR: Migration generation failed for ${failedFiles.size} model` +
|
|
496
|
+
`${failedFiles.size === 1 ? "" : "s"}: ${[...failedFiles].join(", ")}`;
|
|
497
|
+
console.error(chalk_1.default.red(failureSummary));
|
|
498
|
+
if (options.exit !== false) {
|
|
499
|
+
process.exit(1);
|
|
500
|
+
/* istanbul ignore next -- process.exit terminates the process in runtime */
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
throw new Error(failureSummary);
|
|
504
|
+
}
|
|
491
505
|
console.log(chalk_1.default.cyanBright(`OK: Migration generation complete in ${isTest ? "TEST" : "DEVELOPMENT"} mode.\n`));
|
|
492
506
|
if (options.exit !== false) {
|
|
493
507
|
process.exit(0);
|
|
@@ -8,16 +8,16 @@ exports.makeModel = makeModel;
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
11
|
+
const SchemaBuilder_js_1 = require("../../core/schema/SchemaBuilder.js");
|
|
12
|
+
const PathMap_js_1 = require("../utils/PathMap.js");
|
|
13
|
+
const TemplateEngine_js_1 = require("../utils/TemplateEngine.js");
|
|
14
|
+
const ImportResolver_js_1 = require("../utils/ImportResolver.js");
|
|
15
|
+
const resolveConnectionName_js_1 = require("../../core/connection/resolveConnectionName.js");
|
|
16
|
+
const TypeScriptCompiler_js_1 = require("../utils/typescript/TypeScriptCompiler.js");
|
|
17
|
+
const ConnectionFactory_js_1 = require("../../core/connection/ConnectionFactory.js");
|
|
18
|
+
const database_js_1 = require("../../config/database.js");
|
|
19
|
+
const tsRuntime_js_1 = require("../utils/typescript/tsRuntime.js");
|
|
20
|
+
const makeMigration_js_1 = require("./makeMigration.js");
|
|
21
21
|
function pascalCase(name) {
|
|
22
22
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
23
23
|
}
|
|
@@ -155,19 +155,19 @@ async function makeModel(name, options = {}) {
|
|
|
155
155
|
? defaultConnectionName
|
|
156
156
|
: `process.env.DB_CONNECTION ?? "${defaultConnectionName}"`;
|
|
157
157
|
let wroteModel = false;
|
|
158
|
-
|
|
159
|
-
const modelsDir =
|
|
160
|
-
const migrationsDir = isTest ?
|
|
158
|
+
PathMap_js_1.PathMap.ensureDirs();
|
|
159
|
+
const modelsDir = PathMap_js_1.PathMap.models(isTest);
|
|
160
|
+
const migrationsDir = isTest ? PathMap_js_1.PathMap.testMigrations() : PathMap_js_1.PathMap.appMigrations();
|
|
161
161
|
console.log(chalk_1.default.gray(`📁 Models Path: ${modelsDir}`));
|
|
162
162
|
console.log(chalk_1.default.gray(`📁 Migrations Path: ${migrationsDir}`));
|
|
163
|
-
const coreImportPath =
|
|
164
|
-
const schemaImportPath =
|
|
163
|
+
const coreImportPath = ImportResolver_js_1.ImportResolver.coreImportPath(isTest, PathMap_js_1.PathMap.root);
|
|
164
|
+
const schemaImportPath = ImportResolver_js_1.ImportResolver.schemaImportPath(isTest, PathMap_js_1.PathMap.root);
|
|
165
165
|
let tpl = "";
|
|
166
166
|
// 🧠 1️⃣ Generate Model
|
|
167
167
|
const modelFilePath = path_1.default.join(modelsDir, `${modelName}.ts`);
|
|
168
168
|
try {
|
|
169
|
-
tpl =
|
|
170
|
-
const modelContent =
|
|
169
|
+
tpl = TemplateEngine_js_1.TemplateEngine.load("model");
|
|
170
|
+
const modelContent = TemplateEngine_js_1.TemplateEngine.render(tpl, {
|
|
171
171
|
ModelName: modelName,
|
|
172
172
|
tableName,
|
|
173
173
|
coreImportPath,
|
|
@@ -189,7 +189,7 @@ async function makeModel(name, options = {}) {
|
|
|
189
189
|
console.log(chalk_1.default.yellow(`⚠️ Model already exists: ${modelFilePath}`));
|
|
190
190
|
}
|
|
191
191
|
else {
|
|
192
|
-
|
|
192
|
+
TemplateEngine_js_1.TemplateEngine.save(modelFilePath, finalContent);
|
|
193
193
|
wroteModel = true;
|
|
194
194
|
console.log(chalk_1.default.green(`✅ Model created: ${modelFilePath}`));
|
|
195
195
|
}
|
|
@@ -200,13 +200,13 @@ async function makeModel(name, options = {}) {
|
|
|
200
200
|
}
|
|
201
201
|
if (attrsFromSchema && wroteModel) {
|
|
202
202
|
try {
|
|
203
|
-
if (!
|
|
203
|
+
if (!TypeScriptCompiler_js_1.TypeScriptCompiler.compile([modelFilePath])) {
|
|
204
204
|
console.warn(chalk_1.default.yellow(`⚠️ Skipping attrs inference — ${modelName}.ts has TS errors.`));
|
|
205
205
|
}
|
|
206
206
|
else {
|
|
207
207
|
const absModelPath = path_1.default.resolve(modelFilePath);
|
|
208
208
|
delete require.cache[require.resolve(absModelPath)];
|
|
209
|
-
const modelModule = (0,
|
|
209
|
+
const modelModule = (0, tsRuntime_js_1.loadModule)(absModelPath);
|
|
210
210
|
const ModelClass = modelModule[modelName];
|
|
211
211
|
if (!ModelClass?.schema) {
|
|
212
212
|
console.log(chalk_1.default.yellow(`⚠️ Schema not found in ${modelName}.ts — keeping defaults.`));
|
|
@@ -216,7 +216,7 @@ async function makeModel(name, options = {}) {
|
|
|
216
216
|
includeTimestamps: Boolean(ModelClass.timestamps),
|
|
217
217
|
includeSoftDeletes: Boolean(ModelClass.softDeletes),
|
|
218
218
|
});
|
|
219
|
-
const modelContent =
|
|
219
|
+
const modelContent = TemplateEngine_js_1.TemplateEngine.render(tpl, {
|
|
220
220
|
ModelName: modelName,
|
|
221
221
|
tableName,
|
|
222
222
|
coreImportPath,
|
|
@@ -233,7 +233,7 @@ async function makeModel(name, options = {}) {
|
|
|
233
233
|
* Mode: ${mode}
|
|
234
234
|
* Generated at: ${new Date().toISOString()}
|
|
235
235
|
*/\n\n`;
|
|
236
|
-
|
|
236
|
+
TemplateEngine_js_1.TemplateEngine.save(modelFilePath, header + modelContent);
|
|
237
237
|
console.log(chalk_1.default.green(`✅ Inferred attrs type from schema for ${modelName}.ts`));
|
|
238
238
|
}
|
|
239
239
|
}
|
|
@@ -252,30 +252,30 @@ async function makeModel(name, options = {}) {
|
|
|
252
252
|
}
|
|
253
253
|
// 🧱 3️⃣ Generate smart migration (SchemaBuilder v3)
|
|
254
254
|
try {
|
|
255
|
-
if (!
|
|
255
|
+
if (!TypeScriptCompiler_js_1.TypeScriptCompiler.compile([modelFilePath])) {
|
|
256
256
|
console.warn(chalk_1.default.yellow(`⚠️ Skipping migration — ${modelName}.ts has TS errors.`));
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
259
|
const absModelPath = path_1.default.resolve(modelFilePath);
|
|
260
260
|
delete require.cache[require.resolve(absModelPath)];
|
|
261
|
-
const modelModule = (0,
|
|
261
|
+
const modelModule = (0, tsRuntime_js_1.loadModule)(absModelPath);
|
|
262
262
|
const ModelClass = modelModule[modelName];
|
|
263
263
|
if (!ModelClass?.schema || !ModelClass?.tableName) {
|
|
264
264
|
console.log(chalk_1.default.yellow(`⚠️ Schema not found in ${modelName}.ts — skipping migration.`));
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
267
|
const resolvedModelClass = ModelClass;
|
|
268
|
-
const connectionName = (0,
|
|
269
|
-
const connectionMigrationsDir =
|
|
268
|
+
const connectionName = (0, resolveConnectionName_js_1.resolveConnectionName)(resolvedModelClass, { test: isTest });
|
|
269
|
+
const connectionMigrationsDir = PathMap_js_1.PathMap.migrations(isTest, connectionName);
|
|
270
270
|
if (!fs_1.default.existsSync(connectionMigrationsDir)) {
|
|
271
271
|
fs_1.default.mkdirSync(connectionMigrationsDir, { recursive: true });
|
|
272
272
|
}
|
|
273
273
|
console.log(chalk_1.default.gray(`Using connection: ${connectionName}`));
|
|
274
274
|
console.log(chalk_1.default.gray(`Migrations Path: ${connectionMigrationsDir}`));
|
|
275
|
-
const driver =
|
|
275
|
+
const driver = database_js_1.dbConfig.connections[connectionName]?.driver ??
|
|
276
276
|
connectionName;
|
|
277
277
|
if (driver === "mongo") {
|
|
278
|
-
await (0,
|
|
278
|
+
await (0, makeMigration_js_1.makeMigration)(modelName, {
|
|
279
279
|
test: isTest,
|
|
280
280
|
connectionName,
|
|
281
281
|
exit: false,
|
|
@@ -283,7 +283,7 @@ async function makeModel(name, options = {}) {
|
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
const normalizedSchema = normalizedSchemaForMigration(resolvedModelClass);
|
|
286
|
-
const { mainSQL, extraTables, rollbackMainSQL, rollbackExtraTables } = await
|
|
286
|
+
const { mainSQL, extraTables, rollbackMainSQL, rollbackExtraTables } = await SchemaBuilder_js_1.SchemaBuilder.toCreateSQL(resolvedModelClass.tableName, normalizedSchema, driver, true, // smart update detection
|
|
287
287
|
connectionName);
|
|
288
288
|
const isCreate = mainSQL.trim().toUpperCase().startsWith("CREATE TABLE");
|
|
289
289
|
const prefix = isCreate ? "create" : "update";
|
|
@@ -349,7 +349,7 @@ export async function down(db: { query(sql: string): Promise<void> }) {
|
|
|
349
349
|
}
|
|
350
350
|
finally {
|
|
351
351
|
try {
|
|
352
|
-
await (0,
|
|
352
|
+
await (0, ConnectionFactory_js_1.closeAllConnections)();
|
|
353
353
|
console.log(chalk_1.default.gray("All database connections closed."));
|
|
354
354
|
}
|
|
355
355
|
catch {
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
+
import { ImportResolver } from "../utils/ImportResolver.js";
|
|
1
2
|
type RegistryOptions = {
|
|
2
3
|
test?: boolean;
|
|
3
4
|
force?: boolean;
|
|
4
5
|
};
|
|
5
|
-
declare function stripJsonComments(raw: string): string;
|
|
6
|
-
declare function readJsonFile<T>(filePath: string): T | null;
|
|
7
|
-
declare function usesNodeEsmRegistryImports(rootDir: string): boolean;
|
|
8
|
-
declare function withRuntimeRelativeImportExtension(importPath: string, rootDir: string): string;
|
|
9
6
|
export declare const __makeRegistryInternals: {
|
|
10
|
-
stripJsonComments:
|
|
11
|
-
readJsonFile:
|
|
12
|
-
usesNodeEsmRegistryImports: typeof
|
|
13
|
-
withRuntimeRelativeImportExtension: typeof withRuntimeRelativeImportExtension;
|
|
7
|
+
stripJsonComments: (raw: string) => string;
|
|
8
|
+
readJsonFile: <T>(filePath: string) => T | null;
|
|
9
|
+
usesNodeEsmRegistryImports: typeof ImportResolver.usesNodeEsmRuntime;
|
|
10
|
+
withRuntimeRelativeImportExtension: typeof ImportResolver.withRuntimeRelativeImportExtension;
|
|
14
11
|
};
|
|
15
12
|
export declare function makeRegistry(options?: RegistryOptions): Promise<void>;
|
|
16
13
|
export {};
|
|
@@ -8,67 +8,17 @@ exports.makeRegistry = makeRegistry;
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
11
|
+
const TemplateEngine_js_1 = require("../utils/TemplateEngine.js");
|
|
12
|
+
const fileWriter_js_1 = require("../utils/fileWriter.js");
|
|
13
|
+
const PathMap_js_1 = require("../utils/PathMap.js");
|
|
14
|
+
const ImportResolver_js_1 = require("../utils/ImportResolver.js");
|
|
15
15
|
function isValidIdentifier(name) {
|
|
16
16
|
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);
|
|
17
17
|
}
|
|
18
|
-
function stripJsonComments(raw) {
|
|
19
|
-
return raw
|
|
20
|
-
.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
21
|
-
.replace(/^\s*\/\/.*$/gm, "");
|
|
22
|
-
}
|
|
23
|
-
function readJsonFile(filePath) {
|
|
24
|
-
if (!fs_1.default.existsSync(filePath)) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
const raw = fs_1.default.readFileSync(filePath, "utf8");
|
|
29
|
-
return JSON.parse(stripJsonComments(raw));
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function usesNodeEsmRegistryImports(rootDir) {
|
|
36
|
-
const packageJson = readJsonFile(path_1.default.join(rootDir, "package.json"));
|
|
37
|
-
const packageType = typeof packageJson?.type === "string" ? packageJson.type.trim() : "";
|
|
38
|
-
if (packageType === "module") {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
const tsconfig = readJsonFile(path_1.default.join(rootDir, "tsconfig.json"));
|
|
42
|
-
const compilerOptions = tsconfig && typeof tsconfig === "object" ? tsconfig.compilerOptions : undefined;
|
|
43
|
-
const moduleName = typeof compilerOptions?.module === "string"
|
|
44
|
-
? compilerOptions.module.trim().toLowerCase()
|
|
45
|
-
: "";
|
|
46
|
-
const moduleResolution = typeof compilerOptions?.moduleResolution === "string"
|
|
47
|
-
? compilerOptions.moduleResolution.trim().toLowerCase()
|
|
48
|
-
: "";
|
|
49
|
-
return (moduleName === "nodenext" ||
|
|
50
|
-
moduleName === "node16" ||
|
|
51
|
-
moduleResolution === "nodenext" ||
|
|
52
|
-
moduleResolution === "node16");
|
|
53
|
-
}
|
|
54
|
-
function withRuntimeRelativeImportExtension(importPath, rootDir) {
|
|
55
|
-
if (!usesNodeEsmRegistryImports(rootDir)) {
|
|
56
|
-
return importPath;
|
|
57
|
-
}
|
|
58
|
-
const isRelativeImport = importPath.startsWith(".");
|
|
59
|
-
if (!isRelativeImport) {
|
|
60
|
-
return importPath;
|
|
61
|
-
}
|
|
62
|
-
const hasRuntimeExtension = /\.(?:[cm]?js|json)$/i.test(importPath);
|
|
63
|
-
if (hasRuntimeExtension) {
|
|
64
|
-
return importPath;
|
|
65
|
-
}
|
|
66
|
-
return `${importPath}.js`;
|
|
67
|
-
}
|
|
68
18
|
function discoverRegistryModels(isTest) {
|
|
69
|
-
const modelsDir =
|
|
19
|
+
const modelsDir = PathMap_js_1.PathMap.models(isTest);
|
|
70
20
|
const importBase = isTest ? "./database/models" : "./models";
|
|
71
|
-
const rootDir =
|
|
21
|
+
const rootDir = PathMap_js_1.PathMap.root;
|
|
72
22
|
if (!fs_1.default.existsSync(modelsDir)) {
|
|
73
23
|
return [];
|
|
74
24
|
}
|
|
@@ -84,11 +34,11 @@ function discoverRegistryModels(isTest) {
|
|
|
84
34
|
.sort((a, b) => a.localeCompare(b))
|
|
85
35
|
.map((name) => ({
|
|
86
36
|
name,
|
|
87
|
-
importPath: withRuntimeRelativeImportExtension(`${importBase}/${name}`, rootDir),
|
|
37
|
+
importPath: ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension(`${importBase}/${name}`, rootDir),
|
|
88
38
|
}));
|
|
89
39
|
}
|
|
90
40
|
function registryOutputPath(isTest) {
|
|
91
|
-
return path_1.default.resolve(
|
|
41
|
+
return path_1.default.resolve(PathMap_js_1.PathMap.root, isTest ? "src/test/registerModels.ts" : "src/app/registerModels.ts");
|
|
92
42
|
}
|
|
93
43
|
function registryRelativePath(isTest) {
|
|
94
44
|
return isTest ? "src/test/registerModels.ts" : "src/app/registerModels.ts";
|
|
@@ -100,22 +50,22 @@ function registryConstName(isTest) {
|
|
|
100
50
|
return isTest ? "TEST_MODELS" : "APP_MODELS";
|
|
101
51
|
}
|
|
102
52
|
exports.__makeRegistryInternals = {
|
|
103
|
-
stripJsonComments,
|
|
104
|
-
readJsonFile,
|
|
105
|
-
usesNodeEsmRegistryImports,
|
|
106
|
-
withRuntimeRelativeImportExtension,
|
|
53
|
+
stripJsonComments: ImportResolver_js_1.__importResolverInternals.stripJsonComments,
|
|
54
|
+
readJsonFile: ImportResolver_js_1.__importResolverInternals.readJsonFile,
|
|
55
|
+
usesNodeEsmRegistryImports: ImportResolver_js_1.ImportResolver.usesNodeEsmRuntime.bind(ImportResolver_js_1.ImportResolver),
|
|
56
|
+
withRuntimeRelativeImportExtension: ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension.bind(ImportResolver_js_1.ImportResolver),
|
|
107
57
|
};
|
|
108
58
|
async function makeRegistry(options = {}) {
|
|
109
59
|
try {
|
|
110
60
|
const isTest = !!options.test;
|
|
111
61
|
const forceWrite = !!options.force;
|
|
112
|
-
|
|
62
|
+
PathMap_js_1.PathMap.ensureDirs();
|
|
113
63
|
const outputPath = registryOutputPath(isTest);
|
|
114
64
|
const relativePath = registryRelativePath(isTest);
|
|
115
65
|
const models = discoverRegistryModels(isTest);
|
|
116
|
-
const template =
|
|
117
|
-
const outputImportPath = withRuntimeRelativeImportExtension(
|
|
118
|
-
const rendered =
|
|
66
|
+
const template = TemplateEngine_js_1.TemplateEngine.load("model-registry");
|
|
67
|
+
const outputImportPath = ImportResolver_js_1.ImportResolver.withRuntimeRelativeImportExtension(ImportResolver_js_1.ImportResolver.publicApiImportPath(outputPath, PathMap_js_1.PathMap.root), PathMap_js_1.PathMap.root);
|
|
68
|
+
const rendered = TemplateEngine_js_1.TemplateEngine.render(template, {
|
|
119
69
|
packageImportPath: outputImportPath,
|
|
120
70
|
models,
|
|
121
71
|
modelsConstName: registryConstName(isTest),
|
|
@@ -129,8 +79,8 @@ async function makeRegistry(options = {}) {
|
|
|
129
79
|
|
|
130
80
|
`;
|
|
131
81
|
const created = forceWrite
|
|
132
|
-
? (0,
|
|
133
|
-
: (0,
|
|
82
|
+
? (0, fileWriter_js_1.overwriteFile)(outputPath, header + rendered)
|
|
83
|
+
: (0, fileWriter_js_1.writeFileSafe)(outputPath, header + rendered);
|
|
134
84
|
if (!created) {
|
|
135
85
|
return;
|
|
136
86
|
}
|