UNPKG

@swell/cli

Version:

Swell's command line interface/utility

39 lines (38 loc) 1.44 kB
import { Flags } from '@oclif/core'; import ora from 'ora'; import { CreateAppCommand } from '../../create-app-command.js'; import swellConfig from '../../lib/app-config.js'; export default class CreateFrontend extends CreateAppCommand { static description = 'Initialize a frontend app framework and folder structure.'; static examples = [ { command: 'swell create frontend', description: 'Create frontend app following command prompts.', }, { command: 'swell create frontend -y', description: 'Create frontend app and accept all default values.', }, ]; static flags = { pkg: Flags.string({ char: 'p', default: 'npm', description: `use npm or yarn to install default dependencies, or none to disable`, options: ['npm', 'yarn', 'none'], }), }; async run() { const { flags } = await this.parse(CreateFrontend); const newSwellConfig = swellConfig(); const appType = newSwellConfig?.get('type'); const spinner = ora(); if (appType === 'theme') { spinner.fail(`You can't create app frontend in a theme.`); return; } await (appType === 'storefront' ? this.createStorefrontApp(newSwellConfig, flags, true) : this.createFrontendApp(newSwellConfig, flags, true)); } }