@nestjs/cli 10.1.6 → 10.1.8

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.
@@ -15,6 +15,7 @@ export declare const swcDefaultsFactory: (tsOptions?: ts.CompilerOptions, config
15
15
  transform: {
16
16
  legacyDecorator: boolean;
17
17
  decoratorMetadata: boolean;
18
+ useDefineForClassFields: boolean;
18
19
  };
19
20
  keepClassNames: boolean;
20
21
  baseUrl: string | undefined;
@@ -20,6 +20,7 @@ const swcDefaultsFactory = (tsOptions, configuration) => {
20
20
  transform: {
21
21
  legacyDecorator: true,
22
22
  decoratorMetadata: true,
23
+ useDefineForClassFields: false
23
24
  },
24
25
  keepClassNames: true,
25
26
  baseUrl: tsOptions?.baseUrl,
@@ -51,6 +51,8 @@ export declare class PluginMetadataGenerator {
51
51
  private readonly pluginMetadataPrinter;
52
52
  private readonly typeCheckerHost;
53
53
  private readonly typescriptLoader;
54
+ private readonly tsBinary;
55
+ constructor();
54
56
  generate(options: PluginMetadataGenerateOptions): void;
55
57
  private traverseAndPrintMetadata;
56
58
  }
@@ -25,6 +25,7 @@ class PluginMetadataGenerator {
25
25
  this.pluginMetadataPrinter = new plugin_metadata_printer_1.PluginMetadataPrinter();
26
26
  this.typeCheckerHost = new type_checker_host_1.TypeCheckerHost();
27
27
  this.typescriptLoader = new typescript_loader_1.TypeScriptBinaryLoader();
28
+ this.tsBinary = this.typescriptLoader.load();
28
29
  }
29
30
  generate(options) {
30
31
  const { tsconfigPath, visitors, tsProgramRef, outputDir, watch, filename, printDiagnostics = true, } = options;
@@ -77,7 +78,7 @@ class PluginMetadataGenerator {
77
78
  this.pluginMetadataPrinter.print(collectedMetadata, typeImports, {
78
79
  outputDir,
79
80
  filename,
80
- });
81
+ }, this.tsBinary);
81
82
  }
82
83
  }
83
84
  exports.PluginMetadataGenerator = PluginMetadataGenerator;
@@ -9,7 +9,7 @@ type ComposedPluginMeta = Record<string, Record<string, Array<[ts.CallExpression
9
9
  * Prints the metadata to a file.
10
10
  */
11
11
  export declare class PluginMetadataPrinter {
12
- print(metadata: ComposedPluginMeta, typeImports: Record<string, string>, options: PluginMetadataPrintOptions): void;
12
+ print(metadata: ComposedPluginMeta, typeImports: Record<string, string>, options: PluginMetadataPrintOptions, tsBinary: typeof ts): void;
13
13
  private recursivelyCreatePropertyAssignment;
14
14
  private createTypeImportVariableStatement;
15
15
  private createPropertyAssignment;
@@ -3,50 +3,49 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PluginMetadataPrinter = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
- const ts = require("typescript");
7
6
  const SERIALIZED_METADATA_FILENAME = 'metadata.ts';
8
7
  const TYPE_IMPORT_VARIABLE_NAME = 't';
9
8
  /**
10
9
  * Prints the metadata to a file.
11
10
  */
12
11
  class PluginMetadataPrinter {
13
- print(metadata, typeImports, options) {
14
- const objectLiteralExpr = ts.factory.createObjectLiteralExpression(Object.keys(metadata).map((key) => this.recursivelyCreatePropertyAssignment(key, metadata[key])));
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),
12
+ print(metadata, typeImports, options, tsBinary) {
13
+ const objectLiteralExpr = tsBinary.factory.createObjectLiteralExpression(Object.keys(metadata).map((key) => this.recursivelyCreatePropertyAssignment(key, metadata[key], tsBinary)));
14
+ const exportAssignment = tsBinary.factory.createExportAssignment(undefined, undefined, tsBinary.factory.createArrowFunction([tsBinary.factory.createToken(tsBinary.SyntaxKind.AsyncKeyword)], undefined, [], undefined, tsBinary.factory.createToken(tsBinary.SyntaxKind.EqualsGreaterThanToken), tsBinary.factory.createBlock([
15
+ this.createTypeImportVariableStatement(typeImports, tsBinary),
16
+ tsBinary.factory.createReturnStatement(objectLiteralExpr),
18
17
  ], true)));
19
- const printer = ts.createPrinter({
20
- newLine: ts.NewLineKind.LineFeed,
18
+ const printer = tsBinary.createPrinter({
19
+ newLine: tsBinary.NewLineKind.LineFeed,
21
20
  });
22
- const resultFile = ts.createSourceFile('file.ts', '', ts.ScriptTarget.Latest,
23
- /*setParentNodes*/ false, ts.ScriptKind.TS);
21
+ const resultFile = tsBinary.createSourceFile('file.ts', '', tsBinary.ScriptTarget.Latest,
22
+ /*setParentNodes*/ false, tsBinary.ScriptKind.TS);
24
23
  const filename = (0, path_1.join)(options.outputDir, options.filename ?? SERIALIZED_METADATA_FILENAME);
25
24
  const eslintPrefix = `/* eslint-disable */\n`;
26
25
  (0, fs_1.writeFileSync)(filename, eslintPrefix +
27
- printer.printNode(ts.EmitHint.Unspecified, exportAssignment, resultFile));
26
+ printer.printNode(tsBinary.EmitHint.Unspecified, exportAssignment, resultFile));
28
27
  }
29
- recursivelyCreatePropertyAssignment(identifier, meta) {
28
+ recursivelyCreatePropertyAssignment(identifier, meta, tsBinary) {
30
29
  if (Array.isArray(meta)) {
31
- return ts.factory.createPropertyAssignment(ts.factory.createStringLiteral(identifier), ts.factory.createArrayLiteralExpression(meta.map(([importExpr, meta]) => ts.factory.createArrayLiteralExpression([
30
+ return tsBinary.factory.createPropertyAssignment(tsBinary.factory.createStringLiteral(identifier), tsBinary.factory.createArrayLiteralExpression(meta.map(([importExpr, meta]) => tsBinary.factory.createArrayLiteralExpression([
32
31
  importExpr,
33
- ts.factory.createObjectLiteralExpression(Object.keys(meta).map((key) => this.recursivelyCreatePropertyAssignment(key, meta[key]))),
32
+ tsBinary.factory.createObjectLiteralExpression(Object.keys(meta).map((key) => this.recursivelyCreatePropertyAssignment(key, meta[key], tsBinary))),
34
33
  ]))));
35
34
  }
36
- return ts.factory.createPropertyAssignment(ts.factory.createStringLiteral(identifier), ts.isObjectLiteralExpression(meta)
35
+ return tsBinary.factory.createPropertyAssignment(tsBinary.factory.createStringLiteral(identifier), tsBinary.isObjectLiteralExpression(meta)
37
36
  ? meta
38
- : ts.factory.createObjectLiteralExpression(Object.keys(meta).map((key) => this.recursivelyCreatePropertyAssignment(key, meta[key]))));
37
+ : tsBinary.factory.createObjectLiteralExpression(Object.keys(meta).map((key) => this.recursivelyCreatePropertyAssignment(key, meta[key], tsBinary))));
39
38
  }
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));
39
+ createTypeImportVariableStatement(typeImports, tsBinary) {
40
+ return tsBinary.factory.createVariableStatement(undefined, tsBinary.factory.createVariableDeclarationList([
41
+ tsBinary.factory.createVariableDeclaration(tsBinary.factory.createIdentifier(TYPE_IMPORT_VARIABLE_NAME), undefined, undefined, tsBinary.factory.createObjectLiteralExpression(Object.keys(typeImports).map((ti) => this.createPropertyAssignment(ti, typeImports[ti], tsBinary)), true)),
42
+ ], tsBinary.NodeFlags.Const |
43
+ tsBinary.NodeFlags.AwaitContext |
44
+ tsBinary.NodeFlags.ContextFlags |
45
+ tsBinary.NodeFlags.TypeExcludesFlags));
47
46
  }
48
- createPropertyAssignment(identifier, target) {
49
- return ts.factory.createPropertyAssignment(ts.factory.createComputedPropertyName(ts.factory.createStringLiteral(identifier)), ts.factory.createIdentifier(target));
47
+ createPropertyAssignment(identifier, target, tsBinary) {
48
+ return tsBinary.factory.createPropertyAssignment(tsBinary.factory.createComputedPropertyName(tsBinary.factory.createStringLiteral(identifier)), tsBinary.factory.createIdentifier(target));
50
49
  }
51
50
  }
52
51
  exports.PluginMetadataPrinter = PluginMetadataPrinter;
@@ -142,6 +142,12 @@ class SwcCompiler extends base_compiler_1.BaseCompiler {
142
142
  source === null) {
143
143
  return source;
144
144
  }
145
+ if (Array.isArray(target) && Array.isArray(source)) {
146
+ return source.reduce((acc, value, index) => {
147
+ acc[index] = this.deepMerge(target[index], value);
148
+ return acc;
149
+ }, target);
150
+ }
145
151
  const merged = { ...target };
146
152
  for (const key in source) {
147
153
  if (source.hasOwnProperty(key)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/cli",
3
- "version": "10.1.6",
3
+ "version": "10.1.8",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -67,23 +67,23 @@
67
67
  "@swc/cli": "0.1.62",
68
68
  "@swc/core": "1.3.68",
69
69
  "@types/inquirer": "8.2.6",
70
- "@types/jest": "29.5.2",
70
+ "@types/jest": "29.5.3",
71
71
  "@types/node": "18.16.19",
72
72
  "@types/node-emoji": "1.8.2",
73
73
  "@types/shelljs": "0.8.12",
74
74
  "@types/webpack-node-externals": "3.0.0",
75
- "@typescript-eslint/eslint-plugin": "5.61.0",
76
- "@typescript-eslint/parser": "5.61.0",
75
+ "@typescript-eslint/eslint-plugin": "6.0.0",
76
+ "@typescript-eslint/parser": "6.0.0",
77
77
  "delete-empty": "3.0.0",
78
78
  "eslint": "8.44.0",
79
79
  "eslint-config-prettier": "8.8.0",
80
80
  "gulp": "4.0.2",
81
81
  "gulp-clean": "0.4.0",
82
82
  "husky": "8.0.3",
83
- "jest": "29.6.0",
83
+ "jest": "29.6.1",
84
84
  "lint-staged": "13.2.3",
85
- "prettier": "2.8.8",
86
- "release-it": "15.11.0",
85
+ "prettier": "3.0.0",
86
+ "release-it": "16.1.0",
87
87
  "ts-jest": "29.1.1",
88
88
  "ts-loader": "9.4.4"
89
89
  },