Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function handleCreateCmd(pkg, options) {
let template;
const prompt = new Select({
message: 'Choose a template',
choices: ['aws node', 'aws node typescript'],
});
try {
// get the project path
let projectPath = await getProjectPath(
fs.realpathSync(process.cwd()) + '/' + pkg,
pkg
);
if (options.template) {
template = options.template.trim();
if (!prompt.choices.includes(template)) {
template = await prompt.run();
}
off: ' '
}
},
prefix: state => emoji[state.status],
pointer(state, choice, i) {
let status = state.index === i ? 'on' : 'off';
let symbol = this.symbols.radio[status];
let fallback = '🗡️ ';
if (typeof symbol === 'function') {
return symbol(...arguments) || fallback;
}
return symbol || fallback;
}
};
const prompt = new Select({
name: 'halloween',
message: 'Trick or treat! Take your pick',
theme: halloween,
choices: [
{ name: 'candy', value: 'Sweet!' },
{ name: 'apple', value: 'Hard... core?' },
{ name: 'toothpaste', value: 'Orange juice?' },
{ name: 'insult', value: 'You stink!' },
{ name: 'razor blade', value: 'Ouch!' }
]
});
prompt.run()
.then(key => {
let choice = prompt.choices.find(ch => ch.name === key);
console.log('answer:', { [key]: choice.value });
'use strict';
const yosay = require('yosay');
const { Select } = require('enquirer');
const prompt = new Select({
name: 'color',
message: 'Pick a color',
header: yosay('Welcome to my awesome generator!'),
choices: [
'aqua',
'black',
'blue',
'fuchsia',
'gray',
'green'
]
});
prompt.run()
.then(answer => console.log('Answer:', answer))
.catch(console.error);
'use strict';
const colors = require('ansi-colors');
const { Select } = require('enquirer');
const prompt = new Select({
name: 'color',
message: 'Pick a flavor',
choices: ['apple', 'grape', 'watermelon', 'cherry', 'orange'],
pointer(choice, i) {
return this.state.index === i ? colors.green('→') : ' ';
}
});
prompt.run()
.then(answer => console.log('Answer:', answer))
.catch(console.error);
const choices = [];
if (isReady) {
choices.push({ message: "View your monetary accounts", value: "view-monetary-account" });
choices.push({ message: "Call an API endpoint", value: "call-endpoint" });
choices.push({ message: "Create a new monetary account", value: "create-monetary-account" });
if (isSandbox) {
choices.push({ message: "Add funds to sandbox account", value: "request-sandbox-funds" });
}
}
choices.push({ message: isReady ? "Modify API key" : "Setup an API key", value: "setup-api-key" });
choices.push(separatorChoiceOption());
choices.push({ message: "Refresh", value: "refresh" });
choices.push({ message: "Quit", value: "quit" });
const result = await new Select({
message: "What would you like to do",
choices: choices
}).run();
clearConsole();
switch (result) {
case "call-endpoint":
return CallEndpoint(bunqCLI);
case "request-sandbox-funds":
return RequestSandboxFunds(bunqCLI);
case "create-monetary-account":
return CreateMonetaryAccount(bunqCLI);
case "setup-api-key":
return SetupApiKey(bunqCLI);
case "view-monetary-account":
return ViewMonetaryAccounts(bunqCLI);
export default async ENVIRONMENT => {
const prompt = new Select({
message: "Which environment would you like to use?",
choices: [{ message: "Sandbox", value: "SANDBOX" }, { message: "Production", value: "PRODUCTION" }],
initial: ENVIRONMENT ? ENVIRONMENT : ""
});
return prompt.run();
};
export default async accounts => {
const prompt = new Select({
message: "Which monetary account would you like to use?",
choices: accounts.map(accountInfo => {
return {
message: `${accountInfo.id}: ${accountInfo.description} - ${accountInfo.balance.value}`,
value: accountInfo.id
};
})
});
return prompt.run();
};
export default async () => {
const prompt = new Select({
message: "Which type of monetary account would you like to use?",
choices: [{ message: "Regular", value: "regular" }, { message: "Savings", value: "savings" }]
});
return prompt.run();
};
export default async ENCRYPTION_KEY => {
const prompt = new Select({
message: "No encryption key is set, would you like to enter one or have one generated for you?",
choices: [{ message: "Generate a new key", value: "generate" }, { message: "Enter a key", value: "custom" }]
});
const encryptionKeyType = await prompt.run();
if (encryptionKeyType === "generate") {
return randomHex(32);
} else {
const inputPrompt = new Password({
message: "Enter a 16, 24 or 32 bit hex encoded encryption key",
initial: ENCRYPTION_KEY ? ENCRYPTION_KEY : ""
});
return inputPrompt.run();
}
};
'use strict';
const yosay = require('yosay');
const colors = require('ansi-colors');
const { Select } = require('enquirer');
/**
* This prompt shows how you can easily customize the footer
* to render a different value based on conditions.
*/
let keys = Object.keys(colors.styles);
let idx = 0;
const prompt = new Select({
name: 'color',
message: 'Pick a color',
header: yosay('Welcome to my awesome generator!'),
footer() {
let fn = colors[keys[++idx % keys.length]];
return '\n' + fn('(Scroll up and down to reveal more choices)');
},
limit: 5,
choices: [
'aqua',
'black',
'blue',
'fuchsia',
'gray',
'green',
'lime',