@nestjs/cli 7.5.7 → 8.0.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: circleci/node:12
24
+ - image: circleci/node:16
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: circleci/node:12
46
+ - image: circleci/node:16
47
47
  steps:
48
48
  - checkout
49
49
  - *restore-cache
@@ -33,7 +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 collection = schematics_1.CollectionFactory.create(collectionOption || configuration.collection);
36
+ const collection = schematics_1.CollectionFactory.create(collectionOption || configuration.collection || schematics_1.Collection.NESTJS);
37
37
  const schematicOptions = mapSchematicOptions(inputs);
38
38
  schematicOptions.push(new schematics_1.SchematicOption('language', configuration.language));
39
39
  const configurationProjects = configuration.projects;
@@ -170,7 +170,7 @@ const print = (color = null) => (str = '') => {
170
170
  }
171
171
  console.log(leftPadding, str);
172
172
  };
173
- exports.retrieveCols = () => {
173
+ const retrieveCols = () => {
174
174
  const defaultCols = 80;
175
175
  try {
176
176
  const terminalCols = child_process_1.execSync('tput cols', {
@@ -182,4 +182,6 @@ exports.retrieveCols = () => {
182
182
  return defaultCols;
183
183
  }
184
184
  };
185
- exports.exit = () => process.exit(1);
185
+ exports.retrieveCols = retrieveCols;
186
+ const exit = () => process.exit(1);
187
+ exports.exit = exit;
@@ -5,4 +5,5 @@ export declare class StartAction extends BuildAction {
5
5
  handle(inputs: Input[], options: Input[]): Promise<void>;
6
6
  createOnSuccessHook(configuration: Required<Configuration>, appName: string, debugFlag: boolean | string | undefined, outDirName: string, binaryToRun?: string): () => void;
7
7
  private spawnChildProcess;
8
+ private isSourceMapSupportPkgAvailable;
8
9
  }
@@ -93,10 +93,22 @@ class StartAction extends build_action_1.BuildAction {
93
93
  const inspectFlag = typeof debug === 'string' ? `--inspect=${debug}` : '--inspect';
94
94
  processArgs.unshift(inspectFlag);
95
95
  }
96
+ if (this.isSourceMapSupportPkgAvailable()) {
97
+ processArgs.unshift('-r source-map-support/register');
98
+ }
96
99
  return child_process_1.spawn(binaryToRun, processArgs, {
97
100
  stdio: 'inherit',
98
101
  shell: true,
99
102
  });
100
103
  }
104
+ isSourceMapSupportPkgAvailable() {
105
+ try {
106
+ require.resolve('source-map-support');
107
+ return true;
108
+ }
109
+ catch (_a) {
110
+ return false;
111
+ }
112
+ }
101
113
  }
102
114
  exports.StartAction = StartAction;
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.GenerateCommand = void 0;
13
13
  const chalk = require("chalk");
14
14
  const Table = require("cli-table3");
15
- const schematics_1 = require("../lib/schematics");
16
15
  const nest_collection_1 = require("../lib/schematics/nest.collection");
17
16
  const abstract_command_1 = require("./abstract.command");
18
17
  class GenerateCommand extends abstract_command_1.AbstractCommand {
@@ -48,7 +47,7 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
48
47
  });
49
48
  options.push({
50
49
  name: 'collection',
51
- value: command.collection || schematics_1.Collection.NESTJS,
50
+ value: command.collection,
52
51
  });
53
52
  options.push({
54
53
  name: 'project',
@@ -32,10 +32,11 @@ class Compiler {
32
32
  : program;
33
33
  const before = plugins.beforeHooks.map((hook) => hook(programRef));
34
34
  const after = plugins.afterHooks.map((hook) => hook(programRef));
35
+ const afterDeclarations = plugins.afterDeclarationsHooks.map((hook) => hook(programRef));
35
36
  const emitResult = program.emit(undefined, undefined, undefined, undefined, {
36
37
  before: before.concat(tsconfigPathsPlugin),
37
38
  after,
38
- afterDeclarations: [],
39
+ afterDeclarations,
39
40
  });
40
41
  const errorsCount = this.reportAfterCompilationDiagnostic(program, emitResult, tsBinary, formatHost);
41
42
  if (errorsCount) {
@@ -8,7 +8,7 @@ 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
- exports.webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaults_1.defaultConfiguration.compilerOptions.tsConfigPath, plugins) => ({
11
+ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaults_1.defaultConfiguration.compilerOptions.tsConfigPath, plugins) => ({
12
12
  entry: append_extension_1.appendTsExtension(path_1.join(sourceRoot, entryFilename)),
13
13
  devtool: isDebugEnabled ? 'inline-source-map' : false,
14
14
  target: 'node',
@@ -29,6 +29,7 @@ exports.webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename,
29
29
  getCustomTransformers: (program) => ({
30
30
  before: plugins.beforeHooks.map((hook) => hook(program)),
31
31
  after: plugins.afterHooks.map((hook) => hook(program)),
32
+ afterDeclaratqions: plugins.afterDeclarationsHooks.map((hook) => hook(program)),
32
33
  }),
33
34
  },
34
35
  },
@@ -83,7 +84,10 @@ exports.webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename,
83
84
  }),
84
85
  ],
85
86
  });
87
+ exports.webpackDefaultsFactory = webpackDefaultsFactory;
86
88
  function isAnyPluginRegistered(plugins) {
87
89
  return ((plugins.afterHooks && plugins.afterHooks.length > 0) ||
88
- (plugins.beforeHooks && plugins.beforeHooks.length > 0));
90
+ (plugins.beforeHooks && plugins.beforeHooks.length > 0) ||
91
+ (plugins.afterDeclarationsHooks &&
92
+ plugins.afterDeclarationsHooks.length > 0));
89
93
  }
@@ -26,6 +26,7 @@ function tsconfigPathsBeforeHookFactory(compilerOptions) {
26
26
  return node;
27
27
  }
28
28
  newNode.moduleSpecifier = tsBinary.createLiteral(result);
29
+ newNode.moduleSpecifier.parent = node.moduleSpecifier.parent;
29
30
  return newNode;
30
31
  }
31
32
  catch (_a) {
@@ -8,10 +8,12 @@ interface PluginAndOptions {
8
8
  export interface NestCompilerPlugin {
9
9
  before?: (options?: Record<string, any>, program?: ts.Program) => Transformer;
10
10
  after?: (options?: Record<string, any>, program?: ts.Program) => Transformer;
11
+ afterDeclarations?: (options?: Record<string, any>, program?: ts.Program) => Transformer;
11
12
  }
12
13
  export interface MultiNestCompilerPlugins {
13
14
  beforeHooks: Array<(program?: ts.Program) => Transformer>;
14
15
  afterHooks: Array<(program?: ts.Program) => Transformer>;
16
+ afterDeclarationsHooks: Array<(program?: ts.Program) => Transformer>;
15
17
  }
16
18
  export declare class PluginsLoader {
17
19
  load(plugins?: PluginEntry[]): MultiNestCompilerPlugins;
@@ -30,8 +30,9 @@ class PluginsLoader {
30
30
  });
31
31
  const beforeHooks = [];
32
32
  const afterHooks = [];
33
+ const afterDeclarationsHooks = [];
33
34
  pluginRefs.forEach((plugin, index) => {
34
- if (!plugin.before && !plugin.after) {
35
+ if (!plugin.before && !plugin.after && !plugin.afterDeclarations) {
35
36
  throw new Error(ui_1.CLI_ERRORS.WRONG_PLUGIN(pluginNames[index]));
36
37
  }
37
38
  const options = util_1.isObject(plugins[index])
@@ -40,10 +41,13 @@ class PluginsLoader {
40
41
  plugin.before &&
41
42
  beforeHooks.push(plugin.before.bind(plugin.before, options));
42
43
  plugin.after && afterHooks.push(plugin.after.bind(plugin.after, options));
44
+ plugin.afterDeclarations &&
45
+ afterDeclarationsHooks.push(plugin.afterDeclarations.bind(plugin.afterDeclarations, options));
43
46
  });
44
47
  return {
45
48
  beforeHooks,
46
49
  afterHooks,
50
+ afterDeclarationsHooks,
47
51
  };
48
52
  }
49
53
  }
@@ -35,9 +35,11 @@ class WatchCompiler {
35
35
  transforms = typeof transforms !== 'object' ? {} : transforms;
36
36
  const before = plugins.beforeHooks.map((hook) => hook(program.getProgram()));
37
37
  const after = plugins.afterHooks.map((hook) => hook(program.getProgram()));
38
+ const afterDeclarations = plugins.afterDeclarationsHooks.map((hook) => hook(program.getProgram()));
38
39
  before.unshift(tsconfigPathsPlugin);
39
40
  transforms.before = before.concat(transforms.before || []);
40
41
  transforms.after = after.concat(transforms.after || []);
42
+ transforms.afterDeclarations = afterDeclarations.concat(transforms.afterDeclarations || []);
41
43
  return origProgramEmit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, transforms);
42
44
  };
43
45
  return program;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateSelect = exports.generateInput = void 0;
4
- exports.generateInput = (name, message) => {
4
+ const generateInput = (name, message) => {
5
5
  return (defaultAnswer) => ({
6
6
  type: 'input',
7
7
  name,
@@ -9,7 +9,8 @@ exports.generateInput = (name, message) => {
9
9
  default: defaultAnswer,
10
10
  });
11
11
  };
12
- exports.generateSelect = (name) => {
12
+ exports.generateInput = generateInput;
13
+ const generateSelect = (name) => {
13
14
  return (message) => {
14
15
  return (choices) => ({
15
16
  type: 'list',
@@ -19,3 +20,4 @@ exports.generateSelect = (name) => {
19
20
  });
20
21
  };
21
22
  };
23
+ exports.generateSelect = generateSelect;
package/lib/ui/errors.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.CLI_ERRORS = void 0;
5
5
  exports.CLI_ERRORS = {
6
6
  MISSING_TYPESCRIPT: (path) => `Could not find TypeScript configuration file "${path}". Please, ensure that you are running this command in the appropriate directory (inside Nest workspace).`,
7
- WRONG_PLUGIN: (name) => `The "${name}" plugin is not compatible with Nest CLI. Neither "after()" nor "before()" function have been provided.`,
7
+ WRONG_PLUGIN: (name) => `The "${name}" plugin is not compatible with Nest CLI. Neither "after()" nor "before()" nor "afterDeclarations()" function have been provided.`,
8
8
  };
@@ -1 +1 @@
1
- export declare function isError(e: Record<string, any> | undefined): boolean;
1
+ export declare function isError(e: Record<string, any> | undefined): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/cli",
3
- "version": "7.5.7",
3
+ "version": "8.0.2",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -43,57 +43,57 @@
43
43
  },
44
44
  "homepage": "https://github.com/nestjs/nest-cli#readme",
45
45
  "dependencies": {
46
- "@angular-devkit/core": "11.2.6",
47
- "@angular-devkit/schematics": "11.2.6",
48
- "@angular-devkit/schematics-cli": "0.1102.6",
49
- "@nestjs/schematics": "^7.3.0",
50
- "@types/webpack": "5.0.0",
46
+ "@angular-devkit/core": "12.1.1",
47
+ "@angular-devkit/schematics": "12.1.1",
48
+ "@angular-devkit/schematics-cli": "12.1.1",
49
+ "@nestjs/schematics": "^8.0.0",
51
50
  "chalk": "3.0.0",
52
- "chokidar": "3.5.1",
51
+ "chokidar": "3.5.2",
53
52
  "cli-table3": "0.5.1",
54
53
  "commander": "4.1.1",
55
- "fork-ts-checker-webpack-plugin": "6.2.0",
54
+ "fork-ts-checker-webpack-plugin": "6.2.12",
56
55
  "inquirer": "7.3.3",
57
56
  "node-emoji": "1.10.0",
58
- "ora": "5.4.0",
57
+ "ora": "5.4.1",
59
58
  "os-name": "4.0.0",
60
59
  "rimraf": "3.0.2",
61
60
  "shelljs": "0.8.4",
61
+ "source-map-support": "0.5.19",
62
62
  "tree-kill": "1.2.2",
63
- "tsconfig-paths": "3.9.0",
63
+ "tsconfig-paths": "3.10.1",
64
64
  "tsconfig-paths-webpack-plugin": "3.5.1",
65
- "typescript": "4.2.3",
66
- "webpack": "5.28.0",
67
- "webpack-node-externals": "2.5.2"
65
+ "typescript": "4.3.5",
66
+ "webpack": "5.43.0",
67
+ "webpack-node-externals": "3.0.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@commitlint/cli": "12.0.1",
71
- "@commitlint/config-angular": "12.0.1",
70
+ "@commitlint/cli": "12.1.4",
71
+ "@commitlint/config-angular": "12.1.4",
72
72
  "@types/copyfiles": "2.4.0",
73
- "@types/inquirer": "7.3.1",
74
- "@types/jest": "26.0.22",
75
- "@types/node": "14.14.36",
73
+ "@types/inquirer": "7.3.3",
74
+ "@types/jest": "26.0.24",
75
+ "@types/node": "14.17.4",
76
76
  "@types/node-emoji": "1.8.1",
77
77
  "@types/ora": "3.2.0",
78
78
  "@types/os-name": "3.1.0",
79
79
  "@types/rimraf": "3.0.0",
80
- "@types/shelljs": "0.8.8",
81
- "@types/webpack-node-externals": "2.5.1",
82
- "@typescript-eslint/eslint-plugin": "4.19.0",
83
- "@typescript-eslint/parser": "4.19.0",
80
+ "@types/shelljs": "0.8.9",
81
+ "@types/webpack-node-externals": "2.5.2",
82
+ "@typescript-eslint/eslint-plugin": "4.28.2",
83
+ "@typescript-eslint/parser": "4.28.2",
84
84
  "delete-empty": "3.0.0",
85
- "eslint": "7.22.0",
86
- "eslint-config-prettier": "8.1.0",
87
- "eslint-plugin-import": "2.22.1",
85
+ "eslint": "7.30.0",
86
+ "eslint-config-prettier": "8.3.0",
87
+ "eslint-plugin-import": "2.23.4",
88
88
  "gulp": "4.0.2",
89
89
  "gulp-clean": "0.4.0",
90
- "husky": "5.2.0",
91
- "jest": "26.6.3",
92
- "prettier": "2.2.1",
93
- "release-it": "14.5.0",
94
- "ts-jest": "26.5.4",
95
- "ts-loader": "8.0.18",
96
- "ts-node": "9.1.1"
90
+ "husky": "7.0.1",
91
+ "jest": "27.0.6",
92
+ "prettier": "2.3.2",
93
+ "release-it": "14.10.0",
94
+ "ts-jest": "27.0.3",
95
+ "ts-loader": "9.2.3",
96
+ "ts-node": "10.0.0"
97
97
  },
98
98
  "husky": {
99
99
  "hooks": {