/
cli.ts
51 lines (43 loc) · 967 Bytes
/
cli.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
import type { AnyFlags } from "meow";
import meow from "meow";
import * as commands from "./cli/commands";
const helpText = `
Usage
$ remix build [remixRoot]
$ remix run [remixRoot]
Options
--help Print this help message and exit
--version, -v Print the CLI version and exit
Examples
$ remix build my-website
$ remix run my-website
`;
const flags: AnyFlags = {
version: {
type: "boolean",
alias: "v"
}
};
const cli = meow(helpText, {
autoHelp: true,
autoVersion: false,
description: false,
flags
});
if (cli.flags.version) {
cli.showVersion();
}
switch (cli.input[0]) {
case "build":
commands.build(cli.input[1], process.env.NODE_ENV);
break;
case "build2":
commands.build2(cli.input[1], process.env.NODE_ENV);
break;
case "run":
commands.run(cli.input[1]);
break;
default:
// `remix my-project` is shorthand for `remix run my-project`
commands.run(cli.input[0]);
}