@nestjs/cli 9.1.3 → 9.1.5

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.
@@ -26,7 +26,8 @@ class AddAction extends abstract_action_1.AbstractAction {
26
26
  const packageName = this.getPackageName(libraryName);
27
27
  const collectionName = this.getCollectionName(libraryName, packageName);
28
28
  const tagName = this.getTagName(packageName);
29
- const packageInstallSuccess = yield this.installPackage(collectionName, tagName);
29
+ const skipInstall = (0, project_utils_1.hasValidOptionFlag)('skip-install', options);
30
+ const packageInstallSuccess = skipInstall || (yield this.installPackage(collectionName, tagName));
30
31
  if (packageInstallSuccess) {
31
32
  const sourceRootOption = yield this.getSourceRoot(inputs.concat(options));
32
33
  options.push(sourceRootOption);
@@ -33,6 +33,7 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
33
33
  const appName = inputs.find((option) => option.name === 'project')
34
34
  .value;
35
35
  const spec = inputs.find((option) => option.name === 'spec');
36
+ const flat = inputs.find((option) => option.name === 'flat');
36
37
  const collection = schematics_1.CollectionFactory.create(collectionOption || configuration.collection || schematics_1.Collection.NESTJS);
37
38
  const schematicOptions = mapSchematicOptions(inputs);
38
39
  schematicOptions.push(new schematics_1.SchematicOption('language', configuration.language));
@@ -41,8 +42,10 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
41
42
  ? (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName)
42
43
  : configuration.sourceRoot;
43
44
  const specValue = spec.value;
45
+ const flatValue = !!flat;
44
46
  const specOptions = spec.options;
45
47
  let generateSpec = (0, project_utils_1.shouldGenerateSpec)(configuration, schematic, appName, specValue, specOptions.passedAsInput);
48
+ let generateFlat = (0, project_utils_1.shouldGenerateFlat)(configuration, appName, flatValue);
46
49
  // If you only add a `lib` we actually don't have monorepo: true BUT we do have "projects"
47
50
  // Ensure we don't run for new app/libs schematics
48
51
  if ((0, project_utils_1.shouldAskForProject)(schematic, configurationProjects, appName)) {
@@ -63,10 +66,12 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
63
66
  if (answers.appName !== defaultProjectName) {
64
67
  // Only overwrite if the appName is not the default- as it has already been loaded above
65
68
  generateSpec = (0, project_utils_1.shouldGenerateSpec)(configuration, schematic, answers.appName, specValue, specOptions.passedAsInput);
69
+ generateFlat = (0, project_utils_1.shouldGenerateFlat)(configuration, answers.appNames, flatValue);
66
70
  }
67
71
  }
68
72
  schematicOptions.push(new schematics_1.SchematicOption('sourceRoot', sourceRoot));
69
73
  schematicOptions.push(new schematics_1.SchematicOption('spec', generateSpec));
74
+ schematicOptions.push(new schematics_1.SchematicOption('flat', generateFlat));
70
75
  try {
71
76
  const schematicInput = inputs.find((input) => input.name === 'schematic');
72
77
  if (!schematicInput) {
@@ -81,7 +86,7 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
81
86
  }
82
87
  });
83
88
  const mapSchematicOptions = (inputs) => {
84
- const excludedInputNames = ['schematic', 'spec'];
89
+ const excludedInputNames = ['schematic', 'spec', 'flat'];
85
90
  const options = [];
86
91
  inputs.forEach((input) => {
87
92
  if (!excludedInputNames.includes(input.name) && input.value !== undefined) {
@@ -19,11 +19,13 @@ class AddCommand extends abstract_command_1.AbstractCommand {
19
19
  .allowUnknownOption()
20
20
  .description('Adds support for an external library to your project.')
21
21
  .option('-d, --dry-run', 'Report actions that would be performed without writing out results.')
22
+ .option('-s, --skip-install', 'Skip package installation.', false)
22
23
  .option('-p, --project [project]', 'Project in which to generate files.')
23
24
  .usage('<library> [options] [library-specific-options]')
24
25
  .action((library, command) => __awaiter(this, void 0, void 0, function* () {
25
26
  const options = [];
26
27
  options.push({ name: 'dry-run', value: !!command.dryRun });
28
+ options.push({ name: 'skip-install', value: command.skipInstall });
27
29
  options.push({
28
30
  name: 'project',
29
31
  value: command.project,
@@ -8,84 +8,90 @@ const defaults_1 = require("../../configuration/defaults");
8
8
  const append_extension_1 = require("../helpers/append-extension");
9
9
  const webpack = require("webpack");
10
10
  const nodeExternals = require("webpack-node-externals");
11
- const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaults_1.defaultConfiguration.compilerOptions.tsConfigPath, plugins) => ({
12
- entry: (0, append_extension_1.appendTsExtension)((0, path_1.join)(sourceRoot, entryFilename)),
13
- devtool: isDebugEnabled ? 'inline-source-map' : false,
14
- target: 'node',
15
- output: {
16
- filename: (0, path_1.join)(relativeSourceRoot, `${entryFilename}.js`),
17
- },
18
- ignoreWarnings: [/^(?!CriticalDependenciesWarning$)/],
19
- externals: [nodeExternals()],
20
- externalsPresets: { node: true },
21
- module: {
22
- rules: [
23
- {
24
- test: /.tsx?$/,
25
- use: [
26
- {
27
- loader: 'ts-loader',
28
- options: {
29
- transpileOnly: !isAnyPluginRegistered(plugins),
30
- configFile: tsConfigFile,
31
- getCustomTransformers: (program) => ({
32
- before: plugins.beforeHooks.map((hook) => hook(program)),
33
- after: plugins.afterHooks.map((hook) => hook(program)),
34
- afterDeclarations: plugins.afterDeclarationsHooks.map((hook) => hook(program)),
35
- }),
11
+ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaults_1.defaultConfiguration.compilerOptions.tsConfigPath, plugins) => {
12
+ const isPluginRegistered = isAnyPluginRegistered(plugins);
13
+ const webpackConfiguration = {
14
+ entry: (0, append_extension_1.appendTsExtension)((0, path_1.join)(sourceRoot, entryFilename)),
15
+ devtool: isDebugEnabled ? 'inline-source-map' : false,
16
+ target: 'node',
17
+ output: {
18
+ filename: (0, path_1.join)(relativeSourceRoot, `${entryFilename}.js`),
19
+ },
20
+ ignoreWarnings: [/^(?!CriticalDependenciesWarning$)/],
21
+ externals: [nodeExternals()],
22
+ externalsPresets: { node: true },
23
+ module: {
24
+ rules: [
25
+ {
26
+ test: /.tsx?$/,
27
+ use: [
28
+ {
29
+ loader: 'ts-loader',
30
+ options: {
31
+ transpileOnly: !isPluginRegistered,
32
+ configFile: tsConfigFile,
33
+ getCustomTransformers: (program) => ({
34
+ before: plugins.beforeHooks.map((hook) => hook(program)),
35
+ after: plugins.afterHooks.map((hook) => hook(program)),
36
+ afterDeclarations: plugins.afterDeclarationsHooks.map((hook) => hook(program)),
37
+ }),
38
+ },
36
39
  },
37
- },
38
- ],
39
- exclude: /node_modules/,
40
- },
41
- ],
42
- },
43
- resolve: {
44
- extensions: ['.tsx', '.ts', '.js'],
40
+ ],
41
+ exclude: /node_modules/,
42
+ },
43
+ ],
44
+ },
45
+ resolve: {
46
+ extensions: ['.tsx', '.ts', '.js'],
47
+ plugins: [
48
+ new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({
49
+ configFile: tsConfigFile,
50
+ }),
51
+ ],
52
+ },
53
+ mode: 'none',
54
+ optimization: {
55
+ nodeEnv: false,
56
+ },
57
+ node: {
58
+ __filename: false,
59
+ __dirname: false,
60
+ },
45
61
  plugins: [
46
- new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({
47
- configFile: tsConfigFile,
62
+ new webpack.IgnorePlugin({
63
+ checkResource(resource) {
64
+ const lazyImports = [
65
+ '@nestjs/microservices',
66
+ 'cache-manager',
67
+ 'class-validator',
68
+ 'class-transformer',
69
+ ];
70
+ if (!lazyImports.includes(resource)) {
71
+ return false;
72
+ }
73
+ try {
74
+ require.resolve(resource, {
75
+ paths: [process.cwd()],
76
+ });
77
+ }
78
+ catch (err) {
79
+ return true;
80
+ }
81
+ return false;
82
+ },
48
83
  }),
49
84
  ],
50
- },
51
- mode: 'none',
52
- optimization: {
53
- nodeEnv: false,
54
- },
55
- node: {
56
- __filename: false,
57
- __dirname: false,
58
- },
59
- plugins: [
60
- new webpack.IgnorePlugin({
61
- checkResource(resource) {
62
- const lazyImports = [
63
- '@nestjs/microservices',
64
- 'cache-manager',
65
- 'class-validator',
66
- 'class-transformer',
67
- ];
68
- if (!lazyImports.includes(resource)) {
69
- return false;
70
- }
71
- try {
72
- require.resolve(resource, {
73
- paths: [process.cwd()],
74
- });
75
- }
76
- catch (err) {
77
- return true;
78
- }
79
- return false;
80
- },
81
- }),
82
- new ForkTsCheckerWebpackPlugin({
85
+ };
86
+ if (!isPluginRegistered) {
87
+ webpackConfiguration.plugins.push(new ForkTsCheckerWebpackPlugin({
83
88
  typescript: {
84
89
  configFile: tsConfigFile,
85
90
  },
86
- }),
87
- ],
88
- });
91
+ }));
92
+ }
93
+ return webpackConfiguration;
94
+ };
89
95
  exports.webpackDefaultsFactory = webpackDefaultsFactory;
90
96
  function isAnyPluginRegistered(plugins) {
91
97
  return ((plugins.afterHooks && plugins.afterHooks.length > 0) ||
@@ -28,6 +28,7 @@ interface PluginOptions {
28
28
  }
29
29
  interface GenerateOptions {
30
30
  spec?: boolean | Record<string, boolean>;
31
+ flat?: boolean;
31
32
  }
32
33
  export interface ProjectConfiguration {
33
34
  type?: string;
@@ -14,8 +14,8 @@ class PnpmPackageManager extends abstract_package_manager_1.AbstractPackageManag
14
14
  // As of PNPM v5.3, all commands are shared with NPM v6.14.5. See: https://pnpm.js.org/en/pnpm-vs-npm
15
15
  get cli() {
16
16
  return {
17
- install: 'install',
18
- add: 'install',
17
+ install: 'install --strict-peer-dependencies=false',
18
+ add: 'install --strict-peer-dependencies=false',
19
19
  update: 'update',
20
20
  remove: 'uninstall',
21
21
  saveFlag: '--save',
@@ -1,8 +1,11 @@
1
1
  import { Answers } from 'inquirer';
2
+ import { Input } from '../../commands';
2
3
  import { Configuration, ProjectConfiguration } from '../configuration';
3
4
  export declare function shouldAskForProject(schematic: string, configurationProjects: {
4
5
  [key: string]: ProjectConfiguration;
5
6
  }, appName: string): boolean;
6
7
  export declare function shouldGenerateSpec(configuration: Required<Configuration>, schematic: string, appName: string, specValue: boolean, specPassedAsInput?: boolean): any;
8
+ export declare function shouldGenerateFlat(configuration: Required<Configuration>, appName: string, flatValue: boolean): boolean;
7
9
  export declare function askForProjectName(promptQuestion: string, projects: string[]): Promise<Answers>;
8
10
  export declare function moveDefaultProjectToStart(configuration: Configuration, defaultProjectName: string, defaultLabel: string): string[];
11
+ 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.moveDefaultProjectToStart = exports.askForProjectName = exports.shouldGenerateSpec = exports.shouldAskForProject = void 0;
12
+ exports.hasValidOptionFlag = exports.moveDefaultProjectToStart = exports.askForProjectName = 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");
@@ -48,6 +48,18 @@ function shouldGenerateSpec(configuration, schematic, appName, specValue, specPa
48
48
  return specValue;
49
49
  }
50
50
  exports.shouldGenerateSpec = shouldGenerateSpec;
51
+ function shouldGenerateFlat(configuration, appName, flatValue) {
52
+ // CLI parameters have the highest priority
53
+ if (flatValue === true) {
54
+ return flatValue;
55
+ }
56
+ const flatConfiguration = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'generateOptions.flat', appName || '');
57
+ if (typeof flatConfiguration === 'boolean') {
58
+ return flatConfiguration;
59
+ }
60
+ return flatValue;
61
+ }
62
+ exports.shouldGenerateFlat = shouldGenerateFlat;
51
63
  function askForProjectName(promptQuestion, projects) {
52
64
  return __awaiter(this, void 0, void 0, function* () {
53
65
  const questions = [
@@ -67,3 +79,7 @@ function moveDefaultProjectToStart(configuration, defaultProjectName, defaultLab
67
79
  return projects;
68
80
  }
69
81
  exports.moveDefaultProjectToStart = moveDefaultProjectToStart;
82
+ function hasValidOptionFlag(queriedOptionName, options, queriedValue = true) {
83
+ return options.some((option) => option.name === queriedOptionName && option.value === queriedValue);
84
+ }
85
+ exports.hasValidOptionFlag = hasValidOptionFlag;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/cli",
3
- "version": "9.1.3",
3
+ "version": "9.1.5",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -57,7 +57,7 @@
57
57
  "tree-kill": "1.2.2",
58
58
  "tsconfig-paths": "4.1.0",
59
59
  "tsconfig-paths-webpack-plugin": "4.0.0",
60
- "typescript": "4.8.3",
60
+ "typescript": "4.8.4",
61
61
  "webpack": "5.74.0",
62
62
  "webpack-node-externals": "3.0.0"
63
63
  },
@@ -65,19 +65,19 @@
65
65
  "@commitlint/cli": "17.1.2",
66
66
  "@commitlint/config-angular": "17.1.0",
67
67
  "@types/copyfiles": "2.4.1",
68
- "@types/inquirer": "8.2.3",
68
+ "@types/inquirer": "8.2.4",
69
69
  "@types/jest": "28.1.8",
70
- "@types/node": "16.11.58",
71
- "@types/node-emoji": "1.8.1",
70
+ "@types/node": "18.11.7",
71
+ "@types/node-emoji": "1.8.2",
72
72
  "@types/ora": "3.2.0",
73
73
  "@types/os-name": "3.1.0",
74
74
  "@types/rimraf": "3.0.2",
75
75
  "@types/shelljs": "0.8.11",
76
76
  "@types/webpack-node-externals": "2.5.3",
77
- "@typescript-eslint/eslint-plugin": "5.36.2",
78
- "@typescript-eslint/parser": "5.36.2",
77
+ "@typescript-eslint/eslint-plugin": "5.41.0",
78
+ "@typescript-eslint/parser": "5.41.0",
79
79
  "delete-empty": "3.0.0",
80
- "eslint": "8.23.1",
80
+ "eslint": "8.26.0",
81
81
  "eslint-config-prettier": "8.5.0",
82
82
  "eslint-plugin-import": "2.26.0",
83
83
  "gulp": "4.0.2",
@@ -86,9 +86,9 @@
86
86
  "jest": "28.1.3",
87
87
  "lint-staged": "13.0.3",
88
88
  "prettier": "2.7.1",
89
- "release-it": "15.4.1",
89
+ "release-it": "15.5.0",
90
90
  "ts-jest": "28.0.8",
91
- "ts-loader": "9.3.1",
91
+ "ts-loader": "9.4.1",
92
92
  "ts-node": "10.9.1"
93
93
  },
94
94
  "lint-staged": {