@nestjs/cli 10.0.0-next.2 → 10.0.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.
Files changed (47) hide show
  1. package/.circleci/config.yml +11 -12
  2. package/actions/add.action.js +67 -84
  3. package/actions/build.action.js +44 -59
  4. package/actions/generate.action.js +8 -19
  5. package/actions/info.action.js +31 -50
  6. package/actions/new.action.js +36 -47
  7. package/actions/start.action.js +29 -40
  8. package/bin/nest.js +4 -13
  9. package/commands/add.command.js +3 -12
  10. package/commands/build.command.js +5 -15
  11. package/commands/command.loader.js +8 -19
  12. package/commands/generate.command.js +67 -84
  13. package/commands/info.command.js +3 -12
  14. package/commands/new.command.js +3 -12
  15. package/commands/start.command.js +5 -15
  16. package/lib/compiler/assets-manager.js +3 -3
  17. package/lib/compiler/hooks/tsconfig-paths.hook.js +2 -2
  18. package/lib/compiler/interfaces/readonly-visitor.interface.d.ts +1 -1
  19. package/lib/compiler/plugins/plugin-metadata-generator.d.ts +40 -0
  20. package/lib/compiler/plugins/plugin-metadata-generator.js +40 -4
  21. package/lib/compiler/plugins/plugin-metadata-printer.d.ts +4 -1
  22. package/lib/compiler/plugins/plugin-metadata-printer.js +6 -6
  23. package/lib/compiler/plugins/plugins-loader.js +6 -2
  24. package/lib/compiler/swc/forked-type-checker.js +26 -35
  25. package/lib/compiler/swc/swc-compiler.js +36 -43
  26. package/lib/compiler/swc/type-checker-host.d.ts +2 -1
  27. package/lib/compiler/swc/type-checker-host.js +12 -7
  28. package/lib/compiler/typescript-loader.js +1 -1
  29. package/lib/compiler/watch-compiler.js +4 -1
  30. package/lib/compiler/webpack-compiler.js +12 -5
  31. package/lib/compiler/workspace-utils.js +6 -17
  32. package/lib/configuration/nest-configuration.loader.js +27 -28
  33. package/lib/dependency-managers/nest.dependency-manager.js +21 -34
  34. package/lib/package-managers/abstract.package-manager.js +124 -165
  35. package/lib/package-managers/package-manager.factory.js +15 -26
  36. package/lib/package-managers/package-manager.js +1 -1
  37. package/lib/readers/file-system.reader.js +10 -21
  38. package/lib/runners/abstract.runner.js +19 -30
  39. package/lib/runners/runner.js +1 -1
  40. package/lib/runners/schematic.runner.js +1 -1
  41. package/lib/schematics/abstract.collection.js +4 -15
  42. package/lib/schematics/collection.js +1 -1
  43. package/lib/schematics/custom.collection.js +1 -2
  44. package/lib/schematics/nest.collection.js +3 -17
  45. package/lib/utils/load-configuration.js +3 -14
  46. package/lib/utils/project-utils.js +6 -17
  47. package/package.json +18 -18
@@ -13,7 +13,6 @@ class WebpackCompiler extends base_compiler_1.BaseCompiler {
13
13
  super(pluginsLoader);
14
14
  }
15
15
  run(configuration, tsConfigPath, appName, extras, onSuccess) {
16
- var _a, _b;
17
16
  const cwd = process.cwd();
18
17
  const configPath = (0, path_1.join)(cwd, tsConfigPath);
19
18
  if (!(0, fs_1.existsSync)(configPath)) {
@@ -23,7 +22,7 @@ class WebpackCompiler extends base_compiler_1.BaseCompiler {
23
22
  const pathToSource = this.getPathToSource(configuration, tsConfigPath, appName);
24
23
  const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName, 'entryFile', extras.inputs);
25
24
  const entryFileRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'root', appName) || '';
26
- const defaultOptions = (0, webpack_defaults_1.webpackDefaultsFactory)(pathToSource, entryFileRoot, entryFile, (_a = extras.debug) !== null && _a !== void 0 ? _a : false, tsConfigPath, plugins);
25
+ const defaultOptions = (0, webpack_defaults_1.webpackDefaultsFactory)(pathToSource, entryFileRoot, entryFile, extras.debug ?? false, tsConfigPath, plugins);
27
26
  let compiler;
28
27
  let watchOptions;
29
28
  let watch;
@@ -32,7 +31,11 @@ class WebpackCompiler extends base_compiler_1.BaseCompiler {
32
31
  const unwrappedConfig = typeof configOrFactory !== 'function'
33
32
  ? configOrFactory
34
33
  : configOrFactory(defaultOptions, webpack);
35
- return Object.assign(Object.assign(Object.assign({}, defaultOptions), { mode: extras.watchMode ? 'development' : defaultOptions.mode }), unwrappedConfig);
34
+ return {
35
+ ...defaultOptions,
36
+ mode: extras.watchMode ? 'development' : defaultOptions.mode,
37
+ ...unwrappedConfig,
38
+ };
36
39
  });
37
40
  compiler = webpack(webpackConfigurations);
38
41
  watchOptions = webpackConfigurations.map((config) => config.watchOptions || {});
@@ -42,12 +45,16 @@ class WebpackCompiler extends base_compiler_1.BaseCompiler {
42
45
  const projectWebpackOptions = typeof extras.webpackConfigFactoryOrConfig !== 'function'
43
46
  ? extras.webpackConfigFactoryOrConfig
44
47
  : extras.webpackConfigFactoryOrConfig(defaultOptions, webpack);
45
- const webpackConfiguration = Object.assign(Object.assign(Object.assign({}, defaultOptions), { mode: extras.watchMode ? 'development' : defaultOptions.mode }), projectWebpackOptions);
48
+ const webpackConfiguration = {
49
+ ...defaultOptions,
50
+ mode: extras.watchMode ? 'development' : defaultOptions.mode,
51
+ ...projectWebpackOptions,
52
+ };
46
53
  compiler = webpack(webpackConfiguration);
47
54
  watchOptions = webpackConfiguration.watchOptions;
48
55
  watch = webpackConfiguration.watch;
49
56
  }
50
- const afterCallback = this.createAfterCallback(onSuccess, extras.assetsManager, (_b = extras.watchMode) !== null && _b !== void 0 ? _b : false, watch);
57
+ const afterCallback = this.createAfterCallback(onSuccess, extras.assetsManager, extras.watchMode ?? false, watch);
51
58
  if (extras.watchMode || watch) {
52
59
  compiler.hooks.watchRun.tapAsync('Rebuild info', (params, callback) => {
53
60
  console.log(`\n${ui_1.INFO_PREFIX} Webpack is building your sources...\n`);
@@ -1,26 +1,15 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.WorkspaceUtils = void 0;
13
4
  const rimraf_1 = require("rimraf");
14
5
  const get_value_or_default_1 = require("./helpers/get-value-or-default");
15
6
  class WorkspaceUtils {
16
- deleteOutDirIfEnabled(configuration, appName, dirPath) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- const isDeleteEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.deleteOutDir', appName);
19
- if (!isDeleteEnabled) {
20
- return;
21
- }
22
- yield (0, rimraf_1.default)(dirPath);
23
- });
7
+ async deleteOutDirIfEnabled(configuration, appName, dirPath) {
8
+ const isDeleteEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.deleteOutDir', appName);
9
+ if (!isDeleteEnabled) {
10
+ return;
11
+ }
12
+ await (0, rimraf_1.default)(dirPath);
24
13
  }
25
14
  }
26
15
  exports.WorkspaceUtils = WorkspaceUtils;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.NestConfigurationLoader = void 0;
13
4
  const defaults_1 = require("./defaults");
@@ -15,25 +6,33 @@ class NestConfigurationLoader {
15
6
  constructor(reader) {
16
7
  this.reader = reader;
17
8
  }
18
- load(name) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const content = name
21
- ? yield this.reader.read(name)
22
- : yield this.reader.readAnyOf([
23
- 'nest-cli.json',
24
- '.nestcli.json',
25
- '.nest-cli.json',
26
- 'nest.json',
27
- ]);
28
- if (!content) {
29
- return defaults_1.defaultConfiguration;
30
- }
31
- const fileConfig = JSON.parse(content);
32
- if (fileConfig.compilerOptions) {
33
- return Object.assign(Object.assign(Object.assign({}, defaults_1.defaultConfiguration), fileConfig), { compilerOptions: Object.assign(Object.assign({}, defaults_1.defaultConfiguration.compilerOptions), fileConfig.compilerOptions) });
34
- }
35
- return Object.assign(Object.assign({}, defaults_1.defaultConfiguration), fileConfig);
36
- });
9
+ async load(name) {
10
+ const content = name
11
+ ? await this.reader.read(name)
12
+ : await this.reader.readAnyOf([
13
+ 'nest-cli.json',
14
+ '.nestcli.json',
15
+ '.nest-cli.json',
16
+ 'nest.json',
17
+ ]);
18
+ if (!content) {
19
+ return defaults_1.defaultConfiguration;
20
+ }
21
+ const fileConfig = JSON.parse(content);
22
+ if (fileConfig.compilerOptions) {
23
+ return {
24
+ ...defaults_1.defaultConfiguration,
25
+ ...fileConfig,
26
+ compilerOptions: {
27
+ ...defaults_1.defaultConfiguration.compilerOptions,
28
+ ...fileConfig.compilerOptions,
29
+ },
30
+ };
31
+ }
32
+ return {
33
+ ...defaults_1.defaultConfiguration,
34
+ ...fileConfig,
35
+ };
37
36
  }
38
37
  }
39
38
  exports.NestConfigurationLoader = NestConfigurationLoader;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.NestDependencyManager = void 0;
13
4
  const ora = require("ora");
@@ -16,33 +7,29 @@ class NestDependencyManager {
16
7
  constructor(packageManager) {
17
8
  this.packageManager = packageManager;
18
9
  }
19
- read() {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const production = yield this.packageManager.getProduction();
22
- return production
23
- .filter((dependency) => dependency.name.indexOf('@nestjs') > -1)
24
- .map((dependency) => dependency.name);
25
- });
10
+ async read() {
11
+ const production = await this.packageManager.getProduction();
12
+ return production
13
+ .filter((dependency) => dependency.name.indexOf('@nestjs') > -1)
14
+ .map((dependency) => dependency.name);
26
15
  }
27
- update(force, tag = 'latest') {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- const spinner = ora({
30
- spinner: {
31
- interval: 120,
32
- frames: ['▹▹▹▹▹', '▸▹▹▹▹', '▹▸▹▹▹', '▹▹▸▹▹', '▹▹▹▸▹', '▹▹▹▹▸'],
33
- },
34
- text: ui_1.MESSAGES.PACKAGE_MANAGER_UPDATE_IN_PROGRESS,
35
- });
36
- spinner.start();
37
- const dependencies = yield this.read();
38
- if (force) {
39
- yield this.packageManager.upgradeProduction(dependencies, tag);
40
- }
41
- else {
42
- yield this.packageManager.updateProduction(dependencies);
43
- }
44
- spinner.succeed();
16
+ async update(force, tag = 'latest') {
17
+ const spinner = ora({
18
+ spinner: {
19
+ interval: 120,
20
+ frames: ['▹▹▹▹▹', '▸▹▹▹▹', '▹▸▹▹▹', '▹▹▸▹▹', '▹▹▹▸▹', '▹▹▹▹▸'],
21
+ },
22
+ text: ui_1.MESSAGES.PACKAGE_MANAGER_UPDATE_IN_PROGRESS,
45
23
  });
24
+ spinner.start();
25
+ const dependencies = await this.read();
26
+ if (force) {
27
+ await this.packageManager.upgradeProduction(dependencies, tag);
28
+ }
29
+ else {
30
+ await this.packageManager.updateProduction(dependencies);
31
+ }
32
+ spinner.succeed();
46
33
  }
47
34
  }
48
35
  exports.NestDependencyManager = NestDependencyManager;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.AbstractPackageManager = void 0;
13
4
  const chalk = require("chalk");
@@ -20,173 +11,141 @@ class AbstractPackageManager {
20
11
  constructor(runner) {
21
12
  this.runner = runner;
22
13
  }
23
- install(directory, packageManager) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const spinner = ora({
26
- spinner: {
27
- interval: 120,
28
- frames: ['▹▹▹▹▹', '▸▹▹▹▹', '▹▸▹▹▹', '▹▹▸▹▹', '▹▹▹▸▹', '▹▹▹▹▸'],
29
- },
30
- text: ui_1.MESSAGES.PACKAGE_MANAGER_INSTALLATION_IN_PROGRESS,
31
- });
32
- spinner.start();
33
- try {
34
- const commandArgs = `${this.cli.install} ${this.cli.silentFlag}`;
35
- const collect = true;
36
- const normalizedDirectory = (0, formatting_1.normalizeToKebabOrSnakeCase)(directory);
37
- yield this.runner.run(commandArgs, collect, (0, path_1.join)(process.cwd(), normalizedDirectory));
38
- spinner.succeed();
39
- console.info();
40
- console.info(ui_1.MESSAGES.PACKAGE_MANAGER_INSTALLATION_SUCCEED(directory));
41
- console.info(ui_1.MESSAGES.GET_STARTED_INFORMATION);
42
- console.info();
43
- console.info(chalk.gray(ui_1.MESSAGES.CHANGE_DIR_COMMAND(directory)));
44
- console.info(chalk.gray(ui_1.MESSAGES.START_COMMAND(packageManager)));
45
- console.info();
46
- }
47
- catch (_a) {
48
- spinner.fail();
49
- const commandArgs = this.cli.install;
50
- const commandToRun = this.runner.rawFullCommand(commandArgs);
51
- console.error(chalk.red(ui_1.MESSAGES.PACKAGE_MANAGER_INSTALLATION_FAILED(chalk.bold(commandToRun))));
52
- }
53
- });
54
- }
55
- version() {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const commandArguments = '--version';
14
+ async install(directory, packageManager) {
15
+ const spinner = ora({
16
+ spinner: {
17
+ interval: 120,
18
+ frames: ['▹▹▹▹▹', '▸▹▹▹▹', '▹▸▹▹▹', '▹▹▸▹▹', '▹▹▹▸▹', '▹▹▹▹▸'],
19
+ },
20
+ text: ui_1.MESSAGES.PACKAGE_MANAGER_INSTALLATION_IN_PROGRESS,
21
+ });
22
+ spinner.start();
23
+ try {
24
+ const commandArgs = `${this.cli.install} ${this.cli.silentFlag}`;
58
25
  const collect = true;
59
- return this.runner.run(commandArguments, collect);
60
- });
61
- }
62
- addProduction(dependencies, tag) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- const command = [this.cli.add, this.cli.saveFlag]
65
- .filter((i) => i)
66
- .join(' ');
67
- const args = dependencies
68
- .map((dependency) => `${dependency}@${tag}`)
69
- .join(' ');
70
- const spinner = ora({
71
- spinner: {
72
- interval: 120,
73
- frames: ['▹▹▹▹▹', '▸▹▹▹▹', '▹▸▹▹▹', '▹▹▸▹▹', '▹▹▹▸▹', '▹▹▹▹▸'],
74
- },
75
- text: ui_1.MESSAGES.PACKAGE_MANAGER_PRODUCTION_INSTALLATION_IN_PROGRESS,
26
+ const normalizedDirectory = (0, formatting_1.normalizeToKebabOrSnakeCase)(directory);
27
+ await this.runner.run(commandArgs, collect, (0, path_1.join)(process.cwd(), normalizedDirectory));
28
+ spinner.succeed();
29
+ console.info();
30
+ console.info(ui_1.MESSAGES.PACKAGE_MANAGER_INSTALLATION_SUCCEED(directory));
31
+ console.info(ui_1.MESSAGES.GET_STARTED_INFORMATION);
32
+ console.info();
33
+ console.info(chalk.gray(ui_1.MESSAGES.CHANGE_DIR_COMMAND(directory)));
34
+ console.info(chalk.gray(ui_1.MESSAGES.START_COMMAND(packageManager)));
35
+ console.info();
36
+ }
37
+ catch {
38
+ spinner.fail();
39
+ const commandArgs = this.cli.install;
40
+ const commandToRun = this.runner.rawFullCommand(commandArgs);
41
+ console.error(chalk.red(ui_1.MESSAGES.PACKAGE_MANAGER_INSTALLATION_FAILED(chalk.bold(commandToRun))));
42
+ }
43
+ }
44
+ async version() {
45
+ const commandArguments = '--version';
46
+ const collect = true;
47
+ return this.runner.run(commandArguments, collect);
48
+ }
49
+ async addProduction(dependencies, tag) {
50
+ const command = [this.cli.add, this.cli.saveFlag]
51
+ .filter((i) => i)
52
+ .join(' ');
53
+ const args = dependencies
54
+ .map((dependency) => `${dependency}@${tag}`)
55
+ .join(' ');
56
+ const spinner = ora({
57
+ spinner: {
58
+ interval: 120,
59
+ frames: ['▹▹▹▹▹', '▸▹▹▹▹', '▹▸▹▹▹', '▹▹▸▹▹', '▹▹▹▸▹', '▹▹▹▹▸'],
60
+ },
61
+ text: ui_1.MESSAGES.PACKAGE_MANAGER_PRODUCTION_INSTALLATION_IN_PROGRESS,
62
+ });
63
+ spinner.start();
64
+ try {
65
+ await this.add(`${command} ${args}`);
66
+ spinner.succeed();
67
+ return true;
68
+ }
69
+ catch {
70
+ spinner.fail();
71
+ return false;
72
+ }
73
+ }
74
+ async addDevelopment(dependencies, tag) {
75
+ const command = `${this.cli.add} ${this.cli.saveDevFlag}`;
76
+ const args = dependencies
77
+ .map((dependency) => `${dependency}@${tag}`)
78
+ .join(' ');
79
+ await this.add(`${command} ${args}`);
80
+ }
81
+ async add(commandArguments) {
82
+ const collect = true;
83
+ await this.runner.run(commandArguments, collect);
84
+ }
85
+ async getProduction() {
86
+ const packageJsonContent = await this.readPackageJson();
87
+ const packageJsonDependencies = packageJsonContent.dependencies;
88
+ const dependencies = [];
89
+ for (const [name, version] of Object.entries(packageJsonDependencies)) {
90
+ dependencies.push({ name, version });
91
+ }
92
+ return dependencies;
93
+ }
94
+ async getDevelopment() {
95
+ const packageJsonContent = await this.readPackageJson();
96
+ const packageJsonDevDependencies = packageJsonContent.devDependencies;
97
+ const dependencies = [];
98
+ for (const [name, version] of Object.entries(packageJsonDevDependencies)) {
99
+ dependencies.push({ name, version });
100
+ }
101
+ return dependencies;
102
+ }
103
+ async readPackageJson() {
104
+ return new Promise((resolve, reject) => {
105
+ (0, fs_1.readFile)((0, path_1.join)(process.cwd(), 'package.json'), (error, buffer) => {
106
+ if (error !== undefined && error !== null) {
107
+ reject(error);
108
+ }
109
+ else {
110
+ resolve(JSON.parse(buffer.toString()));
111
+ }
76
112
  });
77
- spinner.start();
78
- try {
79
- yield this.add(`${command} ${args}`);
80
- spinner.succeed();
81
- return true;
82
- }
83
- catch (_a) {
84
- spinner.fail();
85
- return false;
86
- }
87
113
  });
88
114
  }
89
- addDevelopment(dependencies, tag) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const command = `${this.cli.add} ${this.cli.saveDevFlag}`;
92
- const args = dependencies
93
- .map((dependency) => `${dependency}@${tag}`)
94
- .join(' ');
95
- yield this.add(`${command} ${args}`);
96
- });
115
+ async updateProduction(dependencies) {
116
+ const commandArguments = `${this.cli.update} ${dependencies.join(' ')}`;
117
+ await this.update(commandArguments);
97
118
  }
98
- add(commandArguments) {
99
- return __awaiter(this, void 0, void 0, function* () {
100
- const collect = true;
101
- yield this.runner.run(commandArguments, collect);
102
- });
119
+ async updateDevelopment(dependencies) {
120
+ const commandArguments = `${this.cli.update} ${dependencies.join(' ')}`;
121
+ await this.update(commandArguments);
103
122
  }
104
- getProduction() {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- const packageJsonContent = yield this.readPackageJson();
107
- const packageJsonDependencies = packageJsonContent.dependencies;
108
- const dependencies = [];
109
- for (const [name, version] of Object.entries(packageJsonDependencies)) {
110
- dependencies.push({ name, version });
111
- }
112
- return dependencies;
113
- });
123
+ async update(commandArguments) {
124
+ const collect = true;
125
+ await this.runner.run(commandArguments, collect);
114
126
  }
115
- getDevelopment() {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- const packageJsonContent = yield this.readPackageJson();
118
- const packageJsonDevDependencies = packageJsonContent.devDependencies;
119
- const dependencies = [];
120
- for (const [name, version] of Object.entries(packageJsonDevDependencies)) {
121
- dependencies.push({ name, version });
122
- }
123
- return dependencies;
124
- });
127
+ async upgradeProduction(dependencies, tag) {
128
+ await this.deleteProduction(dependencies);
129
+ await this.addProduction(dependencies, tag);
125
130
  }
126
- readPackageJson() {
127
- return __awaiter(this, void 0, void 0, function* () {
128
- return new Promise((resolve, reject) => {
129
- (0, fs_1.readFile)((0, path_1.join)(process.cwd(), 'package.json'), (error, buffer) => {
130
- if (error !== undefined && error !== null) {
131
- reject(error);
132
- }
133
- else {
134
- resolve(JSON.parse(buffer.toString()));
135
- }
136
- });
137
- });
138
- });
131
+ async upgradeDevelopment(dependencies, tag) {
132
+ await this.deleteDevelopment(dependencies);
133
+ await this.addDevelopment(dependencies, tag);
139
134
  }
140
- updateProduction(dependencies) {
141
- return __awaiter(this, void 0, void 0, function* () {
142
- const commandArguments = `${this.cli.update} ${dependencies.join(' ')}`;
143
- yield this.update(commandArguments);
144
- });
135
+ async deleteProduction(dependencies) {
136
+ const command = [this.cli.remove, this.cli.saveFlag]
137
+ .filter((i) => i)
138
+ .join(' ');
139
+ const args = dependencies.join(' ');
140
+ await this.delete(`${command} ${args}`);
145
141
  }
146
- updateDevelopment(dependencies) {
147
- return __awaiter(this, void 0, void 0, function* () {
148
- const commandArguments = `${this.cli.update} ${dependencies.join(' ')}`;
149
- yield this.update(commandArguments);
150
- });
142
+ async deleteDevelopment(dependencies) {
143
+ const commandArguments = `${this.cli.remove} ${this.cli.saveDevFlag} ${dependencies.join(' ')}`;
144
+ await this.delete(commandArguments);
151
145
  }
152
- update(commandArguments) {
153
- return __awaiter(this, void 0, void 0, function* () {
154
- const collect = true;
155
- yield this.runner.run(commandArguments, collect);
156
- });
157
- }
158
- upgradeProduction(dependencies, tag) {
159
- return __awaiter(this, void 0, void 0, function* () {
160
- yield this.deleteProduction(dependencies);
161
- yield this.addProduction(dependencies, tag);
162
- });
163
- }
164
- upgradeDevelopment(dependencies, tag) {
165
- return __awaiter(this, void 0, void 0, function* () {
166
- yield this.deleteDevelopment(dependencies);
167
- yield this.addDevelopment(dependencies, tag);
168
- });
169
- }
170
- deleteProduction(dependencies) {
171
- return __awaiter(this, void 0, void 0, function* () {
172
- const command = [this.cli.remove, this.cli.saveFlag]
173
- .filter((i) => i)
174
- .join(' ');
175
- const args = dependencies.join(' ');
176
- yield this.delete(`${command} ${args}`);
177
- });
178
- }
179
- deleteDevelopment(dependencies) {
180
- return __awaiter(this, void 0, void 0, function* () {
181
- const commandArguments = `${this.cli.remove} ${this.cli.saveDevFlag} ${dependencies.join(' ')}`;
182
- yield this.delete(commandArguments);
183
- });
184
- }
185
- delete(commandArguments) {
186
- return __awaiter(this, void 0, void 0, function* () {
187
- const collect = true;
188
- yield this.runner.run(commandArguments, collect);
189
- });
146
+ async delete(commandArguments) {
147
+ const collect = true;
148
+ await this.runner.run(commandArguments, collect);
190
149
  }
191
150
  }
192
151
  exports.AbstractPackageManager = AbstractPackageManager;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.PackageManagerFactory = void 0;
13
4
  const fs = require("fs");
@@ -28,25 +19,23 @@ class PackageManagerFactory {
28
19
  throw new Error(`Package manager ${name} is not managed.`);
29
20
  }
30
21
  }
31
- static find() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const DEFAULT_PACKAGE_MANAGER = package_manager_1.PackageManager.NPM;
34
- try {
35
- const files = yield fs.promises.readdir(process.cwd());
36
- const hasYarnLockFile = files.includes('yarn.lock');
37
- if (hasYarnLockFile) {
38
- return this.create(package_manager_1.PackageManager.YARN);
39
- }
40
- const hasPnpmLockFile = files.includes('pnpm-lock.yaml');
41
- if (hasPnpmLockFile) {
42
- return this.create(package_manager_1.PackageManager.PNPM);
43
- }
44
- return this.create(DEFAULT_PACKAGE_MANAGER);
22
+ static async find() {
23
+ const DEFAULT_PACKAGE_MANAGER = package_manager_1.PackageManager.NPM;
24
+ try {
25
+ const files = await fs.promises.readdir(process.cwd());
26
+ const hasYarnLockFile = files.includes('yarn.lock');
27
+ if (hasYarnLockFile) {
28
+ return this.create(package_manager_1.PackageManager.YARN);
45
29
  }
46
- catch (error) {
47
- return this.create(DEFAULT_PACKAGE_MANAGER);
30
+ const hasPnpmLockFile = files.includes('pnpm-lock.yaml');
31
+ if (hasPnpmLockFile) {
32
+ return this.create(package_manager_1.PackageManager.PNPM);
48
33
  }
49
- });
34
+ return this.create(DEFAULT_PACKAGE_MANAGER);
35
+ }
36
+ catch (error) {
37
+ return this.create(DEFAULT_PACKAGE_MANAGER);
38
+ }
50
39
  }
51
40
  }
52
41
  exports.PackageManagerFactory = PackageManagerFactory;
@@ -6,4 +6,4 @@ var PackageManager;
6
6
  PackageManager["NPM"] = "npm";
7
7
  PackageManager["YARN"] = "yarn";
8
8
  PackageManager["PNPM"] = "pnpm";
9
- })(PackageManager = exports.PackageManager || (exports.PackageManager = {}));
9
+ })(PackageManager || (exports.PackageManager = PackageManager = {}));
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.FileSystemReader = void 0;
13
4
  const fs = require("fs");
@@ -22,19 +13,17 @@ class FileSystemReader {
22
13
  read(name) {
23
14
  return fs.promises.readFile(path.join(this.directory, name), 'utf8');
24
15
  }
25
- readAnyOf(filenames) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- try {
28
- for (const file of filenames) {
29
- return yield this.read(file);
30
- }
16
+ async readAnyOf(filenames) {
17
+ try {
18
+ for (const file of filenames) {
19
+ return await this.read(file);
31
20
  }
32
- catch (err) {
33
- return filenames.length > 0
34
- ? yield this.readAnyOf(filenames.slice(1, filenames.length))
35
- : undefined;
36
- }
37
- });
21
+ }
22
+ catch (err) {
23
+ return filenames.length > 0
24
+ ? await this.readAnyOf(filenames.slice(1, filenames.length))
25
+ : undefined;
26
+ }
38
27
  }
39
28
  }
40
29
  exports.FileSystemReader = FileSystemReader;