-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.mts
77 lines (66 loc) · 2.06 KB
/
index.mts
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env node
import { join, /* resolve */ } from "path";
import { Command } from "commander";
import { FileService, /* ConfigFileService */ } from "@/core/services/index.js";
import * as p from "./package.json" with { type: "json" };
const commander = new Command();
commander.version(p.default.version).description("template file creator.");
interface ICreateCommandOptions {
template: string;
output: string;
}
commander
.command("create <name>")
.requiredOption(
"-t, --template <path | base_template_name>",
"Template name."
)
.requiredOption("-o, --output <path>", "Output path.")
.alias("c")
.description("Create files.")
.action(async (name: string, { output, template }: ICreateCommandOptions) => {
console.log({
name,
output,
template: join(template),
});
// teminal: node dist/index.mjs create -t UITemplate -o ./ UITest
new FileService().create(join(template), output, name);
});
commander.parse(process.argv);
// import chalk from "chalk";
// import { createPromptModule } from "inquirer";
// const prompt = createPromptModule();
// const { red, green, grey, bgBlue } = chalk;
// commander
// .command("all")
// .alias("a")
// .description("Show all configuration files.")
// .action(() => {
// const files = readdirSync("templates");
// const fserv = new FileService();
// fserv.create("templates", "output", "TestFi");
// let data = "";
// for (let file of files) data += `${file} \n`;
// console.log(
// grey(`\nConfiguration files: \n\n${data}`),
// bgBlue("asdasdasdas")
// );
// });
// commander
// .command("init")
// .alias("c")
// .description("Create new configuration file and create folder with templates.")
// .action((name, cmd) => {
// prompt([
// {
// type: "input",
// name: "max_ram_usage",
// message: "Max RAM usage, Mb: ",
// },
// ]).then((options) => {
// console.log(
// green(`\nFile "${name}.${cmd.extension || "cfg"}" created.`)
// );
// });
// });