@dudousxd/nestjs-codegen 0.27.2 → 0.29.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 +16 -0
- package/README.md +25 -0
- package/dist/cli/main.cjs +54 -13
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +55 -14
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +204 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -3
- package/dist/index.d.ts +69 -3
- package/dist/index.js +203 -8
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +48 -7
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.js +49 -8
- package/dist/nest/index.js.map +1 -1
- package/package.json +6 -1
package/dist/nest/index.cjs
CHANGED
|
@@ -5693,11 +5693,36 @@ async function watch(config, onChange, options = {}) {
|
|
|
5693
5693
|
}
|
|
5694
5694
|
return discovery;
|
|
5695
5695
|
}
|
|
5696
|
+
const trackedWatcher = import_chokidar.default.watch([], {
|
|
5697
|
+
ignoreInitial: true,
|
|
5698
|
+
persistent: true,
|
|
5699
|
+
awaitWriteFinish: { stabilityThreshold: 80, pollInterval: 20 }
|
|
5700
|
+
});
|
|
5701
|
+
const trackedPaths = /* @__PURE__ */ new Set();
|
|
5702
|
+
async function syncTrackedInputs() {
|
|
5703
|
+
const manifest = await readManifest(config.codegen.outDir);
|
|
5704
|
+
const fresh = [];
|
|
5705
|
+
for (const path of manifest?.extraInputs ?? []) {
|
|
5706
|
+
const abs = (0, import_node_path17.resolve)(config.codegen.cwd, path);
|
|
5707
|
+
if (trackedPaths.has(abs)) continue;
|
|
5708
|
+
trackedPaths.add(abs);
|
|
5709
|
+
fresh.push(abs);
|
|
5710
|
+
}
|
|
5711
|
+
if (fresh.length > 0) trackedWatcher.add(fresh);
|
|
5712
|
+
}
|
|
5713
|
+
async function generateAndTrack(routes) {
|
|
5714
|
+
try {
|
|
5715
|
+
await generate(config, routes, entryPoint);
|
|
5716
|
+
} finally {
|
|
5717
|
+
await syncTrackedInputs().catch(() => {
|
|
5718
|
+
});
|
|
5719
|
+
}
|
|
5720
|
+
}
|
|
5696
5721
|
async function runInitialPass() {
|
|
5697
5722
|
try {
|
|
5698
5723
|
const initialRoutes = (await getDiscovery()).discover();
|
|
5699
5724
|
lastRoutes = initialRoutes;
|
|
5700
|
-
await
|
|
5725
|
+
await generateAndTrack(initialRoutes);
|
|
5701
5726
|
} catch (err) {
|
|
5702
5727
|
if (err instanceof DriftGuardError) {
|
|
5703
5728
|
console.error(err.message);
|
|
@@ -5707,7 +5732,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5707
5732
|
`[nestjs-codegen] Initial route discovery failed, falling back to pages-only: ${err instanceof Error ? err.message : String(err)}`
|
|
5708
5733
|
);
|
|
5709
5734
|
try {
|
|
5710
|
-
await
|
|
5735
|
+
await generateAndTrack(lastRoutes);
|
|
5711
5736
|
} catch {
|
|
5712
5737
|
}
|
|
5713
5738
|
}
|
|
@@ -5740,7 +5765,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5740
5765
|
pagesDebounceTimer = setTimeout(async () => {
|
|
5741
5766
|
pagesDebounceTimer = void 0;
|
|
5742
5767
|
try {
|
|
5743
|
-
await
|
|
5768
|
+
await generateAndTrack(lastRoutes);
|
|
5744
5769
|
} catch (err) {
|
|
5745
5770
|
console.error(
|
|
5746
5771
|
"[nestjs-codegen] Pages generation failed:",
|
|
@@ -5772,7 +5797,7 @@ async function watch(config, onChange, options = {}) {
|
|
|
5772
5797
|
try {
|
|
5773
5798
|
const routes = await (await getDiscovery()).rediscover(changed);
|
|
5774
5799
|
lastRoutes = routes;
|
|
5775
|
-
await
|
|
5800
|
+
await generateAndTrack(routes);
|
|
5776
5801
|
} catch (err) {
|
|
5777
5802
|
console.error(
|
|
5778
5803
|
"[nestjs-codegen] Contracts generation failed:",
|
|
@@ -5793,6 +5818,9 @@ async function watch(config, onChange, options = {}) {
|
|
|
5793
5818
|
formsWatcher.on("add", (p) => scheduleContractsRegenerate(p));
|
|
5794
5819
|
formsWatcher.on("change", (p) => scheduleContractsRegenerate(p));
|
|
5795
5820
|
formsWatcher.on("unlink", (p) => scheduleContractsRegenerate(p));
|
|
5821
|
+
trackedWatcher.on("add", (p) => scheduleContractsRegenerate(p));
|
|
5822
|
+
trackedWatcher.on("change", (p) => scheduleContractsRegenerate(p));
|
|
5823
|
+
trackedWatcher.on("unlink", (p) => scheduleContractsRegenerate(p));
|
|
5796
5824
|
return {
|
|
5797
5825
|
close: async () => {
|
|
5798
5826
|
if (pagesDebounceTimer !== void 0) {
|
|
@@ -5806,13 +5834,14 @@ async function watch(config, onChange, options = {}) {
|
|
|
5806
5834
|
await pagesWatcher.close();
|
|
5807
5835
|
await contractsWatcher.close();
|
|
5808
5836
|
await formsWatcher.close();
|
|
5837
|
+
await trackedWatcher.close();
|
|
5809
5838
|
await lock.release();
|
|
5810
5839
|
}
|
|
5811
5840
|
};
|
|
5812
5841
|
}
|
|
5813
5842
|
|
|
5814
5843
|
// src/index.ts
|
|
5815
|
-
var VERSION = "0.
|
|
5844
|
+
var VERSION = "0.29.0";
|
|
5816
5845
|
|
|
5817
5846
|
// src/generate-manifest.ts
|
|
5818
5847
|
var MANIFEST_FILE = ".codegen-manifest.json";
|
|
@@ -5904,14 +5933,26 @@ async function computeInputsHash(config, extraInputs = []) {
|
|
|
5904
5933
|
hash.update("\n");
|
|
5905
5934
|
}
|
|
5906
5935
|
for (const file of extra) {
|
|
5907
|
-
const contents = await (0, import_promises15.readFile)((0, import_node_path18.join)(cwd, file), "utf8").catch(() => null);
|
|
5908
5936
|
hash.update(`extra:${file}
|
|
5909
5937
|
`);
|
|
5910
|
-
hash.update(
|
|
5938
|
+
hash.update(await readTrackedInput((0, import_node_path18.join)(cwd, file)));
|
|
5911
5939
|
hash.update("\n");
|
|
5912
5940
|
}
|
|
5913
5941
|
return hash.digest("hex");
|
|
5914
5942
|
}
|
|
5943
|
+
async function readTrackedInput(path) {
|
|
5944
|
+
try {
|
|
5945
|
+
return await (0, import_promises15.readFile)(path, "utf8");
|
|
5946
|
+
} catch (err) {
|
|
5947
|
+
if (err.code !== "EISDIR") return "\0missing";
|
|
5948
|
+
}
|
|
5949
|
+
try {
|
|
5950
|
+
const entries = await (0, import_promises15.readdir)(path);
|
|
5951
|
+
return `\0dir:${entries.sort().join("\n")}`;
|
|
5952
|
+
} catch {
|
|
5953
|
+
return "\0missing";
|
|
5954
|
+
}
|
|
5955
|
+
}
|
|
5915
5956
|
async function readManifest(outDir) {
|
|
5916
5957
|
try {
|
|
5917
5958
|
const raw = await (0, import_promises15.readFile)((0, import_node_path18.join)(outDir, MANIFEST_FILE), "utf8");
|