UNPKG

@quadnix/octo-build

Version:

Octo-Build is a CLI tool to build Octo projects.

51 lines 1.85 kB
import { dirname, resolve } from 'path'; import { fileURLToPath } from 'url'; import chalk from 'chalk'; import { createEnv } from 'yeoman-environment'; const __dirname = dirname(fileURLToPath(import.meta.url)); export const createAppCommand = { builder: (yargs) => { return yargs .option('template', { alias: 't', choices: ['aws-ecs-server', 'aws-s3-website'], demandOption: true, description: 'Template to use for creation.', type: 'string', }) .option('name', { alias: 'n', demandOption: true, description: 'Name of the app to create. A new directory will be created with the same name.', type: 'string', }) .option('path', { alias: 'p', default: '.', description: 'Path to create the app.', type: 'string', }); }, command: 'create-app', describe: 'Create a new Octo app from a template.', handler: async (argv) => { const { name, path, template } = argv; console.log(chalk.blue(`Creating app with template "${template}"...`)); const env = createEnv(); env.register(resolve(__dirname, 'generator-octo-app-template/generators/app/index.js'), { namespace: 'generator-octo-app-template:app', }); try { await env.run(['generator-octo-app-template:app', name, path, template], { skipCache: true, skipInstall: false, }); console.log(chalk.green(`Successfully created app!`)); } catch (error) { console.error(chalk.red(`Failed to create app! ${error.message}`)); process.exit(1); } }, }; //# sourceMappingURL=create-app.command.js.map