Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async execBoilerplate(generator) {
this.log('Fetch the boilerplate which you like...');
const args = await generator.getParameterList();
const argsKeys = Object.keys(args);
if (argsKeys && argsKeys.length) {
this.prompt = new Form({
name: 'user',
message: 'Please provide the following information:',
choices: argsKeys.map(argsKey => {
return {
name: `${argsKey}`,
message: `${args[argsKey].desc}`,
initial: `${args[argsKey].default}`,
};
}),
show: this.showPrompt,
});
const parameters = await this.prompt.run();
// remove undefined property
Object.keys(parameters).forEach(
key => parameters[key] === undefined && delete parameters[key]
async function promptForPermissionDescriptionsAsync(
choices: IOSPermissionChoice[],
hasNativeConfig: boolean,
currentDescriptions: AnyPermissions
): Promise {
console.log('');
const keys = Object.keys(DefaultiOSPermissionNames);
const prompt = new Form({
name: hasNativeConfig ? 'Native project' : 'Universal project',
message: 'Modify iOS Permissions',
header() {
const permission = keys[this.index];
if (!currentDescriptions[permission]) {
return chalk.magenta(
`${CHEVRON} Add a description to enable the "${chalk.bold(
permission
)}" permission in your iOS app`
);
}
return chalk.magenta(
`${CHEVRON} Update the description for the permission "${chalk.bold(permission)}"`
);
},
choices,
'use strict';
const { Form } = require('enquirer');
const prompt = new Form({
name: 'user',
message: 'Please provide the following information:',
choices: [
{ name: 'firstname', message: 'First Name', initial: 'Jon' },
{ name: 'lastname', message: 'Last Name', initial: 'Schlinkert' },
{ name: 'username', message: 'GitHub username', initial: 'jonschlinkert' }
]
});
prompt.run()
.then(value => console.log('ANSWERS:', value))
.catch(console.error);
async function editInfo ({ subject, hs, name, email, date, cname, cemail, cdate }, sequence) {
const message = itemDisplay({ hs, date, name, subject, sequence })
const to = await new Form({
name: 'commit',
message,
choices: [
{ name: 'name', message: 'Name', initial: name },
{ name: 'email', message: 'Email', initial: email },
{ name: 'subject', message: 'Message', initial: subject }
]
}).run()
const diff = { name: name !== to.name, email: email !== to.email, subject: subject !== to.subject }
return () => {
setEnv(Object.assign(to, { date }))
if (diff.name || diff.email) exec`git commit --amend --no-edit --author="${to.name} <${to.email}>"`
if (diff.subject) exec`git commit --amend --no-edit -m "${to.subject}"`
exec`git rebase --skip`
}
}
return prompt => {
let p = new Input({ name, message, initial });
return p.run().then(value => ({ name, message, initial: value, value }));
};
};
/**
* Now will will define a few choices on the Form prompt using the
* 'input' function we just created. Since the prompt won't run until
* all async choices are resolved, each input-question will be asked
* in series before the Form prompt actually runs and displays the
* choices. This creates a nice effect of allowing the user to
* review their answers before submitting the final result.
*/
const prompt = new Form({
name: 'user',
message: 'Please review your answers:',
choices: [
input('name', 'Project name', path.basename(process.cwd())),
input('author', 'Author name', 'jonschlinkert'),
input('username', 'GitHub username/org', 'enquirer'),
{
name: 'repo',
message: 'Repository URL',
onChoice(state, choice, i) {
let { name, username } = this.values;
choice.initial = `https://github.com/${username}/${name}`;
}
}
]
});