From 7b6be5a1c5c616b98fc3b13ec8c11a76b8d07f0e Mon Sep 17 00:00:00 2001 From: selemondev Date: Mon, 11 Mar 2024 22:30:07 +0300 Subject: [PATCH] feat: add program --- src/core/command/create-vue-next/index.ts | 71 ++++++++++++++++++++++- src/core/program.ts | 49 +--------------- 2 files changed, 69 insertions(+), 51 deletions(-) diff --git a/src/core/command/create-vue-next/index.ts b/src/core/command/create-vue-next/index.ts index b6ba4e7..0f837cb 100644 --- a/src/core/command/create-vue-next/index.ts +++ b/src/core/command/create-vue-next/index.ts @@ -3,17 +3,82 @@ import createVueQuestions from '../../questions/vue/createVueQuestions' import initialLog from '../create-vue-next/initialLog' import installDeps from '../create-vue-next/install' import copyTemplate from '../create-vue-next/copyTemplate' +import packageJson from "../../../../package.json" +import options from '../../utils/vue/options' async function createProject() { await initialLog() await createVueQuestions() await copyTemplate() await installDeps(); } - export default async function createVueNext() { program + .name(packageJson.name) + .arguments('') + .version(packageJson.version) .description(`Create Vue Next. The Next Generation Vue Scaffolding Tool ⚡`) - .action(async () => { - createProject() + .action((name: string) => { + options.name = name.trim() }) + .option( + '--ts, --typescript', + ` + + + Initialize as a TypeScript project. + ` + ) + .option( + '--js, --javascript', + ` + + + Initialize as a JavaScript project. + ` + ) + .option( + '--tailwind', + ` + + + Initialize with Tailwind CSS config. (default) + ` + ) + .option( + '--eslint', + ` + + Initialize with eslint config. + ` + ) + .option( + '--use-npm', + ` + + Explicitly tell the CLI to bootstrap the application using npm + ` + ) + .option( + '--use-pnpm', + ` + + Explicitly tell the CLI to bootstrap the application using pnpm + ` + ) + .option( + '--use-yarn', + ` + + Explicitly tell the CLI to bootstrap the application using Yarn + ` + ) + .option( + '--use-bun', + ` + + Explicitly tell the CLI to bootstrap the application using Bun + ` + ) + .allowUnknownOption() + .parse(process.argv); } diff --git a/src/core/program.ts b/src/core/program.ts index 034b16d..615530a 100644 --- a/src/core/program.ts +++ b/src/core/program.ts @@ -1,51 +1,4 @@ import { Command } from 'commander' const program = new Command() -export default program - - -// const program = new Commander.Command(packageJson.name) -// .description(packageJson.description) -// .arguments('') -// .option( -// '--ts', '--typescript', -// 'Initialize as a TypeScript project' -// ) -// .option( -// '--js', '--javascript', -// 'Initialize as a JavaScript project' -// ) -// .option( -// '--tw', '--tailwind', -// 'Initialize as a Tailwind project' -// ) -// .option( -// '--router', '--vue-router', -// 'Initialize with Vue Router' -// ) -// .option( -// '--use-npm', -// 'BootStrap project with npm' -// ) -// .option( -// '--use-pnpm', -// 'BootStrap project with yarn' -// ) -// .option( -// '--use-pnpm', -// 'BootStrap project with pnpm' -// ) -// .option( -// '--use-bun', -// 'BootStrap project with bun' -// ) -// .option( -// '--reset-preferences', -// ` -// Explicitly tell the CLI to reset any stored preferences -// ` -// ) -// .allowUnknownOption() -// .parse(process.argv); - -// export default program \ No newline at end of file +export default program \ No newline at end of file