@dudousxd/nestjs-codegen 0.6.0 → 0.6.1

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @dudousxd/nestjs-codegen
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 95c744f: Fix watcher clobbering `api.ts` with an extension-only stub on page edits. The
8
+ pages fast path called `generate(config)` with no routes, so a route-injecting
9
+ extension (e.g. the notifications codegen) still emitted — overwriting the full
10
+ `api.ts` with just the injected namespace and dropping every contract-derived
11
+ route. The watcher now caches the last discovered routes (from the initial pass
12
+ and each contracts rediscovery) and reuses them for pages-only regenerations.
13
+
3
14
  ## 0.6.0
4
15
 
5
16
  ### Minor Changes
package/dist/cli/main.cjs CHANGED
@@ -4355,6 +4355,7 @@ async function watch(config, onChange) {
4355
4355
  return NO_OP_WATCHER;
4356
4356
  }
4357
4357
  let discovery = null;
4358
+ let lastRoutes = [];
4358
4359
  async function getDiscovery() {
4359
4360
  if (discovery === null) {
4360
4361
  discovery = await PersistentDiscovery.create({
@@ -4368,13 +4369,14 @@ async function watch(config, onChange) {
4368
4369
  }
4369
4370
  try {
4370
4371
  const initialRoutes = (await getDiscovery()).discover();
4372
+ lastRoutes = initialRoutes;
4371
4373
  await generate(config, initialRoutes);
4372
4374
  } catch (err) {
4373
4375
  console.warn(
4374
4376
  `[nestjs-codegen] Initial route discovery failed, falling back to pages-only: ${err instanceof Error ? err.message : String(err)}`
4375
4377
  );
4376
4378
  try {
4377
- await generate(config);
4379
+ await generate(config, lastRoutes);
4378
4380
  } catch {
4379
4381
  }
4380
4382
  }
@@ -4392,7 +4394,7 @@ async function watch(config, onChange) {
4392
4394
  pagesDebounceTimer = setTimeout(async () => {
4393
4395
  pagesDebounceTimer = void 0;
4394
4396
  try {
4395
- await generate(config);
4397
+ await generate(config, lastRoutes);
4396
4398
  } catch (err) {
4397
4399
  console.error(
4398
4400
  "[nestjs-codegen] Pages generation failed:",
@@ -4423,6 +4425,7 @@ async function watch(config, onChange) {
4423
4425
  pendingChangedPaths.clear();
4424
4426
  try {
4425
4427
  const routes = await (await getDiscovery()).rediscover(changed);
4428
+ lastRoutes = routes;
4426
4429
  await generate(config, routes);
4427
4430
  } catch (err) {
4428
4431
  console.error(
@@ -4463,7 +4466,7 @@ async function watch(config, onChange) {
4463
4466
  }
4464
4467
 
4465
4468
  // src/index.ts
4466
- var VERSION = "0.6.0";
4469
+ var VERSION = "0.6.1";
4467
4470
 
4468
4471
  // src/cli/codegen.ts
4469
4472
  async function runCodegen(opts = {}) {