diff --git a/src/new/form.ts b/src/new/form.ts index 83a84cb..51ddd62 100644 --- a/src/new/form.ts +++ b/src/new/form.ts @@ -123,30 +123,21 @@ const enum PackageManager { bun = "bun", } -const projectForm = async (projectName: string, args: any[]): Promise => { - let answer: any; - const projName: string = projectName; - let packageManager: PackageManager | undefined; - let template: keyof typeof Template | undefined; - let directory: string | undefined; - - // Resolving the argument order problem - for (const arg of args) { - if (args.length >= 3) { - if ( - arg === "npm" || - arg === "yarn" || - arg === "pnpm" || - arg === "bun" - ) { - packageManager = arg as PackageManager; - } else if (arg === "non-opinionated" || arg === "opinionated") { - template = arg as keyof typeof Template; - } else { - directory = arg; - } - } - } +type TemplateKeys = keyof typeof Template; + +type ProjectFormArgs = [PackageManager, TemplateKeys, string]; + +const projectForm = async ( + projectName: string, + args: ProjectFormArgs, +): Promise => { + let answer: { + name: string; + packageManager: string; + template: Template; + confirm: boolean; + }; + const [packageManager, template, directory] = args; if (packageManager && template) { answer = { @@ -265,7 +256,7 @@ const projectForm = async (projectName: string, args: any[]): Promise => { changePackageName({ directory: answer.name, - name: projName, + name: projectName, }); renameEnvFile(answer.name);