@dudousxd/nestjs-codegen 0.16.0 → 0.17.0
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 +14 -0
- package/dist/cli/main.cjs +123 -93
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +64 -34
- package/dist/cli/main.js.map +1 -1
- package/dist/extension/index.cjs.map +1 -1
- package/dist/extension/index.d.cts +1 -1
- package/dist/extension/index.d.ts +1 -1
- package/dist/extension/index.js.map +1 -1
- package/dist/{index-LQNP7Ms3.d.cts → index-DCF9QSPY.d.cts} +24 -0
- package/dist/{index-LQNP7Ms3.d.ts → index-DCF9QSPY.d.ts} +24 -0
- package/dist/index.cjs +86 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +58 -28
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +86 -56
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.d.cts +1 -1
- package/dist/nest/index.d.ts +1 -1
- package/dist/nest/index.js +58 -28
- package/dist/nest/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/main.cjs
CHANGED
|
@@ -219,7 +219,7 @@ Run \`nestjs-codegen init\` to create a starter config.`
|
|
|
219
219
|
|
|
220
220
|
// src/generate.ts
|
|
221
221
|
var import_promises12 = require("fs/promises");
|
|
222
|
-
var
|
|
222
|
+
var import_node_path14 = require("path");
|
|
223
223
|
|
|
224
224
|
// src/discovery/pages.ts
|
|
225
225
|
var import_promises2 = require("fs/promises");
|
|
@@ -548,9 +548,10 @@ function inferExpressionType(node) {
|
|
|
548
548
|
|
|
549
549
|
// src/emit/emit-api.ts
|
|
550
550
|
var import_promises3 = require("fs/promises");
|
|
551
|
-
var
|
|
551
|
+
var import_node_path5 = require("path");
|
|
552
552
|
|
|
553
553
|
// src/extension/registry.ts
|
|
554
|
+
var import_node_path4 = require("path");
|
|
554
555
|
var import_ts_morph2 = require("ts-morph");
|
|
555
556
|
function resolveApiSlots(extensions) {
|
|
556
557
|
let layer;
|
|
@@ -583,7 +584,7 @@ function mergeExclusive(target, incoming, {
|
|
|
583
584
|
target.set(key, { value, owner });
|
|
584
585
|
}
|
|
585
586
|
}
|
|
586
|
-
function createExtensionContext(config, getRoutes) {
|
|
587
|
+
function createExtensionContext(config, getRoutes, trackedInputs) {
|
|
587
588
|
let project;
|
|
588
589
|
return {
|
|
589
590
|
cwd: config.codegen.cwd,
|
|
@@ -592,6 +593,13 @@ function createExtensionContext(config, getRoutes) {
|
|
|
592
593
|
get routes() {
|
|
593
594
|
return getRoutes();
|
|
594
595
|
},
|
|
596
|
+
trackInput(...paths) {
|
|
597
|
+
if (!trackedInputs) return;
|
|
598
|
+
for (const path of paths) {
|
|
599
|
+
if (!path) continue;
|
|
600
|
+
trackedInputs.add((0, import_node_path4.relative)(config.codegen.cwd, (0, import_node_path4.resolve)(config.codegen.cwd, path)));
|
|
601
|
+
}
|
|
602
|
+
},
|
|
595
603
|
project() {
|
|
596
604
|
if (!project) {
|
|
597
605
|
project = new import_ts_morph2.Project({
|
|
@@ -651,7 +659,7 @@ function requestShape(route) {
|
|
|
651
659
|
async function emitApi(routes, outDir, opts = {}) {
|
|
652
660
|
await (0, import_promises3.mkdir)(outDir, { recursive: true });
|
|
653
661
|
const content = buildApiFile(routes, outDir, opts);
|
|
654
|
-
await (0, import_promises3.writeFile)((0,
|
|
662
|
+
await (0, import_promises3.writeFile)((0, import_node_path5.join)(outDir, "api.ts"), content, "utf8");
|
|
655
663
|
}
|
|
656
664
|
function splitName(name) {
|
|
657
665
|
return name.split(".");
|
|
@@ -759,7 +767,7 @@ function rawResponseType(c, outDir) {
|
|
|
759
767
|
return c.contractSource.response;
|
|
760
768
|
}
|
|
761
769
|
if (c.controllerRef) {
|
|
762
|
-
let relPath = (0,
|
|
770
|
+
let relPath = (0, import_node_path5.relative)(outDir, c.controllerRef.filePath).replace(/\.ts$/, "");
|
|
763
771
|
if (!relPath.startsWith(".")) relPath = `./${relPath}`;
|
|
764
772
|
return `Awaited<ReturnType<import('${relPath}').${c.controllerRef.className}['${c.controllerRef.methodName}']>>`;
|
|
765
773
|
}
|
|
@@ -1085,6 +1093,11 @@ function buildApiFile(routes, outDir, opts = {}) {
|
|
|
1085
1093
|
config: {},
|
|
1086
1094
|
project: () => {
|
|
1087
1095
|
throw new Error("ExtensionContext.project() is unavailable in standalone emitApi.");
|
|
1096
|
+
},
|
|
1097
|
+
// No manifest is written on the standalone path, so there is nothing for
|
|
1098
|
+
// tracked dependencies to be recorded into — accept and discard them
|
|
1099
|
+
// rather than making every caller supply a sink.
|
|
1100
|
+
trackInput: () => {
|
|
1088
1101
|
}
|
|
1089
1102
|
};
|
|
1090
1103
|
const importsByFile = /* @__PURE__ */ new Map();
|
|
@@ -1140,8 +1153,8 @@ function buildApiFile(routes, outDir, opts = {}) {
|
|
|
1140
1153
|
const emittedNames = /* @__PURE__ */ new Set();
|
|
1141
1154
|
for (const [filePath, names] of importsByFile) {
|
|
1142
1155
|
let relPath;
|
|
1143
|
-
if ((0,
|
|
1144
|
-
relPath = (0,
|
|
1156
|
+
if ((0, import_node_path5.isAbsolute)(filePath)) {
|
|
1157
|
+
relPath = (0, import_node_path5.relative)(outDir, filePath).replace(/\.ts$/, "");
|
|
1145
1158
|
if (!relPath.startsWith(".")) relPath = `./${relPath}`;
|
|
1146
1159
|
} else {
|
|
1147
1160
|
relPath = filePath;
|
|
@@ -1235,7 +1248,7 @@ function buildApiFile(routes, outDir, opts = {}) {
|
|
|
1235
1248
|
|
|
1236
1249
|
// src/emit/emit-cache.ts
|
|
1237
1250
|
var import_promises4 = require("fs/promises");
|
|
1238
|
-
var
|
|
1251
|
+
var import_node_path6 = require("path");
|
|
1239
1252
|
async function emitCache(pages, outDir) {
|
|
1240
1253
|
await (0, import_promises4.mkdir)(outDir, { recursive: true });
|
|
1241
1254
|
const entries = await Promise.all(
|
|
@@ -1249,19 +1262,19 @@ async function emitCache(pages, outDir) {
|
|
|
1249
1262
|
})
|
|
1250
1263
|
);
|
|
1251
1264
|
const cache = { pages: entries };
|
|
1252
|
-
await (0, import_promises4.writeFile)((0,
|
|
1265
|
+
await (0, import_promises4.writeFile)((0, import_node_path6.join)(outDir, "components.json"), `${JSON.stringify(cache, null, 2)}
|
|
1253
1266
|
`, "utf8");
|
|
1254
1267
|
}
|
|
1255
1268
|
|
|
1256
1269
|
// src/emit/emit-forms.ts
|
|
1257
1270
|
var import_promises5 = require("fs/promises");
|
|
1258
|
-
var
|
|
1271
|
+
var import_node_path7 = require("path");
|
|
1259
1272
|
async function emitForms(routes, outDir, config, adapter) {
|
|
1260
1273
|
if (config && config.enabled === false) return false;
|
|
1261
1274
|
const content = buildFormsFileWithAdapter(routes, outDir, adapter, config);
|
|
1262
1275
|
if (content === null) return false;
|
|
1263
1276
|
await (0, import_promises5.mkdir)(outDir, { recursive: true });
|
|
1264
|
-
await (0, import_promises5.writeFile)((0,
|
|
1277
|
+
await (0, import_promises5.writeFile)((0, import_node_path7.join)(outDir, "forms.ts"), content, "utf8");
|
|
1265
1278
|
return true;
|
|
1266
1279
|
}
|
|
1267
1280
|
function pascal(segment) {
|
|
@@ -1274,7 +1287,7 @@ function deriveBaseName(routeName) {
|
|
|
1274
1287
|
return { method, full };
|
|
1275
1288
|
}
|
|
1276
1289
|
function relImport(outDir, filePath) {
|
|
1277
|
-
let relPath = (0,
|
|
1290
|
+
let relPath = (0, import_node_path7.relative)(outDir, filePath).replace(/\.ts$/, "");
|
|
1278
1291
|
if (!relPath.startsWith(".")) relPath = `./${relPath}`;
|
|
1279
1292
|
return relPath;
|
|
1280
1293
|
}
|
|
@@ -1548,7 +1561,7 @@ function buildFormsFileWithAdapter(routes, outDir, adapter, config) {
|
|
|
1548
1561
|
|
|
1549
1562
|
// src/emit/emit-index.ts
|
|
1550
1563
|
var import_promises6 = require("fs/promises");
|
|
1551
|
-
var
|
|
1564
|
+
var import_node_path8 = require("path");
|
|
1552
1565
|
async function emitIndex(outDir, hasContracts = false, hasForms = false) {
|
|
1553
1566
|
await (0, import_promises6.mkdir)(outDir, { recursive: true });
|
|
1554
1567
|
const exports2 = ["export * from './pages.js';", "export * from './routes.js';"];
|
|
@@ -1561,12 +1574,12 @@ async function emitIndex(outDir, hasContracts = false, hasForms = false) {
|
|
|
1561
1574
|
const content = ["// Generated by @dudousxd/nestjs-codegen. Do not edit.", ...exports2, ""].join(
|
|
1562
1575
|
"\n"
|
|
1563
1576
|
);
|
|
1564
|
-
await (0, import_promises6.writeFile)((0,
|
|
1577
|
+
await (0, import_promises6.writeFile)((0, import_node_path8.join)(outDir, "index.d.ts"), content, "utf8");
|
|
1565
1578
|
}
|
|
1566
1579
|
|
|
1567
1580
|
// src/emit/emit-mocks.ts
|
|
1568
1581
|
var import_promises7 = require("fs/promises");
|
|
1569
|
-
var
|
|
1582
|
+
var import_node_path9 = require("path");
|
|
1570
1583
|
|
|
1571
1584
|
// src/ir/schema-node-to-json-schema.ts
|
|
1572
1585
|
var DEFAULT_CTX = { refPrefix: "#/components/schemas/" };
|
|
@@ -1890,12 +1903,12 @@ async function emitMocks(routes, outDir, opts = {}) {
|
|
|
1890
1903
|
await (0, import_promises7.mkdir)(outDir, { recursive: true });
|
|
1891
1904
|
const content = buildMocksFile(routes, opts);
|
|
1892
1905
|
const fileName = opts.fileName ?? "mocks.ts";
|
|
1893
|
-
await (0, import_promises7.writeFile)((0,
|
|
1906
|
+
await (0, import_promises7.writeFile)((0, import_node_path9.join)(outDir, fileName), content, "utf8");
|
|
1894
1907
|
}
|
|
1895
1908
|
|
|
1896
1909
|
// src/emit/emit-openapi.ts
|
|
1897
1910
|
var import_promises8 = require("fs/promises");
|
|
1898
|
-
var
|
|
1911
|
+
var import_node_path10 = require("path");
|
|
1899
1912
|
var REF_PREFIX2 = "#/components/schemas/";
|
|
1900
1913
|
function toOpenApiPath(path) {
|
|
1901
1914
|
return path.replace(/:([^/]+)/g, "{$1}");
|
|
@@ -2016,13 +2029,13 @@ async function emitOpenApi(routes, outDir, opts = {}) {
|
|
|
2016
2029
|
await (0, import_promises8.mkdir)(outDir, { recursive: true });
|
|
2017
2030
|
const doc = buildOpenApiSpec(routes, opts);
|
|
2018
2031
|
const fileName = opts.fileName ?? "openapi.json";
|
|
2019
|
-
await (0, import_promises8.writeFile)((0,
|
|
2032
|
+
await (0, import_promises8.writeFile)((0, import_node_path10.join)(outDir, fileName), `${JSON.stringify(doc, null, 2)}
|
|
2020
2033
|
`, "utf8");
|
|
2021
2034
|
}
|
|
2022
2035
|
|
|
2023
2036
|
// src/emit/emit-pages.ts
|
|
2024
2037
|
var import_promises9 = require("fs/promises");
|
|
2025
|
-
var
|
|
2038
|
+
var import_node_path11 = require("path");
|
|
2026
2039
|
async function emitPages(pages, outDir, _options = {}) {
|
|
2027
2040
|
await (0, import_promises9.mkdir)(outDir, { recursive: true });
|
|
2028
2041
|
const pageNameUnion = pages.length > 0 ? pages.map((p) => JSON.stringify(p.name)).join(" | ") : "never";
|
|
@@ -2043,7 +2056,7 @@ ${augBody}
|
|
|
2043
2056
|
}
|
|
2044
2057
|
${sharedPropsBlock}}
|
|
2045
2058
|
`;
|
|
2046
|
-
await (0, import_promises9.writeFile)((0,
|
|
2059
|
+
await (0, import_promises9.writeFile)((0, import_node_path11.join)(outDir, "pages.d.ts"), content, "utf8");
|
|
2047
2060
|
}
|
|
2048
2061
|
function buildSharedPropsBlock(sharedProps) {
|
|
2049
2062
|
if (!sharedProps) return "";
|
|
@@ -2062,7 +2075,7 @@ ${propsBody}
|
|
|
2062
2075
|
`;
|
|
2063
2076
|
}
|
|
2064
2077
|
function buildAugmentationType(page, outDir) {
|
|
2065
|
-
let importPath = (0,
|
|
2078
|
+
let importPath = (0, import_node_path11.relative)(outDir, page.absolutePath).replace(/\.(tsx?|vue|svelte)$/, "");
|
|
2066
2079
|
if (!importPath.startsWith(".")) {
|
|
2067
2080
|
importPath = `./${importPath}`;
|
|
2068
2081
|
}
|
|
@@ -2074,11 +2087,11 @@ function needsQuotes(name) {
|
|
|
2074
2087
|
|
|
2075
2088
|
// src/emit/emit-routes.ts
|
|
2076
2089
|
var import_promises10 = require("fs/promises");
|
|
2077
|
-
var
|
|
2090
|
+
var import_node_path12 = require("path");
|
|
2078
2091
|
async function emitRoutes(routes, outDir) {
|
|
2079
2092
|
await (0, import_promises10.mkdir)(outDir, { recursive: true });
|
|
2080
2093
|
const content = buildRoutesFile(routes);
|
|
2081
|
-
await (0, import_promises10.writeFile)((0,
|
|
2094
|
+
await (0, import_promises10.writeFile)((0, import_node_path12.join)(outDir, "routes.ts"), content, "utf8");
|
|
2082
2095
|
}
|
|
2083
2096
|
function buildRoutesFile(routes) {
|
|
2084
2097
|
if (routes.length === 0) {
|
|
@@ -2193,7 +2206,7 @@ function buildEmpty() {
|
|
|
2193
2206
|
// src/generate-manifest.ts
|
|
2194
2207
|
var import_node_crypto = require("crypto");
|
|
2195
2208
|
var import_promises11 = require("fs/promises");
|
|
2196
|
-
var
|
|
2209
|
+
var import_node_path13 = require("path");
|
|
2197
2210
|
var import_fast_glob2 = __toESM(require("fast-glob"), 1);
|
|
2198
2211
|
var MANIFEST_FILE = ".codegen-manifest.json";
|
|
2199
2212
|
var LOCK_FILE = ".watcher.lock";
|
|
@@ -2216,6 +2229,9 @@ function isManifestShape(value) {
|
|
|
2216
2229
|
if (candidate.configKeyHashes !== void 0 && !isStringRecord(candidate.configKeyHashes)) {
|
|
2217
2230
|
return false;
|
|
2218
2231
|
}
|
|
2232
|
+
if (candidate.extraInputs !== void 0 && (!Array.isArray(candidate.extraInputs) || !candidate.extraInputs.every((entry) => typeof entry === "string"))) {
|
|
2233
|
+
return false;
|
|
2234
|
+
}
|
|
2219
2235
|
if (!Array.isArray(candidate.files)) return false;
|
|
2220
2236
|
return candidate.files.every((entry) => typeof entry === "string");
|
|
2221
2237
|
}
|
|
@@ -2255,26 +2271,35 @@ async function discoverInputFiles(config) {
|
|
|
2255
2271
|
const matched = await (0, import_fast_glob2.default)(globs, { cwd, absolute: true, onlyFiles: true });
|
|
2256
2272
|
return [...new Set(matched)].sort();
|
|
2257
2273
|
}
|
|
2258
|
-
async function computeInputsHash(config) {
|
|
2274
|
+
async function computeInputsHash(config, extraInputs = []) {
|
|
2259
2275
|
const hash = (0, import_node_crypto.createHash)("sha256");
|
|
2260
2276
|
hash.update(`version:${VERSION}
|
|
2261
2277
|
`);
|
|
2262
2278
|
hash.update(`config:${serializeConfig(config)}
|
|
2263
2279
|
`);
|
|
2264
|
-
const inputFiles = await discoverInputFiles(config);
|
|
2265
2280
|
const cwd = config.codegen.cwd;
|
|
2266
|
-
|
|
2281
|
+
const globbed = await discoverInputFiles(config);
|
|
2282
|
+
const globbedRelative = new Set(globbed.map((file) => (0, import_node_path13.relative)(cwd, file)));
|
|
2283
|
+
const extra = [...new Set(extraInputs)].filter((file) => !globbedRelative.has(file)).sort();
|
|
2284
|
+
for (const file of globbed) {
|
|
2267
2285
|
const contents = await (0, import_promises11.readFile)(file, "utf8");
|
|
2268
|
-
hash.update(`file:${(0,
|
|
2286
|
+
hash.update(`file:${(0, import_node_path13.relative)(cwd, file)}
|
|
2269
2287
|
`);
|
|
2270
2288
|
hash.update(contents);
|
|
2271
2289
|
hash.update("\n");
|
|
2272
2290
|
}
|
|
2291
|
+
for (const file of extra) {
|
|
2292
|
+
const contents = await (0, import_promises11.readFile)((0, import_node_path13.join)(cwd, file), "utf8").catch(() => null);
|
|
2293
|
+
hash.update(`extra:${file}
|
|
2294
|
+
`);
|
|
2295
|
+
hash.update(contents ?? "\0missing");
|
|
2296
|
+
hash.update("\n");
|
|
2297
|
+
}
|
|
2273
2298
|
return hash.digest("hex");
|
|
2274
2299
|
}
|
|
2275
2300
|
async function readManifest(outDir) {
|
|
2276
2301
|
try {
|
|
2277
|
-
const raw = await (0, import_promises11.readFile)((0,
|
|
2302
|
+
const raw = await (0, import_promises11.readFile)((0, import_node_path13.join)(outDir, MANIFEST_FILE), "utf8");
|
|
2278
2303
|
const parsed = JSON.parse(raw);
|
|
2279
2304
|
if (!isManifestShape(parsed)) return null;
|
|
2280
2305
|
return {
|
|
@@ -2283,6 +2308,7 @@ async function readManifest(outDir) {
|
|
|
2283
2308
|
...parsed.entryPoint ? { entryPoint: parsed.entryPoint } : {},
|
|
2284
2309
|
...parsed.configHash ? { configHash: parsed.configHash } : {},
|
|
2285
2310
|
...parsed.configKeyHashes ? { configKeyHashes: parsed.configKeyHashes } : {},
|
|
2311
|
+
...parsed.extraInputs ? { extraInputs: parsed.extraInputs } : {},
|
|
2286
2312
|
files: parsed.files
|
|
2287
2313
|
};
|
|
2288
2314
|
} catch {
|
|
@@ -2293,7 +2319,7 @@ function computeConfigHash(config) {
|
|
|
2293
2319
|
return (0, import_node_crypto.createHash)("sha256").update(serializeConfig(config)).digest("hex");
|
|
2294
2320
|
}
|
|
2295
2321
|
async function writeManifest(outDir, manifest) {
|
|
2296
|
-
await (0, import_promises11.writeFile)((0,
|
|
2322
|
+
await (0, import_promises11.writeFile)((0, import_node_path13.join)(outDir, MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
2297
2323
|
`, "utf8");
|
|
2298
2324
|
}
|
|
2299
2325
|
async function listOutputFiles(outDir) {
|
|
@@ -2301,11 +2327,11 @@ async function listOutputFiles(outDir) {
|
|
|
2301
2327
|
async function walk(dir) {
|
|
2302
2328
|
const entries = await (0, import_promises11.readdir)(dir, { withFileTypes: true }).catch(() => []);
|
|
2303
2329
|
for (const entry of entries) {
|
|
2304
|
-
const abs = (0,
|
|
2330
|
+
const abs = (0, import_node_path13.join)(dir, entry.name);
|
|
2305
2331
|
if (entry.isDirectory()) {
|
|
2306
2332
|
await walk(abs);
|
|
2307
2333
|
} else if (entry.isFile()) {
|
|
2308
|
-
const rel = (0,
|
|
2334
|
+
const rel = (0, import_node_path13.relative)(outDir, abs);
|
|
2309
2335
|
if (rel === MANIFEST_FILE || rel === LOCK_FILE) continue;
|
|
2310
2336
|
found.push(rel);
|
|
2311
2337
|
}
|
|
@@ -2342,8 +2368,8 @@ function driftGuardMessage(outDir, previousEntryPoint, currentEntryPoint, differ
|
|
|
2342
2368
|
}
|
|
2343
2369
|
async function generate(config, inputRoutes = [], entryPoint = "cli") {
|
|
2344
2370
|
setCodegenDebug(config.debug);
|
|
2345
|
-
const inputsHash = await computeInputsHash(config);
|
|
2346
2371
|
const manifest = await readManifest(config.codegen.outDir);
|
|
2372
|
+
const inputsHash = await computeInputsHash(config, manifest?.extraInputs ?? []);
|
|
2347
2373
|
if (await isManifestFresh(config.codegen.outDir, manifest, inputsHash)) {
|
|
2348
2374
|
console.log(`[nestjs-codegen] ${config.codegen.outDir} up to date, skipped`);
|
|
2349
2375
|
return;
|
|
@@ -2364,7 +2390,8 @@ async function generate(config, inputRoutes = [], entryPoint = "cli") {
|
|
|
2364
2390
|
}
|
|
2365
2391
|
const extensions = config.extensions ?? [];
|
|
2366
2392
|
let routes = inputRoutes;
|
|
2367
|
-
const
|
|
2393
|
+
const trackedInputs = /* @__PURE__ */ new Set();
|
|
2394
|
+
const ctx = createExtensionContext(config, () => routes, trackedInputs);
|
|
2368
2395
|
if (extensions.length > 0) {
|
|
2369
2396
|
routes = await applyTransformRoutes(routes, extensions, ctx);
|
|
2370
2397
|
}
|
|
@@ -2418,29 +2445,32 @@ async function generate(config, inputRoutes = [], entryPoint = "cli") {
|
|
|
2418
2445
|
if (extensions.length > 0) {
|
|
2419
2446
|
const extraFiles = await collectEmittedFiles(extensions, ctx);
|
|
2420
2447
|
for (const file of extraFiles) {
|
|
2421
|
-
const dest = (0,
|
|
2422
|
-
await (0, import_promises12.mkdir)((0,
|
|
2448
|
+
const dest = (0, import_node_path14.join)(config.codegen.outDir, file.path);
|
|
2449
|
+
await (0, import_promises12.mkdir)((0, import_node_path14.dirname)(dest), { recursive: true });
|
|
2423
2450
|
await (0, import_promises12.writeFile)(dest, file.contents, "utf8");
|
|
2424
2451
|
}
|
|
2425
2452
|
}
|
|
2426
2453
|
const outputFiles = await listOutputFiles(config.codegen.outDir);
|
|
2454
|
+
const extraInputs = [...trackedInputs].sort();
|
|
2455
|
+
const recordedHash = extraInputs.length > 0 ? await computeInputsHash(config, extraInputs) : inputsHash;
|
|
2427
2456
|
await writeManifest(config.codegen.outDir, {
|
|
2428
2457
|
version: VERSION,
|
|
2429
|
-
hash:
|
|
2458
|
+
hash: recordedHash,
|
|
2430
2459
|
entryPoint,
|
|
2431
2460
|
configHash,
|
|
2432
2461
|
configKeyHashes,
|
|
2433
|
-
files: outputFiles
|
|
2462
|
+
files: outputFiles,
|
|
2463
|
+
...extraInputs.length > 0 ? { extraInputs } : {}
|
|
2434
2464
|
});
|
|
2435
2465
|
}
|
|
2436
2466
|
|
|
2437
2467
|
// src/watch/watcher.ts
|
|
2438
2468
|
var import_promises15 = require("fs/promises");
|
|
2439
|
-
var
|
|
2469
|
+
var import_node_path18 = require("path");
|
|
2440
2470
|
var import_chokidar = __toESM(require("chokidar"), 1);
|
|
2441
2471
|
|
|
2442
2472
|
// src/discovery/contracts-fast.ts
|
|
2443
|
-
var
|
|
2473
|
+
var import_node_path16 = require("path");
|
|
2444
2474
|
var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
2445
2475
|
var import_ts_morph10 = require("ts-morph");
|
|
2446
2476
|
|
|
@@ -2452,7 +2482,7 @@ var import_ts_morph4 = require("ts-morph");
|
|
|
2452
2482
|
|
|
2453
2483
|
// src/discovery/type-ref-resolution.ts
|
|
2454
2484
|
var import_node_fs = require("fs");
|
|
2455
|
-
var
|
|
2485
|
+
var import_node_path15 = require("path");
|
|
2456
2486
|
var import_ts_morph3 = require("ts-morph");
|
|
2457
2487
|
var _EMPTY_CTX = { projectRoot: "", tsconfigPaths: null };
|
|
2458
2488
|
var _ctxByProject = /* @__PURE__ */ new WeakMap();
|
|
@@ -2504,12 +2534,12 @@ function findTypeInFile(name, file) {
|
|
|
2504
2534
|
}
|
|
2505
2535
|
function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
2506
2536
|
if (moduleSpecifier.startsWith(".")) {
|
|
2507
|
-
const dir = (0,
|
|
2537
|
+
const dir = (0, import_node_path15.dirname)(sourceFile.getFilePath());
|
|
2508
2538
|
const noExt = moduleSpecifier.replace(/\.(js|ts)$/, "");
|
|
2509
2539
|
return [
|
|
2510
|
-
(0,
|
|
2511
|
-
(0,
|
|
2512
|
-
(0,
|
|
2540
|
+
(0, import_node_path15.resolve)(dir, `${noExt}.ts`),
|
|
2541
|
+
(0, import_node_path15.resolve)(dir, `${moduleSpecifier}.ts`),
|
|
2542
|
+
(0, import_node_path15.resolve)(dir, moduleSpecifier, "index.ts")
|
|
2513
2543
|
];
|
|
2514
2544
|
}
|
|
2515
2545
|
const ctx = _ctxFor(project);
|
|
@@ -2530,8 +2560,8 @@ function resolveModuleSpecifier(moduleSpecifier, sourceFile, project) {
|
|
|
2530
2560
|
const rest = moduleSpecifier.slice(prefix.length);
|
|
2531
2561
|
const candidates = [];
|
|
2532
2562
|
for (const mapping of mappings) {
|
|
2533
|
-
const resolved = (0,
|
|
2534
|
-
candidates.push(`${resolved}.ts`, (0,
|
|
2563
|
+
const resolved = (0, import_node_path15.resolve)(baseUrl, mapping.replace("*", rest));
|
|
2564
|
+
candidates.push(`${resolved}.ts`, (0, import_node_path15.resolve)(resolved, "index.ts"));
|
|
2535
2565
|
}
|
|
2536
2566
|
dbg(" resolved candidates:", candidates);
|
|
2537
2567
|
return candidates;
|
|
@@ -4390,7 +4420,7 @@ async function discoverContractsFast(opts) {
|
|
|
4390
4420
|
return extractAllRoutes(project);
|
|
4391
4421
|
}
|
|
4392
4422
|
function resolveTsconfigPath(cwd, tsconfig) {
|
|
4393
|
-
return tsconfig ? (0,
|
|
4423
|
+
return tsconfig ? (0, import_node_path16.resolve)(tsconfig) : (0, import_node_path16.join)(cwd, "tsconfig.json");
|
|
4394
4424
|
}
|
|
4395
4425
|
function createDiscoveryProject(tsconfigPath) {
|
|
4396
4426
|
try {
|
|
@@ -4476,7 +4506,7 @@ var PersistentDiscovery = class _PersistentDiscovery {
|
|
|
4476
4506
|
async rediscover(changedPaths) {
|
|
4477
4507
|
if (changedPaths) {
|
|
4478
4508
|
for (const p of changedPaths) {
|
|
4479
|
-
const abs = (0,
|
|
4509
|
+
const abs = (0, import_node_path16.resolve)(p);
|
|
4480
4510
|
const sf = this.project.getSourceFile(abs);
|
|
4481
4511
|
if (sf) {
|
|
4482
4512
|
await sf.refreshFromFileSystem();
|
|
@@ -4794,7 +4824,7 @@ function extractFromSourceFile(sourceFile, project) {
|
|
|
4794
4824
|
// src/watch/lock-file.ts
|
|
4795
4825
|
var import_promises13 = require("fs/promises");
|
|
4796
4826
|
var import_promises14 = require("fs/promises");
|
|
4797
|
-
var
|
|
4827
|
+
var import_node_path17 = require("path");
|
|
4798
4828
|
var LOCK_FILE2 = ".watcher.lock";
|
|
4799
4829
|
function isProcessAlive(pid) {
|
|
4800
4830
|
try {
|
|
@@ -4806,7 +4836,7 @@ function isProcessAlive(pid) {
|
|
|
4806
4836
|
}
|
|
4807
4837
|
async function acquireLock(outDir) {
|
|
4808
4838
|
await (0, import_promises14.mkdir)(outDir, { recursive: true });
|
|
4809
|
-
const lockPath = (0,
|
|
4839
|
+
const lockPath = (0, import_node_path17.join)(outDir, LOCK_FILE2);
|
|
4810
4840
|
const lockData = { pid: process.pid, startedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4811
4841
|
try {
|
|
4812
4842
|
const fd = await (0, import_promises13.open)(lockPath, "wx");
|
|
@@ -4847,7 +4877,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
4847
4877
|
if (lock === null) {
|
|
4848
4878
|
let holderPid = "unknown";
|
|
4849
4879
|
try {
|
|
4850
|
-
const raw = await (0, import_promises15.readFile)((0,
|
|
4880
|
+
const raw = await (0, import_promises15.readFile)((0, import_node_path18.join)(config.codegen.outDir, ".watcher.lock"), "utf8");
|
|
4851
4881
|
const data = JSON.parse(raw);
|
|
4852
4882
|
if (data.pid !== void 0) holderPid = String(data.pid);
|
|
4853
4883
|
} catch {
|
|
@@ -4900,7 +4930,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
4900
4930
|
}
|
|
4901
4931
|
let pagesDebounceTimer;
|
|
4902
4932
|
const pagesGlob = config.pages?.glob ?? ".nestjs-codegen-no-pages";
|
|
4903
|
-
const pagesWatcher = import_chokidar.default.watch((0,
|
|
4933
|
+
const pagesWatcher = import_chokidar.default.watch((0, import_node_path18.join)(config.codegen.cwd, pagesGlob), {
|
|
4904
4934
|
ignoreInitial: true,
|
|
4905
4935
|
persistent: true,
|
|
4906
4936
|
awaitWriteFinish: { stabilityThreshold: 80, pollInterval: 20 }
|
|
@@ -4927,7 +4957,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
4927
4957
|
pagesWatcher.on("unlink", schedulePagesRegenerate);
|
|
4928
4958
|
let contractsDebounceTimer;
|
|
4929
4959
|
const pendingChangedPaths = /* @__PURE__ */ new Set();
|
|
4930
|
-
const contractsWatcher = import_chokidar.default.watch((0,
|
|
4960
|
+
const contractsWatcher = import_chokidar.default.watch((0, import_node_path18.join)(config.codegen.cwd, config.contracts.glob), {
|
|
4931
4961
|
ignoreInitial: true,
|
|
4932
4962
|
persistent: true,
|
|
4933
4963
|
awaitWriteFinish: { stabilityThreshold: 80, pollInterval: 20 }
|
|
@@ -4957,7 +4987,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
4957
4987
|
contractsWatcher.on("add", (p) => scheduleContractsRegenerate(p));
|
|
4958
4988
|
contractsWatcher.on("change", (p) => scheduleContractsRegenerate(p));
|
|
4959
4989
|
contractsWatcher.on("unlink", (p) => scheduleContractsRegenerate(p));
|
|
4960
|
-
const formsWatcher = import_chokidar.default.watch((0,
|
|
4990
|
+
const formsWatcher = import_chokidar.default.watch((0, import_node_path18.join)(config.codegen.cwd, config.forms.watch), {
|
|
4961
4991
|
ignoreInitial: true,
|
|
4962
4992
|
persistent: true,
|
|
4963
4993
|
awaitWriteFinish: { stabilityThreshold: 80, pollInterval: 20 }
|
|
@@ -4984,7 +5014,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
4984
5014
|
}
|
|
4985
5015
|
|
|
4986
5016
|
// src/index.ts
|
|
4987
|
-
var VERSION = "0.
|
|
5017
|
+
var VERSION = "0.17.0";
|
|
4988
5018
|
|
|
4989
5019
|
// src/cli/codegen.ts
|
|
4990
5020
|
async function runCodegen(opts = {}) {
|
|
@@ -4992,9 +5022,9 @@ async function runCodegen(opts = {}) {
|
|
|
4992
5022
|
const config = await loadConfig(cwd);
|
|
4993
5023
|
if (opts.watch) {
|
|
4994
5024
|
const watcher = await watch(config, void 0, { entryPoint: "cli" });
|
|
4995
|
-
await new Promise((
|
|
5025
|
+
await new Promise((resolve5) => {
|
|
4996
5026
|
function onSignal() {
|
|
4997
|
-
watcher.close().then(
|
|
5027
|
+
watcher.close().then(resolve5).catch(resolve5);
|
|
4998
5028
|
}
|
|
4999
5029
|
process.once("SIGINT", onSignal);
|
|
5000
5030
|
process.once("SIGTERM", onSignal);
|
|
@@ -5013,13 +5043,13 @@ async function runCodegen(opts = {}) {
|
|
|
5013
5043
|
// src/cli/doctor.ts
|
|
5014
5044
|
var import_node_child_process2 = require("child_process");
|
|
5015
5045
|
var import_node_fs4 = require("fs");
|
|
5016
|
-
var
|
|
5046
|
+
var import_node_path20 = require("path");
|
|
5017
5047
|
|
|
5018
5048
|
// src/cli/init.ts
|
|
5019
5049
|
var import_node_child_process = require("child_process");
|
|
5020
5050
|
var import_node_fs3 = require("fs");
|
|
5021
5051
|
var import_promises16 = require("fs/promises");
|
|
5022
|
-
var
|
|
5052
|
+
var import_node_path19 = require("path");
|
|
5023
5053
|
var import_node_readline = require("readline");
|
|
5024
5054
|
|
|
5025
5055
|
// src/cli/patch-utils.ts
|
|
@@ -5081,7 +5111,7 @@ ${bold(title)}`);
|
|
|
5081
5111
|
}
|
|
5082
5112
|
async function readPackageJson(cwd) {
|
|
5083
5113
|
try {
|
|
5084
|
-
const raw = await (0, import_promises16.readFile)((0,
|
|
5114
|
+
const raw = await (0, import_promises16.readFile)((0, import_node_path19.join)(cwd, "package.json"), "utf8");
|
|
5085
5115
|
return JSON.parse(raw);
|
|
5086
5116
|
} catch {
|
|
5087
5117
|
return {};
|
|
@@ -5112,7 +5142,7 @@ async function detectTemplateEngine(cwd) {
|
|
|
5112
5142
|
async function detectPackageManager(cwd) {
|
|
5113
5143
|
async function exists(file) {
|
|
5114
5144
|
try {
|
|
5115
|
-
await (0, import_promises16.access)((0,
|
|
5145
|
+
await (0, import_promises16.access)((0, import_node_path19.join)(cwd, file));
|
|
5116
5146
|
return true;
|
|
5117
5147
|
} catch {
|
|
5118
5148
|
return false;
|
|
@@ -5124,16 +5154,16 @@ async function detectPackageManager(cwd) {
|
|
|
5124
5154
|
}
|
|
5125
5155
|
async function promptFramework() {
|
|
5126
5156
|
if (!process.stdin.isTTY) return "react";
|
|
5127
|
-
return new Promise((
|
|
5157
|
+
return new Promise((resolve5) => {
|
|
5128
5158
|
const rl = (0, import_node_readline.createInterface)({ input: process.stdin, output: process.stdout });
|
|
5129
5159
|
rl.question(
|
|
5130
5160
|
"[nestjs-codegen] Which frontend framework? (react/vue/svelte) [react]: ",
|
|
5131
5161
|
(answer) => {
|
|
5132
5162
|
rl.close();
|
|
5133
5163
|
const trimmed = answer.trim().toLowerCase();
|
|
5134
|
-
if (trimmed === "vue")
|
|
5135
|
-
else if (trimmed === "svelte")
|
|
5136
|
-
else
|
|
5164
|
+
if (trimmed === "vue") resolve5("vue");
|
|
5165
|
+
else if (trimmed === "svelte") resolve5("svelte");
|
|
5166
|
+
else resolve5("react");
|
|
5137
5167
|
}
|
|
5138
5168
|
);
|
|
5139
5169
|
});
|
|
@@ -5159,7 +5189,7 @@ async function writeIfNotExists(filePath, content, label) {
|
|
|
5159
5189
|
logCreated(label);
|
|
5160
5190
|
}
|
|
5161
5191
|
async function handleViteConfig(cwd, framework) {
|
|
5162
|
-
const filePath = (0,
|
|
5192
|
+
const filePath = (0, import_node_path19.join)(cwd, "vite.config.ts");
|
|
5163
5193
|
if (await fileExists2(filePath)) {
|
|
5164
5194
|
const existing = await (0, import_promises16.readFile)(filePath, "utf8");
|
|
5165
5195
|
const hasPlugin = existing.includes("nestInertia") || existing.includes("nestjs-inertia-vite/plugin");
|
|
@@ -5217,7 +5247,7 @@ function installDeps(pkgManager, deps, dev) {
|
|
|
5217
5247
|
}
|
|
5218
5248
|
}
|
|
5219
5249
|
async function patchPackageJsonScripts(cwd, scripts) {
|
|
5220
|
-
const pkgPath = (0,
|
|
5250
|
+
const pkgPath = (0, import_node_path19.join)(cwd, "package.json");
|
|
5221
5251
|
let pkg = {};
|
|
5222
5252
|
try {
|
|
5223
5253
|
pkg = JSON.parse(await (0, import_promises16.readFile)(pkgPath, "utf8"));
|
|
@@ -5534,7 +5564,7 @@ export class HomeController {
|
|
|
5534
5564
|
}
|
|
5535
5565
|
`;
|
|
5536
5566
|
function patchTsconfigExclude(cwd, dir, filename = "tsconfig.json") {
|
|
5537
|
-
const filePath = (0,
|
|
5567
|
+
const filePath = (0, import_node_path19.join)(cwd, filename);
|
|
5538
5568
|
return patchJsonFile(
|
|
5539
5569
|
filePath,
|
|
5540
5570
|
(json) => {
|
|
@@ -5549,7 +5579,7 @@ function patchTsconfigExclude(cwd, dir, filename = "tsconfig.json") {
|
|
|
5549
5579
|
);
|
|
5550
5580
|
}
|
|
5551
5581
|
function patchNestCliJson(cwd, shellDir) {
|
|
5552
|
-
const filePath = (0,
|
|
5582
|
+
const filePath = (0, import_node_path19.join)(cwd, "nest-cli.json");
|
|
5553
5583
|
return patchJsonFile(filePath, (json) => {
|
|
5554
5584
|
const compiler = json.compilerOptions ?? {};
|
|
5555
5585
|
const assets = compiler.assets ?? [];
|
|
@@ -5572,46 +5602,46 @@ async function scaffoldFiles(ctx) {
|
|
|
5572
5602
|
const { cwd, framework, engine, shellFileName, entryExt, pageExt } = ctx;
|
|
5573
5603
|
logSection("Scaffold files");
|
|
5574
5604
|
await writeIfNotExists(
|
|
5575
|
-
(0,
|
|
5605
|
+
(0, import_node_path19.join)(cwd, "nestjs-inertia.config.ts"),
|
|
5576
5606
|
configTemplate(framework),
|
|
5577
5607
|
"nestjs-inertia.config.ts"
|
|
5578
5608
|
);
|
|
5579
|
-
await writeIfNotExists((0,
|
|
5609
|
+
await writeIfNotExists((0, import_node_path19.join)(cwd, "nestjs-inertia.d.ts"), DTS_TEMPLATE, "nestjs-inertia.d.ts");
|
|
5580
5610
|
await writeIfNotExists(
|
|
5581
|
-
(0,
|
|
5611
|
+
(0, import_node_path19.join)(cwd, "tsconfig.inertia.json"),
|
|
5582
5612
|
TSCONFIG_INERTIA_TEMPLATE,
|
|
5583
5613
|
"tsconfig.inertia.json"
|
|
5584
5614
|
);
|
|
5585
5615
|
await writeIfNotExists(
|
|
5586
|
-
(0,
|
|
5616
|
+
(0, import_node_path19.join)(cwd, "inertia", "tsconfig.json"),
|
|
5587
5617
|
INERTIA_TSCONFIG_TEMPLATE,
|
|
5588
5618
|
"inertia/tsconfig.json"
|
|
5589
5619
|
);
|
|
5590
5620
|
await writeIfNotExists(
|
|
5591
|
-
(0,
|
|
5621
|
+
(0, import_node_path19.join)(cwd, "inertia", shellFileName),
|
|
5592
5622
|
htmlShellTemplate(framework, engine),
|
|
5593
5623
|
`inertia/${shellFileName}`
|
|
5594
5624
|
);
|
|
5595
5625
|
await handleViteConfig(cwd, framework);
|
|
5596
5626
|
await writeIfNotExists(
|
|
5597
|
-
(0,
|
|
5627
|
+
(0, import_node_path19.join)(cwd, "inertia", "app", `client.${entryExt}`),
|
|
5598
5628
|
entryPointTemplate(framework),
|
|
5599
5629
|
`inertia/app/client.${entryExt}`
|
|
5600
5630
|
);
|
|
5601
5631
|
await writeIfNotExists(
|
|
5602
|
-
(0,
|
|
5632
|
+
(0, import_node_path19.join)(cwd, "inertia", "pages", `Home.${pageExt}`),
|
|
5603
5633
|
samplePageTemplate(framework),
|
|
5604
5634
|
`inertia/pages/Home.${pageExt}`
|
|
5605
5635
|
);
|
|
5606
5636
|
await writeIfNotExists(
|
|
5607
|
-
(0,
|
|
5637
|
+
(0, import_node_path19.join)(cwd, "src", "home.controller.ts"),
|
|
5608
5638
|
SAMPLE_CONTROLLER,
|
|
5609
5639
|
"src/home.controller.ts"
|
|
5610
5640
|
);
|
|
5611
5641
|
}
|
|
5612
5642
|
function patchServerAppModule(ctx) {
|
|
5613
5643
|
const { cwd, rootView } = ctx;
|
|
5614
|
-
const appModulePath = (0,
|
|
5644
|
+
const appModulePath = (0, import_node_path19.join)(cwd, "src", "app.module.ts");
|
|
5615
5645
|
const appModuleResult = patchAppModule(appModulePath, rootView);
|
|
5616
5646
|
if (appModuleResult === "patched") {
|
|
5617
5647
|
logPatched("src/app.module.ts", "added InertiaModule.forRoot");
|
|
@@ -5625,7 +5655,7 @@ function patchServerAppModule(ctx) {
|
|
|
5625
5655
|
}
|
|
5626
5656
|
}
|
|
5627
5657
|
function patchServerMainTs(ctx) {
|
|
5628
|
-
const mainTsPath = (0,
|
|
5658
|
+
const mainTsPath = (0, import_node_path19.join)(ctx.cwd, "src", "main.ts");
|
|
5629
5659
|
const mainTsResult = patchMainTs(mainTsPath);
|
|
5630
5660
|
if (mainTsResult === "patched") {
|
|
5631
5661
|
logPatched("src/main.ts", "added setupInertiaVite after NestFactory.create");
|
|
@@ -5660,7 +5690,7 @@ function patchBuildConfigs(ctx) {
|
|
|
5660
5690
|
}
|
|
5661
5691
|
async function patchGitignoreAndDist(ctx) {
|
|
5662
5692
|
const { cwd } = ctx;
|
|
5663
|
-
await patchGitignore((0,
|
|
5693
|
+
await patchGitignore((0, import_node_path19.join)(cwd, ".gitignore"));
|
|
5664
5694
|
const tsconfigDistResult = patchTsconfigExclude(cwd, "dist", "tsconfig.json");
|
|
5665
5695
|
if (tsconfigDistResult === "patched") {
|
|
5666
5696
|
logPatched("tsconfig.json", "excluded dist/ from server compilation");
|
|
@@ -5766,7 +5796,7 @@ ${green("\u2713")} Setup complete! Run: ${bold("nest start --watch")}
|
|
|
5766
5796
|
|
|
5767
5797
|
// src/cli/doctor.ts
|
|
5768
5798
|
function checkFileExists(cwd, file) {
|
|
5769
|
-
return (0, import_node_fs4.existsSync)((0,
|
|
5799
|
+
return (0, import_node_fs4.existsSync)((0, import_node_path20.join)(cwd, file));
|
|
5770
5800
|
}
|
|
5771
5801
|
function readJson(path) {
|
|
5772
5802
|
try {
|
|
@@ -5802,15 +5832,15 @@ function writeJsonField(filePath, dotPath, value) {
|
|
|
5802
5832
|
}
|
|
5803
5833
|
function getPackageVersion(cwd, pkg) {
|
|
5804
5834
|
try {
|
|
5805
|
-
const pkgJson = readJson((0,
|
|
5835
|
+
const pkgJson = readJson((0, import_node_path20.join)(cwd, "node_modules", pkg, "package.json"));
|
|
5806
5836
|
return pkgJson?.version ?? null;
|
|
5807
5837
|
} catch {
|
|
5808
5838
|
return null;
|
|
5809
5839
|
}
|
|
5810
5840
|
}
|
|
5811
5841
|
function detectPkgManager(cwd) {
|
|
5812
|
-
if ((0, import_node_fs4.existsSync)((0,
|
|
5813
|
-
if ((0, import_node_fs4.existsSync)((0,
|
|
5842
|
+
if ((0, import_node_fs4.existsSync)((0, import_node_path20.join)(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
5843
|
+
if ((0, import_node_fs4.existsSync)((0, import_node_path20.join)(cwd, "yarn.lock"))) return "yarn";
|
|
5814
5844
|
return "npm";
|
|
5815
5845
|
}
|
|
5816
5846
|
async function runDoctor(opts) {
|
|
@@ -5848,7 +5878,7 @@ async function runDoctor(opts) {
|
|
|
5848
5878
|
autoFix: () => runInit({ cwd })
|
|
5849
5879
|
});
|
|
5850
5880
|
if (foundShellDir) {
|
|
5851
|
-
const nestCliPath = (0,
|
|
5881
|
+
const nestCliPath = (0, import_node_path20.join)(cwd, "nest-cli.json");
|
|
5852
5882
|
const nestCli = readJson(nestCliPath);
|
|
5853
5883
|
const compiler = nestCli?.compilerOptions ?? {};
|
|
5854
5884
|
const assets = compiler.assets ?? [];
|
|
@@ -5887,7 +5917,7 @@ async function runDoctor(opts) {
|
|
|
5887
5917
|
fix: "Run: nestjs-codegen codegen",
|
|
5888
5918
|
autoFix: () => runCodegen({ cwd })
|
|
5889
5919
|
});
|
|
5890
|
-
const tsconfigPath = (0,
|
|
5920
|
+
const tsconfigPath = (0, import_node_path20.join)(cwd, "tsconfig.json");
|
|
5891
5921
|
const tsconfig = readJson(tsconfigPath);
|
|
5892
5922
|
const paths = tsconfig?.compilerOptions?.paths;
|
|
5893
5923
|
checks.push({
|
|
@@ -5898,7 +5928,7 @@ async function runDoctor(opts) {
|
|
|
5898
5928
|
});
|
|
5899
5929
|
const inertiaDir = foundShellDir ?? "inertia";
|
|
5900
5930
|
for (const tsconfigFile of ["tsconfig.json", "tsconfig.build.json"]) {
|
|
5901
|
-
const tsc = readJson((0,
|
|
5931
|
+
const tsc = readJson((0, import_node_path20.join)(cwd, tsconfigFile));
|
|
5902
5932
|
if (!tsc) continue;
|
|
5903
5933
|
const excl = tsc.exclude ?? [];
|
|
5904
5934
|
const excludesIt = excl.includes(inertiaDir);
|
|
@@ -5924,7 +5954,7 @@ async function runDoctor(opts) {
|
|
|
5924
5954
|
}
|
|
5925
5955
|
});
|
|
5926
5956
|
}
|
|
5927
|
-
const inertiaTsconfigPath = (0,
|
|
5957
|
+
const inertiaTsconfigPath = (0, import_node_path20.join)(cwd, "tsconfig.inertia.json");
|
|
5928
5958
|
const inertiaTsconfig = readJson(inertiaTsconfigPath);
|
|
5929
5959
|
checks.push({
|
|
5930
5960
|
name: "tsconfig.inertia.json exists",
|
|
@@ -5976,7 +6006,7 @@ async function runDoctor(opts) {
|
|
|
5976
6006
|
fix: 'Add "nestjs-inertia.d.ts" to include array (resolves InertiaRegistry augmentation)'
|
|
5977
6007
|
});
|
|
5978
6008
|
}
|
|
5979
|
-
const innerTsconfigPath = (0,
|
|
6009
|
+
const innerTsconfigPath = (0, import_node_path20.join)(cwd, "inertia", "tsconfig.json");
|
|
5980
6010
|
checks.push({
|
|
5981
6011
|
name: "inertia/tsconfig.json exists (VSCode picks up ~codegen alias)",
|
|
5982
6012
|
pass: (0, import_node_fs4.existsSync)(innerTsconfigPath),
|
|
@@ -5986,7 +6016,7 @@ async function runDoctor(opts) {
|
|
|
5986
6016
|
}
|
|
5987
6017
|
});
|
|
5988
6018
|
if (checkFileExists(cwd, "vite.config.ts")) {
|
|
5989
|
-
const viteContent = (0, import_node_fs4.readFileSync)((0,
|
|
6019
|
+
const viteContent = (0, import_node_fs4.readFileSync)((0, import_node_path20.join)(cwd, "vite.config.ts"), "utf8");
|
|
5990
6020
|
checks.push({
|
|
5991
6021
|
name: "vite.config.ts has resolve.alias",
|
|
5992
6022
|
pass: viteContent.includes("resolve") && viteContent.includes("alias"),
|
|
@@ -6051,7 +6081,7 @@ async function runDoctor(opts) {
|
|
|
6051
6081
|
});
|
|
6052
6082
|
}
|
|
6053
6083
|
if (checkFileExists(cwd, ".gitignore")) {
|
|
6054
|
-
const gitignorePath = (0,
|
|
6084
|
+
const gitignorePath = (0, import_node_path20.join)(cwd, ".gitignore");
|
|
6055
6085
|
const gitignore = (0, import_node_fs4.readFileSync)(gitignorePath, "utf8");
|
|
6056
6086
|
checks.push({
|
|
6057
6087
|
name: ".gitignore includes .nestjs-inertia/",
|
|
@@ -6060,7 +6090,7 @@ async function runDoctor(opts) {
|
|
|
6060
6090
|
autoFix: () => (0, import_node_fs4.appendFileSync)(gitignorePath, "\n.nestjs-inertia/\n")
|
|
6061
6091
|
});
|
|
6062
6092
|
}
|
|
6063
|
-
const pkgJsonPath = (0,
|
|
6093
|
+
const pkgJsonPath = (0, import_node_path20.join)(cwd, "package.json");
|
|
6064
6094
|
const pkgJson = readJson(pkgJsonPath);
|
|
6065
6095
|
const scripts = pkgJson?.scripts ?? {};
|
|
6066
6096
|
checks.push({
|