@nx/nest 16.8.0-beta.4 → 16.8.0-beta.6
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/package.json +7 -7
- package/src/generators/application/application.js +17 -19
- package/src/generators/application/lib/normalize-options.js +19 -16
- package/src/generators/application/lib/update-tsconfig.js +8 -1
- package/src/generators/class/class.js +5 -1
- package/src/generators/controller/controller.js +7 -1
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +94 -97
- package/src/generators/decorator/decorator.js +4 -1
- package/src/generators/filter/filter.js +5 -1
- package/src/generators/gateway/gateway.js +5 -1
- package/src/generators/guard/guard.js +5 -1
- package/src/generators/init/init.js +15 -15
- package/src/generators/init/lib/normalize-options.js +4 -2
- package/src/generators/interceptor/interceptor.js +5 -1
- package/src/generators/library/lib/create-files.js +7 -1
- package/src/generators/library/lib/normalize-options.js +33 -24
- package/src/generators/library/lib/update-tsconfig.js +8 -1
- package/src/generators/library/library.js +17 -19
- package/src/generators/middleware/middleware.js +5 -1
- package/src/generators/module/module.js +6 -1
- package/src/generators/pipe/pipe.js +5 -1
- package/src/generators/provider/provider.js +5 -1
- package/src/generators/resolver/resolver.js +5 -1
- package/src/generators/resource/resource.js +5 -1
- package/src/generators/service/service.js +5 -1
- package/src/generators/utils/normalize-options.js +8 -1
- package/src/generators/utils/run-nest-schematic.js +9 -12
- package/src/migrations/update-13-2-0/update-to-nest-8.js +37 -33
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-4-0-cache-manager/nestjs-10-updates.js +33 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/nest",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.0-beta.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Nest contains executors and generators for allowing your workspace to create powerful Nest best in class APIs.",
|
|
6
6
|
"repository": {
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@nestjs/schematics": "^9.1.0",
|
|
34
|
-
"@nrwl/nest": "16.8.0-beta.
|
|
35
|
-
"@nx/devkit": "16.8.0-beta.
|
|
36
|
-
"@nx/js": "16.8.0-beta.
|
|
37
|
-
"@nx/linter": "16.8.0-beta.
|
|
38
|
-
"@nx/node": "16.8.0-beta.
|
|
34
|
+
"@nrwl/nest": "16.8.0-beta.6",
|
|
35
|
+
"@nx/devkit": "16.8.0-beta.6",
|
|
36
|
+
"@nx/js": "16.8.0-beta.6",
|
|
37
|
+
"@nx/linter": "16.8.0-beta.6",
|
|
38
|
+
"@nx/node": "16.8.0-beta.6",
|
|
39
39
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
40
40
|
"enquirer": "~2.3.6",
|
|
41
41
|
"semver": "7.5.3",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"type": "commonjs",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "0cc6ba996f2ef09f00b932c8eacf42de642457f3"
|
|
49
49
|
}
|
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.applicationSchematic = exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const node_1 = require("@nx/node");
|
|
7
6
|
const init_1 = require("../init/init");
|
|
8
7
|
const lib_1 = require("./lib");
|
|
9
|
-
function applicationGenerator(tree, rawOptions) {
|
|
10
|
-
return
|
|
11
|
-
|
|
8
|
+
async function applicationGenerator(tree, rawOptions) {
|
|
9
|
+
return await applicationGeneratorInternal(tree, {
|
|
10
|
+
projectNameAndRootFormat: 'derived',
|
|
11
|
+
...rawOptions,
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
exports.applicationGenerator = applicationGenerator;
|
|
15
|
-
function applicationGeneratorInternal(tree, rawOptions) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
skipFormat: true,
|
|
22
|
-
});
|
|
23
|
-
const nodeApplicationTask = yield (0, node_1.applicationGenerator)(tree, (0, lib_1.toNodeApplicationGeneratorOptions)(options));
|
|
24
|
-
(0, lib_1.createFiles)(tree, options);
|
|
25
|
-
(0, lib_1.updateTsConfig)(tree, options);
|
|
26
|
-
if (!options.skipFormat) {
|
|
27
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
28
|
-
}
|
|
29
|
-
return (0, devkit_1.runTasksInSerial)(initTask, nodeApplicationTask);
|
|
15
|
+
async function applicationGeneratorInternal(tree, rawOptions) {
|
|
16
|
+
const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
17
|
+
const initTask = await (0, init_1.initGenerator)(tree, {
|
|
18
|
+
skipPackageJson: options.skipPackageJson,
|
|
19
|
+
unitTestRunner: options.unitTestRunner,
|
|
20
|
+
skipFormat: true,
|
|
30
21
|
});
|
|
22
|
+
const nodeApplicationTask = await (0, node_1.applicationGenerator)(tree, (0, lib_1.toNodeApplicationGeneratorOptions)(options));
|
|
23
|
+
(0, lib_1.createFiles)(tree, options);
|
|
24
|
+
(0, lib_1.updateTsConfig)(tree, options);
|
|
25
|
+
if (!options.skipFormat) {
|
|
26
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
27
|
+
}
|
|
28
|
+
return (0, devkit_1.runTasksInSerial)(initTask, nodeApplicationTask);
|
|
31
29
|
}
|
|
32
30
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
33
31
|
exports.default = applicationGenerator;
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toNodeApplicationGeneratorOptions = exports.normalizeOptions = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
5
|
const linter_1 = require("@nx/linter");
|
|
7
|
-
function normalizeOptions(tree, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
rootProject: options.rootProject,
|
|
16
|
-
callingGenerator: '@nx/nest:application',
|
|
17
|
-
});
|
|
18
|
-
options.rootProject = appProjectRoot === '.';
|
|
19
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
20
|
-
return Object.assign(Object.assign({}, options), { strict: (_a = options.strict) !== null && _a !== void 0 ? _a : false, appProjectName,
|
|
21
|
-
appProjectRoot, linter: (_b = options.linter) !== null && _b !== void 0 ? _b : linter_1.Linter.EsLint, unitTestRunner: (_c = options.unitTestRunner) !== null && _c !== void 0 ? _c : 'jest', e2eTestRunner: (_d = options.e2eTestRunner) !== null && _d !== void 0 ? _d : 'jest' });
|
|
6
|
+
async function normalizeOptions(tree, options) {
|
|
7
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
8
|
+
name: options.name,
|
|
9
|
+
projectType: 'application',
|
|
10
|
+
directory: options.directory,
|
|
11
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
12
|
+
rootProject: options.rootProject,
|
|
13
|
+
callingGenerator: '@nx/nest:application',
|
|
22
14
|
});
|
|
15
|
+
options.rootProject = appProjectRoot === '.';
|
|
16
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
17
|
+
return {
|
|
18
|
+
...options,
|
|
19
|
+
strict: options.strict ?? false,
|
|
20
|
+
appProjectName,
|
|
21
|
+
appProjectRoot,
|
|
22
|
+
linter: options.linter ?? linter_1.Linter.EsLint,
|
|
23
|
+
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
24
|
+
e2eTestRunner: options.e2eTestRunner ?? 'jest',
|
|
25
|
+
};
|
|
23
26
|
}
|
|
24
27
|
exports.normalizeOptions = normalizeOptions;
|
|
25
28
|
function toNodeApplicationGeneratorOptions(options) {
|
|
@@ -7,7 +7,14 @@ function updateTsConfig(tree, options) {
|
|
|
7
7
|
json.compilerOptions.emitDecoratorMetadata = true;
|
|
8
8
|
json.compilerOptions.target = 'es2021';
|
|
9
9
|
if (options.strict) {
|
|
10
|
-
json.compilerOptions =
|
|
10
|
+
json.compilerOptions = {
|
|
11
|
+
...json.compilerOptions,
|
|
12
|
+
strictNullChecks: true,
|
|
13
|
+
noImplicitAny: true,
|
|
14
|
+
strictBindCallApply: true,
|
|
15
|
+
forceConsistentCasingInFileNames: true,
|
|
16
|
+
noFallthroughCasesInSwitch: true,
|
|
17
|
+
};
|
|
11
18
|
}
|
|
12
19
|
return json;
|
|
13
20
|
});
|
|
@@ -11,5 +11,9 @@ exports.classGenerator = classGenerator;
|
|
|
11
11
|
exports.default = classGenerator;
|
|
12
12
|
exports.classSchematic = (0, devkit_1.convertNxGenerator)(classGenerator);
|
|
13
13
|
function normalizeClassOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -11,5 +11,11 @@ exports.controllerGenerator = controllerGenerator;
|
|
|
11
11
|
exports.default = controllerGenerator;
|
|
12
12
|
exports.controllerSchematic = (0, devkit_1.convertNxGenerator)(controllerGenerator);
|
|
13
13
|
function normalizeControllerOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
module: options.module,
|
|
18
|
+
skipImport: options.skipImport,
|
|
19
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
20
|
+
};
|
|
15
21
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.conversionSchematic = exports.conversionGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const linter_1 = require("@nx/linter");
|
|
7
6
|
const application_1 = require("@nx/node/src/generators/application/application");
|
|
@@ -9,103 +8,101 @@ const library_1 = require("@nx/js/src/generators/library/library");
|
|
|
9
8
|
/**
|
|
10
9
|
* @deprecated This generator will be removed in v17
|
|
11
10
|
*/
|
|
12
|
-
function conversionGenerator(host, options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}),
|
|
61
|
-
});
|
|
62
|
-
/**
|
|
63
|
-
* If root eslint configuration already exists it will not be recreated
|
|
64
|
-
* but we also don't want to re-run the tslint config conversion
|
|
65
|
-
* as it was likely already done
|
|
66
|
-
*/
|
|
67
|
-
const rootEslintConfigExists = host.exists('.eslintrc.json');
|
|
68
|
-
/**
|
|
69
|
-
* Create the standard (which is applicable to the current package) ESLint setup
|
|
70
|
-
* for converting the project.
|
|
71
|
-
*/
|
|
72
|
-
const eslintInitInstallTask = yield projectConverter.initESLint();
|
|
73
|
-
/**
|
|
74
|
-
* Convert the root tslint.json and apply the converted rules to the root .eslintrc.json.
|
|
75
|
-
*/
|
|
76
|
-
const rootConfigInstallTask = yield projectConverter.convertRootTSLintConfig((json) => removeCodelyzerRelatedRules(json), rootEslintConfigExists);
|
|
77
|
-
/**
|
|
78
|
-
* Convert the project's tslint.json to an equivalent ESLint config.
|
|
79
|
-
*/
|
|
80
|
-
const projectConfigInstallTask = yield projectConverter.convertProjectConfig((json) => json);
|
|
81
|
-
/**
|
|
82
|
-
* Clean up the original TSLint configuration for the project.
|
|
83
|
-
*/
|
|
84
|
-
projectConverter.removeProjectTSLintFile();
|
|
85
|
-
// Only project shouldn't be added as a default
|
|
86
|
-
const { project } = options, defaults = tslib_1.__rest(options, ["project"]);
|
|
87
|
-
/**
|
|
88
|
-
* Store user preferences for the collection
|
|
89
|
-
*/
|
|
90
|
-
projectConverter.setDefaults('@nx/nest', defaults);
|
|
91
|
-
/**
|
|
92
|
-
* Based on user preference and remaining usage, remove TSLint from the workspace entirely.
|
|
93
|
-
*/
|
|
94
|
-
let uninstallTSLintTask = () => Promise.resolve(undefined);
|
|
95
|
-
if (options.removeTSLintIfNoMoreTSLintTargets &&
|
|
96
|
-
!projectConverter.isTSLintUsedInWorkspace()) {
|
|
97
|
-
uninstallTSLintTask = projectConverter.removeTSLintFromWorkspace();
|
|
98
|
-
}
|
|
99
|
-
if (!options.skipFormat) {
|
|
100
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
101
|
-
}
|
|
102
|
-
return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
yield eslintInitInstallTask();
|
|
104
|
-
yield rootConfigInstallTask();
|
|
105
|
-
yield projectConfigInstallTask();
|
|
106
|
-
yield uninstallTSLintTask();
|
|
107
|
-
});
|
|
11
|
+
async function conversionGenerator(host, options) {
|
|
12
|
+
/**
|
|
13
|
+
* The ProjectConverter instance encapsulates all the standard operations we need
|
|
14
|
+
* to perform in order to convert a project from TSLint to ESLint, as well as some
|
|
15
|
+
* extensibility points for adjusting the behavior on a per package basis.
|
|
16
|
+
*
|
|
17
|
+
* E.g. @nx/angular projects might need to make different changes to the final
|
|
18
|
+
* ESLint config when compared with @nx/nest projects.
|
|
19
|
+
*
|
|
20
|
+
* See the ProjectConverter implementation for a full breakdown of what it does.
|
|
21
|
+
*/
|
|
22
|
+
const projectConverter = new linter_1.ProjectConverter({
|
|
23
|
+
host,
|
|
24
|
+
projectName: options.project,
|
|
25
|
+
ignoreExistingTslintConfig: options.ignoreExistingTslintConfig,
|
|
26
|
+
eslintInitializer: async ({ projectName, projectConfig }) => {
|
|
27
|
+
/**
|
|
28
|
+
* Using .js is not an option with NestJS, so we always set it to false when
|
|
29
|
+
* delegating to the external (more generic) generators below.
|
|
30
|
+
*/
|
|
31
|
+
const js = false;
|
|
32
|
+
/**
|
|
33
|
+
* We set the parserOptions.project config just in case the converted config uses
|
|
34
|
+
* rules which require type-checking. Later in the conversion we check if it actually
|
|
35
|
+
* does and remove the config again if it doesn't, so that it is most efficient.
|
|
36
|
+
*/
|
|
37
|
+
const setParserOptionsProject = true;
|
|
38
|
+
if (projectConfig.projectType === 'application') {
|
|
39
|
+
await (0, application_1.addLintingToApplication)(host, {
|
|
40
|
+
linter: 'eslint',
|
|
41
|
+
name: projectName,
|
|
42
|
+
appProjectRoot: projectConfig.root,
|
|
43
|
+
js,
|
|
44
|
+
setParserOptionsProject,
|
|
45
|
+
parsedTags: [],
|
|
46
|
+
skipFormat: options.skipFormat,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (projectConfig.projectType === 'library') {
|
|
50
|
+
await (0, library_1.addLint)(host, {
|
|
51
|
+
linter: 'eslint',
|
|
52
|
+
name: projectName,
|
|
53
|
+
projectRoot: projectConfig.root,
|
|
54
|
+
js,
|
|
55
|
+
setParserOptionsProject,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
108
59
|
});
|
|
60
|
+
/**
|
|
61
|
+
* If root eslint configuration already exists it will not be recreated
|
|
62
|
+
* but we also don't want to re-run the tslint config conversion
|
|
63
|
+
* as it was likely already done
|
|
64
|
+
*/
|
|
65
|
+
const rootEslintConfigExists = host.exists('.eslintrc.json');
|
|
66
|
+
/**
|
|
67
|
+
* Create the standard (which is applicable to the current package) ESLint setup
|
|
68
|
+
* for converting the project.
|
|
69
|
+
*/
|
|
70
|
+
const eslintInitInstallTask = await projectConverter.initESLint();
|
|
71
|
+
/**
|
|
72
|
+
* Convert the root tslint.json and apply the converted rules to the root .eslintrc.json.
|
|
73
|
+
*/
|
|
74
|
+
const rootConfigInstallTask = await projectConverter.convertRootTSLintConfig((json) => removeCodelyzerRelatedRules(json), rootEslintConfigExists);
|
|
75
|
+
/**
|
|
76
|
+
* Convert the project's tslint.json to an equivalent ESLint config.
|
|
77
|
+
*/
|
|
78
|
+
const projectConfigInstallTask = await projectConverter.convertProjectConfig((json) => json);
|
|
79
|
+
/**
|
|
80
|
+
* Clean up the original TSLint configuration for the project.
|
|
81
|
+
*/
|
|
82
|
+
projectConverter.removeProjectTSLintFile();
|
|
83
|
+
// Only project shouldn't be added as a default
|
|
84
|
+
const { project, ...defaults } = options;
|
|
85
|
+
/**
|
|
86
|
+
* Store user preferences for the collection
|
|
87
|
+
*/
|
|
88
|
+
projectConverter.setDefaults('@nx/nest', defaults);
|
|
89
|
+
/**
|
|
90
|
+
* Based on user preference and remaining usage, remove TSLint from the workspace entirely.
|
|
91
|
+
*/
|
|
92
|
+
let uninstallTSLintTask = () => Promise.resolve(undefined);
|
|
93
|
+
if (options.removeTSLintIfNoMoreTSLintTargets &&
|
|
94
|
+
!projectConverter.isTSLintUsedInWorkspace()) {
|
|
95
|
+
uninstallTSLintTask = projectConverter.removeTSLintFromWorkspace();
|
|
96
|
+
}
|
|
97
|
+
if (!options.skipFormat) {
|
|
98
|
+
await (0, devkit_1.formatFiles)(host);
|
|
99
|
+
}
|
|
100
|
+
return async () => {
|
|
101
|
+
await eslintInitInstallTask();
|
|
102
|
+
await rootConfigInstallTask();
|
|
103
|
+
await projectConfigInstallTask();
|
|
104
|
+
await uninstallTSLintTask();
|
|
105
|
+
};
|
|
109
106
|
}
|
|
110
107
|
exports.conversionGenerator = conversionGenerator;
|
|
111
108
|
exports.conversionSchematic = (0, devkit_1.convertNxGenerator)(conversionGenerator);
|
|
@@ -11,5 +11,8 @@ exports.decoratorGenerator = decoratorGenerator;
|
|
|
11
11
|
exports.default = decoratorGenerator;
|
|
12
12
|
exports.decoratorSchematic = (0, devkit_1.convertNxGenerator)(decoratorGenerator);
|
|
13
13
|
function normalizeDecoratorOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
};
|
|
15
18
|
}
|
|
@@ -11,5 +11,9 @@ exports.filterGenerator = filterGenerator;
|
|
|
11
11
|
exports.default = filterGenerator;
|
|
12
12
|
exports.filterSchematic = (0, devkit_1.convertNxGenerator)(filterGenerator);
|
|
13
13
|
function normalizeFilterOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -11,5 +11,9 @@ exports.gatewayGenerator = gatewayGenerator;
|
|
|
11
11
|
exports.default = gatewayGenerator;
|
|
12
12
|
exports.gatewaySchematic = (0, devkit_1.convertNxGenerator)(gatewayGenerator);
|
|
13
13
|
function normalizeGatewayOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -11,5 +11,9 @@ exports.guardGenerator = guardGenerator;
|
|
|
11
11
|
exports.default = guardGenerator;
|
|
12
12
|
exports.guardSchematic = (0, devkit_1.convertNxGenerator)(guardGenerator);
|
|
13
13
|
function normalizeGuardOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initSchematic = exports.initGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const node_1 = require("@nx/node");
|
|
7
6
|
const lib_1 = require("./lib");
|
|
8
|
-
function initGenerator(tree, rawOptions) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (!options.skipPackageJson) {
|
|
15
|
-
const installPackagesTask = (0, lib_1.addDependencies)(tree);
|
|
16
|
-
tasks.push(installPackagesTask);
|
|
17
|
-
}
|
|
18
|
-
if (!options.skipFormat) {
|
|
19
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
20
|
-
}
|
|
21
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
7
|
+
async function initGenerator(tree, rawOptions) {
|
|
8
|
+
const options = (0, lib_1.normalizeOptions)(rawOptions);
|
|
9
|
+
const tasks = [];
|
|
10
|
+
const nodeInitTask = await (0, node_1.initGenerator)(tree, {
|
|
11
|
+
...options,
|
|
12
|
+
skipFormat: true,
|
|
22
13
|
});
|
|
14
|
+
tasks.push(nodeInitTask);
|
|
15
|
+
if (!options.skipPackageJson) {
|
|
16
|
+
const installPackagesTask = (0, lib_1.addDependencies)(tree);
|
|
17
|
+
tasks.push(installPackagesTask);
|
|
18
|
+
}
|
|
19
|
+
if (!options.skipFormat) {
|
|
20
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
21
|
+
}
|
|
22
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
23
23
|
}
|
|
24
24
|
exports.initGenerator = initGenerator;
|
|
25
25
|
exports.default = initGenerator;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
4
|
function normalizeOptions(options) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
return {
|
|
6
|
+
...options,
|
|
7
|
+
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
8
|
+
};
|
|
7
9
|
}
|
|
8
10
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -11,5 +11,9 @@ exports.interceptorGenerator = interceptorGenerator;
|
|
|
11
11
|
exports.default = interceptorGenerator;
|
|
12
12
|
exports.interceptorSchematic = (0, devkit_1.convertNxGenerator)(interceptorGenerator);
|
|
13
13
|
function normalizeInterceptorOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -3,7 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createFiles = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function createFiles(tree, options) {
|
|
6
|
-
const substitutions =
|
|
6
|
+
const substitutions = {
|
|
7
|
+
...options,
|
|
8
|
+
...(0, devkit_1.names)(options.projectName),
|
|
9
|
+
tmpl: '',
|
|
10
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
11
|
+
fileName: options.fileName,
|
|
12
|
+
};
|
|
7
13
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files', 'common'), options.projectRoot, substitutions);
|
|
8
14
|
if (options.controller) {
|
|
9
15
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files', 'controller'), options.projectRoot, substitutions);
|
|
@@ -1,39 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toJsLibraryGeneratorOptions = exports.normalizeOptions = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
5
|
const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
|
|
7
6
|
const linter_1 = require("@nx/linter");
|
|
8
|
-
function normalizeOptions(tree, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
17
|
-
callingGenerator: '@nx/nest:library',
|
|
18
|
-
});
|
|
19
|
-
const fileName = options.simpleName
|
|
20
|
-
? projectNames.projectSimpleName
|
|
21
|
-
: projectNames.projectFileName;
|
|
22
|
-
const parsedTags = options.tags
|
|
23
|
-
? options.tags.split(',').map((s) => s.trim())
|
|
24
|
-
: [];
|
|
25
|
-
const normalized = Object.assign(Object.assign({}, options), { strict: (_a = options.strict) !== null && _a !== void 0 ? _a : true, controller: (_b = options.controller) !== null && _b !== void 0 ? _b : false, fileName, global: (_c = options.global) !== null && _c !== void 0 ? _c : false, linter: (_d = options.linter) !== null && _d !== void 0 ? _d : linter_1.Linter.EsLint, parsedTags, prefix: (0, get_npm_scope_1.getNpmScope)(tree), // we could also allow customizing this
|
|
26
|
-
projectName,
|
|
27
|
-
projectRoot,
|
|
28
|
-
importPath, service: (_e = options.service) !== null && _e !== void 0 ? _e : false, target: (_f = options.target) !== null && _f !== void 0 ? _f : 'es6', testEnvironment: (_g = options.testEnvironment) !== null && _g !== void 0 ? _g : 'node', unitTestRunner: (_h = options.unitTestRunner) !== null && _h !== void 0 ? _h : 'jest' });
|
|
29
|
-
return normalized;
|
|
7
|
+
async function normalizeOptions(tree, options) {
|
|
8
|
+
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
9
|
+
name: options.name,
|
|
10
|
+
projectType: 'library',
|
|
11
|
+
directory: options.directory,
|
|
12
|
+
importPath: options.importPath,
|
|
13
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
14
|
+
callingGenerator: '@nx/nest:library',
|
|
30
15
|
});
|
|
16
|
+
const fileName = options.simpleName
|
|
17
|
+
? projectNames.projectSimpleName
|
|
18
|
+
: projectNames.projectFileName;
|
|
19
|
+
const parsedTags = options.tags
|
|
20
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
21
|
+
: [];
|
|
22
|
+
const normalized = {
|
|
23
|
+
...options,
|
|
24
|
+
strict: options.strict ?? true,
|
|
25
|
+
controller: options.controller ?? false,
|
|
26
|
+
fileName,
|
|
27
|
+
global: options.global ?? false,
|
|
28
|
+
linter: options.linter ?? linter_1.Linter.EsLint,
|
|
29
|
+
parsedTags,
|
|
30
|
+
prefix: (0, get_npm_scope_1.getNpmScope)(tree),
|
|
31
|
+
projectName,
|
|
32
|
+
projectRoot,
|
|
33
|
+
importPath,
|
|
34
|
+
service: options.service ?? false,
|
|
35
|
+
target: options.target ?? 'es6',
|
|
36
|
+
testEnvironment: options.testEnvironment ?? 'node',
|
|
37
|
+
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
38
|
+
};
|
|
39
|
+
return normalized;
|
|
31
40
|
}
|
|
32
41
|
exports.normalizeOptions = normalizeOptions;
|
|
33
42
|
function toJsLibraryGeneratorOptions(options) {
|
|
34
43
|
return {
|
|
35
44
|
name: options.name,
|
|
36
|
-
bundler:
|
|
45
|
+
bundler: options?.buildable ? 'tsc' : 'none',
|
|
37
46
|
directory: options.directory,
|
|
38
47
|
importPath: options.importPath,
|
|
39
48
|
linter: options.linter,
|
|
@@ -7,7 +7,14 @@ function updateTsConfig(tree, options) {
|
|
|
7
7
|
return (0, devkit_1.updateJson)(tree, `${project.root}/tsconfig.lib.json`, (json) => {
|
|
8
8
|
json.compilerOptions.target = options.target;
|
|
9
9
|
if (options.strict) {
|
|
10
|
-
json.compilerOptions =
|
|
10
|
+
json.compilerOptions = {
|
|
11
|
+
...json.compilerOptions,
|
|
12
|
+
strictNullChecks: true,
|
|
13
|
+
noImplicitAny: true,
|
|
14
|
+
strictBindCallApply: true,
|
|
15
|
+
forceConsistentCasingInFileNames: true,
|
|
16
|
+
noFallthroughCasesInSwitch: true,
|
|
17
|
+
};
|
|
11
18
|
}
|
|
12
19
|
return json;
|
|
13
20
|
});
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.librarySchematic = exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const js_1 = require("@nx/js");
|
|
7
6
|
const lib_1 = require("../init/lib");
|
|
8
7
|
const lib_2 = require("./lib");
|
|
9
|
-
function libraryGenerator(tree, rawOptions) {
|
|
10
|
-
return
|
|
11
|
-
|
|
8
|
+
async function libraryGenerator(tree, rawOptions) {
|
|
9
|
+
return await libraryGeneratorInternal(tree, {
|
|
10
|
+
projectNameAndRootFormat: 'derived',
|
|
11
|
+
...rawOptions,
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
exports.libraryGenerator = libraryGenerator;
|
|
15
|
-
function libraryGeneratorInternal(tree, rawOptions) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return installDepsTask;
|
|
29
|
-
});
|
|
15
|
+
async function libraryGeneratorInternal(tree, rawOptions) {
|
|
16
|
+
const options = await (0, lib_2.normalizeOptions)(tree, rawOptions);
|
|
17
|
+
await (0, js_1.libraryGenerator)(tree, (0, lib_2.toJsLibraryGeneratorOptions)(options));
|
|
18
|
+
const installDepsTask = (0, lib_1.addDependencies)(tree);
|
|
19
|
+
(0, lib_2.deleteFiles)(tree, options);
|
|
20
|
+
(0, lib_2.createFiles)(tree, options);
|
|
21
|
+
(0, lib_2.addExportsToBarrelFile)(tree, options);
|
|
22
|
+
(0, lib_2.updateTsConfig)(tree, options);
|
|
23
|
+
(0, lib_2.addProject)(tree, options);
|
|
24
|
+
if (!options.skipFormat) {
|
|
25
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
26
|
+
}
|
|
27
|
+
return installDepsTask;
|
|
30
28
|
}
|
|
31
29
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
32
30
|
exports.default = libraryGenerator;
|
|
@@ -11,5 +11,9 @@ exports.middlewareGenerator = middlewareGenerator;
|
|
|
11
11
|
exports.default = middlewareGenerator;
|
|
12
12
|
exports.middlewareSchematic = (0, devkit_1.convertNxGenerator)(middlewareGenerator);
|
|
13
13
|
function normalizeMiddlewareOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -11,5 +11,10 @@ exports.moduleGenerator = moduleGenerator;
|
|
|
11
11
|
exports.default = moduleGenerator;
|
|
12
12
|
exports.moduleSchematic = (0, devkit_1.convertNxGenerator)(moduleGenerator);
|
|
13
13
|
function normalizeModuleOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
module: options.module,
|
|
18
|
+
skipImport: options.skipImport,
|
|
19
|
+
};
|
|
15
20
|
}
|
|
@@ -11,5 +11,9 @@ exports.pipeGenerator = pipeGenerator;
|
|
|
11
11
|
exports.default = pipeGenerator;
|
|
12
12
|
exports.pipeSchematic = (0, devkit_1.convertNxGenerator)(pipeGenerator);
|
|
13
13
|
function normalizePipeOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -11,5 +11,9 @@ exports.providerGenerator = providerGenerator;
|
|
|
11
11
|
exports.default = providerGenerator;
|
|
12
12
|
exports.providerSchematic = (0, devkit_1.convertNxGenerator)(providerGenerator);
|
|
13
13
|
function normalizeProviderOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -11,5 +11,9 @@ exports.resolverGenerator = resolverGenerator;
|
|
|
11
11
|
exports.default = resolverGenerator;
|
|
12
12
|
exports.resolverSchematic = (0, devkit_1.convertNxGenerator)(resolverGenerator);
|
|
13
13
|
function normalizeResolverOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -11,5 +11,9 @@ exports.resourceGenerator = resourceGenerator;
|
|
|
11
11
|
exports.default = resourceGenerator;
|
|
12
12
|
exports.resourceSchematic = (0, devkit_1.convertNxGenerator)(resourceGenerator);
|
|
13
13
|
function normalizeResourceOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -11,5 +11,9 @@ exports.serviceGenerator = serviceGenerator;
|
|
|
11
11
|
exports.default = serviceGenerator;
|
|
12
12
|
exports.serviceSchematic = (0, devkit_1.convertNxGenerator)(serviceGenerator);
|
|
13
13
|
function normalizeServiceOptions(tree, options) {
|
|
14
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...(0, utils_1.normalizeOptions)(tree, options),
|
|
16
|
+
language: options.language,
|
|
17
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
18
|
+
};
|
|
15
19
|
}
|
|
@@ -4,7 +4,14 @@ exports.unitTestRunnerToSpec = exports.normalizeOptions = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function normalizeOptions(tree, options) {
|
|
6
6
|
const { sourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
7
|
-
const normalizedOptions =
|
|
7
|
+
const normalizedOptions = {
|
|
8
|
+
...options,
|
|
9
|
+
flat: options.flat,
|
|
10
|
+
name: (0, devkit_1.names)(options.name).fileName,
|
|
11
|
+
path: options.directory,
|
|
12
|
+
skipFormat: options.skipFormat,
|
|
13
|
+
sourceRoot,
|
|
14
|
+
};
|
|
8
15
|
return normalizedOptions;
|
|
9
16
|
}
|
|
10
17
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runNestSchematic = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function runNestSchematic(tree, schematic, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return result;
|
|
16
|
-
});
|
|
5
|
+
async function runNestSchematic(tree, schematic, options) {
|
|
6
|
+
const { skipFormat, ...schematicOptions } = options;
|
|
7
|
+
const { wrapAngularDevkitSchematic } = require('@nx/devkit/ngcli-adapter');
|
|
8
|
+
const nestSchematic = wrapAngularDevkitSchematic('@nestjs/schematics', schematic);
|
|
9
|
+
const result = await nestSchematic(tree, schematicOptions);
|
|
10
|
+
if (!skipFormat) {
|
|
11
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
17
14
|
}
|
|
18
15
|
exports.runNestSchematic = runNestSchematic;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const semver_1 = require("@nx/devkit/src/utils/semver");
|
|
6
5
|
const semver_2 = require("semver");
|
|
@@ -8,54 +7,59 @@ const object_sort_1 = require("nx/src/utils/object-sort");
|
|
|
8
7
|
const nestJsSchematicsVersion = '^9.0.0';
|
|
9
8
|
const nestJsVersion8 = '^8.0.0';
|
|
10
9
|
const rxjsVersion7 = '^7.0.0';
|
|
11
|
-
function update(tree) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
});
|
|
10
|
+
async function update(tree) {
|
|
11
|
+
const shouldUpdate = await isUpdatable(tree);
|
|
12
|
+
if (!shouldUpdate) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
updateVersion(tree);
|
|
16
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
17
|
+
return () => {
|
|
18
|
+
devkit_1.logger.info('Please make sure to run npm install or yarn install to get the latest packages added by this migration');
|
|
19
|
+
};
|
|
23
20
|
}
|
|
24
21
|
exports.default = update;
|
|
25
|
-
function isUpdatable(tree) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
const { Confirm } = require('enquirer');
|
|
34
|
-
const prompt = new Confirm({
|
|
35
|
-
name: 'question',
|
|
36
|
-
message: 'Do you want to update to RxJS 7 + Nest 8?',
|
|
37
|
-
initial: true,
|
|
38
|
-
});
|
|
39
|
-
return yield prompt.run();
|
|
22
|
+
async function isUpdatable(tree) {
|
|
23
|
+
const json = (0, devkit_1.readJson)(tree, 'package.json');
|
|
24
|
+
if (json.dependencies['@angular/core']) {
|
|
25
|
+
const rxjs = (0, semver_1.checkAndCleanWithSemver)('rxjs', json.dependencies['rxjs']);
|
|
26
|
+
if ((0, semver_2.satisfies)(rxjs, rxjsVersion7)) {
|
|
27
|
+
return true;
|
|
40
28
|
}
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
const { Confirm } = require('enquirer');
|
|
30
|
+
const prompt = new Confirm({
|
|
31
|
+
name: 'question',
|
|
32
|
+
message: 'Do you want to update to RxJS 7 + Nest 8?',
|
|
33
|
+
initial: true,
|
|
34
|
+
});
|
|
35
|
+
return await prompt.run();
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
43
38
|
}
|
|
44
39
|
function updateVersion(tree) {
|
|
45
40
|
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
46
41
|
json.dependencies = json.dependencies || {};
|
|
47
42
|
json.devDependencies = json.devDependencies || {};
|
|
48
43
|
const rxjs = (0, semver_1.checkAndCleanWithSemver)('rxjs', json.dependencies['rxjs']);
|
|
49
|
-
json.dependencies =
|
|
44
|
+
json.dependencies = {
|
|
45
|
+
...json.dependencies,
|
|
46
|
+
'@nestjs/common': nestJsVersion8,
|
|
47
|
+
'@nestjs/core': nestJsVersion8,
|
|
48
|
+
rxjs: (0, semver_2.satisfies)(rxjs, rxjsVersion7)
|
|
50
49
|
? json.dependencies['rxjs']
|
|
51
|
-
: rxjsVersion7
|
|
50
|
+
: rxjsVersion7,
|
|
51
|
+
};
|
|
52
52
|
if (json.dependencies['@nestjs/platform-express']) {
|
|
53
53
|
json.dependencies['@nestjs/platform-express'] = nestJsVersion8;
|
|
54
54
|
}
|
|
55
55
|
if (json.dependencies['@nestjs/platform-fastify']) {
|
|
56
56
|
json.dependencies['@nestjs/platform-fastify'] = nestJsVersion8;
|
|
57
57
|
}
|
|
58
|
-
json.devDependencies =
|
|
58
|
+
json.devDependencies = {
|
|
59
|
+
...json.devDependencies,
|
|
60
|
+
'@nestjs/schematics': nestJsSchematicsVersion,
|
|
61
|
+
'@nestjs/testing': nestJsVersion8,
|
|
62
|
+
};
|
|
59
63
|
if (json.devDependencies['jasmine-marbles']) {
|
|
60
64
|
json.devDependencies['jasmine-marbles'] = '~0.9.1';
|
|
61
65
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
-
function replacePackage(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
10
|
-
});
|
|
5
|
+
async function replacePackage(tree) {
|
|
6
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/nest', '@nx/nest');
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
8
|
}
|
|
12
9
|
exports.default = replacePackage;
|
|
@@ -1,54 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateTsConfigTarget = exports.updateCacheManagerImport = exports.updateNestJs10 = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
6
|
const typescript_1 = require("typescript");
|
|
8
7
|
const JS_TS_FILE_MATCHER = /\.[jt]sx?$/;
|
|
9
8
|
const importMatch = ':matches(ImportDeclaration, VariableStatement):has(Identifier[name="CacheModule"], Identifier[name="CacheModule"]):has(StringLiteral[value="@nestjs/common"])';
|
|
10
|
-
function updateNestJs10(tree) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const tsConfig = (_d = (_c = (_b = (_a = projectConfig.targets) === null || _a === void 0 ? void 0 : _a.build) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.tsConfig) !== null && _d !== void 0 ? _d : (0, devkit_1.joinPathFragments)(projectConfig.root, projectConfig.projectType === 'application'
|
|
9
|
+
async function updateNestJs10(tree) {
|
|
10
|
+
const nestProjects = await getNestProejcts();
|
|
11
|
+
if (nestProjects.length === 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
let installCacheModuleDeps = false;
|
|
15
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
16
|
+
for (const projectName of nestProjects) {
|
|
17
|
+
const projectConfig = projects.get(projectName);
|
|
18
|
+
const tsConfig = projectConfig.targets?.build?.options?.tsConfig ??
|
|
19
|
+
(0, devkit_1.joinPathFragments)(projectConfig.root, projectConfig.projectType === 'application'
|
|
22
20
|
? 'tsconfig.app.json'
|
|
23
21
|
: 'tsconfig.lib.json');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
|
|
28
|
-
if (!JS_TS_FILE_MATCHER.test(filePath)) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
installCacheModuleDeps =
|
|
32
|
-
updateCacheManagerImport(tree, filePath) || installCacheModuleDeps;
|
|
33
|
-
});
|
|
22
|
+
if (tree.exists(tsConfig)) {
|
|
23
|
+
updateTsConfigTarget(tree, tsConfig);
|
|
34
24
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
25
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
|
|
26
|
+
if (!JS_TS_FILE_MATCHER.test(filePath)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
installCacheModuleDeps =
|
|
30
|
+
updateCacheManagerImport(tree, filePath) || installCacheModuleDeps;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
34
|
+
return installCacheModuleDeps
|
|
35
|
+
? (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
36
|
+
'@nestjs/cache-manager': '^2.0.0',
|
|
37
|
+
'cache-manager': '^5.2.3',
|
|
38
|
+
}, {})
|
|
39
|
+
: () => { };
|
|
43
40
|
}
|
|
44
41
|
exports.updateNestJs10 = updateNestJs10;
|
|
45
|
-
function getNestProejcts() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.map(([projectName]) => projectName);
|
|
51
|
-
});
|
|
42
|
+
async function getNestProejcts() {
|
|
43
|
+
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
44
|
+
return Object.entries(projectGraph.dependencies)
|
|
45
|
+
.filter(([node, dep]) => dep.some(({ target }) => !projectGraph.externalNodes?.[node] && target === 'npm:@nestjs/common'))
|
|
46
|
+
.map(([projectName]) => projectName);
|
|
52
47
|
}
|
|
53
48
|
// change import { CacheModule } from '@nestjs/common';
|
|
54
49
|
// to import { CacheModule } from '@nestjs/cache-manager';
|