Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function loadConfig (program, options) {
let argv = {
...options,
version: program.version()
}
let configFile = argv['configFile'] || './config.json'
try {
const file = fs.readFileSync(configFile)
// Use flags with priority over config file
const config = JSON.parse(file)
argv = { ...config, ...argv }
} catch (err) {
// No file exists, not a problem
console.log(cyan(bold('TIP')), 'create a config.json: `$ solid init`')
}
return argv
}
_getCommands() {
const commandTable = this._getSimpleTable();
this._program._commands
// don't include default command
.filter((c) => c.name() !== '' && c.visible())
.forEach(cmd => {
commandTable.push(
[c.magenta(cmd.getSynopsis()), cmd.description()]
);
});
commandTable.push([c.magenta('help '), 'Display help for a specific command']);
return c.bold('COMMANDS') + "\n\n" + colorize(commandTable.toString());
}
if (alreadyGenerated) await query`UPDATE redirect_keys SET content = ${hash}`;
else await query`INSERT INTO redirect_keys (content) VALUES (${hash})`;
await clipboardy.write(mnemonic);
storeSpinner.succeed();
console.log();
console.log(
c.green('√ '),
'Your passphrase has been stored, and is now ready to use when micro-link is deployed!',
'\n'
);
console.log(' ', c.green('Your passphrase is:'));
console.log(' ', c.bold(mnemonic));
console.log('\n ', c.green('It has also been copied to your clipboard.'));
process.exit(0);
}
console.log();
const { bold, cyan, gray, green, red, symbols } = require('./');
const good = green(symbols.check);
const bad = red(symbols.cross);
console.log(bold(`foo ${cyan.dim('bar')} baz`), good, gray('(ansi-colors)'));
const colorette = require('colorette');
console.log(colorette.bold(`foo ${colorette.cyan(colorette.dim('bar'))} baz`), bad, gray('(colorette)'));
const kleur = require('kleur');
console.log(kleur.bold(`foo ${kleur.cyan.dim('bar')} baz`), bad, gray('(kleur)'));
const chalk = require('chalk');
console.log(chalk.bold(`foo ${chalk.cyan.dim('bar')} baz`), bad, gray('(chalk)'));
console.log();
async function main() {
if (!hasEnvVars) {
console.log(
c.red(
c.bold(
'It looks like you are missing the environment variables required for the script to run.'
)
)
);
console.log(
c.red(
c.bold(
'Try adding them in a `.env` file, or adding them directly to your environment variables.'
)
)
);
console.log(
c.red(
c.bold(
'For information on the required environment variables, refer to the env section of `now.json`.'
)
help += this._renderHelp(cmd._name);
if (args.length) {
help += `\n\n ${c.bold('ARGUMENTS')}\n\n`;
const argsTable = this._getSimpleTable();
args.forEach(a => {
const def = a.hasDefault() ? 'default: ' + JSON.stringify(a.default()) : '';
const req = a.isRequired() ? c.bold('required') : c.gray('optional');
argsTable.push([a.synopsis(), a.description(), req, c.gray(def)])
});
help += argsTable.toString();
}
if (options.length) {
help += `\n\n ${c.bold('OPTIONS')}\n\n`;
const optionsTable = this._getSimpleTable();
options.forEach(a => {
const def = a.hasDefault() ? 'default: ' + JSON.stringify(a.default()) : '';
const req = a.isRequired() ? c.bold('required') : c.gray('optional');
optionsTable.push([a.synopsis(), a.description(), req, c.gray(def)])
});
help += optionsTable.toString();
}
return help;
}
_getCommandHelp(cmd) {
const args = cmd.args();
const options = cmd.options();
let help = (cmd.name() ? cmd.name() + ' ' : '') + args.map(a => a.synopsis()).join(' ');
help += this._renderHelp(cmd._name);
if (args.length) {
help += `\n\n ${c.bold('ARGUMENTS')}\n\n`;
const argsTable = this._getSimpleTable();
args.forEach(a => {
const def = a.hasDefault() ? 'default: ' + JSON.stringify(a.default()) : '';
const req = a.isRequired() ? c.bold('required') : c.gray('optional');
argsTable.push([a.synopsis(), a.description(), req, c.gray(def)])
});
help += argsTable.toString();
}
if (options.length) {
help += `\n\n ${c.bold('OPTIONS')}\n\n`;
const optionsTable = this._getSimpleTable();
options.forEach(a => {
const def = a.hasDefault() ? 'default: ' + JSON.stringify(a.default()) : '';
const req = a.isRequired() ? c.bold('required') : c.gray('optional');
optionsTable.push([a.synopsis(), a.description(), req, c.gray(def)])