@depup/nestjs__cli 11.0.16-depup.1
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/LICENSE +24 -0
- package/README.md +42 -0
- package/actions/abstract.action.d.ts +4 -0
- package/actions/abstract.action.js +6 -0
- package/actions/add.action.d.ts +12 -0
- package/actions/add.action.js +113 -0
- package/actions/build.action.d.ts +22 -0
- package/actions/build.action.js +145 -0
- package/actions/generate.action.d.ts +5 -0
- package/actions/generate.action.js +97 -0
- package/actions/index.d.ts +7 -0
- package/actions/index.js +23 -0
- package/actions/info.action.d.ts +35 -0
- package/actions/info.action.js +181 -0
- package/actions/new.action.d.ts +7 -0
- package/actions/new.action.js +186 -0
- package/actions/start.action.d.ts +10 -0
- package/actions/start.action.js +122 -0
- package/bin/nest.d.ts +2 -0
- package/bin/nest.js +25 -0
- package/changes.json +54 -0
- package/commands/abstract.command.d.ts +7 -0
- package/commands/abstract.command.js +9 -0
- package/commands/add.command.d.ts +5 -0
- package/commands/add.command.js +36 -0
- package/commands/build.command.d.ts +5 -0
- package/commands/build.command.js +74 -0
- package/commands/command.input.d.ts +5 -0
- package/commands/command.input.js +2 -0
- package/commands/command.loader.d.ts +5 -0
- package/commands/command.loader.js +31 -0
- package/commands/generate.command.d.ts +9 -0
- package/commands/generate.command.js +107 -0
- package/commands/index.d.ts +2 -0
- package/commands/index.js +18 -0
- package/commands/info.command.d.ts +5 -0
- package/commands/info.command.js +16 -0
- package/commands/new.command.d.ts +5 -0
- package/commands/new.command.js +61 -0
- package/commands/start.command.d.ts +5 -0
- package/commands/start.command.js +104 -0
- package/lib/compiler/assets-manager.d.ts +15 -0
- package/lib/compiler/assets-manager.js +129 -0
- package/lib/compiler/base-compiler.d.ts +9 -0
- package/lib/compiler/base-compiler.js +26 -0
- package/lib/compiler/compiler.d.ts +12 -0
- package/lib/compiler/compiler.js +61 -0
- package/lib/compiler/defaults/swc-defaults.d.ts +61 -0
- package/lib/compiler/defaults/swc-defaults.js +57 -0
- package/lib/compiler/defaults/webpack-defaults.d.ts +3 -0
- package/lib/compiler/defaults/webpack-defaults.js +104 -0
- package/lib/compiler/helpers/append-extension.d.ts +1 -0
- package/lib/compiler/helpers/append-extension.js +7 -0
- package/lib/compiler/helpers/copy-path-resolve.d.ts +7 -0
- package/lib/compiler/helpers/copy-path-resolve.js +25 -0
- package/lib/compiler/helpers/delete-out-dir.d.ts +2 -0
- package/lib/compiler/helpers/delete-out-dir.js +12 -0
- package/lib/compiler/helpers/get-builder.d.ts +21 -0
- package/lib/compiler/helpers/get-builder.js +19 -0
- package/lib/compiler/helpers/get-tsc-config.path.d.ts +10 -0
- package/lib/compiler/helpers/get-tsc-config.path.js +24 -0
- package/lib/compiler/helpers/get-value-or-default.d.ts +4 -0
- package/lib/compiler/helpers/get-value-or-default.js +66 -0
- package/lib/compiler/helpers/get-webpack-config-path.d.ts +10 -0
- package/lib/compiler/helpers/get-webpack-config-path.js +23 -0
- package/lib/compiler/helpers/manual-restart.d.ts +2 -0
- package/lib/compiler/helpers/manual-restart.js +17 -0
- package/lib/compiler/helpers/tsconfig-provider.d.ts +11 -0
- package/lib/compiler/helpers/tsconfig-provider.js +22 -0
- package/lib/compiler/hooks/tsconfig-paths.hook.d.ts +2 -0
- package/lib/compiler/hooks/tsconfig-paths.hook.js +76 -0
- package/lib/compiler/interfaces/readonly-visitor.interface.d.ts +10 -0
- package/lib/compiler/interfaces/readonly-visitor.interface.js +2 -0
- package/lib/compiler/plugins/plugin-metadata-generator.d.ts +58 -0
- package/lib/compiler/plugins/plugin-metadata-generator.js +84 -0
- package/lib/compiler/plugins/plugin-metadata-printer.d.ts +17 -0
- package/lib/compiler/plugins/plugin-metadata-printer.js +51 -0
- package/lib/compiler/plugins/plugins-loader.d.ts +30 -0
- package/lib/compiler/plugins/plugins-loader.js +70 -0
- package/lib/compiler/swc/constants.d.ts +9 -0
- package/lib/compiler/swc/constants.js +13 -0
- package/lib/compiler/swc/forked-type-checker.d.ts +1 -0
- package/lib/compiler/swc/forked-type-checker.js +63 -0
- package/lib/compiler/swc/swc-compiler.d.ts +25 -0
- package/lib/compiler/swc/swc-compiler.js +231 -0
- package/lib/compiler/swc/type-checker-host.d.ts +14 -0
- package/lib/compiler/swc/type-checker-host.js +90 -0
- package/lib/compiler/typescript-loader.d.ts +6 -0
- package/lib/compiler/typescript-loader.js +31 -0
- package/lib/compiler/watch-compiler.d.ts +22 -0
- package/lib/compiler/watch-compiler.js +89 -0
- package/lib/compiler/webpack-compiler.d.ts +21 -0
- package/lib/compiler/webpack-compiler.js +99 -0
- package/lib/configuration/configuration.d.ts +91 -0
- package/lib/configuration/configuration.js +2 -0
- package/lib/configuration/configuration.loader.d.ts +4 -0
- package/lib/configuration/configuration.loader.js +2 -0
- package/lib/configuration/defaults.d.ts +6 -0
- package/lib/configuration/defaults.js +86 -0
- package/lib/configuration/index.d.ts +3 -0
- package/lib/configuration/index.js +19 -0
- package/lib/configuration/nest-configuration.loader.d.ts +8 -0
- package/lib/configuration/nest-configuration.loader.js +61 -0
- package/lib/package-managers/abstract.package-manager.d.ts +25 -0
- package/lib/package-managers/abstract.package-manager.js +151 -0
- package/lib/package-managers/index.d.ts +8 -0
- package/lib/package-managers/index.js +24 -0
- package/lib/package-managers/npm.package-manager.d.ts +7 -0
- package/lib/package-managers/npm.package-manager.js +26 -0
- package/lib/package-managers/package-manager-commands.d.ts +9 -0
- package/lib/package-managers/package-manager-commands.js +2 -0
- package/lib/package-managers/package-manager.d.ts +5 -0
- package/lib/package-managers/package-manager.factory.d.ts +6 -0
- package/lib/package-managers/package-manager.factory.js +41 -0
- package/lib/package-managers/package-manager.js +9 -0
- package/lib/package-managers/pnpm.package-manager.d.ts +7 -0
- package/lib/package-managers/pnpm.package-manager.js +27 -0
- package/lib/package-managers/project.dependency.d.ts +4 -0
- package/lib/package-managers/project.dependency.js +2 -0
- package/lib/package-managers/yarn.package-manager.d.ts +7 -0
- package/lib/package-managers/yarn.package-manager.js +26 -0
- package/lib/questions/questions.d.ts +9 -0
- package/lib/questions/questions.js +27 -0
- package/lib/readers/file-system.reader.d.ts +8 -0
- package/lib/readers/file-system.reader.js +46 -0
- package/lib/readers/index.d.ts +2 -0
- package/lib/readers/index.js +18 -0
- package/lib/readers/reader.d.ts +10 -0
- package/lib/readers/reader.js +11 -0
- package/lib/runners/abstract.runner.d.ts +11 -0
- package/lib/runners/abstract.runner.js +47 -0
- package/lib/runners/git.runner.d.ts +4 -0
- package/lib/runners/git.runner.js +10 -0
- package/lib/runners/index.d.ts +3 -0
- package/lib/runners/index.js +19 -0
- package/lib/runners/npm.runner.d.ts +4 -0
- package/lib/runners/npm.runner.js +10 -0
- package/lib/runners/pnpm.runner.d.ts +4 -0
- package/lib/runners/pnpm.runner.js +10 -0
- package/lib/runners/runner.d.ts +6 -0
- package/lib/runners/runner.factory.d.ts +8 -0
- package/lib/runners/runner.factory.js +26 -0
- package/lib/runners/runner.js +10 -0
- package/lib/runners/schematic.runner.d.ts +6 -0
- package/lib/runners/schematic.runner.js +21 -0
- package/lib/runners/yarn.runner.d.ts +4 -0
- package/lib/runners/yarn.runner.js +10 -0
- package/lib/schematics/abstract.collection.d.ts +12 -0
- package/lib/schematics/abstract.collection.js +23 -0
- package/lib/schematics/collection.d.ts +3 -0
- package/lib/schematics/collection.factory.d.ts +5 -0
- package/lib/schematics/collection.factory.js +19 -0
- package/lib/schematics/collection.js +7 -0
- package/lib/schematics/custom.collection.d.ts +10 -0
- package/lib/schematics/custom.collection.js +33 -0
- package/lib/schematics/index.d.ts +4 -0
- package/lib/schematics/index.js +20 -0
- package/lib/schematics/nest.collection.d.ts +15 -0
- package/lib/schematics/nest.collection.js +126 -0
- package/lib/schematics/schematic.option.d.ts +8 -0
- package/lib/schematics/schematic.option.js +44 -0
- package/lib/ui/banner.d.ts +1 -0
- package/lib/ui/banner.js +12 -0
- package/lib/ui/emojis.d.ts +19 -0
- package/lib/ui/emojis.js +23 -0
- package/lib/ui/errors.d.ts +4 -0
- package/lib/ui/errors.js +8 -0
- package/lib/ui/index.d.ts +5 -0
- package/lib/ui/index.js +21 -0
- package/lib/ui/messages.d.ts +24 -0
- package/lib/ui/messages.js +32 -0
- package/lib/ui/prefixes.d.ts +2 -0
- package/lib/ui/prefixes.js +6 -0
- package/lib/utils/formatting.d.ts +8 -0
- package/lib/utils/formatting.js +18 -0
- package/lib/utils/get-default-tsconfig-path.d.ts +1 -0
- package/lib/utils/get-default-tsconfig-path.js +12 -0
- package/lib/utils/gracefully-exit-on-prompt-error.d.ts +1 -0
- package/lib/utils/gracefully-exit-on-prompt-error.js +11 -0
- package/lib/utils/is-module-available.d.ts +1 -0
- package/lib/utils/is-module-available.js +12 -0
- package/lib/utils/load-configuration.d.ts +2 -0
- package/lib/utils/load-configuration.js +9 -0
- package/lib/utils/local-binaries.d.ts +3 -0
- package/lib/utils/local-binaries.js +15 -0
- package/lib/utils/os-info.utils.d.ts +1 -0
- package/lib/utils/os-info.utils.js +23 -0
- package/lib/utils/project-utils.d.ts +11 -0
- package/lib/utils/project-utils.js +83 -0
- package/lib/utils/remaining-flags.d.ts +2 -0
- package/lib/utils/remaining-flags.js +36 -0
- package/lib/utils/tree-kill.d.ts +1 -0
- package/lib/utils/tree-kill.js +68 -0
- package/lib/utils/type-assertions.d.ts +1 -0
- package/lib/utils/type-assertions.js +8 -0
- package/package.json +161 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoAction = void 0;
|
|
4
|
+
const ansis_1 = require("ansis");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const os_1 = require("os");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const package_managers_1 = require("../lib/package-managers");
|
|
9
|
+
const ui_1 = require("../lib/ui");
|
|
10
|
+
const abstract_action_1 = require("./abstract.action");
|
|
11
|
+
const os_info_utils_1 = require("../lib/utils/os-info.utils");
|
|
12
|
+
class InfoAction extends abstract_action_1.AbstractAction {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
// Nest dependencies whitelist used to compare the major version
|
|
16
|
+
this.warningMessageDependenciesWhiteList = [
|
|
17
|
+
'@nestjs/core',
|
|
18
|
+
'@nestjs/common',
|
|
19
|
+
'@nestjs/schematics',
|
|
20
|
+
'@nestjs/platform-express',
|
|
21
|
+
'@nestjs/platform-fastify',
|
|
22
|
+
'@nestjs/platform-socket.io',
|
|
23
|
+
'@nestjs/platform-ws',
|
|
24
|
+
'@nestjs/websockets',
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
async handle() {
|
|
28
|
+
this.manager = await package_managers_1.PackageManagerFactory.find();
|
|
29
|
+
this.displayBanner();
|
|
30
|
+
await this.displaySystemInformation();
|
|
31
|
+
await this.displayNestInformation();
|
|
32
|
+
}
|
|
33
|
+
displayBanner() {
|
|
34
|
+
console.info((0, ansis_1.red)(ui_1.BANNER));
|
|
35
|
+
}
|
|
36
|
+
async displaySystemInformation() {
|
|
37
|
+
console.info((0, ansis_1.green) `[System Information]`);
|
|
38
|
+
console.info('OS Version :', (0, ansis_1.blue)((0, os_info_utils_1.default)((0, os_1.platform)(), (0, os_1.release)()) + (0, os_1.release)()));
|
|
39
|
+
console.info('NodeJS Version :', (0, ansis_1.blue)(process.version));
|
|
40
|
+
await this.displayPackageManagerVersion();
|
|
41
|
+
}
|
|
42
|
+
async displayPackageManagerVersion() {
|
|
43
|
+
try {
|
|
44
|
+
const version = await this.manager.version();
|
|
45
|
+
console.info(`${this.manager.name} Version :`, (0, ansis_1.blue)(version), '\n');
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
console.error(`${this.manager.name} Version :`, (0, ansis_1.red) `Unknown`, '\n');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async displayNestInformation() {
|
|
52
|
+
this.displayCliVersion();
|
|
53
|
+
console.info((0, ansis_1.green) `[Nest Platform Information]`);
|
|
54
|
+
await this.displayNestInformationFromPackage();
|
|
55
|
+
}
|
|
56
|
+
async displayNestInformationFromPackage() {
|
|
57
|
+
try {
|
|
58
|
+
const dependencies = this.readProjectPackageDependencies();
|
|
59
|
+
this.displayNestVersions(dependencies);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
console.error((0, ansis_1.red)(ui_1.MESSAGES.NEST_INFORMATION_PACKAGE_MANAGER_FAILED));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
displayCliVersion() {
|
|
66
|
+
console.info((0, ansis_1.green) `[Nest CLI]`);
|
|
67
|
+
console.info('Nest CLI Version :', (0, ansis_1.blue)(JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../package.json')).toString())
|
|
68
|
+
.version), '\n');
|
|
69
|
+
}
|
|
70
|
+
readProjectPackageDependencies() {
|
|
71
|
+
const buffer = (0, fs_1.readFileSync)((0, path_1.join)(process.cwd(), 'package.json'));
|
|
72
|
+
const pack = JSON.parse(buffer.toString());
|
|
73
|
+
const dependencies = { ...pack.dependencies, ...pack.devDependencies };
|
|
74
|
+
Object.keys(dependencies).forEach((key) => {
|
|
75
|
+
dependencies[key] = {
|
|
76
|
+
version: dependencies[key],
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
return dependencies;
|
|
80
|
+
}
|
|
81
|
+
displayNestVersions(dependencies) {
|
|
82
|
+
const nestDependencies = this.buildNestVersionsMessage(dependencies);
|
|
83
|
+
nestDependencies.forEach((dependency) => console.info(dependency.name, (0, ansis_1.blue)(dependency.value)));
|
|
84
|
+
this.displayWarningMessage(nestDependencies);
|
|
85
|
+
}
|
|
86
|
+
displayWarningMessage(nestDependencies) {
|
|
87
|
+
try {
|
|
88
|
+
const warnings = this.buildNestVersionsWarningMessage(nestDependencies);
|
|
89
|
+
const majorVersions = Object.keys(warnings);
|
|
90
|
+
if (majorVersions.length > 0) {
|
|
91
|
+
console.info('\r');
|
|
92
|
+
console.info((0, ansis_1.yellow) `[Warnings]`);
|
|
93
|
+
console.info('The following packages are not in the same major version');
|
|
94
|
+
console.info('This could lead to runtime errors');
|
|
95
|
+
majorVersions.forEach((version) => {
|
|
96
|
+
console.info((0, ansis_1.bold) `* Under version ${version}`);
|
|
97
|
+
warnings[version].forEach(({ packageName, value }) => {
|
|
98
|
+
console.info(`- ${packageName} ${value}`);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
console.info('\t');
|
|
105
|
+
console.error((0, ansis_1.red)(ui_1.MESSAGES.NEST_INFORMATION_PACKAGE_WARNING_FAILED(this.warningMessageDependenciesWhiteList)));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
buildNestVersionsWarningMessage(nestDependencies) {
|
|
109
|
+
const unsortedWarnings = nestDependencies.reduce((depWarningsGroup, { name, packageName, value }) => {
|
|
110
|
+
if (!this.warningMessageDependenciesWhiteList.includes(packageName)) {
|
|
111
|
+
return depWarningsGroup;
|
|
112
|
+
}
|
|
113
|
+
const [major] = value.replace(/[^\d.]/g, '').split('.', 1);
|
|
114
|
+
const minimumVersion = major;
|
|
115
|
+
depWarningsGroup[minimumVersion] = [
|
|
116
|
+
...(depWarningsGroup[minimumVersion] || []),
|
|
117
|
+
{ name, packageName, value },
|
|
118
|
+
];
|
|
119
|
+
return depWarningsGroup;
|
|
120
|
+
}, Object.create(null));
|
|
121
|
+
const unsortedMinorVersions = Object.keys(unsortedWarnings);
|
|
122
|
+
if (unsortedMinorVersions.length <= 1) {
|
|
123
|
+
return {};
|
|
124
|
+
}
|
|
125
|
+
const sortedMinorVersions = unsortedMinorVersions.sort((versionA, versionB) => {
|
|
126
|
+
const numA = parseFloat(versionA);
|
|
127
|
+
const numB = parseFloat(versionB);
|
|
128
|
+
if (isNaN(numA) && isNaN(numB)) {
|
|
129
|
+
// If both are not valid numbers, maintain the current order.
|
|
130
|
+
return 0;
|
|
131
|
+
}
|
|
132
|
+
// NaN is considered greater than any number, so if numA is NaN, place it later.
|
|
133
|
+
return isNaN(numA) ? 1 : isNaN(numB) ? -1 : numB - numA;
|
|
134
|
+
});
|
|
135
|
+
return sortedMinorVersions.reduce((warnings, minorVersion) => {
|
|
136
|
+
warnings[minorVersion] = unsortedWarnings[minorVersion];
|
|
137
|
+
return warnings;
|
|
138
|
+
}, Object.create(null));
|
|
139
|
+
}
|
|
140
|
+
buildNestVersionsMessage(dependencies) {
|
|
141
|
+
const nestDependencies = this.collectNestDependencies(dependencies);
|
|
142
|
+
return this.format(nestDependencies);
|
|
143
|
+
}
|
|
144
|
+
collectNestDependencies(dependencies) {
|
|
145
|
+
const nestDependencies = [];
|
|
146
|
+
Object.keys(dependencies).forEach((key) => {
|
|
147
|
+
if (key.indexOf('@nestjs') > -1) {
|
|
148
|
+
const depPackagePath = require.resolve(key + '/package.json', {
|
|
149
|
+
paths: [process.cwd()],
|
|
150
|
+
});
|
|
151
|
+
const depPackage = (0, fs_1.readFileSync)(depPackagePath).toString();
|
|
152
|
+
const value = JSON.parse(depPackage).version;
|
|
153
|
+
nestDependencies.push({
|
|
154
|
+
name: `${key.replace(/@nestjs\//, '').replace(/@.*/, '')} version`,
|
|
155
|
+
value: value || dependencies[key].version,
|
|
156
|
+
packageName: key,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return nestDependencies;
|
|
161
|
+
}
|
|
162
|
+
format(dependencies) {
|
|
163
|
+
const sorted = dependencies.sort((dependencyA, dependencyB) => dependencyB.name.length - dependencyA.name.length);
|
|
164
|
+
const length = sorted[0].name.length;
|
|
165
|
+
sorted.forEach((dependency) => {
|
|
166
|
+
if (dependency.name.length < length) {
|
|
167
|
+
dependency.name = this.rightPad(dependency.name, length);
|
|
168
|
+
}
|
|
169
|
+
dependency.name = dependency.name.concat(' :');
|
|
170
|
+
dependency.value = dependency.value.replace(/(\^|\~)/, '');
|
|
171
|
+
});
|
|
172
|
+
return sorted;
|
|
173
|
+
}
|
|
174
|
+
rightPad(name, length) {
|
|
175
|
+
while (name.length < length) {
|
|
176
|
+
name = name.concat(' ');
|
|
177
|
+
}
|
|
178
|
+
return name;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.InfoAction = InfoAction;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Input } from '../commands';
|
|
2
|
+
import { AbstractAction } from './abstract.action';
|
|
3
|
+
export declare class NewAction extends AbstractAction {
|
|
4
|
+
handle(inputs: Input[], options: Input[]): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare const retrieveCols: () => number;
|
|
7
|
+
export declare const exit: () => never;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exit = exports.retrieveCols = exports.NewAction = void 0;
|
|
4
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
5
|
+
const ansis = require("ansis");
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const defaults_1 = require("../lib/configuration/defaults");
|
|
10
|
+
const package_managers_1 = require("../lib/package-managers");
|
|
11
|
+
const questions_1 = require("../lib/questions/questions");
|
|
12
|
+
const git_runner_1 = require("../lib/runners/git.runner");
|
|
13
|
+
const schematics_1 = require("../lib/schematics");
|
|
14
|
+
const ui_1 = require("../lib/ui");
|
|
15
|
+
const formatting_1 = require("../lib/utils/formatting");
|
|
16
|
+
const gracefully_exit_on_prompt_error_1 = require("../lib/utils/gracefully-exit-on-prompt-error");
|
|
17
|
+
const abstract_action_1 = require("./abstract.action");
|
|
18
|
+
const type_assertions_1 = require("../lib/utils/type-assertions");
|
|
19
|
+
class NewAction extends abstract_action_1.AbstractAction {
|
|
20
|
+
async handle(inputs, options) {
|
|
21
|
+
const directoryOption = options.find((option) => option.name === 'directory');
|
|
22
|
+
const dryRunOption = options.find((option) => option.name === 'dry-run');
|
|
23
|
+
const isDryRunEnabled = dryRunOption && dryRunOption.value;
|
|
24
|
+
await askForMissingInformation(inputs, options);
|
|
25
|
+
await generateApplicationFiles(inputs, options).catch(exports.exit);
|
|
26
|
+
const shouldSkipInstall = options.some((option) => option.name === 'skip-install' && option.value === true);
|
|
27
|
+
const shouldSkipGit = options.some((option) => option.name === 'skip-git' && option.value === true);
|
|
28
|
+
const projectDirectory = getProjectDirectory(getApplicationNameInput(inputs), directoryOption);
|
|
29
|
+
if (!shouldSkipInstall) {
|
|
30
|
+
await installPackages(options, isDryRunEnabled, projectDirectory);
|
|
31
|
+
}
|
|
32
|
+
if (!isDryRunEnabled) {
|
|
33
|
+
if (!shouldSkipGit) {
|
|
34
|
+
await initializeGitRepository(projectDirectory);
|
|
35
|
+
await createGitIgnoreFile(projectDirectory);
|
|
36
|
+
}
|
|
37
|
+
printCollective();
|
|
38
|
+
}
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.NewAction = NewAction;
|
|
43
|
+
const getApplicationNameInput = (inputs) => inputs.find((input) => input.name === 'name');
|
|
44
|
+
const getPackageManagerInput = (inputs) => inputs.find((options) => options.name === 'packageManager');
|
|
45
|
+
const getProjectDirectory = (applicationName, directoryOption) => {
|
|
46
|
+
return ((directoryOption && directoryOption.value) ||
|
|
47
|
+
(0, formatting_1.normalizeToKebabOrSnakeCase)(applicationName.value));
|
|
48
|
+
};
|
|
49
|
+
const askForMissingInformation = async (inputs, options) => {
|
|
50
|
+
console.info(ui_1.MESSAGES.PROJECT_INFORMATION_START);
|
|
51
|
+
console.info();
|
|
52
|
+
const nameInput = getApplicationNameInput(inputs);
|
|
53
|
+
if (!nameInput.value) {
|
|
54
|
+
const message = ui_1.MESSAGES.PROJECT_NAME_QUESTION;
|
|
55
|
+
const question = (0, questions_1.generateInput)('name', message)('nest-app');
|
|
56
|
+
const answer = await (0, prompts_1.input)(question).catch(gracefully_exit_on_prompt_error_1.gracefullyExitOnPromptError);
|
|
57
|
+
replaceInputMissingInformation(inputs, { name: 'name', value: answer });
|
|
58
|
+
}
|
|
59
|
+
const packageManagerInput = getPackageManagerInput(options);
|
|
60
|
+
if (!packageManagerInput.value) {
|
|
61
|
+
const answer = await askForPackageManager();
|
|
62
|
+
replaceInputMissingInformation(options, {
|
|
63
|
+
name: 'packageManager',
|
|
64
|
+
value: answer,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const replaceInputMissingInformation = (inputs, answer) => {
|
|
69
|
+
const input = inputs.find((input) => input.name === answer.name);
|
|
70
|
+
if (input) {
|
|
71
|
+
input.value = input.value !== undefined ? input.value : answer.value;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const generateApplicationFiles = async (args, options) => {
|
|
75
|
+
const collectionName = options.find((option) => option.name === 'collection' && option.value != null).value;
|
|
76
|
+
const collection = schematics_1.CollectionFactory.create(collectionName || schematics_1.Collection.NESTJS);
|
|
77
|
+
const schematicOptions = mapSchematicOptions(args.concat(options));
|
|
78
|
+
await collection.execute('application', schematicOptions);
|
|
79
|
+
console.info();
|
|
80
|
+
};
|
|
81
|
+
const mapSchematicOptions = (options) => {
|
|
82
|
+
return options.reduce((schematicOptions, option) => {
|
|
83
|
+
if (option.name !== 'skip-install') {
|
|
84
|
+
(0, type_assertions_1.assertNonArray)(option.value);
|
|
85
|
+
schematicOptions.push(new schematics_1.SchematicOption(option.name, option.value));
|
|
86
|
+
}
|
|
87
|
+
return schematicOptions;
|
|
88
|
+
}, []);
|
|
89
|
+
};
|
|
90
|
+
const installPackages = async (options, dryRunMode, installDirectory) => {
|
|
91
|
+
const inputPackageManager = getPackageManagerInput(options).value;
|
|
92
|
+
let packageManager;
|
|
93
|
+
if (dryRunMode) {
|
|
94
|
+
console.info();
|
|
95
|
+
console.info(ansis.green(ui_1.MESSAGES.DRY_RUN_MODE));
|
|
96
|
+
console.info();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
packageManager = package_managers_1.PackageManagerFactory.create(inputPackageManager);
|
|
101
|
+
await packageManager.install(installDirectory, inputPackageManager);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (error && error.message) {
|
|
105
|
+
console.error(ansis.red(error.message));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const askForPackageManager = async () => {
|
|
110
|
+
const question = (0, questions_1.generateSelect)('packageManager')(ui_1.MESSAGES.PACKAGE_MANAGER_QUESTION)([package_managers_1.PackageManager.NPM, package_managers_1.PackageManager.YARN, package_managers_1.PackageManager.PNPM]);
|
|
111
|
+
return (0, prompts_1.select)(question).catch(gracefully_exit_on_prompt_error_1.gracefullyExitOnPromptError);
|
|
112
|
+
};
|
|
113
|
+
const initializeGitRepository = async (dir) => {
|
|
114
|
+
const runner = new git_runner_1.GitRunner();
|
|
115
|
+
await runner.run('init', true, (0, path_1.join)(process.cwd(), dir)).catch(() => {
|
|
116
|
+
console.error(ansis.red(ui_1.MESSAGES.GIT_INITIALIZATION_ERROR));
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Write a file `.gitignore` in the root of the newly created project.
|
|
121
|
+
* `.gitignore` available in `@nestjs/schematics` cannot be published to
|
|
122
|
+
* NPM (needs to be investigated).
|
|
123
|
+
*
|
|
124
|
+
* @param dir Relative path to the project.
|
|
125
|
+
* @param content (optional) Content written in the `.gitignore`.
|
|
126
|
+
*
|
|
127
|
+
* @return Resolves when succeeds, or rejects with any error from `fn.writeFile`.
|
|
128
|
+
*/
|
|
129
|
+
const createGitIgnoreFile = (dir, content) => {
|
|
130
|
+
const fileContent = content || defaults_1.defaultGitIgnore;
|
|
131
|
+
const filePath = (0, path_1.join)(process.cwd(), dir, '.gitignore');
|
|
132
|
+
if (fileExists(filePath)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
return fs.promises.writeFile(filePath, fileContent);
|
|
136
|
+
};
|
|
137
|
+
const printCollective = () => {
|
|
138
|
+
const dim = print('dim');
|
|
139
|
+
const yellow = print('yellow');
|
|
140
|
+
const emptyLine = print();
|
|
141
|
+
emptyLine();
|
|
142
|
+
yellow(`Thanks for installing Nest ${ui_1.EMOJIS.PRAY}`);
|
|
143
|
+
dim('Please consider donating to our open collective');
|
|
144
|
+
dim('to help us maintain this package.');
|
|
145
|
+
emptyLine();
|
|
146
|
+
emptyLine();
|
|
147
|
+
print()(`${ansis.bold `${ui_1.EMOJIS.WINE} Donate:`} ${ansis.underline('https://opencollective.com/nest')}`);
|
|
148
|
+
emptyLine();
|
|
149
|
+
};
|
|
150
|
+
const print = (color = null) => (str = '') => {
|
|
151
|
+
const terminalCols = (0, exports.retrieveCols)();
|
|
152
|
+
const strLength = str.replace(/\u001b\[[0-9]{2}m/g, '').length;
|
|
153
|
+
const leftPaddingLength = Math.floor((terminalCols - strLength) / 2);
|
|
154
|
+
const leftPadding = ' '.repeat(Math.max(leftPaddingLength, 0));
|
|
155
|
+
if (color) {
|
|
156
|
+
str = ansis[color](str);
|
|
157
|
+
}
|
|
158
|
+
console.log(leftPadding, str);
|
|
159
|
+
};
|
|
160
|
+
const retrieveCols = () => {
|
|
161
|
+
const defaultCols = 80;
|
|
162
|
+
try {
|
|
163
|
+
const terminalCols = (0, child_process_1.execSync)('tput cols', {
|
|
164
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
165
|
+
});
|
|
166
|
+
return parseInt(terminalCols.toString(), 10) || defaultCols;
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return defaultCols;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
exports.retrieveCols = retrieveCols;
|
|
173
|
+
const fileExists = (path) => {
|
|
174
|
+
try {
|
|
175
|
+
fs.accessSync(path);
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
if (err.code === 'ENOENT') {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
throw err;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const exit = () => process.exit(1);
|
|
186
|
+
exports.exit = exit;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Input } from '../commands';
|
|
2
|
+
import { BuildAction } from './build.action';
|
|
3
|
+
export declare class StartAction extends BuildAction {
|
|
4
|
+
handle(commandInputs: Input[], commandOptions: Input[]): Promise<void>;
|
|
5
|
+
createOnSuccessHook(entryFile: string, sourceRoot: string, debugFlag: boolean | string | undefined, outDirName: string, binaryToRun: string, options: {
|
|
6
|
+
shell: boolean;
|
|
7
|
+
envFile?: string[];
|
|
8
|
+
}): () => void;
|
|
9
|
+
private spawnChildProcess;
|
|
10
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StartAction = void 0;
|
|
4
|
+
const ansis_1 = require("ansis");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const get_tsc_config_path_1 = require("../lib/compiler/helpers/get-tsc-config.path");
|
|
9
|
+
const get_value_or_default_1 = require("../lib/compiler/helpers/get-value-or-default");
|
|
10
|
+
const defaults_1 = require("../lib/configuration/defaults");
|
|
11
|
+
const ui_1 = require("../lib/ui");
|
|
12
|
+
const tree_kill_1 = require("../lib/utils/tree-kill");
|
|
13
|
+
const type_assertions_1 = require("../lib/utils/type-assertions");
|
|
14
|
+
const build_action_1 = require("./build.action");
|
|
15
|
+
class StartAction extends build_action_1.BuildAction {
|
|
16
|
+
async handle(commandInputs, commandOptions) {
|
|
17
|
+
try {
|
|
18
|
+
const configFileName = commandOptions.find((option) => option.name === 'config').value;
|
|
19
|
+
const configuration = await this.loader.load(configFileName);
|
|
20
|
+
const appName = commandInputs.find((input) => input.name === 'app')
|
|
21
|
+
.value;
|
|
22
|
+
const pathToTsconfig = (0, get_tsc_config_path_1.getTscConfigPath)(configuration, commandOptions, appName);
|
|
23
|
+
const debugModeOption = commandOptions.find((option) => option.name === 'debug');
|
|
24
|
+
const watchModeOption = commandOptions.find((option) => option.name === 'watch');
|
|
25
|
+
const isWatchEnabled = !!(watchModeOption && watchModeOption.value);
|
|
26
|
+
const watchAssetsModeOption = commandOptions.find((option) => option.name === 'watchAssets');
|
|
27
|
+
const isWatchAssetsEnabled = !!(watchAssetsModeOption && watchAssetsModeOption.value);
|
|
28
|
+
const debugFlag = debugModeOption && debugModeOption.value;
|
|
29
|
+
(0, type_assertions_1.assertNonArray)(debugFlag);
|
|
30
|
+
const binaryToRun = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'exec', appName, 'exec', commandOptions, defaults_1.defaultConfiguration.exec);
|
|
31
|
+
const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
|
|
32
|
+
const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
|
|
33
|
+
const entryFile = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'entryFile', appName, 'entryFile', commandOptions, defaults_1.defaultConfiguration.entryFile);
|
|
34
|
+
const sourceRoot = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'sourceRoot', appName, 'sourceRoot', commandOptions, defaults_1.defaultConfiguration.sourceRoot);
|
|
35
|
+
const shellOption = commandOptions.find((option) => option.name === 'shell');
|
|
36
|
+
const useShell = !!shellOption?.value;
|
|
37
|
+
const envFileOption = commandOptions.find((option) => option.name === 'envFile');
|
|
38
|
+
const envFile = (envFileOption?.value ?? []);
|
|
39
|
+
const onSuccess = this.createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDir, binaryToRun, {
|
|
40
|
+
shell: useShell,
|
|
41
|
+
envFile,
|
|
42
|
+
});
|
|
43
|
+
await this.runBuild(commandInputs, commandOptions, isWatchEnabled, isWatchAssetsEnabled, !!debugFlag, onSuccess);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (err instanceof Error) {
|
|
47
|
+
console.log(`\n${ui_1.ERROR_PREFIX} ${err.message}\n`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.error(`\n${(0, ansis_1.red)(err)}\n`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
createOnSuccessHook(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, options) {
|
|
55
|
+
let childProcessRef;
|
|
56
|
+
process.on('exit', () => childProcessRef && (0, tree_kill_1.treeKillSync)(childProcessRef.pid));
|
|
57
|
+
return () => {
|
|
58
|
+
if (childProcessRef) {
|
|
59
|
+
childProcessRef.removeAllListeners('exit');
|
|
60
|
+
childProcessRef.on('exit', () => {
|
|
61
|
+
childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, {
|
|
62
|
+
shell: options.shell,
|
|
63
|
+
envFile: options.envFile,
|
|
64
|
+
});
|
|
65
|
+
childProcessRef.on('exit', () => (childProcessRef = undefined));
|
|
66
|
+
});
|
|
67
|
+
childProcessRef.stdin && childProcessRef.stdin.pause();
|
|
68
|
+
(0, tree_kill_1.treeKillSync)(childProcessRef.pid);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
childProcessRef = this.spawnChildProcess(entryFile, sourceRoot, debugFlag, outDirName, binaryToRun, {
|
|
72
|
+
shell: options.shell,
|
|
73
|
+
envFile: options.envFile,
|
|
74
|
+
});
|
|
75
|
+
childProcessRef.on('exit', (code) => {
|
|
76
|
+
process.exitCode = code;
|
|
77
|
+
childProcessRef = undefined;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
spawnChildProcess(entryFile, sourceRoot, debug, outDirName, binaryToRun, options) {
|
|
83
|
+
let outputFilePath = (0, path_1.join)(outDirName, sourceRoot, entryFile);
|
|
84
|
+
if (!fs.existsSync(outputFilePath + '.js')) {
|
|
85
|
+
outputFilePath = (0, path_1.join)(outDirName, entryFile);
|
|
86
|
+
}
|
|
87
|
+
let childProcessArgs = [];
|
|
88
|
+
const argsStartIndex = process.argv.indexOf('--');
|
|
89
|
+
if (argsStartIndex >= 0) {
|
|
90
|
+
// Prevents the need for users to double escape strings
|
|
91
|
+
// i.e. I can run the more natural
|
|
92
|
+
// nest start -- '{"foo": "bar"}'
|
|
93
|
+
// instead of
|
|
94
|
+
// nest start -- '\'{"foo": "bar"}\''
|
|
95
|
+
childProcessArgs = process.argv
|
|
96
|
+
.slice(argsStartIndex + 1)
|
|
97
|
+
.map((arg) => JSON.stringify(arg));
|
|
98
|
+
}
|
|
99
|
+
outputFilePath =
|
|
100
|
+
outputFilePath.indexOf(' ') >= 0 ? `"${outputFilePath}"` : outputFilePath;
|
|
101
|
+
const processArgs = [outputFilePath, ...childProcessArgs];
|
|
102
|
+
if (debug) {
|
|
103
|
+
const inspectFlag = typeof debug === 'string' ? `--inspect=${debug}` : '--inspect';
|
|
104
|
+
processArgs.unshift(inspectFlag);
|
|
105
|
+
}
|
|
106
|
+
if (options.envFile && options.envFile.length > 0) {
|
|
107
|
+
const envFileNodeArgs = options.envFile.map((envFilePath) => `--env-file=${envFilePath}`);
|
|
108
|
+
processArgs.unshift(envFileNodeArgs.join(' '));
|
|
109
|
+
}
|
|
110
|
+
processArgs.unshift('--enable-source-maps');
|
|
111
|
+
const spawnOptions = {
|
|
112
|
+
stdio: 'inherit',
|
|
113
|
+
shell: options.shell,
|
|
114
|
+
};
|
|
115
|
+
if (options.shell) {
|
|
116
|
+
const command = [binaryToRun, ...processArgs].join(' ');
|
|
117
|
+
return (0, child_process_1.spawn)(command, spawnOptions);
|
|
118
|
+
}
|
|
119
|
+
return (0, child_process_1.spawn)(binaryToRun, processArgs, spawnOptions);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.StartAction = StartAction;
|
package/bin/nest.d.ts
ADDED
package/bin/nest.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander = require("commander");
|
|
5
|
+
const commands_1 = require("../commands");
|
|
6
|
+
const local_binaries_1 = require("../lib/utils/local-binaries");
|
|
7
|
+
const bootstrap = async () => {
|
|
8
|
+
const program = commander;
|
|
9
|
+
program
|
|
10
|
+
.version(require('../package.json').version, '-v, --version', 'Output the current version.')
|
|
11
|
+
.usage('<command> [options]')
|
|
12
|
+
.helpOption('-h, --help', 'Output usage information.');
|
|
13
|
+
if ((0, local_binaries_1.localBinExists)()) {
|
|
14
|
+
const localCommandLoader = (0, local_binaries_1.loadLocalBinCommandLoader)();
|
|
15
|
+
await localCommandLoader.load(program);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
await commands_1.CommandLoader.load(program);
|
|
19
|
+
}
|
|
20
|
+
await commander.parseAsync(process.argv);
|
|
21
|
+
if (!process.argv.slice(2).length) {
|
|
22
|
+
program.outputHelp();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
bootstrap();
|
package/changes.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bumped": {
|
|
3
|
+
"@angular-devkit/core": {
|
|
4
|
+
"from": "19.2.19",
|
|
5
|
+
"to": "^21.2.3"
|
|
6
|
+
},
|
|
7
|
+
"@angular-devkit/schematics": {
|
|
8
|
+
"from": "19.2.19",
|
|
9
|
+
"to": "^21.2.3"
|
|
10
|
+
},
|
|
11
|
+
"@angular-devkit/schematics-cli": {
|
|
12
|
+
"from": "19.2.19",
|
|
13
|
+
"to": "^21.2.3"
|
|
14
|
+
},
|
|
15
|
+
"@inquirer/prompts": {
|
|
16
|
+
"from": "7.10.1",
|
|
17
|
+
"to": "^8.3.2"
|
|
18
|
+
},
|
|
19
|
+
"@nestjs/schematics": {
|
|
20
|
+
"from": "^11.0.1",
|
|
21
|
+
"to": "^11.0.9"
|
|
22
|
+
},
|
|
23
|
+
"chokidar": {
|
|
24
|
+
"from": "4.0.3",
|
|
25
|
+
"to": "^5.0.0"
|
|
26
|
+
},
|
|
27
|
+
"commander": {
|
|
28
|
+
"from": "4.1.1",
|
|
29
|
+
"to": "^14.0.3"
|
|
30
|
+
},
|
|
31
|
+
"glob": {
|
|
32
|
+
"from": "13.0.0",
|
|
33
|
+
"to": "^13.0.6"
|
|
34
|
+
},
|
|
35
|
+
"node-emoji": {
|
|
36
|
+
"from": "1.11.0",
|
|
37
|
+
"to": "^2.2.0"
|
|
38
|
+
},
|
|
39
|
+
"ora": {
|
|
40
|
+
"from": "5.4.1",
|
|
41
|
+
"to": "^9.3.0"
|
|
42
|
+
},
|
|
43
|
+
"typescript": {
|
|
44
|
+
"from": "5.9.3",
|
|
45
|
+
"to": "^6.0.2"
|
|
46
|
+
},
|
|
47
|
+
"webpack": {
|
|
48
|
+
"from": "5.104.1",
|
|
49
|
+
"to": "^5.105.4"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"timestamp": "2026-03-23T16:27:57.880Z",
|
|
53
|
+
"totalUpdated": 12
|
|
54
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CommanderStatic } from 'commander';
|
|
2
|
+
import { AbstractAction } from '../actions/abstract.action';
|
|
3
|
+
export declare abstract class AbstractCommand {
|
|
4
|
+
protected action: AbstractAction;
|
|
5
|
+
constructor(action: AbstractAction);
|
|
6
|
+
abstract load(program: CommanderStatic): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AddCommand = void 0;
|
|
4
|
+
const remaining_flags_1 = require("../lib/utils/remaining-flags");
|
|
5
|
+
const abstract_command_1 = require("./abstract.command");
|
|
6
|
+
class AddCommand extends abstract_command_1.AbstractCommand {
|
|
7
|
+
load(program) {
|
|
8
|
+
program
|
|
9
|
+
.command('add <library>')
|
|
10
|
+
.allowUnknownOption()
|
|
11
|
+
.description('Adds support for an external library to your project.')
|
|
12
|
+
.option('-d, --dry-run', 'Report actions that would be performed without writing out results.')
|
|
13
|
+
.option('-s, --skip-install', 'Skip package installation.', false)
|
|
14
|
+
.option('-p, --project [project]', 'Project in which to generate files.')
|
|
15
|
+
.usage('<library> [options] [library-specific-options]')
|
|
16
|
+
.action(async (library, command) => {
|
|
17
|
+
const options = [];
|
|
18
|
+
options.push({ name: 'dry-run', value: !!command.dryRun });
|
|
19
|
+
options.push({ name: 'skip-install', value: command.skipInstall });
|
|
20
|
+
options.push({
|
|
21
|
+
name: 'project',
|
|
22
|
+
value: command.project,
|
|
23
|
+
});
|
|
24
|
+
const inputs = [];
|
|
25
|
+
inputs.push({ name: 'library', value: library });
|
|
26
|
+
const flags = (0, remaining_flags_1.getRemainingFlags)(program);
|
|
27
|
+
try {
|
|
28
|
+
await this.action.handle(inputs, options, flags);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.AddCommand = AddCommand;
|