prisma-laravel-migrate 3.1.3 → 3.1.5
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 +39 -15
- package/dist/cli/ts.index.js +39 -15
- package/dist/index.js +39 -15
- package/package.json +1 -1
package/dist/cli/cli.js
CHANGED
|
@@ -2667,20 +2667,49 @@ var TsPrinter = class {
|
|
|
2667
2667
|
}).join("\n");
|
|
2668
2668
|
}
|
|
2669
2669
|
/**
|
|
2670
|
-
|
|
2671
|
-
|
|
2670
|
+
* Merge & dedupe imports from multiple model contexts.
|
|
2671
|
+
*
|
|
2672
|
+
* We re-parse the per-model import lines into TsImport objects so that
|
|
2673
|
+
* `normalizeTsImports` can group everything by `from` and merge type lists.
|
|
2674
|
+
*/
|
|
2672
2675
|
collectImports(ctxs) {
|
|
2673
|
-
const
|
|
2676
|
+
const collected = [];
|
|
2677
|
+
const importRe = /^import\s*\{\s*([^}]+)\}\s*from\s*(['"])([^'"]+)\2;?$/;
|
|
2674
2678
|
for (const ctx of ctxs) {
|
|
2675
2679
|
const raw = (ctx.imports || "").replace(/\r\n/g, "\n");
|
|
2676
2680
|
if (!raw.trim()) continue;
|
|
2677
2681
|
for (const line of raw.split("\n")) {
|
|
2678
2682
|
const trimmed = line.trim();
|
|
2679
2683
|
if (!trimmed) continue;
|
|
2680
|
-
|
|
2684
|
+
const m = importRe.exec(trimmed);
|
|
2685
|
+
if (!m) {
|
|
2686
|
+
if (trimmed.startsWith("import ")) {
|
|
2687
|
+
collected.push({
|
|
2688
|
+
from: trimmed,
|
|
2689
|
+
// sentinel; will emit as-is below
|
|
2690
|
+
types: []
|
|
2691
|
+
// no types
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
continue;
|
|
2695
|
+
}
|
|
2696
|
+
const typeList = m[1].split(",").map((t) => t.trim()).filter(Boolean);
|
|
2697
|
+
const from = m[3];
|
|
2698
|
+
collected.push({ from, types: typeList });
|
|
2681
2699
|
}
|
|
2682
2700
|
}
|
|
2683
|
-
|
|
2701
|
+
const rawLines = collected.filter((imp) => !imp.types?.length && imp.from.startsWith("import ")).map((imp) => imp.from);
|
|
2702
|
+
const structured = collected.filter(
|
|
2703
|
+
(imp) => imp.types && imp.types.length && !imp.from.startsWith("import ")
|
|
2704
|
+
);
|
|
2705
|
+
const normalized = this.normalizeTsImports(structured);
|
|
2706
|
+
const structuredLines = normalized.map(
|
|
2707
|
+
(i) => `import { ${i.types.join(", ")} } from ${JSON.stringify(i.from)};`
|
|
2708
|
+
);
|
|
2709
|
+
const allLines = Array.from(
|
|
2710
|
+
/* @__PURE__ */ new Set([...rawLines, ...structuredLines])
|
|
2711
|
+
);
|
|
2712
|
+
return allLines.join("\n");
|
|
2684
2713
|
}
|
|
2685
2714
|
// ---------------------------------------------------------------------------
|
|
2686
2715
|
// MODEL RENDERING (DEFAULT)
|
|
@@ -2950,12 +2979,9 @@ async function generateTypesFromPrisma(options) {
|
|
|
2950
2979
|
groups,
|
|
2951
2980
|
// TS-specific
|
|
2952
2981
|
outputDir: pick("outputDir") ?? getDefaultTsOutDir(generator),
|
|
2953
|
-
|
|
2954
|
-
* declaration now only affects enums:
|
|
2955
|
-
* - true → enums.d.ts
|
|
2956
|
-
* - false → enums.ts
|
|
2957
|
-
*/
|
|
2982
|
+
// enums-only knobs
|
|
2958
2983
|
declaration: pick("declaration", false),
|
|
2984
|
+
noEmitEnums: pick("noEmitEnums", false),
|
|
2959
2985
|
shape: pick("shape", "interface"),
|
|
2960
2986
|
scalarMap: pick("scalarMap"),
|
|
2961
2987
|
nullableAsOptional: pick("nullableAsOptional", false),
|
|
@@ -2996,13 +3022,11 @@ async function generateTypesFromPrisma(options) {
|
|
|
2996
3022
|
});
|
|
2997
3023
|
const modelExt = ".d.ts";
|
|
2998
3024
|
const enumExt = cfg.declaration ? ".d.ts" : ".ts";
|
|
2999
|
-
if (enums.length) {
|
|
3025
|
+
if (!cfg.noEmitEnums && enums.length) {
|
|
3000
3026
|
const enumsCode = printer.printEnums(enums);
|
|
3001
3027
|
if (enumsCode.trim()) {
|
|
3002
|
-
const
|
|
3003
|
-
|
|
3004
|
-
`${cfg.enumsFileName ?? "enums"}${enumExt}`
|
|
3005
|
-
);
|
|
3028
|
+
const enumsBase = cfg.enumsFileName || "enums";
|
|
3029
|
+
const enumsPath = path13.join(tsOutDir, `${enumsBase}${enumExt}`);
|
|
3006
3030
|
await writeWithMerge(
|
|
3007
3031
|
enumsPath,
|
|
3008
3032
|
enumsCode,
|
package/dist/cli/ts.index.js
CHANGED
|
@@ -511,20 +511,49 @@ var TsPrinter = class {
|
|
|
511
511
|
}).join("\n");
|
|
512
512
|
}
|
|
513
513
|
/**
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
* Merge & dedupe imports from multiple model contexts.
|
|
515
|
+
*
|
|
516
|
+
* We re-parse the per-model import lines into TsImport objects so that
|
|
517
|
+
* `normalizeTsImports` can group everything by `from` and merge type lists.
|
|
518
|
+
*/
|
|
516
519
|
collectImports(ctxs) {
|
|
517
|
-
const
|
|
520
|
+
const collected = [];
|
|
521
|
+
const importRe = /^import\s*\{\s*([^}]+)\}\s*from\s*(['"])([^'"]+)\2;?$/;
|
|
518
522
|
for (const ctx of ctxs) {
|
|
519
523
|
const raw = (ctx.imports || "").replace(/\r\n/g, "\n");
|
|
520
524
|
if (!raw.trim()) continue;
|
|
521
525
|
for (const line of raw.split("\n")) {
|
|
522
526
|
const trimmed = line.trim();
|
|
523
527
|
if (!trimmed) continue;
|
|
524
|
-
|
|
528
|
+
const m = importRe.exec(trimmed);
|
|
529
|
+
if (!m) {
|
|
530
|
+
if (trimmed.startsWith("import ")) {
|
|
531
|
+
collected.push({
|
|
532
|
+
from: trimmed,
|
|
533
|
+
// sentinel; will emit as-is below
|
|
534
|
+
types: []
|
|
535
|
+
// no types
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
const typeList = m[1].split(",").map((t) => t.trim()).filter(Boolean);
|
|
541
|
+
const from = m[3];
|
|
542
|
+
collected.push({ from, types: typeList });
|
|
525
543
|
}
|
|
526
544
|
}
|
|
527
|
-
|
|
545
|
+
const rawLines = collected.filter((imp) => !imp.types?.length && imp.from.startsWith("import ")).map((imp) => imp.from);
|
|
546
|
+
const structured = collected.filter(
|
|
547
|
+
(imp) => imp.types && imp.types.length && !imp.from.startsWith("import ")
|
|
548
|
+
);
|
|
549
|
+
const normalized = this.normalizeTsImports(structured);
|
|
550
|
+
const structuredLines = normalized.map(
|
|
551
|
+
(i) => `import { ${i.types.join(", ")} } from ${JSON.stringify(i.from)};`
|
|
552
|
+
);
|
|
553
|
+
const allLines = Array.from(
|
|
554
|
+
/* @__PURE__ */ new Set([...rawLines, ...structuredLines])
|
|
555
|
+
);
|
|
556
|
+
return allLines.join("\n");
|
|
528
557
|
}
|
|
529
558
|
// ---------------------------------------------------------------------------
|
|
530
559
|
// MODEL RENDERING (DEFAULT)
|
|
@@ -907,12 +936,9 @@ async function generateTypesFromPrisma(options) {
|
|
|
907
936
|
groups,
|
|
908
937
|
// TS-specific
|
|
909
938
|
outputDir: pick("outputDir") ?? getDefaultTsOutDir(generator),
|
|
910
|
-
|
|
911
|
-
* declaration now only affects enums:
|
|
912
|
-
* - true → enums.d.ts
|
|
913
|
-
* - false → enums.ts
|
|
914
|
-
*/
|
|
939
|
+
// enums-only knobs
|
|
915
940
|
declaration: pick("declaration", false),
|
|
941
|
+
noEmitEnums: pick("noEmitEnums", false),
|
|
916
942
|
shape: pick("shape", "interface"),
|
|
917
943
|
scalarMap: pick("scalarMap"),
|
|
918
944
|
nullableAsOptional: pick("nullableAsOptional", false),
|
|
@@ -953,13 +979,11 @@ async function generateTypesFromPrisma(options) {
|
|
|
953
979
|
});
|
|
954
980
|
const modelExt = ".d.ts";
|
|
955
981
|
const enumExt = cfg.declaration ? ".d.ts" : ".ts";
|
|
956
|
-
if (enums.length) {
|
|
982
|
+
if (!cfg.noEmitEnums && enums.length) {
|
|
957
983
|
const enumsCode = printer.printEnums(enums);
|
|
958
984
|
if (enumsCode.trim()) {
|
|
959
|
-
const
|
|
960
|
-
|
|
961
|
-
`${cfg.enumsFileName ?? "enums"}${enumExt}`
|
|
962
|
-
);
|
|
985
|
+
const enumsBase = cfg.enumsFileName || "enums";
|
|
986
|
+
const enumsPath = path7.join(tsOutDir, `${enumsBase}${enumExt}`);
|
|
963
987
|
await writeWithMerge(
|
|
964
988
|
enumsPath,
|
|
965
989
|
enumsCode,
|
package/dist/index.js
CHANGED
|
@@ -2662,20 +2662,49 @@ var TsPrinter = class {
|
|
|
2662
2662
|
}).join("\n");
|
|
2663
2663
|
}
|
|
2664
2664
|
/**
|
|
2665
|
-
|
|
2666
|
-
|
|
2665
|
+
* Merge & dedupe imports from multiple model contexts.
|
|
2666
|
+
*
|
|
2667
|
+
* We re-parse the per-model import lines into TsImport objects so that
|
|
2668
|
+
* `normalizeTsImports` can group everything by `from` and merge type lists.
|
|
2669
|
+
*/
|
|
2667
2670
|
collectImports(ctxs) {
|
|
2668
|
-
const
|
|
2671
|
+
const collected = [];
|
|
2672
|
+
const importRe = /^import\s*\{\s*([^}]+)\}\s*from\s*(['"])([^'"]+)\2;?$/;
|
|
2669
2673
|
for (const ctx of ctxs) {
|
|
2670
2674
|
const raw = (ctx.imports || "").replace(/\r\n/g, "\n");
|
|
2671
2675
|
if (!raw.trim()) continue;
|
|
2672
2676
|
for (const line of raw.split("\n")) {
|
|
2673
2677
|
const trimmed = line.trim();
|
|
2674
2678
|
if (!trimmed) continue;
|
|
2675
|
-
|
|
2679
|
+
const m = importRe.exec(trimmed);
|
|
2680
|
+
if (!m) {
|
|
2681
|
+
if (trimmed.startsWith("import ")) {
|
|
2682
|
+
collected.push({
|
|
2683
|
+
from: trimmed,
|
|
2684
|
+
// sentinel; will emit as-is below
|
|
2685
|
+
types: []
|
|
2686
|
+
// no types
|
|
2687
|
+
});
|
|
2688
|
+
}
|
|
2689
|
+
continue;
|
|
2690
|
+
}
|
|
2691
|
+
const typeList = m[1].split(",").map((t) => t.trim()).filter(Boolean);
|
|
2692
|
+
const from = m[3];
|
|
2693
|
+
collected.push({ from, types: typeList });
|
|
2676
2694
|
}
|
|
2677
2695
|
}
|
|
2678
|
-
|
|
2696
|
+
const rawLines = collected.filter((imp) => !imp.types?.length && imp.from.startsWith("import ")).map((imp) => imp.from);
|
|
2697
|
+
const structured = collected.filter(
|
|
2698
|
+
(imp) => imp.types && imp.types.length && !imp.from.startsWith("import ")
|
|
2699
|
+
);
|
|
2700
|
+
const normalized = this.normalizeTsImports(structured);
|
|
2701
|
+
const structuredLines = normalized.map(
|
|
2702
|
+
(i) => `import { ${i.types.join(", ")} } from ${JSON.stringify(i.from)};`
|
|
2703
|
+
);
|
|
2704
|
+
const allLines = Array.from(
|
|
2705
|
+
/* @__PURE__ */ new Set([...rawLines, ...structuredLines])
|
|
2706
|
+
);
|
|
2707
|
+
return allLines.join("\n");
|
|
2679
2708
|
}
|
|
2680
2709
|
// ---------------------------------------------------------------------------
|
|
2681
2710
|
// MODEL RENDERING (DEFAULT)
|
|
@@ -2945,12 +2974,9 @@ async function generateTypesFromPrisma(options) {
|
|
|
2945
2974
|
groups,
|
|
2946
2975
|
// TS-specific
|
|
2947
2976
|
outputDir: pick("outputDir") ?? getDefaultTsOutDir(generator),
|
|
2948
|
-
|
|
2949
|
-
* declaration now only affects enums:
|
|
2950
|
-
* - true → enums.d.ts
|
|
2951
|
-
* - false → enums.ts
|
|
2952
|
-
*/
|
|
2977
|
+
// enums-only knobs
|
|
2953
2978
|
declaration: pick("declaration", false),
|
|
2979
|
+
noEmitEnums: pick("noEmitEnums", false),
|
|
2954
2980
|
shape: pick("shape", "interface"),
|
|
2955
2981
|
scalarMap: pick("scalarMap"),
|
|
2956
2982
|
nullableAsOptional: pick("nullableAsOptional", false),
|
|
@@ -2991,13 +3017,11 @@ async function generateTypesFromPrisma(options) {
|
|
|
2991
3017
|
});
|
|
2992
3018
|
const modelExt = ".d.ts";
|
|
2993
3019
|
const enumExt = cfg.declaration ? ".d.ts" : ".ts";
|
|
2994
|
-
if (enums.length) {
|
|
3020
|
+
if (!cfg.noEmitEnums && enums.length) {
|
|
2995
3021
|
const enumsCode = printer.printEnums(enums);
|
|
2996
3022
|
if (enumsCode.trim()) {
|
|
2997
|
-
const
|
|
2998
|
-
|
|
2999
|
-
`${cfg.enumsFileName ?? "enums"}${enumExt}`
|
|
3000
|
-
);
|
|
3023
|
+
const enumsBase = cfg.enumsFileName || "enums";
|
|
3024
|
+
const enumsPath = path9.join(tsOutDir, `${enumsBase}${enumExt}`);
|
|
3001
3025
|
await writeWithMerge(
|
|
3002
3026
|
enumsPath,
|
|
3003
3027
|
enumsCode,
|