From d2bbc2e8fcfeebcb064d8c2278bfa1ad02464cc4 Mon Sep 17 00:00:00 2001 From: Richard Zampieri Date: Tue, 19 Mar 2024 00:57:08 -0700 Subject: [PATCH 1/3] refactor: adjust op and nop templates, proj confirm msg --- src/new/form.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/new/form.ts b/src/new/form.ts index e6e3344..ad51bdd 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" = 0, + "opinionated" = 1, } 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!", ); From a1ff88df86940f3a63baca9c11a5fb83a89a46a8 Mon Sep 17 00:00:00 2001 From: Richard Zampieri Date: Tue, 19 Mar 2024 01:12:18 -0700 Subject: [PATCH 2/3] refactor: adjust sponsor message spacing --- src/new/form.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/new/form.ts b/src/new/form.ts index ad51bdd..00d00d6 100644 --- a/src/new/form.ts +++ b/src/new/form.ts @@ -80,8 +80,8 @@ function changePackageName({ } enum Template { - "non-opinionated" = 0, - "opinionated" = 1, + "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 { @@ -279,6 +279,7 @@ const projectForm = async (projectName: string, args: any[]): Promise => { ), ), ); + console.log("\n"); } }; From 1782206b3991269598a071c18dd8b406946d0755 Mon Sep 17 00:00:00 2001 From: Richard Zampieri Date: Tue, 19 Mar 2024 11:13:59 -0700 Subject: [PATCH 3/3] refactor: improve new cmd cli performance --- src/new/cli.ts | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) 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,