prisma-laravel-migrate 3.1.6 → 3.1.7

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
@@ -2888,7 +2888,7 @@ ${indented}
2888
2888
  if (body.trim()) parts.push(body.trimEnd());
2889
2889
  return parts.join("\n\n") + "\n";
2890
2890
  }
2891
- const stubPath = resolveStub(this.stubConfig, "ts", "index");
2891
+ const stubPath = resolveStub(this.stubConfig, "ts", "index") ?? getStubPath("ts.stub");
2892
2892
  if (!stubPath) {
2893
2893
  const parts = [];
2894
2894
  if (hasImports) parts.push(imports.trimEnd());
@@ -3,7 +3,7 @@ import path7, { resolve, extname, dirname } from 'path';
3
3
  import fs, { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from 'fs';
4
4
  import { readFile } from 'fs/promises';
5
5
  import { createRequire } from 'module';
6
- import { pathToFileURL } from 'url';
6
+ import { fileURLToPath, pathToFileURL } from 'url';
7
7
  import { Minimatch } from 'minimatch';
8
8
  import * as diff3 from 'node-diff3';
9
9
  import * as prettier from 'prettier';
@@ -177,6 +177,21 @@ var listFrom = (doc, tag) => {
177
177
  }
178
178
  return cleaned;
179
179
  };
180
+ var FOLDER = "prisma-laravel-migrate";
181
+ function getStubPath(pathString, folder) {
182
+ const __filename = fileURLToPath(import.meta.url);
183
+ const __dirname = path7.dirname(__filename);
184
+ const __file = folder ?? FOLDER;
185
+ const normalised = pathString.replace(/\\/g, "/");
186
+ const dir = __dirname.replace(/\\/g, "/");
187
+ const idx = dir.lastIndexOf(__file);
188
+ if (idx === -1) {
189
+ if (!folder) return getStubPath(pathString, "prisma-to-laravel-migration");
190
+ return path7.resolve(process.cwd(), normalised);
191
+ }
192
+ const baseDir = dir.slice(0, idx + __file.length);
193
+ return path7.join(baseDir, "stubs", normalised);
194
+ }
180
195
 
181
196
  // src/generator/ts/generator.ts
182
197
  var PrismaToTypesGenerator = class {
@@ -732,7 +747,7 @@ ${indented}
732
747
  if (body.trim()) parts.push(body.trimEnd());
733
748
  return parts.join("\n\n") + "\n";
734
749
  }
735
- const stubPath = resolveStub(this.stubConfig, "ts", "index");
750
+ const stubPath = resolveStub(this.stubConfig, "ts", "index") ?? getStubPath("ts.stub");
736
751
  if (!stubPath) {
737
752
  const parts = [];
738
753
  if (hasImports) parts.push(imports.trimEnd());
package/dist/index.js CHANGED
@@ -2883,7 +2883,7 @@ ${indented}
2883
2883
  if (body.trim()) parts.push(body.trimEnd());
2884
2884
  return parts.join("\n\n") + "\n";
2885
2885
  }
2886
- const stubPath = resolveStub(this.stubConfig, "ts", "index");
2886
+ const stubPath = resolveStub(this.stubConfig, "ts", "index") ?? getStubPath("ts.stub");
2887
2887
  if (!stubPath) {
2888
2888
  const parts = [];
2889
2889
  if (hasImports) parts.push(imports.trimEnd());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-laravel-migrate",
3
- "version": "3.1.6",
3
+ "version": "3.1.7",
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",
@@ -30,7 +30,7 @@
30
30
  "main": "dist/index.js",
31
31
  "types": "dist/index.d.ts",
32
32
  "scripts": {
33
- "test": "echo \"Error: no test specified\" && exit 1",
33
+ "test": "npx prisma generate --schema=small.prisma",
34
34
  "cjs": "node scripts/toCommons.cjs",
35
35
  "gen:laravel": "node scripts/gen-laravel.js",
36
36
  "build": "rm -rf dist @types && tsup",
package/stubs/ts.stub CHANGED
@@ -1,5 +1,4 @@
1
- ${ctx.imports}
2
-
3
- ${ctx.body}
4
-
5
- export {};
1
+ declare module "${moduleName}" {
2
+ ${imports}
3
+ ${content}
4
+ }