@nestjs/cli 10.0.0 → 10.0.2

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.
@@ -21,7 +21,7 @@ jobs:
21
21
  build:
22
22
  working_directory: ~/nest
23
23
  docker:
24
- - image: cimg/node:20.3
24
+ - image: cimg/node:20.2
25
25
  steps:
26
26
  - checkout
27
27
  - run:
@@ -43,7 +43,7 @@ jobs:
43
43
  unit_tests:
44
44
  working_directory: ~/nest
45
45
  docker:
46
- - image: cimg/node:20.3
46
+ - image: cimg/node:20.2
47
47
  steps:
48
48
  - checkout
49
49
  - *restore-cache
@@ -4,6 +4,7 @@ export type DeepPluginMeta = ts.ObjectLiteralExpression | {
4
4
  };
5
5
  export interface ReadonlyVisitor {
6
6
  key: string;
7
+ typeImports: Record<string, string>;
7
8
  visit(program: ts.Program, sf: ts.SourceFile): void;
8
9
  collect(): Record<string, Array<[ts.CallExpression, DeepPluginMeta]>>;
9
10
  }
@@ -65,11 +65,16 @@ class PluginMetadataGenerator {
65
65
  visitors.forEach((visitor) => visitor.visit(programRef, sourceFile));
66
66
  }
67
67
  }
68
+ let typeImports = {};
68
69
  const collectedMetadata = {};
69
70
  visitors.forEach((visitor) => {
70
71
  collectedMetadata[visitor.key] = visitor.collect();
72
+ typeImports = {
73
+ ...typeImports,
74
+ ...visitor.typeImports,
75
+ };
71
76
  });
72
- this.pluginMetadataPrinter.print(collectedMetadata, {
77
+ this.pluginMetadataPrinter.print(collectedMetadata, typeImports, {
73
78
  outputDir,
74
79
  filename,
75
80
  });
@@ -4,10 +4,14 @@ export interface PluginMetadataPrintOptions {
4
4
  outputDir: string;
5
5
  filename?: string;
6
6
  }
7
+ type ComposedPluginMeta = Record<string, Record<string, Array<[ts.CallExpression, DeepPluginMeta]>>>;
7
8
  /**
8
9
  * Prints the metadata to a file.
9
10
  */
10
11
  export declare class PluginMetadataPrinter {
11
- print(metadata: Record<string, Record<string, Array<[ts.CallExpression, DeepPluginMeta]>>>, options: PluginMetadataPrintOptions): void;
12
+ print(metadata: ComposedPluginMeta, typeImports: Record<string, string>, options: PluginMetadataPrintOptions): void;
12
13
  private recursivelyCreatePropertyAssignment;
14
+ private createTypeImportVariableStatement;
15
+ private createPropertyAssignment;
13
16
  }
17
+ export {};
@@ -5,13 +5,17 @@ const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const ts = require("typescript");
7
7
  const SERIALIZED_METADATA_FILENAME = 'metadata.ts';
8
+ const TYPE_IMPORT_VARIABLE_NAME = 't';
8
9
  /**
9
10
  * Prints the metadata to a file.
10
11
  */
11
12
  class PluginMetadataPrinter {
12
- print(metadata, options) {
13
+ print(metadata, typeImports, options) {
13
14
  const objectLiteralExpr = ts.factory.createObjectLiteralExpression(Object.keys(metadata).map((key) => this.recursivelyCreatePropertyAssignment(key, metadata[key])));
14
- const exportAssignment = ts.factory.createExportAssignment(undefined, undefined, objectLiteralExpr);
15
+ const exportAssignment = ts.factory.createExportAssignment(undefined, undefined, ts.factory.createArrowFunction([ts.factory.createToken(ts.SyntaxKind.AsyncKeyword)], undefined, [], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createBlock([
16
+ this.createTypeImportVariableStatement(typeImports),
17
+ ts.factory.createReturnStatement(objectLiteralExpr),
18
+ ], true)));
15
19
  const printer = ts.createPrinter({
16
20
  newLine: ts.NewLineKind.LineFeed,
17
21
  });
@@ -33,5 +37,16 @@ class PluginMetadataPrinter {
33
37
  ? meta
34
38
  : ts.factory.createObjectLiteralExpression(Object.keys(meta).map((key) => this.recursivelyCreatePropertyAssignment(key, meta[key]))));
35
39
  }
40
+ createTypeImportVariableStatement(typeImports) {
41
+ return ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([
42
+ ts.factory.createVariableDeclaration(ts.factory.createIdentifier(TYPE_IMPORT_VARIABLE_NAME), undefined, undefined, ts.factory.createObjectLiteralExpression(Object.keys(typeImports).map((ti) => this.createPropertyAssignment(ti, typeImports[ti])), true)),
43
+ ], ts.NodeFlags.Const |
44
+ ts.NodeFlags.AwaitContext |
45
+ ts.NodeFlags.ContextFlags |
46
+ ts.NodeFlags.TypeExcludesFlags));
47
+ }
48
+ createPropertyAssignment(identifier, target) {
49
+ return ts.factory.createPropertyAssignment(ts.factory.createComputedPropertyName(ts.factory.createStringLiteral(identifier)), ts.factory.createIdentifier(target));
50
+ }
36
51
  }
37
52
  exports.PluginMetadataPrinter = PluginMetadataPrinter;
@@ -7,6 +7,7 @@ const chokidar = require("chokidar");
7
7
  const fs_1 = require("fs");
8
8
  const path_1 = require("path");
9
9
  const ui_1 = require("../../ui");
10
+ const tree_kill_1 = require("../../utils/tree-kill");
10
11
  const base_compiler_1 = require("../base-compiler");
11
12
  const swc_defaults_1 = require("../defaults/swc-defaults");
12
13
  const plugin_metadata_generator_1 = require("../plugins/plugin-metadata-generator");
@@ -48,9 +49,10 @@ class SwcCompiler extends base_compiler_1.BaseCompiler {
48
49
  configuration.sourceRoot ?? 'src',
49
50
  JSON.stringify(configuration.compilerOptions.plugins ?? []),
50
51
  ];
51
- (0, child_process_1.fork)((0, path_1.join)(__dirname, 'forked-type-checker.js'), args, {
52
+ const childProcessRef = (0, child_process_1.fork)((0, path_1.join)(__dirname, 'forked-type-checker.js'), args, {
52
53
  cwd: process.cwd(),
53
54
  });
55
+ process.on('exit', () => childProcessRef && (0, tree_kill_1.treeKillSync)(childProcessRef.pid));
54
56
  }
55
57
  else {
56
58
  const { readonlyVisitors } = this.loadPlugins(configuration, tsConfigPath, appName);
@@ -109,7 +111,7 @@ class SwcCompiler extends base_compiler_1.BaseCompiler {
109
111
  catch (err) {
110
112
  console.error(ui_1.ERROR_PREFIX +
111
113
  ' Failed to load "@swc/cli" and "@swc/core" packages. Please, install them by running "npm i -D @swc/cli @swc/core".');
112
- throw err;
114
+ process.exit(1);
113
115
  }
114
116
  }
115
117
  getSwcRcFileContentIfExists() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/cli",
3
- "version": "10.0.0",
3
+ "version": "10.0.2",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -41,7 +41,7 @@
41
41
  "@angular-devkit/core": "16.1.0",
42
42
  "@angular-devkit/schematics": "16.1.0",
43
43
  "@angular-devkit/schematics-cli": "16.1.0",
44
- "@nestjs/schematics": "^10.0.0",
44
+ "@nestjs/schematics": "^10.0.1",
45
45
  "chalk": "4.1.2",
46
46
  "chokidar": "3.5.3",
47
47
  "cli-table3": "0.6.3",