@nestjs/schematics 10.2.2 → 11.0.0-next.1

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.
@@ -16,22 +16,20 @@ function main(options) {
16
16
  }
17
17
  function transform(options) {
18
18
  const target = Object.assign({}, options);
19
- target.author = !!target.author ? target.author : defaults_1.DEFAULT_AUTHOR;
20
- target.description = !!target.description
19
+ target.author = target.author ? target.author : defaults_1.DEFAULT_AUTHOR;
20
+ target.description = target.description
21
21
  ? target.description
22
22
  : defaults_1.DEFAULT_DESCRIPTION;
23
- target.language = !!target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
23
+ target.language = target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
24
24
  target.name = resolvePackageName(target.name.toString());
25
- target.version = !!target.version ? target.version : defaults_1.DEFAULT_VERSION;
25
+ target.version = target.version ? target.version : defaults_1.DEFAULT_VERSION;
26
26
  target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
27
27
  target.packageManager =
28
28
  !target.packageManager || target.packageManager === 'undefined'
29
29
  ? 'npm'
30
30
  : target.packageManager;
31
- target.dependencies = !!target.dependencies ? target.dependencies : '';
32
- target.devDependencies = !!target.devDependencies
33
- ? target.devDependencies
34
- : '';
31
+ target.dependencies = target.dependencies ? target.dependencies : '';
32
+ target.devDependencies = target.devDependencies ? target.devDependencies : '';
35
33
  return target;
36
34
  }
37
35
  function resolvePackageName(path) {
@@ -46,7 +44,9 @@ function resolvePackageName(path) {
46
44
  }
47
45
  function generate(options, path) {
48
46
  return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
49
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('__specFileSuffix__.ts')),
47
+ options.spec
48
+ ? (0, schematics_1.noop)()
49
+ : (0, schematics_1.filter)((path) => !path.endsWith('__specFileSuffix__.ts')),
50
50
  options.spec
51
51
  ? (0, schematics_1.noop)()
52
52
  : (0, schematics_1.filter)((path) => {
@@ -22,13 +22,13 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@nestjs/testing": "^10.0.0",
25
- "@babel/core": "7.25.8",
26
- "@babel/node": "7.25.7",
27
- "@babel/plugin-proposal-decorators": "7.25.7",
28
- "@babel/plugin-transform-runtime": "7.25.7",
29
- "@babel/preset-env": "7.25.8",
30
- "@babel/register": "7.25.7",
31
- "@babel/runtime": "7.25.7",
25
+ "@babel/core": "7.26.0",
26
+ "@babel/node": "7.26.0",
27
+ "@babel/plugin-proposal-decorators": "7.25.9",
28
+ "@babel/plugin-transform-runtime": "7.25.9",
29
+ "@babel/preset-env": "7.26.0",
30
+ "@babel/register": "7.25.9",
31
+ "@babel/runtime": "7.26.0",
32
32
  "jest": "29.7.0",
33
33
  "nodemon": "3.1.7",
34
34
  "prettier": "3.3.3",
@@ -0,0 +1,36 @@
1
+ // @ts-check
2
+ import eslint from '@eslint/js';
3
+ import tseslint from 'typescript-eslint';
4
+ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
5
+ import globals from 'globals';
6
+
7
+ export default tseslint.config(
8
+ {
9
+ ignores: ['eslint.config.mjs'],
10
+ },
11
+ eslint.configs.recommended,
12
+ ...tseslint.configs.recommendedTypeChecked,
13
+ eslintPluginPrettierRecommended,
14
+ {
15
+ languageOptions: {
16
+ globals: {
17
+ ...globals.node,
18
+ ...globals.jest,
19
+ },
20
+ ecmaVersion: 5,
21
+ sourceType: 'module',
22
+ parserOptions: {
23
+ projectService: true,
24
+ tsconfigRootDir: import.meta.dirname,
25
+ },
26
+ },
27
+ },
28
+ {
29
+ rules: {
30
+ '@typescript-eslint/interface-name-prefix': 'off',
31
+ '@typescript-eslint/explicit-function-return-type': 'off',
32
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
33
+ '@typescript-eslint/no-explicit-any': 'off',
34
+ },
35
+ },
36
+ );
@@ -27,27 +27,29 @@
27
27
  "rxjs": "^7.8.1"
28
28
  },
29
29
  "devDependencies": {
30
+ "@eslint/eslintrc": "^3.1.0",
31
+ "@eslint/js": "^9.12.0",
30
32
  "@nestjs/cli": "^10.0.0",
31
33
  "@nestjs/schematics": "^10.0.0",
32
34
  "@nestjs/testing": "^10.0.0",
35
+ "@types/eslint__js": "^8.42.3",
33
36
  "@types/express": "^5.0.0",
34
37
  "@types/jest": "^29.5.2",
35
- "@types/node": "^20.3.1",
38
+ "@types/node": "^22.0.0",
36
39
  "@types/supertest": "^6.0.0",
37
- "@typescript-eslint/eslint-plugin": "^8.0.0",
38
- "@typescript-eslint/parser": "^8.0.0",
39
- "eslint": "^9.0.0",
40
- "eslint-config-prettier": "^9.0.0",
41
- "eslint-plugin-prettier": "^5.0.0",
40
+ "eslint": "^9.12.0",
41
+ "eslint-plugin-prettier": "^5.2.1",
42
+ "globals": "^15.11.0",
42
43
  "jest": "^29.5.0",
43
- "prettier": "^3.0.0",
44
+ "prettier": "^3.3.3",
44
45
  "source-map-support": "^0.5.21",
45
46
  "supertest": "^7.0.0",
46
47
  "ts-jest": "^29.1.0",
47
48
  "ts-loader": "^9.4.3",
48
49
  "ts-node": "^10.9.1",
49
50
  "tsconfig-paths": "^4.2.0",
50
- "typescript": "^5.1.3"
51
+ "typescript": "^5.3.3",
52
+ "typescript-eslint": "^8.8.1"
51
53
  },
52
54
  "jest": {
53
55
  "moduleFileExtensions": [
@@ -90,8 +90,8 @@ function addGlobalPrefix() {
90
90
  });
91
91
  const tsFile = tsProject.addSourceFileAtPath(mainFilePath);
92
92
  const bootstrapFunction = tsFile.getFunction('bootstrap');
93
- const listenStatement = bootstrapFunction.getStatement(node => node.getText().includes('listen'));
94
- const setPrefixStatement = bootstrapFunction.getStatement(node => node.getText().includes('setGlobalPrefix'));
93
+ const listenStatement = bootstrapFunction.getStatement((node) => node.getText().includes('listen'));
94
+ const setPrefixStatement = bootstrapFunction.getStatement((node) => node.getText().includes('setGlobalPrefix'));
95
95
  if (!listenStatement || setPrefixStatement) {
96
96
  return tree;
97
97
  }
@@ -27,11 +27,12 @@ function getDefaultLibraryPrefix(defaultLibraryPrefix = '@app') {
27
27
  ]);
28
28
  try {
29
29
  const nestJson = JSON.parse(content || '{}');
30
- if (nestJson.hasOwnProperty('defaultLibraryPrefix')) {
30
+ if (Object.prototype.hasOwnProperty.call(nestJson, 'defaultLibraryPrefix')) {
31
31
  return nestJson['defaultLibraryPrefix'];
32
32
  }
33
33
  }
34
- catch (e) {
34
+ catch {
35
+ return defaultLibraryPrefix;
35
36
  }
36
37
  return defaultLibraryPrefix;
37
38
  }
@@ -41,7 +42,7 @@ function transform(options) {
41
42
  if (!target.name) {
42
43
  throw new schematics_1.SchematicsException('Option (name) is required.');
43
44
  }
44
- target.language = !!target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
45
+ target.language = target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
45
46
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(target.name);
46
47
  target.path =
47
48
  target.path !== undefined
@@ -99,7 +100,8 @@ function updateNpmScripts(scripts, options) {
99
100
  if (scripts[defaultFormatScriptName] &&
100
101
  scripts[defaultFormatScriptName].indexOf(defaults_1.DEFAULT_PATH_NAME) >= 0) {
101
102
  const defaultSourceRoot = options.rootDir !== undefined ? options.rootDir : defaults_1.DEFAULT_LIB_PATH;
102
- scripts[defaultFormatScriptName] = `prettier --write "src/**/*.ts" "test/**/*.ts" "${defaultSourceRoot}/**/*.ts"`;
103
+ scripts[defaultFormatScriptName] =
104
+ `prettier --write "src/**/*.ts" "test/**/*.ts" "${defaultSourceRoot}/**/*.ts"`;
103
105
  }
104
106
  }
105
107
  function updateJestEndToEnd(options) {
@@ -22,7 +22,7 @@ class FileSystemReader {
22
22
  return await this.read(file);
23
23
  }
24
24
  }
25
- catch (err) {
25
+ catch {
26
26
  return filenames.length > 0
27
27
  ? await this.readAnyOf(filenames.slice(1, filenames.length))
28
28
  : undefined;
@@ -34,7 +34,7 @@ class FileSystemReader {
34
34
  return this.readSync(file);
35
35
  }
36
36
  }
37
- catch (err) {
37
+ catch {
38
38
  return filenames.length > 0
39
39
  ? this.readSyncAnyOf(filenames.slice(1, filenames.length))
40
40
  : undefined;
@@ -67,7 +67,8 @@ function generate(options) {
67
67
  path.endsWith('.controller.__specFileSuffix__.ts')) {
68
68
  return options.type === 'microservice' || options.type === 'rest';
69
69
  }
70
- if (path.endsWith('.gateway.ts') || path.endsWith('.gateway.__specFileSuffix__.ts')) {
70
+ if (path.endsWith('.gateway.ts') ||
71
+ path.endsWith('.gateway.__specFileSuffix__.ts')) {
71
72
  return options.type === 'ws';
72
73
  }
73
74
  if (path.includes('@ent')) {
@@ -138,7 +139,7 @@ function addMappedTypesDependencyIfApplies(options) {
138
139
  context.addTask(new tasks_1.NodePackageInstallTask());
139
140
  }
140
141
  }
141
- catch (err) {
142
+ catch {
142
143
  }
143
144
  };
144
145
  }
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
- const util_1 = require("util");
7
6
  const formatting_1 = require("../../utils/formatting");
8
7
  const module_declarator_1 = require("../../utils/module.declarator");
9
8
  const module_finder_1 = require("../../utils/module.finder");
10
9
  const name_parser_1 = require("../../utils/name.parser");
11
10
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
11
+ function isNullOrUndefined(value) {
12
+ return value === null || value === undefined;
13
+ }
12
14
  function main(options) {
13
15
  options = transform(options);
14
16
  return (tree, context) => {
@@ -23,7 +25,7 @@ function transform(source) {
23
25
  const target = Object.assign({}, source);
24
26
  target.metadata = 'providers';
25
27
  target.type = 'service';
26
- if ((0, util_1.isNullOrUndefined)(target.name)) {
28
+ if (isNullOrUndefined(target.name)) {
27
29
  throw new schematics_1.SchematicsException('Option (name) is required.');
28
30
  }
29
31
  const location = new name_parser_1.NameParser().parse(target);
@@ -33,7 +33,7 @@ function getAppNameFromPackageJson() {
33
33
  return defaults_1.DEFAULT_DIR_ENTRY_APP;
34
34
  }
35
35
  let name = packageJson.name;
36
- name = name.replace(/[^\w.]+/g, '-').replace(/\-+/g, '-');
36
+ name = name.replace(/[^\w.]+/g, '-').replace(/-+/g, '-');
37
37
  return name[0] === '-' ? name.substr(1) : name;
38
38
  }
39
39
  catch {
@@ -52,7 +52,7 @@ function transform(options) {
52
52
  if (!target.name) {
53
53
  target.name = defaults_1.DEFAULT_APP_NAME;
54
54
  }
55
- target.language = !!target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
55
+ target.language = target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
56
56
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(target.name);
57
57
  target.path =
58
58
  target.path !== undefined
@@ -135,12 +135,14 @@ function updateNpmScripts(scripts, options, defaultAppName) {
135
135
  if (scripts[defaultFormatScriptName] &&
136
136
  scripts[defaultFormatScriptName].indexOf(defaults_1.DEFAULT_PATH_NAME) >= 0) {
137
137
  const defaultSourceRoot = options.rootDir !== undefined ? options.rootDir : defaults_1.DEFAULT_APPS_PATH;
138
- scripts[defaultFormatScriptName] = `prettier --write "${defaultSourceRoot}/**/*.ts" "${defaults_1.DEFAULT_LIB_PATH}/**/*.ts"`;
138
+ scripts[defaultFormatScriptName] =
139
+ `prettier --write "${defaultSourceRoot}/**/*.ts" "${defaults_1.DEFAULT_LIB_PATH}/**/*.ts"`;
139
140
  }
140
141
  if (scripts[defaultStartScriptName] &&
141
142
  scripts[defaultStartScriptName].indexOf('dist/main') >= 0) {
142
143
  const defaultSourceRoot = options.rootDir !== undefined ? options.rootDir : defaults_1.DEFAULT_APPS_PATH;
143
- scripts[defaultStartScriptName] = `node dist/${defaultSourceRoot}/${defaultAppName}/main`;
144
+ scripts[defaultStartScriptName] =
145
+ `node dist/${defaultSourceRoot}/${defaultAppName}/main`;
144
146
  }
145
147
  }
146
148
  function updateJestOptions(jestOptions, options) {
@@ -161,8 +161,8 @@ class MetadataManager {
161
161
  }
162
162
  const spacing = 6;
163
163
  let options = JSON.stringify(staticOptions.value, null, spacing);
164
- options = options.replace(/\"([^(\")"]+)\":/g, '$1:');
165
- options = options.replace(/\"/g, `'`);
164
+ options = options.replace(/"([^(")"]+)":/g, '$1:');
165
+ options = options.replace(/"/g, `'`);
166
166
  options = options.slice(0, options.length - 1) + ' }';
167
167
  symbol += `.${staticOptions.name}(${options})`;
168
168
  return symbol;
@@ -16,7 +16,7 @@ class ModuleImportDeclarator {
16
16
  }
17
17
  findImportsEndpoint(contentLines) {
18
18
  const reversedContent = Array.from(contentLines).reverse();
19
- const reverseImports = reversedContent.filter(line => line.match(/\} from ('|")/));
19
+ const reverseImports = reversedContent.filter((line) => line.match(/\} from ('|")/));
20
20
  if (reverseImports.length <= 0) {
21
21
  return 0;
22
22
  }
@@ -15,7 +15,7 @@ class ModuleFinder {
15
15
  if (!directory) {
16
16
  return null;
17
17
  }
18
- const moduleFilename = directory.subfiles.find(filename => /\.module\.(t|j)s$/.test(filename));
18
+ const moduleFilename = directory.subfiles.find((filename) => /\.module\.(t|j)s$/.test(filename));
19
19
  return moduleFilename !== undefined
20
20
  ? (0, core_1.join)(directory.path, moduleFilename.valueOf())
21
21
  : this.findIn(directory.parent);
@@ -6,9 +6,7 @@ class PathSolver {
6
6
  relative(from, to) {
7
7
  const placeholder = '/placeholder';
8
8
  const relativeDir = (0, core_1.relative)((0, core_1.dirname)((placeholder + from)), (0, core_1.dirname)((placeholder + to)));
9
- return (relativeDir.startsWith('.')
10
- ? relativeDir
11
- : './' + relativeDir).concat(relativeDir.length === 0 ? (0, core_1.basename)(to) : '/' + (0, core_1.basename)(to));
9
+ return (relativeDir.startsWith('.') ? relativeDir : './' + relativeDir).concat(relativeDir.length === 0 ? (0, core_1.basename)(to) : '/' + (0, core_1.basename)(to));
12
10
  }
13
11
  }
14
12
  exports.PathSolver = PathSolver;
@@ -6,7 +6,7 @@ const core_1 = require("@angular-devkit/core");
6
6
  const defaults_1 = require("../lib/defaults");
7
7
  function isInRootDirectory(host, extraFiles = []) {
8
8
  const files = ['nest-cli.json', 'nest.json'].concat(extraFiles || []);
9
- return files.map(file => host.exists(file)).some(isPresent => isPresent);
9
+ return files.map((file) => host.exists(file)).some((isPresent) => isPresent);
10
10
  }
11
11
  function mergeSourceRoot(options) {
12
12
  return (host) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/schematics",
3
- "version": "10.2.2",
3
+ "version": "11.0.0-next.1",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@schematics)",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -24,7 +24,7 @@
24
24
  "test:dev": "NODE_ENV=test npm run -s test -- --watchAll",
25
25
  "prerelease": "npm run build",
26
26
  "release": "release-it",
27
- "prepare": "husky install"
27
+ "prepare": "husky"
28
28
  },
29
29
  "repository": {
30
30
  "type": "git",
@@ -41,32 +41,39 @@
41
41
  },
42
42
  "homepage": "https://github.com/nestjs/schematics#readme",
43
43
  "dependencies": {
44
- "@angular-devkit/core": "17.3.10",
45
- "@angular-devkit/schematics": "17.3.10",
44
+ "@angular-devkit/core": "19.0.1",
45
+ "@angular-devkit/schematics": "19.0.1",
46
46
  "comment-json": "4.2.5",
47
47
  "jsonc-parser": "3.3.1",
48
48
  "pluralize": "8.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@commitlint/cli": "19.5.0",
52
- "@commitlint/config-angular": "19.5.0",
53
- "@types/jest": "29.5.13",
54
- "@types/node": "20.16.12",
55
- "@typescript-eslint/eslint-plugin": "8.9.0",
56
- "@typescript-eslint/parser": "8.9.0",
51
+ "@commitlint/cli": "19.6.0",
52
+ "@commitlint/config-angular": "19.6.0",
53
+ "@eslint/eslintrc": "3.2.0",
54
+ "@eslint/js": "9.15.0",
55
+ "@types/eslint__js": "8.42.3",
56
+ "@types/jest": "29.5.14",
57
+ "@types/node": "22.9.3",
58
+ "@typescript-eslint/eslint-plugin": "8.15.0",
59
+ "@typescript-eslint/parser": "8.15.0",
57
60
  "cpx2": "8.0.0",
58
- "eslint": "9.12.0",
61
+ "eslint": "9.15.0",
59
62
  "eslint-config-prettier": "9.1.0",
60
63
  "eslint-plugin-import": "2.31.0",
64
+ "eslint-plugin-prettier": "^5.2.1",
65
+ "globals": "15.12.0",
61
66
  "gulp": "5.0.0",
62
67
  "gulp-clean": "0.4.0",
63
- "husky": "9.1.6",
68
+ "husky": "9.1.7",
64
69
  "jest": "29.7.0",
65
70
  "nyc": "17.1.0",
66
- "release-it": "17.8.2",
71
+ "prettier": "3.3.3",
72
+ "release-it": "17.10.0",
67
73
  "ts-jest": "29.2.5",
68
74
  "ts-node": "10.9.2",
69
- "typescript": "5.6.3"
75
+ "typescript": "5.7.2",
76
+ "typescript-eslint": "^8.15.0"
70
77
  },
71
78
  "peerDependencies": {
72
79
  "typescript": ">=4.8.2"
@@ -1,25 +0,0 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- parserOptions: {
4
- project: 'tsconfig.json',
5
- tsconfigRootDir: __dirname,
6
- sourceType: 'module',
7
- },
8
- plugins: ['@typescript-eslint/eslint-plugin'],
9
- extends: [
10
- 'plugin:@typescript-eslint/recommended',
11
- 'plugin:prettier/recommended',
12
- ],
13
- root: true,
14
- env: {
15
- node: true,
16
- jest: true,
17
- },
18
- ignorePatterns: ['.eslintrc.js'],
19
- rules: {
20
- '@typescript-eslint/interface-name-prefix': 'off',
21
- '@typescript-eslint/explicit-function-return-type': 'off',
22
- '@typescript-eslint/explicit-module-boundary-types': 'off',
23
- '@typescript-eslint/no-explicit-any': 'off',
24
- },
25
- };