@nestjs/cli 8.1.5 → 8.2.0

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.
package/.eslintrc.js CHANGED
@@ -8,8 +8,7 @@ module.exports = {
8
8
  extends: [
9
9
  'plugin:@typescript-eslint/eslint-recommended',
10
10
  'plugin:@typescript-eslint/recommended',
11
- 'prettier',
12
- 'prettier/@typescript-eslint',
11
+ 'prettier'
13
12
  ],
14
13
  root: true,
15
14
  env: {
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2020
3
+ Copyright (c) 2017-2022
4
4
  Kamil Mysliwiec <https://kamilmysliwiec.com>
5
5
  Thomas Ricart <thomasr2309@gmail.com>
6
6
 
@@ -39,14 +39,14 @@ class AddAction extends abstract_action_1.AbstractAction {
39
39
  }
40
40
  getSourceRoot(inputs) {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
- const configuration = yield load_configuration_1.loadConfiguration();
42
+ const configuration = yield (0, load_configuration_1.loadConfiguration)();
43
43
  const configurationProjects = configuration.projects;
44
44
  const appName = inputs.find((option) => option.name === 'project')
45
45
  .value;
46
46
  let sourceRoot = appName
47
- ? get_value_or_default_1.getValueOrDefault(configuration, 'sourceRoot', appName)
47
+ ? (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName)
48
48
  : configuration.sourceRoot;
49
- const shouldAsk = project_utils_1.shouldAskForProject(schematicName, configurationProjects, appName);
49
+ const shouldAsk = (0, project_utils_1.shouldAskForProject)(schematicName, configurationProjects, appName);
50
50
  if (shouldAsk) {
51
51
  const defaultLabel = ' [ Default ]';
52
52
  let defaultProjectName = configuration.sourceRoot + defaultLabel;
@@ -57,8 +57,8 @@ class AddAction extends abstract_action_1.AbstractAction {
57
57
  break;
58
58
  }
59
59
  }
60
- const projects = project_utils_1.moveDefaultProjectToStart(configuration, defaultProjectName, defaultLabel);
61
- const answers = yield project_utils_1.askForProjectName(ui_1.MESSAGES.LIBRARY_PROJECT_SELECTION_QUESTION, projects);
60
+ const projects = (0, project_utils_1.moveDefaultProjectToStart)(configuration, defaultProjectName, defaultLabel);
61
+ const answers = yield (0, project_utils_1.askForProjectName)(ui_1.MESSAGES.LIBRARY_PROJECT_SELECTION_QUESTION, projects);
62
62
  const project = answers.appName.replace(defaultLabel, '');
63
63
  if (project !== configuration.sourceRoot) {
64
64
  sourceRoot = configurationProjects[project].sourceRoot;
@@ -66,14 +66,14 @@ class BuildAction extends abstract_action_1.AbstractAction {
66
66
  const configuration = yield this.loader.load(configFileName);
67
67
  const appName = inputs.find((input) => input.name === 'app')
68
68
  .value;
69
- const pathToTsconfig = get_value_or_default_1.getValueOrDefault(configuration, 'compilerOptions.tsConfigPath', appName, 'path', options);
69
+ const pathToTsconfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.tsConfigPath', appName, 'path', options);
70
70
  const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
71
71
  const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
72
- const isWebpackEnabled = get_value_or_default_1.getValueOrDefault(configuration, 'compilerOptions.webpack', appName, 'webpack', options);
72
+ const isWebpackEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpack', appName, 'webpack', options);
73
73
  yield this.workspaceUtils.deleteOutDirIfEnabled(configuration, appName, outDir);
74
74
  this.assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode);
75
75
  if (isWebpackEnabled) {
76
- const webpackPath = get_value_or_default_1.getValueOrDefault(configuration, 'compilerOptions.webpackConfigPath', appName, 'webpackPath', options);
76
+ const webpackPath = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpackConfigPath', appName, 'webpackPath', options);
77
77
  const webpackConfigFactoryOrConfig = this.getWebpackConfigFactoryByPath(webpackPath, configuration.compilerOptions.webpackConfigPath);
78
78
  return this.webpackCompiler.run(configuration, webpackConfigFactoryOrConfig, pathToTsconfig, appName, isDebugEnabled, watchMode, this.assetsManager, onSuccess);
79
79
  }
@@ -92,7 +92,7 @@ class BuildAction extends abstract_action_1.AbstractAction {
92
92
  });
93
93
  }
94
94
  getWebpackConfigFactoryByPath(webpackPath, defaultPath) {
95
- const pathToWebpackFile = path_1.join(process.cwd(), webpackPath);
95
+ const pathToWebpackFile = (0, path_1.join)(process.cwd(), webpackPath);
96
96
  try {
97
97
  return require(pathToWebpackFile);
98
98
  }
@@ -26,7 +26,7 @@ class GenerateAction extends abstract_action_1.AbstractAction {
26
26
  }
27
27
  exports.GenerateAction = GenerateAction;
28
28
  const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* () {
29
- const configuration = yield load_configuration_1.loadConfiguration();
29
+ const configuration = yield (0, load_configuration_1.loadConfiguration)();
30
30
  const collectionOption = inputs.find((option) => option.name === 'collection').value;
31
31
  const schematic = inputs.find((option) => option.name === 'schematic')
32
32
  .value;
@@ -38,14 +38,14 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
38
38
  schematicOptions.push(new schematics_1.SchematicOption('language', configuration.language));
39
39
  const configurationProjects = configuration.projects;
40
40
  let sourceRoot = appName
41
- ? get_value_or_default_1.getValueOrDefault(configuration, 'sourceRoot', appName)
41
+ ? (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName)
42
42
  : configuration.sourceRoot;
43
43
  const specValue = spec.value;
44
44
  const specOptions = spec.options;
45
- let generateSpec = project_utils_1.shouldGenerateSpec(configuration, schematic, appName, specValue, specOptions.passedAsInput);
45
+ let generateSpec = (0, project_utils_1.shouldGenerateSpec)(configuration, schematic, appName, specValue, specOptions.passedAsInput);
46
46
  // If you only add a `lib` we actually don't have monorepo: true BUT we do have "projects"
47
47
  // Ensure we don't run for new app/libs schematics
48
- if (project_utils_1.shouldAskForProject(schematic, configurationProjects, appName)) {
48
+ if ((0, project_utils_1.shouldAskForProject)(schematic, configurationProjects, appName)) {
49
49
  const defaultLabel = ' [ Default ]';
50
50
  let defaultProjectName = configuration.sourceRoot + defaultLabel;
51
51
  for (const property in configurationProjects) {
@@ -54,15 +54,15 @@ const generateFiles = (inputs) => __awaiter(void 0, void 0, void 0, function* ()
54
54
  break;
55
55
  }
56
56
  }
57
- const projects = project_utils_1.moveDefaultProjectToStart(configuration, defaultProjectName, defaultLabel);
58
- const answers = yield project_utils_1.askForProjectName(ui_1.MESSAGES.PROJECT_SELECTION_QUESTION, projects);
57
+ const projects = (0, project_utils_1.moveDefaultProjectToStart)(configuration, defaultProjectName, defaultLabel);
58
+ const answers = yield (0, project_utils_1.askForProjectName)(ui_1.MESSAGES.PROJECT_SELECTION_QUESTION, projects);
59
59
  const project = answers.appName.replace(defaultLabel, '');
60
60
  if (project !== configuration.sourceRoot) {
61
61
  sourceRoot = configurationProjects[project].sourceRoot;
62
62
  }
63
63
  if (answers.appName !== defaultProjectName) {
64
64
  // Only overwrite if the appName is not the default- as it has already been loaded above
65
- generateSpec = project_utils_1.shouldGenerateSpec(configuration, schematic, answers.appName, specValue, specOptions.passedAsInput);
65
+ generateSpec = (0, project_utils_1.shouldGenerateSpec)(configuration, schematic, answers.appName, specValue, specOptions.passedAsInput);
66
66
  }
67
67
  }
68
68
  schematicOptions.push(new schematics_1.SchematicOption('sourceRoot', sourceRoot));
@@ -33,7 +33,7 @@ class InfoAction extends abstract_action_1.AbstractAction {
33
33
  displaySystemInformation() {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
35
  console.info(chalk.green('[System Information]'));
36
- console.info('OS Version :', chalk.blue(osName(os_1.platform(), os_1.release())));
36
+ console.info('OS Version :', chalk.blue(osName((0, os_1.platform)(), (0, os_1.release)())));
37
37
  console.info('NodeJS Version :', chalk.blue(process.version));
38
38
  yield this.displayPackageManagerVersion();
39
39
  });
@@ -69,10 +69,10 @@ class InfoAction extends abstract_action_1.AbstractAction {
69
69
  }
70
70
  displayCliVersion() {
71
71
  console.info(chalk.green('[Nest CLI]'));
72
- console.info('Nest CLI Version :', chalk.blue(JSON.parse(fs_1.readFileSync(path_1.join(__dirname, '../package.json')).toString()).version), '\n');
72
+ console.info('Nest CLI Version :', chalk.blue(JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../package.json')).toString()).version), '\n');
73
73
  }
74
74
  readProjectPackageDependencies() {
75
- const buffer = fs_1.readFileSync(path_1.join(process.cwd(), 'package.json'));
75
+ const buffer = (0, fs_1.readFileSync)((0, path_1.join)(process.cwd(), 'package.json'));
76
76
  const pack = JSON.parse(buffer.toString());
77
77
  const dependencies = Object.assign(Object.assign({}, pack.dependencies), pack.devDependencies);
78
78
  Object.keys(dependencies).forEach((key) => {
@@ -94,7 +94,7 @@ class InfoAction extends abstract_action_1.AbstractAction {
94
94
  Object.keys(dependencies).forEach((key) => {
95
95
  if (key.indexOf('@nestjs') > -1) {
96
96
  const depPackagePath = require.resolve(key + '/package.json', { paths: [process.cwd()] });
97
- const depPackage = fs_1.readFileSync(depPackagePath).toString();
97
+ const depPackage = (0, fs_1.readFileSync)(depPackagePath).toString();
98
98
  const value = JSON.parse(depPackage).version;
99
99
  nestDependencies.push({
100
100
  name: `${key.replace(/@nestjs\//, '').replace(/@.*/, '')} version`,
@@ -53,7 +53,7 @@ exports.NewAction = NewAction;
53
53
  const getApplicationNameInput = (inputs) => inputs.find((input) => input.name === 'name');
54
54
  const getProjectDirectory = (applicationName, directoryOption) => {
55
55
  return ((directoryOption && directoryOption.value) ||
56
- strings_1.dasherize(applicationName.value));
56
+ (0, strings_1.dasherize)(applicationName.value));
57
57
  };
58
58
  const askForMissingInformation = (inputs) => __awaiter(void 0, void 0, void 0, function* () {
59
59
  console.info(ui_1.MESSAGES.PROJECT_INFORMATION_START);
@@ -62,7 +62,7 @@ const askForMissingInformation = (inputs) => __awaiter(void 0, void 0, void 0, f
62
62
  const nameInput = getApplicationNameInput(inputs);
63
63
  if (!nameInput.value) {
64
64
  const message = 'What name would you like to use for the new project?';
65
- const questions = [questions_1.generateInput('name', message)('nest-app')];
65
+ const questions = [(0, questions_1.generateInput)('name', message)('nest-app')];
66
66
  const answers = yield prompt(questions);
67
67
  replaceInputMissingInformation(inputs, answers);
68
68
  }
@@ -118,7 +118,7 @@ const selectPackageManager = () => __awaiter(void 0, void 0, void 0, function* (
118
118
  });
119
119
  const askForPackageManager = () => __awaiter(void 0, void 0, void 0, function* () {
120
120
  const questions = [
121
- questions_1.generateSelect('package-manager')(ui_1.MESSAGES.PACKAGE_MANAGER_QUESTION)([
121
+ (0, questions_1.generateSelect)('package-manager')(ui_1.MESSAGES.PACKAGE_MANAGER_QUESTION)([
122
122
  package_managers_1.PackageManager.NPM,
123
123
  package_managers_1.PackageManager.YARN,
124
124
  package_managers_1.PackageManager.PNPM
@@ -129,7 +129,7 @@ const askForPackageManager = () => __awaiter(void 0, void 0, void 0, function* (
129
129
  });
130
130
  const initializeGitRepository = (dir) => __awaiter(void 0, void 0, void 0, function* () {
131
131
  const runner = new git_runner_1.GitRunner();
132
- yield runner.run('init', true, path_1.join(process.cwd(), dir)).catch(() => {
132
+ yield runner.run('init', true, (0, path_1.join)(process.cwd(), dir)).catch(() => {
133
133
  console.error(chalk.red(ui_1.MESSAGES.GIT_INITIALIZATION_ERROR));
134
134
  });
135
135
  });
@@ -145,8 +145,8 @@ const initializeGitRepository = (dir) => __awaiter(void 0, void 0, void 0, funct
145
145
  */
146
146
  const createGitIgnoreFile = (dir, content) => {
147
147
  const fileContent = content || defaults_1.defaultGitIgnore;
148
- const filePath = path_1.join(process.cwd(), dir, '.gitignore');
149
- return util_1.promisify(fs.writeFile)(filePath, fileContent);
148
+ const filePath = (0, path_1.join)(process.cwd(), dir, '.gitignore');
149
+ return (0, util_1.promisify)(fs.writeFile)(filePath, fileContent);
150
150
  };
151
151
  const printCollective = () => {
152
152
  const dim = print('dim');
@@ -162,7 +162,7 @@ const printCollective = () => {
162
162
  emptyLine();
163
163
  };
164
164
  const print = (color = null) => (str = '') => {
165
- const terminalCols = exports.retrieveCols();
165
+ const terminalCols = (0, exports.retrieveCols)();
166
166
  const strLength = str.replace(/\u001b\[[0-9]{2}m/g, '').length;
167
167
  const leftPaddingLength = Math.floor((terminalCols - strLength) / 2);
168
168
  const leftPadding = ' '.repeat(Math.max(leftPaddingLength, 0));
@@ -174,7 +174,7 @@ const print = (color = null) => (str = '') => {
174
174
  const retrieveCols = () => {
175
175
  const defaultCols = 80;
176
176
  try {
177
- const terminalCols = child_process_1.execSync('tput cols', {
177
+ const terminalCols = (0, child_process_1.execSync)('tput cols', {
178
178
  stdio: ['pipe', 'pipe', 'ignore'],
179
179
  });
180
180
  return parseInt(terminalCols.toString(), 10) || defaultCols;
@@ -29,7 +29,7 @@ class StartAction extends build_action_1.BuildAction {
29
29
  const configuration = yield this.loader.load(configFileName);
30
30
  const appName = inputs.find((input) => input.name === 'app')
31
31
  .value;
32
- const pathToTsconfig = get_value_or_default_1.getValueOrDefault(configuration, 'compilerOptions.tsConfigPath', appName, 'path', options);
32
+ const pathToTsconfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.tsConfigPath', appName, 'path', options);
33
33
  const binaryToRunOption = options.find((option) => option.name === 'exec');
34
34
  const debugModeOption = options.find((option) => option.name === 'debug');
35
35
  const watchModeOption = options.find((option) => option.name === 'watch');
@@ -54,10 +54,10 @@ class StartAction extends build_action_1.BuildAction {
54
54
  });
55
55
  }
56
56
  createOnSuccessHook(configuration, appName, debugFlag, outDirName, binaryToRun = 'node') {
57
- const sourceRoot = get_value_or_default_1.getValueOrDefault(configuration, 'sourceRoot', appName);
58
- const entryFile = get_value_or_default_1.getValueOrDefault(configuration, 'entryFile', appName);
57
+ const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName);
58
+ const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName);
59
59
  let childProcessRef;
60
- process.on('exit', () => childProcessRef && tree_kill_1.treeKillSync(childProcessRef.pid));
60
+ process.on('exit', () => childProcessRef && (0, tree_kill_1.treeKillSync)(childProcessRef.pid));
61
61
  return () => {
62
62
  if (childProcessRef) {
63
63
  childProcessRef.removeAllListeners('exit');
@@ -78,9 +78,9 @@ class StartAction extends build_action_1.BuildAction {
78
78
  };
79
79
  }
80
80
  spawnChildProcess(entryFile, sourceRoot, debug, outDirName, binaryToRun) {
81
- let outputFilePath = path_1.join(outDirName, sourceRoot, entryFile);
81
+ let outputFilePath = (0, path_1.join)(outDirName, sourceRoot, entryFile);
82
82
  if (!fs.existsSync(outputFilePath + '.js')) {
83
- outputFilePath = path_1.join(outDirName, entryFile);
83
+ outputFilePath = (0, path_1.join)(outDirName, entryFile);
84
84
  }
85
85
  let childProcessArgs = [];
86
86
  const argsStartIndex = process.argv.indexOf('--');
@@ -97,7 +97,7 @@ class StartAction extends build_action_1.BuildAction {
97
97
  if (this.isSourceMapSupportPkgAvailable()) {
98
98
  processArgs.unshift('-r source-map-support/register');
99
99
  }
100
- return child_process_1.spawn(binaryToRun, processArgs, {
100
+ return (0, child_process_1.spawn)(binaryToRun, processArgs, {
101
101
  stdio: 'inherit',
102
102
  shell: true,
103
103
  });
package/bin/nest.js CHANGED
@@ -10,8 +10,8 @@ const bootstrap = () => {
10
10
  .version(require('../package.json').version, '-v, --version', 'Output the current version.')
11
11
  .usage('<command> [options]')
12
12
  .helpOption('-h, --help', 'Output usage information.');
13
- if (local_binaries_1.localBinExists()) {
14
- const localCommandLoader = local_binaries_1.loadLocalBinCommandLoader();
13
+ if ((0, local_binaries_1.localBinExists)()) {
14
+ const localCommandLoader = (0, local_binaries_1.loadLocalBinCommandLoader)();
15
15
  localCommandLoader.load(program);
16
16
  }
17
17
  else {
@@ -30,7 +30,7 @@ class AddCommand extends abstract_command_1.AbstractCommand {
30
30
  });
31
31
  const inputs = [];
32
32
  inputs.push({ name: 'library', value: library });
33
- const flags = remaining_flags_1.getRemainingFlags(program);
33
+ const flags = (0, remaining_flags_1.getRemainingFlags)(program);
34
34
  try {
35
35
  yield this.action.handle(inputs, options, flags);
36
36
  }
@@ -62,7 +62,7 @@ class GenerateCommand extends abstract_command_1.AbstractCommand {
62
62
  }
63
63
  buildDescription() {
64
64
  return ('Generate a Nest element.\n' +
65
- ' Available schematics:\n' +
65
+ ` Schematics available on ${chalk.bold('@nestjs/schematics')} collection:\n` +
66
66
  this.buildSchematicsListAsTable());
67
67
  }
68
68
  buildSchematicsListAsTable() {
@@ -33,29 +33,29 @@ class AssetsManager {
33
33
  setTimeout(closeFn, timeoutMs);
34
34
  }
35
35
  copyAssets(configuration, appName, outDir, watchAssetsMode) {
36
- const assets = get_value_or_default_1.getValueOrDefault(configuration, 'compilerOptions.assets', appName) || [];
36
+ const assets = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.assets', appName) || [];
37
37
  if (assets.length <= 0) {
38
38
  return;
39
39
  }
40
40
  try {
41
- let sourceRoot = get_value_or_default_1.getValueOrDefault(configuration, 'sourceRoot', appName);
42
- sourceRoot = path_1.join(process.cwd(), sourceRoot);
41
+ let sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName);
42
+ sourceRoot = (0, path_1.join)(process.cwd(), sourceRoot);
43
43
  const filesToCopy = assets.map((item) => {
44
44
  if (typeof item === 'string') {
45
45
  return {
46
- glob: path_1.join(sourceRoot, item),
46
+ glob: (0, path_1.join)(sourceRoot, item),
47
47
  outDir,
48
48
  };
49
49
  }
50
50
  return {
51
51
  outDir: item.outDir || outDir,
52
- glob: path_1.join(sourceRoot, item.include),
53
- exclude: item.exclude ? path_1.join(sourceRoot, item.exclude) : undefined,
52
+ glob: (0, path_1.join)(sourceRoot, item.include),
53
+ exclude: item.exclude ? (0, path_1.join)(sourceRoot, item.exclude) : undefined,
54
54
  flat: item.flat,
55
55
  watchAssets: item.watchAssets,
56
56
  };
57
57
  });
58
- const isWatchEnabled = get_value_or_default_1.getValueOrDefault(configuration, 'compilerOptions.watchAssets', appName) || watchAssetsMode;
58
+ const isWatchEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.watchAssets', appName) || watchAssetsMode;
59
59
  for (const item of filesToCopy) {
60
60
  const option = {
61
61
  action: 'change',
@@ -88,10 +88,10 @@ class AssetsManager {
88
88
  this.watchAssetsKeyValue[path] = true;
89
89
  // Set action to true to avoid watches getting cutoff
90
90
  this.actionInProgress = true;
91
- const dest = copy_path_resolve_1.copyPathResolve(path, item.outDir, sourceRoot.split(path_1.sep).length);
91
+ const dest = (0, copy_path_resolve_1.copyPathResolve)(path, item.outDir, sourceRoot.split(path_1.sep).length);
92
92
  // Copy to output dir if file is changed or added
93
93
  if (action === 'change') {
94
- shell.mkdir('-p', path_1.dirname(dest));
94
+ shell.mkdir('-p', (0, path_1.dirname)(dest));
95
95
  shell.cp(path, dest);
96
96
  }
97
97
  else if (action === 'unlink') {
@@ -24,9 +24,9 @@ class Compiler {
24
24
  projectReferences,
25
25
  options,
26
26
  });
27
- const pluginsConfig = get_value_or_default_1.getValueOrDefault(configuration, 'compilerOptions.plugins', appName);
27
+ const pluginsConfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.plugins', appName);
28
28
  const plugins = this.pluginsLoader.load(pluginsConfig);
29
- const tsconfigPathsPlugin = tsconfig_paths_hook_1.tsconfigPathsBeforeHookFactory(options);
29
+ const tsconfigPathsPlugin = (0, tsconfig_paths_hook_1.tsconfigPathsBeforeHookFactory)(options);
30
30
  const programRef = program.getProgram
31
31
  ? program.getProgram()
32
32
  : program;
@@ -9,13 +9,15 @@ const append_extension_1 = require("../helpers/append-extension");
9
9
  const webpack = require("webpack");
10
10
  const nodeExternals = require("webpack-node-externals");
11
11
  const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaults_1.defaultConfiguration.compilerOptions.tsConfigPath, plugins) => ({
12
- entry: append_extension_1.appendTsExtension(path_1.join(sourceRoot, entryFilename)),
12
+ entry: (0, append_extension_1.appendTsExtension)((0, path_1.join)(sourceRoot, entryFilename)),
13
13
  devtool: isDebugEnabled ? 'inline-source-map' : false,
14
14
  target: 'node',
15
15
  output: {
16
- filename: path_1.join(relativeSourceRoot, `${entryFilename}.js`),
16
+ filename: (0, path_1.join)(relativeSourceRoot, `${entryFilename}.js`),
17
17
  },
18
+ ignoreWarnings: [/^(?!CriticalDependenciesWarning$)/],
18
19
  externals: [nodeExternals()],
20
+ externalsPresets: { node: true },
19
21
  module: {
20
22
  rules: [
21
23
  {
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.appendTsExtension = void 0;
4
4
  const path_1 = require("path");
5
5
  function appendTsExtension(path) {
6
- return path_1.extname(path) === '.ts' ? path : path + '.ts';
6
+ return (0, path_1.extname)(path) === '.ts' ? path : path + '.ts';
7
7
  }
8
8
  exports.appendTsExtension = appendTsExtension;
@@ -9,8 +9,8 @@ class TsConfigProvider {
9
9
  this.typescriptLoader = typescriptLoader;
10
10
  }
11
11
  getByConfigFilename(configFilename) {
12
- const configPath = path_1.join(process.cwd(), configFilename);
13
- if (!fs_1.existsSync(configPath)) {
12
+ const configPath = (0, path_1.join)(process.cwd(), configFilename);
13
+ if (!(0, fs_1.existsSync)(configPath)) {
14
14
  throw new Error(ui_1.CLI_ERRORS.MISSING_TYPESCRIPT(configFilename));
15
15
  }
16
16
  const tsBinary = this.typescriptLoader.load();
@@ -27,6 +27,7 @@ function tsconfigPathsBeforeHookFactory(compilerOptions) {
27
27
  }
28
28
  newNode.moduleSpecifier = tsBinary.createLiteral(result);
29
29
  newNode.moduleSpecifier.parent = node.moduleSpecifier.parent;
30
+ newNode.flags = node.flags;
30
31
  return newNode;
31
32
  }
32
33
  catch (_a) {
@@ -59,6 +60,6 @@ function getNotAliasedPath(sf, matcher, text) {
59
60
  }
60
61
  }
61
62
  catch (_a) { }
62
- const resolvedPath = path_1.posix.relative(path_1.dirname(sf.fileName), result) || './';
63
+ const resolvedPath = path_1.posix.relative((0, path_1.dirname)(sf.fileName), result) || './';
63
64
  return resolvedPath[0] === '.' ? resolvedPath : './' + resolvedPath;
64
65
  }
@@ -7,15 +7,15 @@ const ui_1 = require("../ui");
7
7
  const PLUGIN_ENTRY_FILENAME = 'plugin';
8
8
  class PluginsLoader {
9
9
  load(plugins = []) {
10
- const pluginNames = plugins.map((entry) => util_1.isObject(entry) ? entry.name : entry);
10
+ const pluginNames = plugins.map((entry) => (0, util_1.isObject)(entry) ? entry.name : entry);
11
11
  const nodeModulePaths = [
12
- path_1.join(process.cwd(), 'node_modules'),
12
+ (0, path_1.join)(process.cwd(), 'node_modules'),
13
13
  ...module.paths,
14
14
  ];
15
15
  const pluginRefs = pluginNames.map((item) => {
16
16
  try {
17
17
  try {
18
- const binaryPath = require.resolve(path_1.join(item, PLUGIN_ENTRY_FILENAME), {
18
+ const binaryPath = require.resolve((0, path_1.join)(item, PLUGIN_ENTRY_FILENAME), {
19
19
  paths: nodeModulePaths,
20
20
  });
21
21
  return require(binaryPath);
@@ -35,7 +35,7 @@ class PluginsLoader {
35
35
  if (!plugin.before && !plugin.after && !plugin.afterDeclarations) {
36
36
  throw new Error(ui_1.CLI_ERRORS.WRONG_PLUGIN(pluginNames[index]));
37
37
  }
38
- const options = util_1.isObject(plugins[index])
38
+ const options = (0, util_1.isObject)(plugins[index])
39
39
  ? plugins[index].options || {}
40
40
  : {};
41
41
  plugin.before &&
@@ -21,13 +21,13 @@ class WatchCompiler {
21
21
  const origDiagnosticReporter = tsBin.createDiagnosticReporter(tsBin.sys, true);
22
22
  const origWatchStatusReporter = tsBin.createWatchStatusReporter(tsBin.sys, true);
23
23
  const host = tsBin.createWatchCompilerHost(configPath, tsCompilerOptions, tsBin.sys, createProgram, this.createDiagnosticReporter(origDiagnosticReporter), this.createWatchStatusChanged(origWatchStatusReporter, onSuccess));
24
- const pluginsConfig = get_value_or_default_1.getValueOrDefault(configuration, 'compilerOptions.plugins', appName);
24
+ const pluginsConfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.plugins', appName);
25
25
  const plugins = this.pluginsLoader.load(pluginsConfig);
26
26
  const origCreateProgram = host.createProgram;
27
27
  host.createProgram = (rootNames, options,
28
28
  // tslint:disable-next-line:no-shadowed-variable
29
29
  host, oldProgram) => {
30
- const tsconfigPathsPlugin = tsconfig_paths_hook_1.tsconfigPathsBeforeHookFactory(options);
30
+ const tsconfigPathsPlugin = (0, tsconfig_paths_hook_1.tsconfigPathsBeforeHookFactory)(options);
31
31
  const program = origCreateProgram(rootNames, options, host, oldProgram, undefined, projectReferences);
32
32
  const origProgramEmit = program.emit;
33
33
  program.emit = (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) => {
@@ -13,20 +13,20 @@ class WebpackCompiler {
13
13
  }
14
14
  run(configuration, webpackConfigFactoryOrConfig, tsConfigPath, appName, isDebugEnabled = false, watchMode = false, assetsManager, onSuccess) {
15
15
  const cwd = process.cwd();
16
- const configPath = path_1.join(cwd, tsConfigPath);
17
- if (!fs_1.existsSync(configPath)) {
16
+ const configPath = (0, path_1.join)(cwd, tsConfigPath);
17
+ if (!(0, fs_1.existsSync)(configPath)) {
18
18
  throw new Error(`Could not find TypeScript configuration file "${tsConfigPath}".`);
19
19
  }
20
- const pluginsConfig = get_value_or_default_1.getValueOrDefault(configuration, 'compilerOptions.plugins', appName);
20
+ const pluginsConfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.plugins', appName);
21
21
  const plugins = this.pluginsLoader.load(pluginsConfig);
22
- const relativeRootPath = path_1.dirname(path_1.relative(cwd, configPath));
23
- const sourceRoot = get_value_or_default_1.getValueOrDefault(configuration, 'sourceRoot', appName);
24
- const pathToSource = path_1.normalize(sourceRoot).indexOf(path_1.normalize(relativeRootPath)) >= 0
25
- ? path_1.join(cwd, sourceRoot)
26
- : path_1.join(cwd, relativeRootPath, sourceRoot);
27
- const entryFile = get_value_or_default_1.getValueOrDefault(configuration, 'entryFile', appName);
28
- const entryFileRoot = get_value_or_default_1.getValueOrDefault(configuration, 'root', appName) || '';
29
- const defaultOptions = webpack_defaults_1.webpackDefaultsFactory(pathToSource, entryFileRoot, entryFile, isDebugEnabled, tsConfigPath, plugins);
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);
24
+ const pathToSource = (0, path_1.normalize)(sourceRoot).indexOf((0, path_1.normalize)(relativeRootPath)) >= 0
25
+ ? (0, path_1.join)(cwd, sourceRoot)
26
+ : (0, path_1.join)(cwd, relativeRootPath, sourceRoot);
27
+ const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName);
28
+ const entryFileRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'root', appName) || '';
29
+ const defaultOptions = (0, webpack_defaults_1.webpackDefaultsFactory)(pathToSource, entryFileRoot, entryFile, isDebugEnabled, tsConfigPath, plugins);
30
30
  const projectWebpackOptions = typeof webpackConfigFactoryOrConfig !== 'function'
31
31
  ? webpackConfigFactoryOrConfig
32
32
  : webpackConfigFactoryOrConfig(defaultOptions, webpack);
@@ -44,7 +44,6 @@ class WebpackCompiler {
44
44
  colors: true,
45
45
  modules: false,
46
46
  assets: false,
47
- warningsFilter: /^(?!CriticalDependenciesWarning$)/,
48
47
  });
49
48
  if (!err && !stats.hasErrors()) {
50
49
  if (!onSuccess) {
@@ -15,7 +15,7 @@ const get_value_or_default_1 = require("./helpers/get-value-or-default");
15
15
  class WorkspaceUtils {
16
16
  deleteOutDirIfEnabled(configuration, appName, dirPath) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
- const isDeleteEnabled = get_value_or_default_1.getValueOrDefault(configuration, 'compilerOptions.deleteOutDir', appName);
18
+ const isDeleteEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.deleteOutDir', appName);
19
19
  if (!isDeleteEnabled) {
20
20
  return;
21
21
  }
@@ -33,8 +33,8 @@ class AbstractPackageManager {
33
33
  try {
34
34
  const commandArguments = `${this.cli.install} --silent`;
35
35
  const collect = true;
36
- const dasherizedDirectory = strings_1.dasherize(directory);
37
- yield this.runner.run(commandArguments, collect, path_1.join(process.cwd(), dasherizedDirectory));
36
+ const dasherizedDirectory = (0, strings_1.dasherize)(directory);
37
+ yield this.runner.run(commandArguments, collect, (0, path_1.join)(process.cwd(), dasherizedDirectory));
38
38
  spinner.succeed();
39
39
  console.info();
40
40
  console.info(ui_1.MESSAGES.PACKAGE_MANAGER_INSTALLATION_SUCCEED(directory));
@@ -124,7 +124,7 @@ class AbstractPackageManager {
124
124
  readPackageJson() {
125
125
  return __awaiter(this, void 0, void 0, function* () {
126
126
  return new Promise((resolve, reject) => {
127
- fs_1.readFile(path_1.join(process.cwd(), 'package.json'), (error, buffer) => {
127
+ (0, fs_1.readFile)((0, path_1.join)(process.cwd(), 'package.json'), (error, buffer) => {
128
128
  if (error !== undefined && error !== null) {
129
129
  reject(error);
130
130
  }
@@ -31,7 +31,7 @@ class PackageManagerFactory {
31
31
  static find() {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
33
  return new Promise((resolve) => {
34
- fs_1.readdir(process.cwd(), (error, files) => {
34
+ (0, fs_1.readdir)(process.cwd(), (error, files) => {
35
35
  if (error) {
36
36
  resolve(this.create(package_manager_1.PackageManager.NPM));
37
37
  }
@@ -27,7 +27,7 @@ class AbstractRunner {
27
27
  shell: true,
28
28
  };
29
29
  return new Promise((resolve, reject) => {
30
- const child = child_process_1.spawn(`${this.binary}`, [...this.args, ...args], options);
30
+ const child = (0, child_process_1.spawn)(`${this.binary}`, [...this.args, ...args], options);
31
31
  if (collect) {
32
32
  child.stdout.on('data', (data) => resolve(data.toString().replace(/\r\n|\n/, '')));
33
33
  }
package/lib/ui/emojis.js CHANGED
@@ -3,21 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EMOJIS = void 0;
4
4
  const node_emoji_1 = require("node-emoji");
5
5
  exports.EMOJIS = {
6
- HEART: node_emoji_1.get('heart'),
7
- COFFEE: node_emoji_1.get('coffee'),
8
- BEER: node_emoji_1.get('beer'),
9
- BROKEN_HEART: node_emoji_1.get('broken_heart'),
10
- CRYING: node_emoji_1.get('crying_cat_face'),
11
- HEART_EYES: node_emoji_1.get('heart_eyes_cat'),
12
- JOY: node_emoji_1.get('joy_cat'),
13
- KISSING: node_emoji_1.get('kissing_cat'),
14
- SCREAM: node_emoji_1.get('scream_cat'),
15
- ROCKET: node_emoji_1.get('rocket'),
16
- SMIRK: node_emoji_1.get('smirk_cat'),
17
- RAISED_HANDS: node_emoji_1.get('raised_hands'),
18
- POINT_RIGHT: node_emoji_1.get('point_right'),
19
- ZAP: node_emoji_1.get('zap'),
20
- BOOM: node_emoji_1.get('boom'),
21
- PRAY: node_emoji_1.get('pray'),
22
- WINE: node_emoji_1.get('wine_glass'),
6
+ HEART: (0, node_emoji_1.get)('heart'),
7
+ COFFEE: (0, node_emoji_1.get)('coffee'),
8
+ BEER: (0, node_emoji_1.get)('beer'),
9
+ BROKEN_HEART: (0, node_emoji_1.get)('broken_heart'),
10
+ CRYING: (0, node_emoji_1.get)('crying_cat_face'),
11
+ HEART_EYES: (0, node_emoji_1.get)('heart_eyes_cat'),
12
+ JOY: (0, node_emoji_1.get)('joy_cat'),
13
+ KISSING: (0, node_emoji_1.get)('kissing_cat'),
14
+ SCREAM: (0, node_emoji_1.get)('scream_cat'),
15
+ ROCKET: (0, node_emoji_1.get)('rocket'),
16
+ SMIRK: (0, node_emoji_1.get)('smirk_cat'),
17
+ RAISED_HANDS: (0, node_emoji_1.get)('raised_hands'),
18
+ POINT_RIGHT: (0, node_emoji_1.get)('point_right'),
19
+ ZAP: (0, node_emoji_1.get)('zap'),
20
+ BOOM: (0, node_emoji_1.get)('boom'),
21
+ PRAY: (0, node_emoji_1.get)('pray'),
22
+ WINE: (0, node_emoji_1.get)('wine_glass'),
23
23
  };
@@ -5,7 +5,7 @@ const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const localBinPathSegments = [process.cwd(), 'node_modules', '@nestjs', 'cli'];
7
7
  function localBinExists() {
8
- return fs_1.existsSync(path_1.join(...localBinPathSegments));
8
+ return (0, fs_1.existsSync)((0, path_1.join)(...localBinPathSegments));
9
9
  }
10
10
  exports.localBinExists = localBinExists;
11
11
  function loadLocalBinCommandLoader() {
@@ -25,7 +25,7 @@ function shouldGenerateSpec(configuration, schematic, appName, specValue, specPa
25
25
  // CLI parameters has the highest priority
26
26
  return specValue;
27
27
  }
28
- let specConfiguration = get_value_or_default_1.getValueOrDefault(configuration, 'generateOptions.spec', appName || '');
28
+ let specConfiguration = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'generateOptions.spec', appName || '');
29
29
  if (typeof specConfiguration === 'boolean') {
30
30
  return specConfiguration;
31
31
  }
@@ -36,7 +36,7 @@ function shouldGenerateSpec(configuration, schematic, appName, specValue, specPa
36
36
  if (typeof specConfiguration === 'object' && appName) {
37
37
  // The appName has a generateOption spec, but not for the schematic trying to generate
38
38
  // Check if the global generateOptions has a spec to use instead
39
- specConfiguration = get_value_or_default_1.getValueOrDefault(configuration, 'generateOptions.spec', '');
39
+ specConfiguration = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'generateOptions.spec', '');
40
40
  if (typeof specConfiguration === 'boolean') {
41
41
  return specConfiguration;
42
42
  }
@@ -51,7 +51,7 @@ exports.shouldGenerateSpec = shouldGenerateSpec;
51
51
  function askForProjectName(promptQuestion, projects) {
52
52
  return __awaiter(this, void 0, void 0, function* () {
53
53
  const questions = [
54
- questions_1.generateSelect('appName')(promptQuestion)(projects),
54
+ (0, questions_1.generateSelect)('appName')(promptQuestion)(projects),
55
55
  ];
56
56
  const prompt = inquirer.createPromptModule();
57
57
  return prompt(questions);
@@ -59,7 +59,7 @@ function askForProjectName(promptQuestion, projects) {
59
59
  }
60
60
  exports.askForProjectName = askForProjectName;
61
61
  function moveDefaultProjectToStart(configuration, defaultProjectName, defaultLabel) {
62
- let projects = Object.keys(configuration.projects);
62
+ let projects = configuration.projects != null ? Object.keys(configuration.projects) : [];
63
63
  if (configuration.sourceRoot !== 'src') {
64
64
  projects = projects.filter((p) => p !== defaultProjectName.replace(defaultLabel, ''));
65
65
  }
@@ -4,7 +4,7 @@ exports.treeKillSync = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  function treeKillSync(pid, signal) {
6
6
  if (process.platform === 'win32') {
7
- child_process_1.execSync('taskkill /pid ' + pid + ' /T /F');
7
+ (0, child_process_1.execSync)('taskkill /pid ' + pid + ' /T /F');
8
8
  return;
9
9
  }
10
10
  const childs = getAllChilds(pid);
@@ -16,14 +16,14 @@ function treeKillSync(pid, signal) {
16
16
  }
17
17
  exports.treeKillSync = treeKillSync;
18
18
  function getAllPid() {
19
- const rows = child_process_1.execSync('ps -A -o pid,ppid')
19
+ const rows = (0, child_process_1.execSync)('ps -A -o pid,ppid')
20
20
  .toString()
21
21
  .trim()
22
22
  .split('\n')
23
23
  .slice(1);
24
24
  return rows
25
25
  .map(function (row) {
26
- var parts = row.match(/\s*(\d+)\s*(\d+)/);
26
+ const parts = row.match(/\s*(\d+)\s*(\d+)/);
27
27
  if (parts === null) {
28
28
  return null;
29
29
  }
@@ -38,8 +38,8 @@ function getAllPid() {
38
38
  }
39
39
  function getAllChilds(pid) {
40
40
  const allpid = getAllPid();
41
- let ppidHash = {};
42
- let result = [];
41
+ const ppidHash = {};
42
+ const result = [];
43
43
  allpid.forEach(function (item) {
44
44
  ppidHash[item.ppid] = ppidHash[item.ppid] || [];
45
45
  ppidHash[item.ppid].push(item.pid);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/cli",
3
- "version": "8.1.5",
3
+ "version": "8.2.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -43,55 +43,55 @@
43
43
  },
44
44
  "homepage": "https://github.com/nestjs/nest-cli#readme",
45
45
  "dependencies": {
46
- "@angular-devkit/core": "13.0.3",
47
- "@angular-devkit/schematics": "13.0.3",
48
- "@angular-devkit/schematics-cli": "13.0.3",
46
+ "@angular-devkit/core": "13.1.2",
47
+ "@angular-devkit/schematics": "13.1.2",
48
+ "@angular-devkit/schematics-cli": "13.1.2",
49
49
  "@nestjs/schematics": "^8.0.3",
50
50
  "chalk": "3.0.0",
51
51
  "chokidar": "3.5.2",
52
- "cli-table3": "0.6.0",
52
+ "cli-table3": "0.6.1",
53
53
  "commander": "4.1.1",
54
- "fork-ts-checker-webpack-plugin": "6.4.0",
54
+ "fork-ts-checker-webpack-plugin": "6.5.0",
55
55
  "inquirer": "7.3.3",
56
56
  "node-emoji": "1.11.0",
57
57
  "ora": "5.4.1",
58
58
  "os-name": "4.0.1",
59
59
  "rimraf": "3.0.2",
60
- "shelljs": "0.8.4",
61
- "source-map-support": "0.5.20",
60
+ "shelljs": "0.8.5",
61
+ "source-map-support": "0.5.21",
62
62
  "tree-kill": "1.2.2",
63
- "tsconfig-paths": "3.11.0",
63
+ "tsconfig-paths": "3.12.0",
64
64
  "tsconfig-paths-webpack-plugin": "3.5.2",
65
- "typescript": "4.3.5",
66
- "webpack": "5.64.1",
65
+ "typescript": "4.5.4",
66
+ "webpack": "5.66.0",
67
67
  "webpack-node-externals": "3.0.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@commitlint/cli": "15.0.0",
71
- "@commitlint/config-angular": "15.0.0",
70
+ "@commitlint/cli": "16.0.2",
71
+ "@commitlint/config-angular": "16.0.0",
72
72
  "@types/copyfiles": "2.4.1",
73
73
  "@types/inquirer": "7.3.3",
74
- "@types/jest": "27.0.2",
75
- "@types/node": "16.11.7",
74
+ "@types/jest": "27.4.0",
75
+ "@types/node": "16.11.19",
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.2",
80
- "@types/shelljs": "0.8.9",
80
+ "@types/shelljs": "0.8.10",
81
81
  "@types/webpack-node-externals": "2.5.3",
82
- "@typescript-eslint/eslint-plugin": "5.4.0",
83
- "@typescript-eslint/parser": "5.4.0",
82
+ "@typescript-eslint/eslint-plugin": "5.9.1",
83
+ "@typescript-eslint/parser": "5.9.1",
84
84
  "delete-empty": "3.0.0",
85
- "eslint": "8.2.0",
85
+ "eslint": "8.6.0",
86
86
  "eslint-config-prettier": "8.3.0",
87
- "eslint-plugin-import": "2.25.3",
87
+ "eslint-plugin-import": "2.25.4",
88
88
  "gulp": "4.0.2",
89
89
  "gulp-clean": "0.4.0",
90
90
  "husky": "7.0.4",
91
- "jest": "27.3.1",
92
- "prettier": "2.4.1",
93
- "release-it": "14.11.7",
94
- "ts-jest": "27.0.7",
91
+ "jest": "27.4.7",
92
+ "prettier": "2.5.1",
93
+ "release-it": "14.12.1",
94
+ "ts-jest": "27.1.2",
95
95
  "ts-loader": "9.2.6",
96
96
  "ts-node": "10.4.0"
97
97
  },
@@ -0,0 +1,23 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`tsconfig paths hooks should remove unused imports 1`] = `
4
+ Map {
5
+ "dist/foo.js" => "\\"use strict\\";
6
+ Object.defineProperty(exports, \\"__esModule\\", { value: true });
7
+ exports.Foo = void 0;
8
+ class Foo {
9
+ }
10
+ exports.Foo = Foo;
11
+ ",
12
+ "dist/bar.js" => "\\"use strict\\";
13
+ Object.defineProperty(exports, \\"__esModule\\", { value: true });
14
+ exports.Bar = void 0;
15
+ class Bar {
16
+ }
17
+ exports.Bar = Bar;
18
+ ",
19
+ "dist/main.js" => "\\"use strict\\";
20
+ Object.defineProperty(exports, \\"__esModule\\", { value: true });
21
+ ",
22
+ }
23
+ `;