-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.ts
More file actions
54 lines (44 loc) · 1.48 KB
/
cli.ts
File metadata and controls
54 lines (44 loc) · 1.48 KB
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
#!/usr/bin/env node
import { Command } from "commander";
import { VERSION } from "./src/utils/constant";
import main from "./src/index";
import { createTemplate, scaffoldTemplate, fetchTemplate } from "./src/actions";
// News and Updates...
import logUpdates from "./src/hooks/logUpdates";
const program = new Command();
program
.name("Skelpro")
.usage("[options] [command]")
.description(
"A fast and simple tool to set up your project structure in seconds."
)
.version(`Version ${VERSION}`, "-v, --version", "Output the version number");
program
.command("launch")
.description("Launches the main CLI interface")
.action(() => {
main().catch((error) => console.error(error));
});
program
.command("save <templateName> <projectPath>")
.description("Saves a new reusable project template")
.action((templateName, projectPath) => {
createTemplate(projectPath, templateName);
});
program
.command("create <projectName> <templatePath>")
.description("Creates a project using a local or remote JSON template")
.option("-i, --install", "Install dependencies flag")
.action(async (projectName, templatePath, opt) => {
const install = opt.install ? true : false;
if (templatePath.startsWith("http")) {
fetchTemplate(templatePath, projectName, install);
logUpdates();
} else {
scaffoldTemplate(templatePath, projectName, install);
}
});
program.parse(process.argv);
if (!process.argv.slice(2).length) {
program.outputHelp();
}