@nx/nest 16.4.0-beta.9 → 16.4.0

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/migrations.json CHANGED
@@ -11,6 +11,12 @@
11
11
  "version": "16.0.0-beta.1",
12
12
  "description": "Replace @nrwl/nest with @nx/nest",
13
13
  "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
14
+ },
15
+ "update-16-4-0-support-nestjs-10": {
16
+ "cli": "nx",
17
+ "version": "16.4.0-beta.16",
18
+ "description": "Update TsConfig target to es2021 and CacheModule if being used. Read more at https://docs.nestjs.com/migration-guide",
19
+ "implementation": "./src/migrations/update-16-4-0-cache-manager/nestjs-10-updates"
14
20
  }
15
21
  },
16
22
  "packageJsonUpdates": {
@@ -71,6 +77,35 @@
71
77
  "alwaysAddToPackageJson": false
72
78
  }
73
79
  }
80
+ },
81
+ "16.4.0": {
82
+ "version": "16.4.0-beta.11",
83
+ "packages": {
84
+ "@nestjs/common": {
85
+ "version": "^10.0.2",
86
+ "alwaysAddToPackageJson": false
87
+ },
88
+ "@nestjs/core": {
89
+ "version": "^10.0.2",
90
+ "alwaysAddToPackageJson": false
91
+ },
92
+ "@nestjs/platform-express": {
93
+ "version": "^10.0.2",
94
+ "alwaysAddToPackageJson": false
95
+ },
96
+ "@nestjs/schematics": {
97
+ "version": "^10.0.1",
98
+ "alwaysAddToPackageJson": false
99
+ },
100
+ "@nestjs/swagger": {
101
+ "version": "^7.0.2",
102
+ "alwaysAddToPackageJson": false
103
+ },
104
+ "@nestjs/testing": {
105
+ "version": "^10.0.2",
106
+ "alwaysAddToPackageJson": false
107
+ }
108
+ }
74
109
  }
75
110
  }
76
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/nest",
3
- "version": "16.4.0-beta.9",
3
+ "version": "16.4.0",
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,16 +31,17 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@nestjs/schematics": "^9.1.0",
34
- "@nrwl/nest": "16.4.0-beta.9",
35
- "@nx/devkit": "16.4.0-beta.9",
36
- "@nx/js": "16.4.0-beta.9",
37
- "@nx/linter": "16.4.0-beta.9",
38
- "@nx/node": "16.4.0-beta.9",
34
+ "@nrwl/nest": "16.4.0",
35
+ "@nx/devkit": "16.4.0",
36
+ "@nx/js": "16.4.0",
37
+ "@nx/linter": "16.4.0",
38
+ "@nx/node": "16.4.0",
39
+ "@phenomnomnominal/tsquery": "~5.0.1",
39
40
  "enquirer": "~2.3.6"
40
41
  },
41
42
  "publishConfig": {
42
43
  "access": "public"
43
44
  },
44
45
  "types": "./index.d.ts",
45
- "gitHead": "b7fbc25d5be1789d42805e2254cf4a6070889157"
46
+ "gitHead": "ae698a72748d9f33aa5395aeeaa7b7af436a1dc5"
46
47
  }
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  function updateTsConfig(tree, options) {
6
6
  (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'), (json) => {
7
7
  json.compilerOptions.emitDecoratorMetadata = true;
8
- json.compilerOptions.target = 'es2015';
8
+ json.compilerOptions.target = 'es2021';
9
9
  if (options.strict) {
10
10
  json.compilerOptions = Object.assign(Object.assign({}, json.compilerOptions), { strictNullChecks: true, noImplicitAny: true, strictBindCallApply: true, forceConsistentCasingInFileNames: true, noFallthroughCasesInSwitch: true });
11
11
  }
@@ -24,7 +24,8 @@ export interface LibraryGeneratorOptions {
24
24
  | 'es2017'
25
25
  | 'es2018'
26
26
  | 'es2019'
27
- | 'es2020';
27
+ | 'es2020'
28
+ | 'es2021';
28
29
  testEnvironment?: 'jsdom' | 'node';
29
30
  unitTestRunner?: UnitTestRunner;
30
31
  standaloneConfig?: boolean;
@@ -92,9 +92,9 @@
92
92
  "default": "node"
93
93
  },
94
94
  "target": {
95
- "description": "The ES target, Nest suggest using es6 or higher.",
95
+ "description": "The ES target, Nest suggest using es2021 or higher.",
96
96
  "type": "string",
97
- "default": "es6",
97
+ "default": "es2021",
98
98
  "enum": [
99
99
  "es5",
100
100
  "es6",
@@ -104,7 +104,8 @@
104
104
  "es2017",
105
105
  "es2018",
106
106
  "es2019",
107
- "es2020"
107
+ "es2020",
108
+ "es2021"
108
109
  ]
109
110
  },
110
111
  "strict": {
@@ -0,0 +1,5 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function updateNestJs10(tree: Tree): Promise<import("@nx/devkit").GeneratorCallback>;
3
+ export declare function updateCacheManagerImport(tree: Tree, filePath: string): boolean;
4
+ export declare function updateTsConfigTarget(tree: Tree, tsConfigPath: string): void;
5
+ export default updateNestJs10;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateTsConfigTarget = exports.updateCacheManagerImport = exports.updateNestJs10 = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
7
+ const typescript_1 = require("typescript");
8
+ const JS_TS_FILE_MATCHER = /\.[jt]sx?$/;
9
+ const importMatch = ':matches(ImportDeclaration, VariableStatement):has(Identifier[name="CacheModule"], Identifier[name="CacheModule"]):has(StringLiteral[value="@nestjs/common"])';
10
+ function updateNestJs10(tree) {
11
+ var _a, _b, _c, _d;
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
+ const nestProjects = yield getNestProejcts();
14
+ if (nestProjects.length === 0) {
15
+ return;
16
+ }
17
+ let installCacheModuleDeps = false;
18
+ const projects = (0, devkit_1.getProjects)(tree);
19
+ for (const projectName of nestProjects) {
20
+ const projectConfig = projects.get(projectName);
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'
22
+ ? 'tsconfig.app.json'
23
+ : 'tsconfig.lib.json');
24
+ if (tree.exists(tsConfig)) {
25
+ updateTsConfigTarget(tree, tsConfig);
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
+ });
34
+ }
35
+ yield (0, devkit_1.formatFiles)(tree);
36
+ return installCacheModuleDeps
37
+ ? (0, devkit_1.addDependenciesToPackageJson)(tree, {
38
+ '@nestjs/cache-manager': '^2.0.0',
39
+ 'cache-manager': '^5.2.3',
40
+ }, {})
41
+ : () => { };
42
+ });
43
+ }
44
+ exports.updateNestJs10 = updateNestJs10;
45
+ function getNestProejcts() {
46
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
47
+ const projectGraph = yield (0, devkit_1.createProjectGraphAsync)();
48
+ return Object.entries(projectGraph.dependencies)
49
+ .filter(([node, dep]) => dep.some(({ target }) => { var _a; return !((_a = projectGraph.externalNodes) === null || _a === void 0 ? void 0 : _a[node]) && target === 'npm:@nestjs/common'; }))
50
+ .map(([projectName]) => projectName);
51
+ });
52
+ }
53
+ // change import { CacheModule } from '@nestjs/common';
54
+ // to import { CacheModule } from '@nestjs/cache-manager';
55
+ function updateCacheManagerImport(tree, filePath) {
56
+ const content = tree.read(filePath, 'utf-8');
57
+ const updated = tsquery_1.tsquery.replace(content, importMatch, (node) => {
58
+ const text = node.getText();
59
+ return `${text.replace('CacheModule', '')}\n${(0, typescript_1.isVariableStatement)(node)
60
+ ? "const { CacheModule } = require('@nestjs/cache-manager')"
61
+ : "import { CacheModule } from '@nestjs/cache-manager';"}`;
62
+ });
63
+ if (updated !== content) {
64
+ tree.write(filePath, updated);
65
+ return true;
66
+ }
67
+ }
68
+ exports.updateCacheManagerImport = updateCacheManagerImport;
69
+ function updateTsConfigTarget(tree, tsConfigPath) {
70
+ (0, devkit_1.updateJson)(tree, tsConfigPath, (json) => {
71
+ if (!json.compilerOptions.target) {
72
+ return;
73
+ }
74
+ const normalizedTargetName = json.compilerOptions.target.toUpperCase();
75
+ // es6 isn't apart of the ScriptTarget enum but is a valid tsconfig target in json file
76
+ const existingTarget = normalizedTargetName === 'ES6'
77
+ ? typescript_1.ScriptTarget.ES2015
78
+ : typescript_1.ScriptTarget[normalizedTargetName];
79
+ if (existingTarget < typescript_1.ScriptTarget.ES2021) {
80
+ json.compilerOptions.target = 'es2021';
81
+ }
82
+ return json;
83
+ });
84
+ }
85
+ exports.updateTsConfigTarget = updateTsConfigTarget;
86
+ exports.default = updateNestJs10;
@@ -1,6 +1,6 @@
1
1
  export declare const nxVersion: any;
2
- export declare const nestJsVersion = "^9.1.1";
3
- export declare const nestJsSchematicsVersion = "^9.1.0";
2
+ export declare const nestJsVersion = "^10.0.2";
3
+ export declare const nestJsSchematicsVersion = "^10.0.1";
4
4
  export declare const rxjsVersion = "^7.8.0";
5
5
  export declare const reflectMetadataVersion = "^0.1.13";
6
6
  export declare const tsLibVersion = "^2.3.0";
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tsLibVersion = exports.reflectMetadataVersion = exports.rxjsVersion = exports.nestJsSchematicsVersion = exports.nestJsVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
- exports.nestJsVersion = '^9.1.1';
6
- exports.nestJsSchematicsVersion = '^9.1.0';
5
+ exports.nestJsVersion = '^10.0.2';
6
+ exports.nestJsSchematicsVersion = '^10.0.1';
7
7
  exports.rxjsVersion = '^7.8.0';
8
8
  exports.reflectMetadataVersion = '^0.1.13';
9
9
  exports.tsLibVersion = '^2.3.0';