Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const invalidLabel = pluralize('deployment', invalid.length)
console.error(`Error invalid ${invalidLabel} [${invalid.join(', ')}]`)
process.exit(1)
}
// TODO: if any projects are specified without deployment version info, then
// expand them out to include all deployments in those projects
// TODO: currently if you specify a project, it'll do project@latest...
const deployments = parsedArgs.map(({ deploymentId }) => deploymentId)
if (!opts.yes) {
console.error(`${deploymentsLabel}:`, deployments.join(', '))
const prompt = new Confirm({
message: `Are you sure you want to delete these ${deployments.length} ${deploymentsLabel}?`,
initial: true
})
const answer = await prompt.run()
if (!answer) {
process.exit(1)
}
}
await spinner(
pMap(
deployments,
(deploymentId) => {
return client.removeDeployment(deploymentId, {
safe: opts.safe
throw new Error(`Invalid project identifier [${identifier}]`)
}
const { projectId } = parsedFaas
// TODO: remove this call to resolveConsumers?
// TODO: is moving all parsing and ID formatting logic to be shared between
// client and server really a good idea?
const consumer = await spinner(
client.getConsumerByProject(projectId),
`Resolving subscription for project [${projectId}]`
)
if (!opts.yes) {
const prompt = new Confirm({
message: `Are you sure you want to unsubscribe from project [${consumer.project}]?`,
initial: true
})
const answer = await prompt.run()
if (!answer) {
process.exit(1)
}
}
await spinner(
client.removeConsumer(consumer),
`Cancelling subscription to project [${consumer.project}]`
)
program.appendOutput(
async function eject([_sourceFile, destinationPath]: string[]) {
const sourceFile = path.resolve(
__dirname,
'../ejectableFiles/' + _sourceFile
);
debug(`ejecting: from ${_sourceFile} to ${destinationPath}`);
if (fs.existsSync(sourceFile)) {
try {
ensureDirectoryExistence(destinationPath);
if (fs.existsSync(destinationPath)) {
const prompt = new Confirm({
name: 'question',
message: `A file exists at ${chalk.cyan(
destinationPath
)}. Are you sure you want to overwrite?`
});
const answer = await prompt.run();
if (!answer) return; // dont override
try {
fs.renameSync(destinationPath, destinationPath + '.old');
} catch (err) {
console.log('renaming failed. copying and overwriting instead.');
fs.copyFileSync(destinationPath, destinationPath + '.copy');
}
}
fs.copyFileSync(sourceFile, destinationPath);
console.log(
const whoamiLabel = formatWhoami({ user, team })
const { temp = tempy.directory(), debug = false, publish = false } = opts
console.log(`Aggregating saasify projects from ${repos.length} ${reposLabel}`)
console.log(temp)
const projects = await getProjects(repos, { temp })
const projectNames = projects.map((project) => project.config.name)
const projectsLabel = pluralize('project', projects.length)
console.log(`Found ${projects.length} saasify ${projectsLabel}`)
console.log(JSON.stringify(projectNames, null, 2))
if (!opts.yes) {
const prompt = new Confirm({
message: `Are you sure you want to deploy these ${projects.length} ${projectsLabel} under ${whoamiLabel}?`,
initial: true
})
const answer = await prompt.run()
if (!answer) {
process.exit(1)
}
}
const deployments = []
const errors = []
await pMap(
projects,
async (project) => {
const checkForNewlines = async (secret, logger) => {
const eolIndex = secret.indexOf(os.EOL);
if (eolIndex !== -1) {
const newlinesDetectedPrompt = new Confirm({
name: 'question',
message: `Secret contains newlines at index ${eolIndex}. Continue encrypting this secret?`
});
const response = await newlinesDetectedPrompt.run();
if (!response) {
logger.info('Aborting - secrets contains newline');
process.exit(0);
}
}
};
'use strict';
const { Confirm } = require('enquirer');
const prompt = new Confirm({
name: 'toast',
message: 'Do you like toast?',
initial: true
});
prompt.run()
.then(answer => console.log('Answer:', answer))
.catch(console.error);
'use strict';
const { Confirm } = require('enquirer');
const prompt = new Confirm({
name: 'toast',
message: 'Do you like toast?',
initial: false
});
prompt.run()
.then(answer => console.log('Answer:', answer))
.catch(console.error);
const { Confirm } = require('enquirer');
const prompt = new Confirm({
name: 'apples',
message: 'How do you like these apples?',
onRun() {
this.isTrue = value => value === 'f';
this.isFalse = value => value === 't';
}
});
prompt.run()
.then(answer => console.log('Answer:', answer))
.catch(console.error);
(async () => {
const args = process.argv.slice(2);
if (isInternal()) {
const prompt = new Confirm({
name: 'really',
message: '检测到目前可能处于内网环境,推荐使用 @ali/midway-init,确定要继续吗?',
initial: false,
default: '[Y(es)|N(o)]',
});
const isContinue = await prompt.run();
if (!isContinue) {
return;
}
}
try {
const cmd = new Command();
await cmd.run(process.cwd(), args);
} catch (err) {