@nestjs/cli 10.3.1 → 10.4.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.
@@ -21,7 +21,7 @@ jobs:
21
21
  build:
22
22
  working_directory: ~/nest
23
23
  docker:
24
- - image: cimg/node:21.6
24
+ - image: cimg/node:22.3
25
25
  steps:
26
26
  - checkout
27
27
  - run:
@@ -43,7 +43,7 @@ jobs:
43
43
  unit_tests:
44
44
  working_directory: ~/nest
45
45
  docker:
46
- - image: cimg/node:21.6
46
+ - image: cimg/node:22.3
47
47
  steps:
48
48
  - checkout
49
49
  - *restore-cache
@@ -3,7 +3,6 @@ import { AssetsManager } from '../lib/compiler/assets-manager';
3
3
  import { TsConfigProvider } from '../lib/compiler/helpers/tsconfig-provider';
4
4
  import { PluginsLoader } from '../lib/compiler/plugins/plugins-loader';
5
5
  import { TypeScriptBinaryLoader } from '../lib/compiler/typescript-loader';
6
- import { WorkspaceUtils } from '../lib/compiler/workspace-utils';
7
6
  import { ConfigurationLoader } from '../lib/configuration';
8
7
  import { FileSystemReader } from '../lib/readers';
9
8
  import { AbstractAction } from './abstract.action';
@@ -14,7 +13,6 @@ export declare class BuildAction extends AbstractAction {
14
13
  protected readonly fileSystemReader: FileSystemReader;
15
14
  protected readonly loader: ConfigurationLoader;
16
15
  protected readonly assetsManager: AssetsManager;
17
- protected readonly workspaceUtils: WorkspaceUtils;
18
16
  handle(commandInputs: Input[], commandOptions: Input[]): Promise<void>;
19
17
  runBuild(commandInputs: Input[], commandOptions: Input[], watchMode: boolean, watchAssetsMode: boolean, isDebugEnabled?: boolean, onSuccess?: () => void): Promise<void>;
20
18
  private runSwc;
@@ -11,7 +11,7 @@ const get_webpack_config_path_1 = require("../lib/compiler/helpers/get-webpack-c
11
11
  const tsconfig_provider_1 = require("../lib/compiler/helpers/tsconfig-provider");
12
12
  const plugins_loader_1 = require("../lib/compiler/plugins/plugins-loader");
13
13
  const typescript_loader_1 = require("../lib/compiler/typescript-loader");
14
- const workspace_utils_1 = require("../lib/compiler/workspace-utils");
14
+ const delete_out_dir_1 = require("../lib/compiler/helpers/delete-out-dir");
15
15
  const configuration_1 = require("../lib/configuration");
16
16
  const defaults_1 = require("../lib/configuration/defaults");
17
17
  const readers_1 = require("../lib/readers");
@@ -26,7 +26,6 @@ class BuildAction extends abstract_action_1.AbstractAction {
26
26
  this.fileSystemReader = new readers_1.FileSystemReader(process.cwd());
27
27
  this.loader = new configuration_1.NestConfigurationLoader(this.fileSystemReader);
28
28
  this.assetsManager = new assets_manager_1.AssetsManager();
29
- this.workspaceUtils = new workspace_utils_1.WorkspaceUtils();
30
29
  }
31
30
  async handle(commandInputs, commandOptions) {
32
31
  try {
@@ -58,7 +57,7 @@ class BuildAction extends abstract_action_1.AbstractAction {
58
57
  const builder = isWebpackEnabled
59
58
  ? { type: 'webpack' }
60
59
  : (0, get_builder_1.getBuilder)(configuration, commandOptions, appName);
61
- await this.workspaceUtils.deleteOutDirIfEnabled(configuration, appName, outDir);
60
+ await (0, delete_out_dir_1.deleteOutDirIfEnabled)(configuration, appName, outDir);
62
61
  this.assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode);
63
62
  switch (builder.type) {
64
63
  case 'tsc':
@@ -12,7 +12,7 @@ const os_info_utils_1 = require("../lib/utils/os-info.utils");
12
12
  class InfoAction extends abstract_action_1.AbstractAction {
13
13
  constructor() {
14
14
  super(...arguments);
15
- // Nest dependencies whitelist used to compare minor version
15
+ // Nest dependencies whitelist used to compare the major version
16
16
  this.warningMessageDependenciesWhiteList = [
17
17
  '@nestjs/core',
18
18
  '@nestjs/common',
@@ -86,13 +86,13 @@ class InfoAction extends abstract_action_1.AbstractAction {
86
86
  displayWarningMessage(nestDependencies) {
87
87
  try {
88
88
  const warnings = this.buildNestVersionsWarningMessage(nestDependencies);
89
- const minorVersions = Object.keys(warnings);
90
- if (minorVersions.length > 0) {
89
+ const majorVersions = Object.keys(warnings);
90
+ if (majorVersions.length > 0) {
91
91
  console.info('\r');
92
92
  console.info(chalk.yellow('[Warnings]'));
93
- console.info('The following packages are not in the same minor version');
93
+ console.info('The following packages are not in the same major version');
94
94
  console.info('This could lead to runtime errors');
95
- minorVersions.forEach((version) => {
95
+ majorVersions.forEach((version) => {
96
96
  console.info(chalk.bold(`* Under version ${version}`));
97
97
  warnings[version].forEach(({ packageName, value }) => {
98
98
  console.info(`- ${packageName} ${value}`);
@@ -106,19 +106,18 @@ class InfoAction extends abstract_action_1.AbstractAction {
106
106
  }
107
107
  }
108
108
  buildNestVersionsWarningMessage(nestDependencies) {
109
- const unsortedWarnings = nestDependencies.reduce((acc, { name, packageName, value }) => {
109
+ const unsortedWarnings = nestDependencies.reduce((depWarningsGroup, { name, packageName, value }) => {
110
110
  if (!this.warningMessageDependenciesWhiteList.includes(packageName)) {
111
- return acc;
111
+ return depWarningsGroup;
112
112
  }
113
- const cleanedValue = value.replace(/[^\d.]/g, '');
114
- const [major, minor] = cleanedValue.split('.');
115
- const minorVersion = `${major}.${minor}`;
116
- acc[minorVersion] = [
117
- ...(acc[minorVersion] || []),
113
+ const [major] = value.replace(/[^\d.]/g, '').split('.', 1);
114
+ const minimumVersion = major;
115
+ depWarningsGroup[minimumVersion] = [
116
+ ...(depWarningsGroup[minimumVersion] || []),
118
117
  { name, packageName, value },
119
118
  ];
120
- return acc;
121
- }, {});
119
+ return depWarningsGroup;
120
+ }, Object.create(null));
122
121
  const unsortedMinorVersions = Object.keys(unsortedWarnings);
123
122
  if (unsortedMinorVersions.length <= 1) {
124
123
  return {};
@@ -136,7 +135,7 @@ class InfoAction extends abstract_action_1.AbstractAction {
136
135
  return sortedMinorVersions.reduce((warnings, minorVersion) => {
137
136
  warnings[minorVersion] = unsortedWarnings[minorVersion];
138
137
  return warnings;
139
- }, {});
138
+ }, Object.create(null));
140
139
  }
141
140
  buildNestVersionsMessage(dependencies) {
142
141
  const nestDependencies = this.collectNestDependencies(dependencies);
@@ -5,7 +5,6 @@ const chokidar = require("chokidar");
5
5
  const fs_1 = require("fs");
6
6
  const glob_1 = require("glob");
7
7
  const path_1 = require("path");
8
- const shell = require("shelljs");
9
8
  const copy_path_resolve_1 = require("./helpers/copy-path-resolve");
10
9
  const get_value_or_default_1 = require("./helpers/get-value-or-default");
11
10
  class AssetsManager {
@@ -43,18 +42,16 @@ class AssetsManager {
43
42
  let sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName);
44
43
  sourceRoot = (0, path_1.join)(process.cwd(), sourceRoot);
45
44
  const filesToCopy = assets.map((item) => {
46
- if (typeof item === 'string') {
47
- return {
48
- glob: (0, path_1.join)(sourceRoot, item),
49
- outDir,
50
- };
51
- }
45
+ let includePath = typeof item === 'string' ? item : item.include;
46
+ let excludePath = typeof item !== 'string' && item.exclude ? item.exclude : undefined;
47
+ includePath = (0, path_1.join)(sourceRoot, includePath).replace(/\\/g, '/');
48
+ excludePath = excludePath ? (0, path_1.join)(sourceRoot, excludePath).replace(/\\/g, '/') : undefined;
52
49
  return {
53
- outDir: item.outDir || outDir,
54
- glob: (0, path_1.join)(sourceRoot, item.include),
55
- exclude: item.exclude ? (0, path_1.join)(sourceRoot, item.exclude) : undefined,
56
- flat: item.flat, // deprecated field
57
- watchAssets: item.watchAssets,
50
+ outDir: typeof item !== 'string' ? item.outDir || outDir : outDir,
51
+ glob: includePath,
52
+ exclude: excludePath,
53
+ flat: typeof item !== 'string' ? item.flat : undefined, // deprecated field
54
+ watchAssets: typeof item !== 'string' ? item.watchAssets : undefined,
58
55
  };
59
56
  });
60
57
  const isWatchEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.watchAssets', appName) || watchAssetsMode;
@@ -101,12 +98,12 @@ class AssetsManager {
101
98
  const dest = (0, copy_path_resolve_1.copyPathResolve)(path, item.outDir, sourceRoot.split(path_1.sep).length);
102
99
  // Copy to output dir if file is changed or added
103
100
  if (action === 'change') {
104
- shell.mkdir('-p', (0, path_1.dirname)(dest));
105
- shell.cp(path, dest);
101
+ (0, fs_1.mkdirSync)((0, path_1.dirname)(dest), { recursive: true });
102
+ (0, fs_1.copyFileSync)(path, dest);
106
103
  }
107
104
  else if (action === 'unlink') {
108
105
  // Remove from output dir if file is deleted
109
- shell.rm(dest);
106
+ (0, fs_1.rmSync)(dest, { force: true });
110
107
  }
111
108
  }
112
109
  }
@@ -0,0 +1,2 @@
1
+ import { Configuration } from '../../configuration';
2
+ export declare function deleteOutDirIfEnabled(configuration: Required<Configuration>, appName: string, dirPath: string): Promise<void>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteOutDirIfEnabled = void 0;
4
+ const promises_1 = require("fs/promises");
5
+ const get_value_or_default_1 = require("./get-value-or-default");
6
+ async function deleteOutDirIfEnabled(configuration, appName, dirPath) {
7
+ const isDeleteEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.deleteOutDir', appName);
8
+ if (!isDeleteEnabled) {
9
+ return;
10
+ }
11
+ await (0, promises_1.rm)(dirPath, { recursive: true, force: true });
12
+ }
13
+ exports.deleteOutDirIfEnabled = deleteOutDirIfEnabled;
@@ -30,8 +30,8 @@ class NestConfigurationLoader {
30
30
  'nest.json',
31
31
  ]);
32
32
  if (contentOrError) {
33
- const isMissingPersmissionsError = contentOrError instanceof readers_1.ReaderFileLackPersmissionsError;
34
- if (isMissingPersmissionsError) {
33
+ const isMissingPermissionsError = contentOrError instanceof readers_1.ReaderFileLackPermissionsError;
34
+ if (isMissingPermissionsError) {
35
35
  console.error(contentOrError.message);
36
36
  process.exit(1);
37
37
  }
@@ -1,8 +1,8 @@
1
- import { Reader, ReaderFileLackPersmissionsError } from './reader';
1
+ import { Reader, ReaderFileLackPermissionsError } from './reader';
2
2
  export declare class FileSystemReader implements Reader {
3
3
  private readonly directory;
4
4
  constructor(directory: string);
5
5
  list(): string[];
6
6
  read(name: string): string;
7
- readAnyOf(filenames: string[]): string | undefined | ReaderFileLackPersmissionsError;
7
+ readAnyOf(filenames: string[]): string | undefined | ReaderFileLackPermissionsError;
8
8
  }
@@ -34,7 +34,7 @@ class FileSystemReader {
34
34
  continue;
35
35
  }
36
36
  if (firstFilePathFoundButWithInsufficientPermissions) {
37
- return new reader_1.ReaderFileLackPersmissionsError(firstFilePathFoundButWithInsufficientPermissions, readErr.code);
37
+ return new reader_1.ReaderFileLackPermissionsError(firstFilePathFoundButWithInsufficientPermissions, readErr.code);
38
38
  }
39
39
  else {
40
40
  return undefined;
@@ -1,4 +1,4 @@
1
- export declare class ReaderFileLackPersmissionsError extends Error {
1
+ export declare class ReaderFileLackPermissionsError extends Error {
2
2
  readonly filePath: string;
3
3
  readonly fsErrorCode: string;
4
4
  constructor(filePath: string, fsErrorCode: string);
@@ -6,5 +6,5 @@ export declare class ReaderFileLackPersmissionsError extends Error {
6
6
  export interface Reader {
7
7
  list(): string[];
8
8
  read(name: string): string;
9
- readAnyOf(filenames: string[]): string | undefined | ReaderFileLackPersmissionsError;
9
+ readAnyOf(filenames: string[]): string | undefined | ReaderFileLackPermissionsError;
10
10
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReaderFileLackPersmissionsError = void 0;
4
- class ReaderFileLackPersmissionsError extends Error {
3
+ exports.ReaderFileLackPermissionsError = void 0;
4
+ class ReaderFileLackPermissionsError extends Error {
5
5
  constructor(filePath, fsErrorCode) {
6
6
  super(`File ${filePath} lacks read permissions!`);
7
7
  this.filePath = filePath;
8
8
  this.fsErrorCode = fsErrorCode;
9
9
  }
10
10
  }
11
- exports.ReaderFileLackPersmissionsError = ReaderFileLackPersmissionsError;
11
+ exports.ReaderFileLackPermissionsError = ReaderFileLackPermissionsError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/cli",
3
- "version": "10.3.1",
3
+ "version": "10.4.0-next.1",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -38,53 +38,50 @@
38
38
  },
39
39
  "homepage": "https://github.com/nestjs/nest-cli#readme",
40
40
  "dependencies": {
41
- "@angular-devkit/core": "17.1.2",
42
- "@angular-devkit/schematics": "17.1.2",
43
- "@angular-devkit/schematics-cli": "17.1.2",
41
+ "@angular-devkit/core": "17.3.8",
42
+ "@angular-devkit/schematics": "17.3.8",
43
+ "@angular-devkit/schematics-cli": "17.3.8",
44
44
  "@nestjs/schematics": "^10.0.1",
45
45
  "chalk": "4.1.2",
46
- "chokidar": "3.5.3",
47
- "cli-table3": "0.6.3",
46
+ "chokidar": "3.6.0",
47
+ "cli-table3": "0.6.5",
48
48
  "commander": "4.1.1",
49
49
  "fork-ts-checker-webpack-plugin": "9.0.2",
50
- "glob": "10.3.10",
50
+ "glob": "10.4.2",
51
51
  "inquirer": "8.2.6",
52
52
  "node-emoji": "1.11.0",
53
53
  "ora": "5.4.1",
54
- "rimraf": "4.4.1",
55
- "shelljs": "0.8.5",
56
54
  "source-map-support": "0.5.21",
57
55
  "tree-kill": "1.2.2",
58
56
  "tsconfig-paths": "4.2.0",
59
57
  "tsconfig-paths-webpack-plugin": "4.1.0",
60
58
  "typescript": "5.3.3",
61
- "webpack": "5.90.1",
59
+ "webpack": "5.92.1",
62
60
  "webpack-node-externals": "3.0.0"
63
61
  },
64
62
  "devDependencies": {
65
- "@commitlint/cli": "18.6.0",
66
- "@commitlint/config-angular": "18.6.0",
67
- "@swc/cli": "0.3.6",
68
- "@swc/core": "1.3.107",
63
+ "@commitlint/cli": "19.3.0",
64
+ "@commitlint/config-angular": "19.3.0",
65
+ "@swc/cli": "0.3.12",
66
+ "@swc/core": "1.5.7",
69
67
  "@types/inquirer": "9.0.3",
70
68
  "@types/jest": "29.5.12",
71
- "@types/node": "20.11.16",
69
+ "@types/node": "20.14.9",
72
70
  "@types/node-emoji": "1.8.2",
73
- "@types/shelljs": "0.8.15",
74
71
  "@types/webpack-node-externals": "3.0.4",
75
- "@typescript-eslint/eslint-plugin": "6.20.0",
76
- "@typescript-eslint/parser": "6.20.0",
72
+ "@typescript-eslint/eslint-plugin": "7.10.0",
73
+ "@typescript-eslint/parser": "7.10.0",
77
74
  "delete-empty": "3.0.0",
78
- "eslint": "8.56.0",
75
+ "eslint": "8.57.0",
79
76
  "eslint-config-prettier": "9.1.0",
80
- "gulp": "4.0.2",
77
+ "gulp": "5.0.0",
81
78
  "gulp-clean": "0.4.0",
82
- "husky": "9.0.10",
79
+ "husky": "9.0.11",
83
80
  "jest": "29.7.0",
84
- "lint-staged": "15.2.1",
85
- "prettier": "3.2.5",
86
- "release-it": "17.0.3",
87
- "ts-jest": "29.1.2",
81
+ "lint-staged": "15.2.7",
82
+ "prettier": "3.3.2",
83
+ "release-it": "17.3.0",
84
+ "ts-jest": "29.1.5",
88
85
  "ts-loader": "9.5.1"
89
86
  },
90
87
  "lint-staged": {