diff --git a/src/new/cli.ts b/src/new/cli.ts index 1f6a87c..5599fed 100644 --- a/src/new/cli.ts +++ b/src/new/cli.ts @@ -1,47 +1,47 @@ import { Argv, CommandModule } from "yargs"; import { projectForm } from "./form"; -// eslint-disable-next-line @typescript-eslint/ban-types -type CommandModuleArgs = {}; +type CommandModuleArgs = object; -const createProject = (): CommandModule => { - const packageManagers: Array = ["npm", "yarn", "pnpm"]; +const packageManagers: Array = [ + "npm", + "yarn", + "pnpm", + ...(process.platform !== "win32" ? ["bun"] : []), +]; - if (process.platform !== "win32") { - packageManagers.push("bun"); - } +const commandOptions = (yargs: Argv): Argv => { + return yargs + .positional("project-name", { + describe: "The name of the project", + type: "string", + }) + .option("template", { + describe: "The project template to use", + type: "string", + choices: ["opinionated", "non-opinionated"], + alias: "t", + }) + .option("package-manager", { + describe: "The package manager to use", + type: "string", + choices: packageManagers, + alias: "p", + }) + .option("directory", { + describe: "The directory for new project", + type: "string", + alias: "d", + }) + .implies("package-manager", "template") + .implies("template", "package-manager"); +}; +const createProject = (): CommandModule => { return { command: "new [package-manager] [template] [directory]", describe: "Create a new project", - builder: (yargs: Argv): Argv => { - yargs - .positional("project-name", { - describe: "The name of the project", - type: "string", - }) - .option("template", { - describe: "The project template to use", - type: "string", - choices: ["opinionated", "non-opinionated"], - alias: "t", - }) - .option("package-manager", { - describe: "The package manager to use", - type: "string", - choices: packageManagers, - alias: "p", - }) - .option("directory", { - describe: "The directory for new project", - type: "string", - alias: "d", - }) - .implies("package-manager", "template") - .implies("template", "package-manager"); - - return yargs; - }, + builder: commandOptions, handler: async ({ projectName, packageManager, diff --git a/src/new/form.ts b/src/new/form.ts index e6e3344..00d00d6 100644 --- a/src/new/form.ts +++ b/src/new/form.ts @@ -80,8 +80,8 @@ function changePackageName({ } enum Template { - "non-opinionated" = "Non-Opinionated :: A simple ExpressoTS project.", - opinionated = "Opinionated :: A complete ExpressoTS project with an opinionated structure and features.", + "non-opinionated" = "Non-Opinionated :: Allows users to choose where to scaffold resources, offering flexible project organization.", + opinionated = "Opinionated :: Automatically scaffolds resources into a preset project structure. (Recommended)", } const enum PackageManager { @@ -145,8 +145,10 @@ const projectForm = async (projectName: string, args: any[]): Promise => { name: "template", message: "Select a template", choices: [ - "Opinionated :: A complete ExpressoTS project with an opinionated structure and features.", - "Non-Opinionated :: A simple ExpressoTS project.", + `Opinionated :: Automatically scaffolds resources into a preset project structure. (${chalk.yellow( + "Recommended", + )})`, + "Non-Opinionated :: Allows users to choose where to scaffold resources, offering flexible project organization.", ], }, { @@ -239,7 +241,7 @@ const projectForm = async (projectName: string, args: any[]): Promise => { console.log("\n"); console.log( - "🐎 Project ", + "🐎 Project", chalk.green(answer.name), "created successfully!", ); @@ -277,6 +279,7 @@ const projectForm = async (projectName: string, args: any[]): Promise => { ), ), ); + console.log("\n"); } };