@nestjs/cli 11.0.0-next.2 → 11.0.0-next.3
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/actions/new.action.js +10 -10
- package/lib/ui/emojis.d.ts +1 -1
- package/lib/ui/emojis.js +1 -1
- package/lib/ui/messages.js +1 -1
- 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/project-utils.js +3 -4
- package/package.json +1 -1
package/actions/new.action.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.exit = exports.retrieveCols = exports.NewAction = void 0;
|
|
4
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
4
5
|
const chalk = require("chalk");
|
|
5
6
|
const child_process_1 = require("child_process");
|
|
6
7
|
const fs = require("fs");
|
|
@@ -12,8 +13,8 @@ const git_runner_1 = require("../lib/runners/git.runner");
|
|
|
12
13
|
const schematics_1 = require("../lib/schematics");
|
|
13
14
|
const ui_1 = require("../lib/ui");
|
|
14
15
|
const formatting_1 = require("../lib/utils/formatting");
|
|
16
|
+
const gracefully_exit_on_prompt_error_1 = require("../lib/utils/gracefully-exit-on-prompt-error");
|
|
15
17
|
const abstract_action_1 = require("./abstract.action");
|
|
16
|
-
const prompts_1 = require("@inquirer/prompts");
|
|
17
18
|
class NewAction extends abstract_action_1.AbstractAction {
|
|
18
19
|
async handle(inputs, options) {
|
|
19
20
|
const directoryOption = options.find((option) => option.name === 'directory');
|
|
@@ -51,17 +52,20 @@ const askForMissingInformation = async (inputs, options) => {
|
|
|
51
52
|
if (!nameInput.value) {
|
|
52
53
|
const message = ui_1.MESSAGES.PROJECT_NAME_QUESTION;
|
|
53
54
|
const question = (0, questions_1.generateInput)('name', message)('nest-app');
|
|
54
|
-
const answer = await (0, prompts_1.input)(question);
|
|
55
|
+
const answer = await (0, prompts_1.input)(question).catch(gracefully_exit_on_prompt_error_1.gracefullyExitOnPromptError);
|
|
55
56
|
replaceInputMissingInformation(inputs, { name: 'name', value: answer });
|
|
56
57
|
}
|
|
57
58
|
const packageManagerInput = getPackageManagerInput(options);
|
|
58
59
|
if (!packageManagerInput.value) {
|
|
59
60
|
const answer = await askForPackageManager();
|
|
60
|
-
replaceInputMissingInformation(options, {
|
|
61
|
+
replaceInputMissingInformation(options, {
|
|
62
|
+
name: 'packageManager',
|
|
63
|
+
value: answer,
|
|
64
|
+
});
|
|
61
65
|
}
|
|
62
66
|
};
|
|
63
67
|
const replaceInputMissingInformation = (inputs, answer) => {
|
|
64
|
-
const input = inputs.find(input => input.name === answer.name);
|
|
68
|
+
const input = inputs.find((input) => input.name === answer.name);
|
|
65
69
|
if (input) {
|
|
66
70
|
input.value = input.value !== undefined ? input.value : answer.value;
|
|
67
71
|
}
|
|
@@ -101,12 +105,8 @@ const installPackages = async (options, dryRunMode, installDirectory) => {
|
|
|
101
105
|
}
|
|
102
106
|
};
|
|
103
107
|
const askForPackageManager = async () => {
|
|
104
|
-
const question = (0, questions_1.generateSelect)('packageManager')(ui_1.MESSAGES.PACKAGE_MANAGER_QUESTION)([
|
|
105
|
-
|
|
106
|
-
package_managers_1.PackageManager.YARN,
|
|
107
|
-
package_managers_1.PackageManager.PNPM,
|
|
108
|
-
]);
|
|
109
|
-
return (0, prompts_1.select)(question);
|
|
108
|
+
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]);
|
|
109
|
+
return (0, prompts_1.select)(question).catch(gracefully_exit_on_prompt_error_1.gracefullyExitOnPromptError);
|
|
110
110
|
};
|
|
111
111
|
const initializeGitRepository = async (dir) => {
|
|
112
112
|
const runner = new git_runner_1.GitRunner();
|
package/lib/ui/emojis.d.ts
CHANGED
package/lib/ui/emojis.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.EMOJIS = {
|
|
|
16
16
|
SMIRK: (0, node_emoji_1.get)('smirk_cat'),
|
|
17
17
|
RAISED_HANDS: (0, node_emoji_1.get)('raised_hands'),
|
|
18
18
|
POINT_RIGHT: (0, node_emoji_1.get)('point_right'),
|
|
19
|
-
|
|
19
|
+
SPARKLES: (0, node_emoji_1.get)('sparkles'),
|
|
20
20
|
BOOM: (0, node_emoji_1.get)('boom'),
|
|
21
21
|
PRAY: (0, node_emoji_1.get)('pray'),
|
|
22
22
|
WINE: (0, node_emoji_1.get)('wine_glass'),
|
package/lib/ui/messages.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.MESSAGES = {
|
|
|
8
8
|
PROJECT_SELECTION_QUESTION: 'Which project would you like to generate to?',
|
|
9
9
|
LIBRARY_PROJECT_SELECTION_QUESTION: 'Which project would you like to add the library to?',
|
|
10
10
|
DRY_RUN_MODE: 'Command has been executed in dry run mode, nothing changed!',
|
|
11
|
-
PROJECT_INFORMATION_START: `${emojis_1.EMOJIS.
|
|
11
|
+
PROJECT_INFORMATION_START: `${emojis_1.EMOJIS.SPARKLES} We will scaffold your app in a few seconds..`,
|
|
12
12
|
RUNNER_EXECUTION_ERROR: (command) => `\nFailed to execute command: ${command}`,
|
|
13
13
|
PACKAGE_MANAGER_QUESTION: `Which package manager would you ${emojis_1.EMOJIS.HEART} to use?`,
|
|
14
14
|
PACKAGE_MANAGER_INSTALLATION_IN_PROGRESS: `Installation in progress... ${emojis_1.EMOJIS.COFFEE}`,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function gracefullyExitOnPromptError(err: Error): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gracefullyExitOnPromptError = gracefullyExitOnPromptError;
|
|
4
|
+
function gracefullyExitOnPromptError(err) {
|
|
5
|
+
if (err.name === 'ExitPromptError') {
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
throw err;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -10,6 +10,7 @@ exports.hasValidOptionFlag = hasValidOptionFlag;
|
|
|
10
10
|
const prompts_1 = require("@inquirer/prompts");
|
|
11
11
|
const get_value_or_default_1 = require("../compiler/helpers/get-value-or-default");
|
|
12
12
|
const questions_1 = require("../questions/questions");
|
|
13
|
+
const gracefully_exit_on_prompt_error_1 = require("./gracefully-exit-on-prompt-error");
|
|
13
14
|
function shouldAskForProject(schematic, configurationProjects, appName) {
|
|
14
15
|
return (['app', 'sub-app', 'library', 'lib'].includes(schematic) === false &&
|
|
15
16
|
configurationProjects &&
|
|
@@ -66,10 +67,8 @@ function getSpecFileSuffix(configuration, appName, specFileSuffixValue) {
|
|
|
66
67
|
return specFileSuffixValue;
|
|
67
68
|
}
|
|
68
69
|
async function askForProjectName(promptQuestion, projects) {
|
|
69
|
-
const questions = [
|
|
70
|
-
|
|
71
|
-
];
|
|
72
|
-
return (0, prompts_1.select)(questions);
|
|
70
|
+
const questions = [(0, questions_1.generateSelect)('appName')(promptQuestion)(projects)];
|
|
71
|
+
return (0, prompts_1.select)(questions).catch(gracefully_exit_on_prompt_error_1.gracefullyExitOnPromptError);
|
|
73
72
|
}
|
|
74
73
|
function moveDefaultProjectToStart(configuration, defaultProjectName, defaultLabel) {
|
|
75
74
|
let projects = configuration.projects != null ? Object.keys(configuration.projects) : [];
|