Skip to content

Commit 88c7b80

Browse files
fix(schematics): warn when ng add setup runs with no features selected (#3717)
* fix(schematics): warn when ng add setup runs with no features selected Pressing Enter without toggling any checkbox at the features prompt silently exited with the CLI's stock "Nothing to be done." message, giving no indication that Space selects a feature. Print a warning explaining the checkbox controls and inviting a retry. * refactor(schematics): derive the empty-features warning from the prompt message The empty-features warning duplicated the checkbox prompt's message as a second string literal, so a reworded prompt would leave the warning pointing at text the user never sees. Export the message as a shared constant and reference it in both places, matching the shared-constant pattern used for the firebase-tools version message in 59c8a2f.
1 parent b551b5f commit 88c7b80

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/schematics/setup/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
createFirestoreStarterFiles,
2222
setDefaultProjectInFirebaseRc,
2323
} from './firebaseConfigs';
24-
import { appPrompt, featuresPrompt, projectPrompt, userPrompt } from './prompts';
24+
import { appPrompt, featuresPrompt, featuresPromptMessage, projectPrompt, userPrompt } from './prompts';
2525

2626
// FirebaseOptions keys — apps.sdkconfig responses include management-API extras that initializeApp() rejects.
2727
const firebaseOptionsKeys = [
@@ -67,7 +67,14 @@ export const ngAddSetupProject = (
6767

6868
const features = await featuresPrompt();
6969

70-
if (features.length > 0) {
70+
if (features.length === 0) {
71+
context.logger.warn(
72+
'No features were selected, so there is nothing to set up. ' +
73+
`At the "${featuresPromptMessage}" prompt, use the arrow keys to move, ` +
74+
'press Space to select each feature you want, then Enter to confirm. ' +
75+
'Re-run ng add @angular/fire to try again.'
76+
);
77+
} else {
7178

7279
const firebaseTools = await getFirebaseTools();
7380

src/schematics/setup/prompts.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ type Prompt = <K extends string, U= unknown>(questions: { name: K, source: (...a
7979
const autocomplete: Prompt = (questions) => inquirer.prompt(questions);
8080

8181

82+
export const featuresPromptMessage = 'What features would you like to setup?';
83+
8284
export const featuresPrompt = async (): Promise<FEATURES[]> => {
8385
const { features } = await inquirer.prompt({
8486
type: 'checkbox',
8587
name: 'features',
8688
choices: featureOptions,
87-
message: 'What features would you like to setup?',
89+
message: featuresPromptMessage,
8890
default: [],
8991
}) as { features: FEATURES[] };
9092
return features;

0 commit comments

Comments
 (0)