prisma-laravel-migrate 3.1.16 → 3.1.18

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 CHANGED
@@ -328,12 +328,12 @@ function decorate(name, opts) {
328
328
  const suf = opts.tableSuffix ?? "";
329
329
  return `${pre}${name}${suf}`.trim();
330
330
  }
331
+ var config = {};
331
332
  function addToConfig(key, value) {
332
- global._config = global._config ?? {};
333
- global._config[key] = value;
333
+ config[key] = value;
334
334
  }
335
335
  function getConfig(key, property) {
336
- const cfg = global._config ?? {};
336
+ const cfg = config;
337
337
  const section = cfg[key];
338
338
  return property ? section?.[property] : section;
339
339
  }
@@ -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);
@@ -2258,7 +2258,7 @@ async function generateLaravelModels(options) {
2258
2258
  const { dmmf, generator } = options;
2259
2259
  const raw = generator.config ?? {};
2260
2260
  const schemaDir = path13.dirname(generator.sourceFilePath ?? path13.resolve(options.schemaPath));
2261
- const shared = await loadSharedConfig(schemaDir);
2261
+ const shared = await loadSharedConfig(schemaDir, "models");
2262
2262
  let groups = [];
2263
2263
  if (raw["groups"]) {
2264
2264
  const groupsModulePath = path13.resolve(process.cwd(), raw["groups"]);
@@ -3183,8 +3183,8 @@ function hasModelSpecificTsStub(model, cfg) {
3183
3183
  async function generateTypesFromPrisma(options) {
3184
3184
  const { dmmf, generator } = options;
3185
3185
  const raw = generator.config ?? {};
3186
- const schemaDir = path13.dirname(options.schemaPath);
3187
- const shared = await loadSharedConfig(schemaDir);
3186
+ const schemaDir = path13.dirname(generator.sourceFilePath ?? path13.resolve(options.schemaPath));
3187
+ const shared = await loadSharedConfig(schemaDir, "typescript");
3188
3188
  let groups = [];
3189
3189
  if (raw["groups"]) {
3190
3190
  const groupsModulePath = path13.resolve(process.cwd(), raw["groups"]);
@@ -3234,6 +3234,8 @@ async function generateTypesFromPrisma(options) {
3234
3234
  if (!existsSync(tsOutDir)) {
3235
3235
  mkdirSync(tsOutDir, { recursive: true });
3236
3236
  }
3237
+ addToConfig("typescript", cfg);
3238
+ addToConfig("model", { tablePrefix: cfg.tablePrefix, tableSuffix: cfg.tableSuffix });
3237
3239
  global._config = global._config || {};
3238
3240
  global._config.ts = {
3239
3241
  prettier: !!cfg.prettier
@@ -3348,7 +3350,7 @@ async function runGenerators(configPath, skipPrismaGenerate = false) {
3348
3350
  const { migCfg, modCfg, tsCfg } = await getLaravelGeneratorConfigs(datamodel);
3349
3351
  const sdk = dmf.default ?? dmf;
3350
3352
  const dmmf = await sdk.getDMMF({ datamodel });
3351
- const config = (conf) => {
3353
+ const config2 = (conf) => {
3352
3354
  return {
3353
3355
  dmmf,
3354
3356
  // pass the models block config directly
@@ -3361,9 +3363,9 @@ async function runGenerators(configPath, skipPrismaGenerate = false) {
3361
3363
  version: ""
3362
3364
  };
3363
3365
  };
3364
- await generateLaravelSchema(config(migCfg));
3365
- await generateLaravelModels(config(modCfg));
3366
- await generateTypesFromPrisma(config(tsCfg));
3366
+ await generateLaravelSchema(config2(migCfg));
3367
+ await generateLaravelModels(config2(modCfg));
3368
+ await generateTypesFromPrisma(config2(tsCfg));
3367
3369
  };
3368
3370
  if (skipPrismaGenerate) {
3369
3371
  await doRun();
@@ -240,12 +240,12 @@ function decorate(name, opts) {
240
240
  const suf = opts.tableSuffix ?? "";
241
241
  return `${pre}${name}${suf}`.trim();
242
242
  }
243
+ var config = {};
243
244
  function addToConfig(key, value) {
244
- global._config = global._config ?? {};
245
- global._config[key] = value;
245
+ config[key] = value;
246
246
  }
247
247
  function getConfig(key, property) {
248
- const cfg = global._config ?? {};
248
+ const cfg = config;
249
249
  const section = cfg[key];
250
250
  return property ? section?.[property] : section;
251
251
  }
@@ -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
  }
@@ -77,12 +77,12 @@ function decorate(name, opts) {
77
77
  const suf = opts.tableSuffix ?? "";
78
78
  return `${pre}${name}${suf}`.trim();
79
79
  }
80
+ var config = {};
80
81
  function addToConfig(key, value) {
81
- global._config = global._config ?? {};
82
- global._config[key] = value;
82
+ config[key] = value;
83
83
  }
84
84
  function getConfig(key, property) {
85
- const cfg = global._config ?? {};
85
+ const cfg = config;
86
86
  const section = cfg[key];
87
87
  return property ? section?.[property] : section;
88
88
  }
@@ -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);
@@ -1264,7 +1264,7 @@ async function generateLaravelModels(options) {
1264
1264
  const { dmmf, generator } = options;
1265
1265
  const raw = generator.config ?? {};
1266
1266
  const schemaDir = path7.dirname(generator.sourceFilePath ?? path7.resolve(options.schemaPath));
1267
- const shared = await loadSharedConfig(schemaDir);
1267
+ const shared = await loadSharedConfig(schemaDir, "models");
1268
1268
  let groups = [];
1269
1269
  if (raw["groups"]) {
1270
1270
  const groupsModulePath = path7.resolve(process.cwd(), raw["groups"]);
@@ -1355,7 +1355,7 @@ generatorHandler({
1355
1355
  if (options.sourceFilePath) {
1356
1356
  try {
1357
1357
  const schemaDir = path7.dirname(options.sourceFilePath);
1358
- const shared = await loadSharedConfig(schemaDir);
1358
+ const shared = await loadSharedConfig(schemaDir, "models");
1359
1359
  if (!modelOutput) {
1360
1360
  modelOutput = shared?.modeler?.outputDir ?? shared?.output?.models ?? void 0;
1361
1361
  }
@@ -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,8 +167,12 @@ function decorate(name, opts) {
167
167
  const suf = opts.tableSuffix ?? "";
168
168
  return `${pre}${name}${suf}`.trim();
169
169
  }
170
+ var config = {};
171
+ function addToConfig(key, value) {
172
+ config[key] = value;
173
+ }
170
174
  function getConfig(key, property) {
171
- const cfg = global._config ?? {};
175
+ const cfg = config;
172
176
  const section = cfg[key];
173
177
  return property ? section?.[property] : section;
174
178
  }
@@ -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,8 @@ async function generateTypesFromPrisma(options) {
1684
1688
  if (!existsSync(tsOutDir)) {
1685
1689
  mkdirSync(tsOutDir, { recursive: true });
1686
1690
  }
1691
+ addToConfig("typescript", cfg);
1692
+ addToConfig("model", { tablePrefix: cfg.tablePrefix, tableSuffix: cfg.tableSuffix });
1687
1693
  global._config = global._config || {};
1688
1694
  global._config.ts = {
1689
1695
  prettier: !!cfg.prettier
@@ -1771,7 +1777,7 @@ generatorHandler({
1771
1777
  if (!defaultOutput && options.sourceFilePath) {
1772
1778
  try {
1773
1779
  const schemaDir = path7.dirname(options.sourceFilePath);
1774
- const shared = await loadSharedConfig(schemaDir);
1780
+ const shared = await loadSharedConfig(schemaDir, "typescript");
1775
1781
  if (shared && shared.ts) {
1776
1782
  defaultOutput = shared.ts.outputDir;
1777
1783
  }
package/dist/index.js CHANGED
@@ -392,12 +392,12 @@ function decorate(name, opts) {
392
392
  const suf = opts.tableSuffix ?? "";
393
393
  return `${pre}${name}${suf}`.trim();
394
394
  }
395
+ var config = {};
395
396
  function addToConfig(key, value) {
396
- global._config = global._config ?? {};
397
- global._config[key] = value;
397
+ config[key] = value;
398
398
  }
399
399
  function getConfig(key, property) {
400
- const cfg = global._config ?? {};
400
+ const cfg = config;
401
401
  const section = cfg[key];
402
402
  return property ? section?.[property] : section;
403
403
  }
@@ -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);
@@ -2253,7 +2253,7 @@ async function generateLaravelModels(options) {
2253
2253
  const { dmmf, generator } = options;
2254
2254
  const raw = generator.config ?? {};
2255
2255
  const schemaDir = path9.dirname(generator.sourceFilePath ?? path9.resolve(options.schemaPath));
2256
- const shared = await loadSharedConfig(schemaDir);
2256
+ const shared = await loadSharedConfig(schemaDir, "models");
2257
2257
  let groups = [];
2258
2258
  if (raw["groups"]) {
2259
2259
  const groupsModulePath = path9.resolve(process.cwd(), raw["groups"]);
@@ -3178,8 +3178,8 @@ function hasModelSpecificTsStub(model, cfg) {
3178
3178
  async function generateTypesFromPrisma(options) {
3179
3179
  const { dmmf, generator } = options;
3180
3180
  const raw = generator.config ?? {};
3181
- const schemaDir = path9.dirname(options.schemaPath);
3182
- const shared = await loadSharedConfig(schemaDir);
3181
+ const schemaDir = path9.dirname(generator.sourceFilePath ?? path9.resolve(options.schemaPath));
3182
+ const shared = await loadSharedConfig(schemaDir, "typescript");
3183
3183
  let groups = [];
3184
3184
  if (raw["groups"]) {
3185
3185
  const groupsModulePath = path9.resolve(process.cwd(), raw["groups"]);
@@ -3229,6 +3229,8 @@ async function generateTypesFromPrisma(options) {
3229
3229
  if (!existsSync(tsOutDir)) {
3230
3230
  mkdirSync(tsOutDir, { recursive: true });
3231
3231
  }
3232
+ addToConfig("typescript", cfg);
3233
+ addToConfig("model", { tablePrefix: cfg.tablePrefix, tableSuffix: cfg.tableSuffix });
3232
3234
  global._config = global._config || {};
3233
3235
  global._config.ts = {
3234
3236
  prettier: !!cfg.prettier
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-laravel-migrate",
3
- "version": "3.1.16",
3
+ "version": "3.1.18",
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",