-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.ts
More file actions
64 lines (55 loc) · 1.74 KB
/
entrypoint.ts
File metadata and controls
64 lines (55 loc) · 1.74 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
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
import {Command} from 'commander';
import {Application} from "./src/application";
import {availableOptions, CliInput} from "./src/options/cli-options";
import {DevServer} from "./src/commands/dev-server";
import {BuildStatic} from "./src/commands/build-static";
import {Server} from "./src/commands/server";
import {Build} from "./src/commands/build";
const packageJson = require('./package.json');
const program = new Command();
program
.description('Welcome to ragu-cli. Check the list of commands bellow:')
.version(packageJson.version);
const defaultOptions = (program: Command | any): Command => {
for (const option of Object.keys(availableOptions) as (keyof CliInput)[]) {
const optionDescription = availableOptions[option];
if (optionDescription.boolean) {
program = program.option(`--${option}`, optionDescription.description)
} else {
program = program.option(`--${option} <${option}>`, optionDescription.description)
}
}
return program
}
const commands = [
{
name: 'dev',
description: 'Starts ragu server in development mode for the given component.',
command: DevServer
},
{
name: 'static',
description: "Build the project as a static ragu project",
command: BuildStatic
},
{
name: 'build',
description: "Build the project to production",
command: Build
},
{
name: 'serve',
description: "Production server. You must the same options given for build command.",
command: Server
}
]
commands.forEach((command) => {
defaultOptions(program
.command(command.name)
.description(command.description))
.action((input: CliInput) => {
Application.init(input).execute(command.command)
});
});
program.parse();