@dudousxd/nestjs-codegen 0.22.0 → 0.22.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,29 @@
1
1
  # @dudousxd/nestjs-codegen
2
2
 
3
+ ## 0.22.1
4
+
5
+ ### Patch Changes
6
+
7
+ - da8ec39: Order routes by file path, so an unchanged source tree always generates the same client
8
+
9
+ Route order decided the order of everything emitted from it — the groups in
10
+ `api.ts`, the entries in `routes.ts` — and it was whatever order discovery
11
+ happened to reach the files in. The cold path adds controllers in `fast-glob`'s
12
+ directory-walk order, which is I/O-completion order from a concurrent walk: it
13
+ holds while the FS cache is warm and can differ on a cold one, so regenerating
14
+ an untouched project could move a controller group to a different position. The
15
+ watcher appended each newly-created controller to the end of its set, so from
16
+ the moment a file was added its output no longer matched a cold run's, for the
17
+ rest of the session.
18
+
19
+ Both extraction entry points now sort their roots by path. `discoverPages` has
20
+ sorted its glob from the start, which is why only the controller-derived
21
+ artifacts ever moved.
22
+
23
+ Nothing about the generated client changes except the order of its blocks —
24
+ same routes, same types, same members. Consumers who commit their generated
25
+ directory should expect one reorder-only diff on the first run after upgrading.
26
+
3
27
  ## 0.22.0
4
28
 
5
29
  ### Minor Changes
package/dist/cli/main.cjs CHANGED
@@ -2754,7 +2754,7 @@ function bindDiscoveryContext(project, cwd, tsconfigPath, tsconfig = loadDiscove
2754
2754
  }
2755
2755
  function extractRoutesFrom(project, controllerPaths) {
2756
2756
  const routes = [];
2757
- for (const path of controllerPaths) {
2757
+ for (const path of byPath([...controllerPaths])) {
2758
2758
  const sourceFile = project.getSourceFile(path);
2759
2759
  if (sourceFile) routes.push(...extractFromSourceFile(sourceFile, project));
2760
2760
  }
@@ -2762,11 +2762,17 @@ function extractRoutesFrom(project, controllerPaths) {
2762
2762
  }
2763
2763
  function extractAllRoutes(project) {
2764
2764
  const routes = [];
2765
- for (const sourceFile of project.getSourceFiles()) {
2765
+ for (const sourceFile of byPath(project.getSourceFiles(), (f) => f.getFilePath())) {
2766
2766
  routes.push(...extractFromSourceFile(sourceFile, project));
2767
2767
  }
2768
2768
  return routes;
2769
2769
  }
2770
+ function byPath(items, path = String) {
2771
+ return [...items].sort((a, b) => {
2772
+ const [x, y] = [path(a), path(b)];
2773
+ return x < y ? -1 : x > y ? 1 : 0;
2774
+ });
2775
+ }
2770
2776
  var PersistentDiscovery = class _PersistentDiscovery {
2771
2777
  project;
2772
2778
  cwd;
@@ -5247,7 +5253,7 @@ async function watch(config, onChange, options = {}) {
5247
5253
  }
5248
5254
 
5249
5255
  // src/index.ts
5250
- var VERSION = "0.22.0";
5256
+ var VERSION = "0.22.1";
5251
5257
 
5252
5258
  // src/cli/codegen.ts
5253
5259
  async function runCodegen(opts = {}) {