|
| 1 | +#!/usr/bin/env node |
1 | 2 | import fs from "fs";
|
2 | 3 | import fse from "fs-extra";
|
3 | 4 | import path from "path";
|
4 | 5 | import * as url from "url";
|
5 |
| -import _yargs from "yargs"; |
6 |
| -import { hideBin } from "yargs/helpers"; |
7 |
| -const yargs = _yargs(hideBin(process.argv)); |
| 6 | + |
| 7 | +import { input, select } from "@inquirer/prompts"; |
| 8 | + |
| 9 | +// Ask user for params |
| 10 | +const params = { |
| 11 | + projectName: await input({ message: "Enter project name" }), |
| 12 | + template: await select({ |
| 13 | + message: "Select an app template", |
| 14 | + choices: [ |
| 15 | + { |
| 16 | + name: "basic", |
| 17 | + value: "basic", |
| 18 | + description: "Javascript template - Vite + Zustand", |
| 19 | + }, |
| 20 | + { |
| 21 | + name: "typescript", |
| 22 | + value: "typescript", |
| 23 | + description: "Typescript template - Vite + Zustand", |
| 24 | + disabled: true, |
| 25 | + }, |
| 26 | + ], |
| 27 | + }), |
| 28 | +}; |
8 | 29 |
|
9 | 30 | // Alternative for ES module
|
10 | 31 | const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
11 | 32 |
|
12 |
| -const argv = await yargs |
13 |
| - .option("projectName", { type: "string", require: true }) |
14 |
| - .option("template", { type: "string", require: true }).argv; |
15 |
| - |
16 | 33 | const DESTINATION_FOLDER = process.cwd(); // Folder from which the script is called - first create destination folder
|
17 | 34 |
|
18 | 35 | // Helpers
|
@@ -86,7 +103,7 @@ const main = async ({ projectName, template }) => {
|
86 | 103 |
|
87 | 104 | console.log("Provided params");
|
88 | 105 | console.log("---------------");
|
89 |
| -console.log("Project name - ", argv.projectName); |
90 |
| -console.log("Template - ", argv.template); |
| 106 | +console.log("Project name - ", params.projectName); |
| 107 | +console.log("Template - ", params.template); |
91 | 108 |
|
92 |
| -main(argv).catch((e) => console.log(e)); |
| 109 | +main(params).catch((e) => console.log(e)); |
0 commit comments