UNPKG

@magidoc/cli

Version:

Magidoc CLI application responsible for generating GraphQL documentation websites.

44 lines (41 loc) 2.15 kB
import { Option } from 'commander'; import path from 'path'; import { PACKAGE_MANAGER_TYPES } from '../../node/packageManager.js'; import { AVAILABLE_TEMPLATES } from '../../template/index.js'; import { getVersion } from '../../version.js'; import { withStacktrace } from '../utils/withStacktrace.js'; import eject from './index.js'; import { STACKTRACE_OPTION } from '../utils/commander.js'; import { printSeparator, printInfo, printLine } from '../utils/log.js'; import { cyan } from '../utils/outputColors.js'; function buildEjectCommand(program) { program .command('eject') .description('Ejects from Magidoc basic template configuration, to allow for full customization of the template. This will initialize a folder from a template of your choice, which can then be modified however you wish.\n') .addOption(new Option('-t|--template <template>', 'The name of the template to use.') .choices(AVAILABLE_TEMPLATES) .makeOptionMandatory()) .addOption(new Option('-e|--template-version <version>', 'The target version of the template to use. Defaults to the current CLI version.').default(getVersion())) .option('-d|--destination <directory>', 'Specifies the destination directory of the project', './template') .addOption(new Option('-p|--package-manager <type>', 'Selects a different Package Manager. Pnpm is the recommended default.') .default('pnpm') .choices(PACKAGE_MANAGER_TYPES)) .addOption(STACKTRACE_OPTION()) .action(async ({ packageManager, template, templateVersion, destination, stacktrace }) => { await withStacktrace(stacktrace, async () => { await eject({ packageManager, website: { template, templateVersion, }, destination: path.resolve(destination), }); printSeparator(); printInfo(`Template ${cyan(template)} created at ${cyan(destination)}`); printLine(); }); }); } export { buildEjectCommand as default }; //# sourceMappingURL=command.js.map