-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathindex.ts
56 lines (48 loc) · 1.27 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import * as prompts from "@clack/prompts";
import chalk from "chalk";
import { parseArgs } from "node:util";
import { create } from "../create/index.js";
import { initialize } from "../initialize/index.js";
import { migrate } from "../migrate/index.js";
import { logLine } from "../shared/cli/lines.js";
import { promptForMode } from "./mode.js";
export async function bin(args: string[]) {
console.clear();
prompts.intro(
[
chalk.greenBright(`Welcome to`),
chalk.bgGreenBright.black(`template-typescript-node-package`),
chalk.greenBright(`! 🎉`),
].join(" "),
);
logLine();
logLine(
chalk.yellow(
"⚠️ This template is early stage, opinionated, and not endorsed by the TypeScript team. ⚠️",
),
);
logLine(
chalk.yellow(
"⚠️ If any tooling it sets displeases you, you can always remove that portion manually. ⚠️",
),
);
const { values } = parseArgs({
args,
options: {
mode: { type: "string" },
},
strict: false,
});
const mode = await promptForMode(values.mode);
if (mode instanceof Error) {
prompts.outro(chalk.red(mode.message));
return 1;
}
logLine();
logLine(
chalk.blue(
"Let's collect some information to fill out repository details...",
),
);
return await { create, initialize, migrate }[mode](args);
}