@nestjs/cli 9.4.0 → 9.4.2

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:19.9
24
+ - image: cimg/node:20.0
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:19.9
46
+ - image: cimg/node:20.0
47
47
  steps:
48
48
  - checkout
49
49
  - *restore-cache
@@ -76,7 +76,7 @@ class BuildAction extends abstract_action_1.AbstractAction {
76
76
  if (isWebpackEnabled) {
77
77
  const webpackPath = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpackConfigPath', appName, 'webpackPath', options);
78
78
  const webpackConfigFactoryOrConfig = this.getWebpackConfigFactoryByPath(webpackPath, configuration.compilerOptions.webpackConfigPath);
79
- return this.webpackCompiler.run(configuration, webpackConfigFactoryOrConfig, pathToTsconfig, appName, isDebugEnabled, watchMode, this.assetsManager, onSuccess);
79
+ return this.webpackCompiler.run(configuration, options, webpackConfigFactoryOrConfig, pathToTsconfig, appName, isDebugEnabled, watchMode, this.assetsManager, onSuccess);
80
80
  }
81
81
  if (watchMode) {
82
82
  const tsCompilerOptions = {};
@@ -34,6 +34,7 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
34
34
  .value;
35
35
  const spec = inputs.find((option) => option.name === 'spec');
36
36
  const flat = inputs.find((option) => option.name === 'flat');
37
+ const specFileSuffix = inputs.find((option) => option.name === 'specFileSuffix');
37
38
  const collection = schematics_1.CollectionFactory.create(collectionOption || configuration.collection || schematics_1.Collection.NESTJS);
38
39
  const schematicOptions = mapSchematicOptions(inputs);
39
40
  schematicOptions.push(new schematics_1.SchematicOption('language', configuration.language));
@@ -42,10 +43,12 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
42
43
  ? (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName)
43
44
  : configuration.sourceRoot;
44
45
  const specValue = spec.value;
45
- const flatValue = !!flat;
46
+ const flatValue = !!(flat === null || flat === void 0 ? void 0 : flat.value);
47
+ const specFileSuffixValue = specFileSuffix.value;
46
48
  const specOptions = spec.options;
47
49
  let generateSpec = (0, project_utils_1.shouldGenerateSpec)(configuration, schematic, appName, specValue, specOptions.passedAsInput);
48
50
  let generateFlat = (0, project_utils_1.shouldGenerateFlat)(configuration, appName, flatValue);
51
+ let generateSpecFileSuffix = (0, project_utils_1.getSpecFileSuffix)(configuration, appName, specFileSuffixValue);
49
52
  // If you only add a `lib` we actually don't have monorepo: true BUT we do have "projects"
50
53
  // Ensure we don't run for new app/libs schematics
51
54
  if ((0, project_utils_1.shouldAskForProject)(schematic, configurationProjects, appName)) {
@@ -67,11 +70,13 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
67
70
  // Only overwrite if the appName is not the default- as it has already been loaded above
68
71
  generateSpec = (0, project_utils_1.shouldGenerateSpec)(configuration, schematic, answers.appName, specValue, specOptions.passedAsInput);
69
72
  generateFlat = (0, project_utils_1.shouldGenerateFlat)(configuration, answers.appNames, flatValue);
73
+ generateSpecFileSuffix = (0, project_utils_1.getSpecFileSuffix)(configuration, appName, specFileSuffixValue);
70
74
  }
71
75
  }
72
76
  schematicOptions.push(new schematics_1.SchematicOption('sourceRoot', sourceRoot));
73
77
  schematicOptions.push(new schematics_1.SchematicOption('spec', generateSpec));
74
78
  schematicOptions.push(new schematics_1.SchematicOption('flat', generateFlat));
79
+ schematicOptions.push(new schematics_1.SchematicOption('specFileSuffix', generateSpecFileSuffix));
75
80
  try {
76
81
  const schematicInput = inputs.find((input) => input.name === 'schematic');
77
82
  if (!schematicInput) {
@@ -86,7 +91,7 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
86
91
  }
87
92
  });
88
93
  const mapSchematicOptions = (inputs) => {
89
- const excludedInputNames = ['schematic', 'spec', 'flat'];
94
+ const excludedInputNames = ['schematic', 'spec', 'flat', 'specFileSuffix'];
90
95
  const options = [];
91
96
  inputs.forEach((input) => {
92
97
  if (!excludedInputNames.includes(input.name) && input.value !== undefined) {
@@ -29,6 +29,7 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
29
29
  .option('--spec', 'Enforce spec files generation.', () => {
30
30
  return { value: true, passedAsInput: true };
31
31
  }, true)
32
+ .option('--spec-file-suffix [suffix]', 'Use a custom suffix for spec files.')
32
33
  .option('--skip-import', 'Skip importing', () => true, false)
33
34
  .option('--no-spec', 'Disable spec files generation.', () => {
34
35
  return { value: false, passedAsInput: true };
@@ -51,6 +52,10 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
51
52
  : command.spec.passedAsInput,
52
53
  },
53
54
  });
55
+ options.push({
56
+ name: 'specFileSuffix',
57
+ value: command.specFileSuffix,
58
+ });
54
59
  options.push({
55
60
  name: 'collection',
56
61
  value: command.collection,
@@ -1,12 +1,13 @@
1
1
  import { Configuration } from '../configuration';
2
2
  import { AssetsManager } from './assets-manager';
3
3
  import { PluginsLoader } from './plugins-loader';
4
+ import { Input } from '../../commands';
4
5
  import webpack = require('webpack');
5
6
  type WebpackConfigFactory = (config: webpack.Configuration, webpackRef: typeof webpack) => webpack.Configuration;
6
7
  type WebpackConfigFactoryOrConfig = WebpackConfigFactory | webpack.Configuration;
7
8
  export declare class WebpackCompiler {
8
9
  private readonly pluginsLoader;
9
10
  constructor(pluginsLoader: PluginsLoader);
10
- run(configuration: Required<Configuration>, webpackConfigFactoryOrConfig: WebpackConfigFactoryOrConfig | WebpackConfigFactoryOrConfig[], tsConfigPath: string, appName: string, isDebugEnabled: boolean | undefined, watchMode: boolean | undefined, assetsManager: AssetsManager, onSuccess?: () => void): void;
11
+ run(configuration: Required<Configuration>, options: Input[], webpackConfigFactoryOrConfig: WebpackConfigFactoryOrConfig | WebpackConfigFactoryOrConfig[], tsConfigPath: string, appName: string, isDebugEnabled: boolean | undefined, watchMode: boolean | undefined, assetsManager: AssetsManager, onSuccess?: () => void): void;
11
12
  }
12
13
  export {};
@@ -11,7 +11,7 @@ class WebpackCompiler {
11
11
  constructor(pluginsLoader) {
12
12
  this.pluginsLoader = pluginsLoader;
13
13
  }
14
- run(configuration, webpackConfigFactoryOrConfig, tsConfigPath, appName, isDebugEnabled = false, watchMode = false, assetsManager, onSuccess) {
14
+ run(configuration, options, webpackConfigFactoryOrConfig, tsConfigPath, appName, isDebugEnabled = false, watchMode = false, assetsManager, onSuccess) {
15
15
  const cwd = process.cwd();
16
16
  const configPath = (0, path_1.join)(cwd, tsConfigPath);
17
17
  if (!(0, fs_1.existsSync)(configPath)) {
@@ -20,11 +20,11 @@ class WebpackCompiler {
20
20
  const pluginsConfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.plugins', appName);
21
21
  const plugins = this.pluginsLoader.load(pluginsConfig);
22
22
  const relativeRootPath = (0, path_1.dirname)((0, path_1.relative)(cwd, configPath));
23
- const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName);
23
+ const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName, 'sourceRoot', options);
24
24
  const pathToSource = (0, path_1.normalize)(sourceRoot).indexOf((0, path_1.normalize)(relativeRootPath)) >= 0
25
25
  ? (0, path_1.join)(cwd, sourceRoot)
26
26
  : (0, path_1.join)(cwd, relativeRootPath, sourceRoot);
27
- const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName);
27
+ const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName, 'entryFile', options);
28
28
  const entryFileRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'root', appName) || '';
29
29
  const defaultOptions = (0, webpack_defaults_1.webpackDefaultsFactory)(pathToSource, entryFileRoot, entryFile, isDebugEnabled, tsConfigPath, plugins);
30
30
  let compiler;
@@ -29,6 +29,7 @@ interface PluginOptions {
29
29
  interface GenerateOptions {
30
30
  spec?: boolean | Record<string, boolean>;
31
31
  flat?: boolean;
32
+ specFileSuffix?: string;
32
33
  }
33
34
  export interface ProjectConfiguration {
34
35
  type?: string;
@@ -20,9 +20,9 @@ class NestConfigurationLoader {
20
20
  const content = name
21
21
  ? yield this.reader.read(name)
22
22
  : yield this.reader.readAnyOf([
23
+ 'nest-cli.json',
23
24
  '.nestcli.json',
24
25
  '.nest-cli.json',
25
- 'nest-cli.json',
26
26
  'nest.json',
27
27
  ]);
28
28
  if (!content) {
@@ -6,6 +6,7 @@ export declare function shouldAskForProject(schematic: string, configurationProj
6
6
  }, appName: string): boolean;
7
7
  export declare function shouldGenerateSpec(configuration: Required<Configuration>, schematic: string, appName: string, specValue: boolean, specPassedAsInput?: boolean): any;
8
8
  export declare function shouldGenerateFlat(configuration: Required<Configuration>, appName: string, flatValue: boolean): boolean;
9
+ export declare function getSpecFileSuffix(configuration: Required<Configuration>, appName: string, specFileSuffixValue: string): string;
9
10
  export declare function askForProjectName(promptQuestion: string, projects: string[]): Promise<Answers>;
10
11
  export declare function moveDefaultProjectToStart(configuration: Configuration, defaultProjectName: string, defaultLabel: string): string[];
11
12
  export declare function hasValidOptionFlag(queriedOptionName: string, options: Input[], queriedValue?: string | number | boolean): boolean;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.hasValidOptionFlag = exports.moveDefaultProjectToStart = exports.askForProjectName = exports.shouldGenerateFlat = exports.shouldGenerateSpec = exports.shouldAskForProject = void 0;
12
+ exports.hasValidOptionFlag = exports.moveDefaultProjectToStart = exports.askForProjectName = exports.getSpecFileSuffix = exports.shouldGenerateFlat = exports.shouldGenerateSpec = exports.shouldAskForProject = void 0;
13
13
  const inquirer = require("inquirer");
14
14
  const get_value_or_default_1 = require("../compiler/helpers/get-value-or-default");
15
15
  const questions_1 = require("../questions/questions");
@@ -60,6 +60,18 @@ function shouldGenerateFlat(configuration, appName, flatValue) {
60
60
  return flatValue;
61
61
  }
62
62
  exports.shouldGenerateFlat = shouldGenerateFlat;
63
+ function getSpecFileSuffix(configuration, appName, specFileSuffixValue) {
64
+ // CLI parameters have the highest priority
65
+ if (specFileSuffixValue) {
66
+ return specFileSuffixValue;
67
+ }
68
+ const specFileSuffixConfiguration = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'generateOptions.specFileSuffix', appName || '', undefined, undefined, 'spec');
69
+ if (typeof specFileSuffixConfiguration === 'string') {
70
+ return specFileSuffixConfiguration;
71
+ }
72
+ return specFileSuffixValue;
73
+ }
74
+ exports.getSpecFileSuffix = getSpecFileSuffix;
63
75
  function askForProjectName(promptQuestion, projects) {
64
76
  return __awaiter(this, void 0, void 0, function* () {
65
77
  const questions = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/cli",
3
- "version": "9.4.0",
3
+ "version": "9.4.2",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -58,29 +58,29 @@
58
58
  "tsconfig-paths": "4.2.0",
59
59
  "tsconfig-paths-webpack-plugin": "4.0.1",
60
60
  "typescript": "4.9.5",
61
- "webpack": "5.79.0",
61
+ "webpack": "5.80.0",
62
62
  "webpack-node-externals": "3.0.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@commitlint/cli": "17.5.1",
66
- "@commitlint/config-angular": "17.4.4",
65
+ "@commitlint/cli": "17.6.1",
66
+ "@commitlint/config-angular": "17.6.1",
67
67
  "@types/inquirer": "8.2.6",
68
- "@types/jest": "29.5.0",
69
- "@types/node": "18.15.11",
68
+ "@types/jest": "29.5.1",
69
+ "@types/node": "18.16.0",
70
70
  "@types/node-emoji": "1.8.2",
71
71
  "@types/shelljs": "0.8.12",
72
72
  "@types/webpack-node-externals": "3.0.0",
73
- "@typescript-eslint/eslint-plugin": "5.58.0",
74
- "@typescript-eslint/parser": "5.58.0",
73
+ "@typescript-eslint/eslint-plugin": "5.59.0",
74
+ "@typescript-eslint/parser": "5.59.0",
75
75
  "delete-empty": "3.0.0",
76
- "eslint": "8.38.0",
76
+ "eslint": "8.39.0",
77
77
  "eslint-config-prettier": "8.8.0",
78
78
  "gulp": "4.0.2",
79
79
  "gulp-clean": "0.4.0",
80
80
  "husky": "8.0.3",
81
81
  "jest": "29.5.0",
82
82
  "lint-staged": "13.2.1",
83
- "prettier": "2.8.7",
83
+ "prettier": "2.8.8",
84
84
  "release-it": "15.10.1",
85
85
  "ts-jest": "29.1.0",
86
86
  "ts-loader": "9.4.2"