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 generate() {
// Get the details about the component to create.
const answers = await prompts(questions)
// Verify the answers.
if (!(await verifyAnswers(answers))) {
process.exit(1)
}
const { confirmation, folders, name } = answers
if (confirmation) {
// Create the folders and modify the theme to add the new component.
const created = await createFolders({ componentName: name, folders })
if (created) {
console.log(
"Component created. Don't forget to add your component theme into src/theme/componentsFactory.js.",
)
} else {
const warnings = migrationsWithDbSteps.flatMap(m => m.warnings)
if (warnings.length > 0 && !autoApprove) {
if (onWarnings && typeof onWarnings === 'function' && !autoApprove) {
const ok = await onWarnings(warnings)
if (!ok) {
await exit()
}
}
console.log(chalk.bold(`\n\n⚠️ There will be data loss:\n`))
for (const warning of warnings) {
console.log(` • ${warning.description}`)
}
console.log() // empty line before prompt
if (!autoApprove && !onWarnings) {
const response = await prompt({
type: 'confirm',
name: 'value',
message: `Are you sure you want to apply this change?`,
})
if (!response.value) {
await exit()
}
} else {
console.log(`As ${chalk.bold('--auto-approve')} is provided, the destructive changes are accepted.\n`)
}
}
const progressRenderer = new ProgressRenderer(migrationsWithDbSteps, short || false)
progressRenderer.render()
const run = async opts => {
prompts.inject(opts)
const response = await prompts(form)
if (!response.confirm) {
log('aborted')
process.exit(0)
}
const { name } = response
const template = templates[response.template] || templates[0]
log('creating docs...')
if (!name) {
log.error('name is required')
// todo: prompt again
process.exit(1)
}
module.exports = async function(repo, dest, argv) {
// Prompt if incomplete data
if (!repo || !dest) {
const questions = requestParams(argv);
const onCancel = () => {
info('Aborting execution');
process.exit();
};
const response = await prompt(questions, { onCancel });
Object.assign(argv, response);
repo = repo || response.template;
dest = dest || response.dest;
}
if (!repo || !dest) {
warn('Insufficient arguments!');
info('Alternatively, run `preact create --help` for usage info.');
return;
}
let cwd = resolve(argv.cwd);
let target = resolve(cwd, dest);
let isYarn = argv.yarn && hasCommand('yarn');
let exists = isDir(target);
* npm init @open-wc --type scaffold --scaffoldType app --tagName foo-bar --installDependencies false
* npm init @open-wc --type upgrade --features linting demoing --tagName foo-bar --scaffoldFilesFor demoing --installDependencies false
*/
const optionDefinitions = [
{ name: 'destinationPath', type: String }, // path
{ name: 'type', type: String }, // scaffold, upgrade
{ name: 'scaffoldType', type: String }, // wc, app
{ name: 'features', type: String, multiple: true }, // linting, testing, demoing, building
{ name: 'buildingType', type: String }, // rollup, webpack
{ name: 'scaffoldFilesFor', type: String, multiple: true }, // testing, demoing, building
{ name: 'tagName', type: String },
{ name: 'installDependencies', type: String }, // yarn, npm, false
{ name: 'writeToDisk', type: String }, // true, false
];
const overrides = commandLineArgs(optionDefinitions);
prompts.override(overrides);
export const AppMixin = subclass =>
// eslint-disable-next-line no-shadow
class AppMixin extends subclass {
constructor() {
super();
this.wantsNpmInstall = false;
this.wantsWriteToDisk = false;
this.wantsRecreateInfo = false;
}
async execute() {
console.log(header);
const scaffoldOptions = [];
const questions = [
{
public async run(): Promise {
const { flags } = this.parse(PublishCommand);
if (!flags.token) {
flags.token = configManager.get("token");
}
if (flags.network) {
return this.performPublishment(flags);
}
// Interactive CLI
const response = await prompts([
{
type: "select",
name: "network",
message: "What network do you want to operate on?",
choices: this.getNetworksForPrompt(),
},
{
type: "confirm",
name: "confirm",
message: "Can you confirm?",
},
]);
if (!response.network) {
this.abortWithInvalidInput();
}
public async run(): Promise {
const { flags, paths } = await this.parseWithNetwork(DatabaseCommand);
const envFile: string = `${paths.config}/.env`;
if (this.hasValidFlag(flags)) {
updateEnvironmentVariables(envFile, this.conform(flags));
return;
}
// Interactive CLI
const response = await prompts([
{
type: "text",
name: "host",
message: "What host do you want to use?",
initial: "localhost",
},
{
type: "text",
name: "port",
message: "What port do you want to use?",
initial: 5432,
validate: value => (value < 1 || value > 65535 ? `The port must be in the range of 1-65535.` : true),
},
{
type: "text",
name: "database",
public async run(): Promise {
const { flags } = await this.parseWithNetwork(BIP39Command);
if (flags.bip39) {
return this.performConfiguration(flags);
}
// Interactive CLI
const response = await prompts([
{
type: "password",
name: "bip39",
message: "Please enter your delegate passphrase",
validate: value =>
!bip39.validateMnemonic(value) ? `Failed to verify the given passphrase as BIP39 compliant.` : true,
},
{
type: "confirm",
name: "confirm",
message: "Can you confirm?",
},
]);
if (!response.bip39) {
this.abortWithInvalidInput();
public async run(): Promise {
const { flags } = this.parse(GenerateCommand);
if (!Object.keys(GenerateCommand.flags).find(flagName => !flags[flagName])) {
// all the flags are filled, we can generate network
return this.generateNetwork(flags);
}
const stringFlags = ["network", "premine", "token", "symbol", "explorer"];
const response = await prompts(Object.keys(GenerateCommand.flags)
.map(
flagName =>
({
type: stringFlags.includes(flagName) ? "text" : "number",
name: flagName,
message: GenerateCommand.flags[flagName].description,
initial: `${flags[flagName]}`,
} as prompts.PromptObject),
)
.concat({
type: "confirm",
name: "confirm",
message: "Can you confirm?",
} as prompts.PromptObject) as Array>);
if (Object.keys(GenerateCommand.flags).find(flagName => !response[flagName])) {
const run = async opts => {
prompts.inject(opts)
const response = await prompts(form)
if (!response.confirm) {
log('aborted')
process.exit(0)
}
const { name } = response
const theme = themes[response.theme] || themes[0]
log('Creating docs ...')
if (!name) {
log.error('name is required')
process.exit(1)
}