prisma-laravel-migrate 3.1.15 → 3.1.17
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/cli.js +8 -8
- package/dist/cli/migrator.index.js +4 -4
- package/dist/cli/models.index.js +5 -6
- package/dist/cli/ts.index.js +10 -5
- package/dist/index.js +8 -8
- package/package.json +3 -2
package/dist/cli/cli.js
CHANGED
|
@@ -1176,11 +1176,11 @@ function safeUnlink(p) {
|
|
|
1176
1176
|
} catch {
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
|
-
async function loadSharedConfig(schemaDir) {
|
|
1179
|
+
async function loadSharedConfig(schemaDir, type) {
|
|
1180
1180
|
const envOverride = process.env.PRISMA_LARAVEL_CFG;
|
|
1181
1181
|
const defaultPath = path13.join(schemaDir, "prisma-laravel.config.js");
|
|
1182
1182
|
const cfgPath = envOverride ? path13.resolve(envOverride) : defaultPath;
|
|
1183
|
-
console.log("Loading shared config from - " + cfgPath);
|
|
1183
|
+
console.log("Loading shared config for " + type + " from - " + cfgPath);
|
|
1184
1184
|
try {
|
|
1185
1185
|
await fs.accessSync(cfgPath);
|
|
1186
1186
|
const mod = await loadConfig(cfgPath);
|
|
@@ -1196,7 +1196,7 @@ async function generateLaravelSchema(options) {
|
|
|
1196
1196
|
const { dmmf, generator } = options;
|
|
1197
1197
|
const raw = generator.config ?? {};
|
|
1198
1198
|
const schemaDir = path13.dirname(generator.sourceFilePath ?? path13.resolve(options.schemaPath));
|
|
1199
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
1199
|
+
const shared = await loadSharedConfig(schemaDir, "migrations");
|
|
1200
1200
|
let groups = [];
|
|
1201
1201
|
const loadGroups = async (p) => {
|
|
1202
1202
|
const abs = path13.resolve(process.cwd(), p);
|
|
@@ -2256,10 +2256,9 @@ function buildModelContent(model) {
|
|
|
2256
2256
|
// src/generator/modeler/index.ts
|
|
2257
2257
|
async function generateLaravelModels(options) {
|
|
2258
2258
|
const { dmmf, generator } = options;
|
|
2259
|
-
generator.sourceFilePath;
|
|
2260
2259
|
const raw = generator.config ?? {};
|
|
2261
|
-
const schemaDir = path13.dirname(path13.resolve(options.schemaPath));
|
|
2262
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
2260
|
+
const schemaDir = path13.dirname(generator.sourceFilePath ?? path13.resolve(options.schemaPath));
|
|
2261
|
+
const shared = await loadSharedConfig(schemaDir, "models");
|
|
2263
2262
|
let groups = [];
|
|
2264
2263
|
if (raw["groups"]) {
|
|
2265
2264
|
const groupsModulePath = path13.resolve(process.cwd(), raw["groups"]);
|
|
@@ -3184,8 +3183,8 @@ function hasModelSpecificTsStub(model, cfg) {
|
|
|
3184
3183
|
async function generateTypesFromPrisma(options) {
|
|
3185
3184
|
const { dmmf, generator } = options;
|
|
3186
3185
|
const raw = generator.config ?? {};
|
|
3187
|
-
const schemaDir = path13.dirname(options.schemaPath);
|
|
3188
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
3186
|
+
const schemaDir = path13.dirname(generator.sourceFilePath ?? path13.resolve(options.schemaPath));
|
|
3187
|
+
const shared = await loadSharedConfig(schemaDir, "typescript");
|
|
3189
3188
|
let groups = [];
|
|
3190
3189
|
if (raw["groups"]) {
|
|
3191
3190
|
const groupsModulePath = path13.resolve(process.cwd(), raw["groups"]);
|
|
@@ -3235,6 +3234,7 @@ async function generateTypesFromPrisma(options) {
|
|
|
3235
3234
|
if (!existsSync(tsOutDir)) {
|
|
3236
3235
|
mkdirSync(tsOutDir, { recursive: true });
|
|
3237
3236
|
}
|
|
3237
|
+
addToConfig("typescript", cfg);
|
|
3238
3238
|
global._config = global._config || {};
|
|
3239
3239
|
global._config.ts = {
|
|
3240
3240
|
prettier: !!cfg.prettier
|
|
@@ -1145,11 +1145,11 @@ async function loadConfig2(configPath) {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
|
|
1147
1147
|
// src/utils/loadSharedCfg.ts
|
|
1148
|
-
async function loadSharedConfig(schemaDir) {
|
|
1148
|
+
async function loadSharedConfig(schemaDir, type) {
|
|
1149
1149
|
const envOverride = process.env.PRISMA_LARAVEL_CFG;
|
|
1150
1150
|
const defaultPath = path7.join(schemaDir, "prisma-laravel.config.js");
|
|
1151
1151
|
const cfgPath = envOverride ? path7.resolve(envOverride) : defaultPath;
|
|
1152
|
-
console.log("Loading shared config from - " + cfgPath);
|
|
1152
|
+
console.log("Loading shared config for " + type + " from - " + cfgPath);
|
|
1153
1153
|
try {
|
|
1154
1154
|
await fs2.accessSync(cfgPath);
|
|
1155
1155
|
const mod = await loadConfig2(cfgPath);
|
|
@@ -1165,7 +1165,7 @@ async function generateLaravelSchema(options) {
|
|
|
1165
1165
|
const { dmmf, generator } = options;
|
|
1166
1166
|
const raw = generator.config ?? {};
|
|
1167
1167
|
const schemaDir = path7.dirname(generator.sourceFilePath ?? path7.resolve(options.schemaPath));
|
|
1168
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
1168
|
+
const shared = await loadSharedConfig(schemaDir, "migrations");
|
|
1169
1169
|
let groups = [];
|
|
1170
1170
|
const loadGroups = async (p) => {
|
|
1171
1171
|
const abs = path7.resolve(process.cwd(), p);
|
|
@@ -1279,7 +1279,7 @@ generatorHandler({
|
|
|
1279
1279
|
if (!migrationsOutput && options.sourceFilePath) {
|
|
1280
1280
|
try {
|
|
1281
1281
|
const schemaDir = path7.dirname(options.sourceFilePath);
|
|
1282
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
1282
|
+
const shared = await loadSharedConfig(schemaDir, "models");
|
|
1283
1283
|
migrationsOutput = shared?.migrate?.outputDir ?? shared?.output?.migrations ?? void 0;
|
|
1284
1284
|
} catch {
|
|
1285
1285
|
}
|
package/dist/cli/models.index.js
CHANGED
|
@@ -1179,11 +1179,11 @@ async function loadConfig2(configPath) {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
|
|
1181
1181
|
// src/utils/loadSharedCfg.ts
|
|
1182
|
-
async function loadSharedConfig(schemaDir) {
|
|
1182
|
+
async function loadSharedConfig(schemaDir, type) {
|
|
1183
1183
|
const envOverride = process.env.PRISMA_LARAVEL_CFG;
|
|
1184
1184
|
const defaultPath = path7.join(schemaDir, "prisma-laravel.config.js");
|
|
1185
1185
|
const cfgPath = envOverride ? path7.resolve(envOverride) : defaultPath;
|
|
1186
|
-
console.log("Loading shared config from - " + cfgPath);
|
|
1186
|
+
console.log("Loading shared config for " + type + " from - " + cfgPath);
|
|
1187
1187
|
try {
|
|
1188
1188
|
await fs.accessSync(cfgPath);
|
|
1189
1189
|
const mod = await loadConfig2(cfgPath);
|
|
@@ -1262,10 +1262,9 @@ function buildModelContent(model) {
|
|
|
1262
1262
|
// src/generator/modeler/index.ts
|
|
1263
1263
|
async function generateLaravelModels(options) {
|
|
1264
1264
|
const { dmmf, generator } = options;
|
|
1265
|
-
generator.sourceFilePath;
|
|
1266
1265
|
const raw = generator.config ?? {};
|
|
1267
|
-
const schemaDir = path7.dirname(path7.resolve(options.schemaPath));
|
|
1268
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
1266
|
+
const schemaDir = path7.dirname(generator.sourceFilePath ?? path7.resolve(options.schemaPath));
|
|
1267
|
+
const shared = await loadSharedConfig(schemaDir, "models");
|
|
1269
1268
|
let groups = [];
|
|
1270
1269
|
if (raw["groups"]) {
|
|
1271
1270
|
const groupsModulePath = path7.resolve(process.cwd(), raw["groups"]);
|
|
@@ -1356,7 +1355,7 @@ generatorHandler({
|
|
|
1356
1355
|
if (options.sourceFilePath) {
|
|
1357
1356
|
try {
|
|
1358
1357
|
const schemaDir = path7.dirname(options.sourceFilePath);
|
|
1359
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
1358
|
+
const shared = await loadSharedConfig(schemaDir, "models");
|
|
1360
1359
|
if (!modelOutput) {
|
|
1361
1360
|
modelOutput = shared?.modeler?.outputDir ?? shared?.output?.models ?? void 0;
|
|
1362
1361
|
}
|
package/dist/cli/ts.index.js
CHANGED
|
@@ -68,11 +68,11 @@ async function loadConfig(configPath) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// src/utils/loadSharedCfg.ts
|
|
71
|
-
async function loadSharedConfig(schemaDir) {
|
|
71
|
+
async function loadSharedConfig(schemaDir, type) {
|
|
72
72
|
const envOverride = process.env.PRISMA_LARAVEL_CFG;
|
|
73
73
|
const defaultPath = path7.join(schemaDir, "prisma-laravel.config.js");
|
|
74
74
|
const cfgPath = envOverride ? path7.resolve(envOverride) : defaultPath;
|
|
75
|
-
console.log("Loading shared config from - " + cfgPath);
|
|
75
|
+
console.log("Loading shared config for " + type + " from - " + cfgPath);
|
|
76
76
|
try {
|
|
77
77
|
await fs.accessSync(cfgPath);
|
|
78
78
|
const mod = await loadConfig(cfgPath);
|
|
@@ -167,6 +167,10 @@ function decorate(name, opts) {
|
|
|
167
167
|
const suf = opts.tableSuffix ?? "";
|
|
168
168
|
return `${pre}${name}${suf}`.trim();
|
|
169
169
|
}
|
|
170
|
+
function addToConfig(key, value) {
|
|
171
|
+
global._config = global._config ?? {};
|
|
172
|
+
global._config[key] = value;
|
|
173
|
+
}
|
|
170
174
|
function getConfig(key, property) {
|
|
171
175
|
const cfg = global._config ?? {};
|
|
172
176
|
const section = cfg[key];
|
|
@@ -1633,8 +1637,8 @@ function hasModelSpecificTsStub(model, cfg) {
|
|
|
1633
1637
|
async function generateTypesFromPrisma(options) {
|
|
1634
1638
|
const { dmmf, generator } = options;
|
|
1635
1639
|
const raw = generator.config ?? {};
|
|
1636
|
-
const schemaDir = path7.dirname(options.schemaPath);
|
|
1637
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
1640
|
+
const schemaDir = path7.dirname(generator.sourceFilePath ?? path7.resolve(options.schemaPath));
|
|
1641
|
+
const shared = await loadSharedConfig(schemaDir, "typescript");
|
|
1638
1642
|
let groups = [];
|
|
1639
1643
|
if (raw["groups"]) {
|
|
1640
1644
|
const groupsModulePath = path7.resolve(process.cwd(), raw["groups"]);
|
|
@@ -1684,6 +1688,7 @@ async function generateTypesFromPrisma(options) {
|
|
|
1684
1688
|
if (!existsSync(tsOutDir)) {
|
|
1685
1689
|
mkdirSync(tsOutDir, { recursive: true });
|
|
1686
1690
|
}
|
|
1691
|
+
addToConfig("typescript", cfg);
|
|
1687
1692
|
global._config = global._config || {};
|
|
1688
1693
|
global._config.ts = {
|
|
1689
1694
|
prettier: !!cfg.prettier
|
|
@@ -1771,7 +1776,7 @@ generatorHandler({
|
|
|
1771
1776
|
if (!defaultOutput && options.sourceFilePath) {
|
|
1772
1777
|
try {
|
|
1773
1778
|
const schemaDir = path7.dirname(options.sourceFilePath);
|
|
1774
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
1779
|
+
const shared = await loadSharedConfig(schemaDir, "typescript");
|
|
1775
1780
|
if (shared && shared.ts) {
|
|
1776
1781
|
defaultOutput = shared.ts.outputDir;
|
|
1777
1782
|
}
|
package/dist/index.js
CHANGED
|
@@ -1298,11 +1298,11 @@ async function loadConfig2(configPath) {
|
|
|
1298
1298
|
}
|
|
1299
1299
|
|
|
1300
1300
|
// src/utils/loadSharedCfg.ts
|
|
1301
|
-
async function loadSharedConfig(schemaDir) {
|
|
1301
|
+
async function loadSharedConfig(schemaDir, type) {
|
|
1302
1302
|
const envOverride = process.env.PRISMA_LARAVEL_CFG;
|
|
1303
1303
|
const defaultPath = path9.join(schemaDir, "prisma-laravel.config.js");
|
|
1304
1304
|
const cfgPath = envOverride ? path9.resolve(envOverride) : defaultPath;
|
|
1305
|
-
console.log("Loading shared config from - " + cfgPath);
|
|
1305
|
+
console.log("Loading shared config for " + type + " from - " + cfgPath);
|
|
1306
1306
|
try {
|
|
1307
1307
|
await fs2.accessSync(cfgPath);
|
|
1308
1308
|
const mod = await loadConfig2(cfgPath);
|
|
@@ -1318,7 +1318,7 @@ async function generateLaravelSchema(options) {
|
|
|
1318
1318
|
const { dmmf, generator } = options;
|
|
1319
1319
|
const raw = generator.config ?? {};
|
|
1320
1320
|
const schemaDir = path9.dirname(generator.sourceFilePath ?? path9.resolve(options.schemaPath));
|
|
1321
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
1321
|
+
const shared = await loadSharedConfig(schemaDir, "migrations");
|
|
1322
1322
|
let groups = [];
|
|
1323
1323
|
const loadGroups = async (p) => {
|
|
1324
1324
|
const abs = path9.resolve(process.cwd(), p);
|
|
@@ -2251,10 +2251,9 @@ var PrismaToLaravelModelGenerator = class {
|
|
|
2251
2251
|
// src/generator/modeler/index.ts
|
|
2252
2252
|
async function generateLaravelModels(options) {
|
|
2253
2253
|
const { dmmf, generator } = options;
|
|
2254
|
-
generator.sourceFilePath;
|
|
2255
2254
|
const raw = generator.config ?? {};
|
|
2256
|
-
const schemaDir = path9.dirname(path9.resolve(options.schemaPath));
|
|
2257
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
2255
|
+
const schemaDir = path9.dirname(generator.sourceFilePath ?? path9.resolve(options.schemaPath));
|
|
2256
|
+
const shared = await loadSharedConfig(schemaDir, "models");
|
|
2258
2257
|
let groups = [];
|
|
2259
2258
|
if (raw["groups"]) {
|
|
2260
2259
|
const groupsModulePath = path9.resolve(process.cwd(), raw["groups"]);
|
|
@@ -3179,8 +3178,8 @@ function hasModelSpecificTsStub(model, cfg) {
|
|
|
3179
3178
|
async function generateTypesFromPrisma(options) {
|
|
3180
3179
|
const { dmmf, generator } = options;
|
|
3181
3180
|
const raw = generator.config ?? {};
|
|
3182
|
-
const schemaDir = path9.dirname(options.schemaPath);
|
|
3183
|
-
const shared = await loadSharedConfig(schemaDir);
|
|
3181
|
+
const schemaDir = path9.dirname(generator.sourceFilePath ?? path9.resolve(options.schemaPath));
|
|
3182
|
+
const shared = await loadSharedConfig(schemaDir, "typescript");
|
|
3184
3183
|
let groups = [];
|
|
3185
3184
|
if (raw["groups"]) {
|
|
3186
3185
|
const groupsModulePath = path9.resolve(process.cwd(), raw["groups"]);
|
|
@@ -3230,6 +3229,7 @@ async function generateTypesFromPrisma(options) {
|
|
|
3230
3229
|
if (!existsSync(tsOutDir)) {
|
|
3231
3230
|
mkdirSync(tsOutDir, { recursive: true });
|
|
3232
3231
|
}
|
|
3232
|
+
addToConfig("typescript", cfg);
|
|
3233
3233
|
global._config = global._config || {};
|
|
3234
3234
|
global._config.ts = {
|
|
3235
3235
|
prettier: !!cfg.prettier
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-laravel-migrate",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.17",
|
|
4
4
|
"description": "Generate laravel migrations and/or models using prisma files",
|
|
5
5
|
"bin": {
|
|
6
6
|
"prisma-laravel-migrations": "./dist/cli/migrator.index.js",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"minimatch": "^10.0.3",
|
|
55
55
|
"node-diff3": "^3.1.2",
|
|
56
56
|
"pluralize": "^8.0.0",
|
|
57
|
-
"prettier": "^3.6.2"
|
|
57
|
+
"prettier": "^3.6.2",
|
|
58
|
+
"prisma-laravel-migrate": "^3.1.16"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@types/ejs": "^3.1.5",
|