@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.
- package/lib/compiler/defaults/swc-defaults.d.ts +1 -0
- package/lib/compiler/defaults/swc-defaults.js +1 -0
- package/lib/compiler/plugins/plugin-metadata-generator.d.ts +2 -0
- package/lib/compiler/plugins/plugin-metadata-generator.js +2 -1
- package/lib/compiler/plugins/plugin-metadata-printer.d.ts +1 -1
- package/lib/compiler/plugins/plugin-metadata-printer.js +24 -25
- package/lib/compiler/swc/swc-compiler.js +6 -0
- package/package.json +7 -7
|
@@ -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 =
|
|
15
|
-
const exportAssignment =
|
|
16
|
-
this.createTypeImportVariableStatement(typeImports),
|
|
17
|
-
|
|
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 =
|
|
20
|
-
newLine:
|
|
18
|
+
const printer = tsBinary.createPrinter({
|
|
19
|
+
newLine: tsBinary.NewLineKind.LineFeed,
|
|
21
20
|
});
|
|
22
|
-
const resultFile =
|
|
23
|
-
/*setParentNodes*/ false,
|
|
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(
|
|
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
|
|
30
|
+
return tsBinary.factory.createPropertyAssignment(tsBinary.factory.createStringLiteral(identifier), tsBinary.factory.createArrayLiteralExpression(meta.map(([importExpr, meta]) => tsBinary.factory.createArrayLiteralExpression([
|
|
32
31
|
importExpr,
|
|
33
|
-
|
|
32
|
+
tsBinary.factory.createObjectLiteralExpression(Object.keys(meta).map((key) => this.recursivelyCreatePropertyAssignment(key, meta[key], tsBinary))),
|
|
34
33
|
]))));
|
|
35
34
|
}
|
|
36
|
-
return
|
|
35
|
+
return tsBinary.factory.createPropertyAssignment(tsBinary.factory.createStringLiteral(identifier), tsBinary.isObjectLiteralExpression(meta)
|
|
37
36
|
? meta
|
|
38
|
-
:
|
|
37
|
+
: tsBinary.factory.createObjectLiteralExpression(Object.keys(meta).map((key) => this.recursivelyCreatePropertyAssignment(key, meta[key], tsBinary))));
|
|
39
38
|
}
|
|
40
|
-
createTypeImportVariableStatement(typeImports) {
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
],
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
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.
|
|
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.
|
|
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": "
|
|
76
|
-
"@typescript-eslint/parser": "
|
|
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.
|
|
83
|
+
"jest": "29.6.1",
|
|
84
84
|
"lint-staged": "13.2.3",
|
|
85
|
-
"prettier": "
|
|
86
|
-
"release-it": "
|
|
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
|
},
|