Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added value check for "feature" parameter in init #3449

Merged
merged 2 commits into from
Jun 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 51 additions & 40 deletions src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,61 @@ var _isOutside = function (from, to) {
return path.relative(from, to).match(/^\.\./);
};

const choices = [
{
value: "database",
name:
"Realtime Database: Configure a security rules file for Realtime Database and (optionally) provision default instance",
checked: false,
},
{
value: "firestore",
name: "Firestore: Configure security rules and indexes files for Firestore",
checked: false,
},
{
value: "functions",
name: "Functions: Configure a Cloud Functions directory and its files",
checked: false,
},
{
value: "hosting",
name:
"Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys",
checked: false,
},
{
value: "storage",
name: "Storage: Configure a security rules file for Cloud Storage",
checked: false,
},
{
value: "emulators",
name: "Emulators: Set up local emulators for Firebase products",
checked: false,
},
{
value: "remoteconfig",
name: "Remote Config: Configure a template file for Remote Config",
checked: false,
},
];
const featureNames = choices.map((choice) => choice.value);

module.exports = new Command("init [feature]")
.description("set up a Firebase project in the current directory")
.before(requireAuth)
.action(function (feature, options) {
if (feature && !featureNames.includes(feature)) {
return utils.reject(
clc.bold(feature) +
" is not a supported feature; must be one of " +
featureNames.join(", ") +
".",
{ exit: 1 }
);
}

var cwd = options.cwd || process.cwd();

var warnings = [];
Expand Down Expand Up @@ -70,46 +121,6 @@ module.exports = new Command("init [feature]")
}),
};

var choices = [
{
value: "database",
name:
"Realtime Database: Configure a security rules file for Realtime Database and (optionally) provision default instance",
checked: false,
},
{
value: "firestore",
name: "Firestore: Configure security rules and indexes files for Firestore",
checked: false,
},
{
value: "functions",
name: "Functions: Configure a Cloud Functions directory and its files",
checked: false,
},
{
value: "hosting",
name:
"Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys",
checked: false,
},
{
value: "storage",
name: "Storage: Configure a security rules file for Cloud Storage",
checked: false,
},
{
value: "emulators",
name: "Emulators: Set up local emulators for Firebase products",
checked: false,
},
{
value: "remoteconfig",
name: "Remote Config: Configure a template file for Remote Config",
checked: false,
},
];

var next;
// HACK: Windows Node has issues with selectables as the first prompt, so we
// add an extra confirmation prompt that fixes the problem
Expand Down