1 | import * as program from 'commander';
|
2 | import * as fs from 'fs-extra';
|
3 | import { CommandLineOptions } from '../index.d.ts';
|
4 |
|
5 | const packageJSON: {
|
6 | version: string;
|
7 | } = JSON.parse(fs.readFileSync('./package.json').toString());
|
8 |
|
9 | program
|
10 | .version(packageJSON.version)
|
11 | .option('-p, --port [port]', 'Specify the server\'s port')
|
12 |
|
13 |
|
14 |
|
15 | .option('--build-static', 'Create a static build of the current working directory. The output will be in a directory called dist in the current working directory')
|
16 | .option('--target [target]', 'The ECMAScript version to compile to; if omitted, defaults to ES2015. Any targets supported by the TypeScript compiler are supported here (ES3, ES5, ES6/ES2015, ES2016, ES2017, ESNext)')
|
17 | .option('--disable-spa', 'Disable the SPA redirect to index.html')
|
18 | .option('--exclude [exclude]', 'A comma-separated list of paths, relative to the current directory, to exclude from the static build')
|
19 | .option('--include [include]', 'A comma-separated list of paths, relative to the current directory, to include in the static build')
|
20 | .option('--headers [headers]', 'A path to a file, relative to the current directory, for custom HTTP headers')
|
21 | .parse(process.argv);
|
22 |
|
23 |
|
24 | const buildStatic: boolean = program.buildStatic || false;
|
25 |
|
26 | const watchFiles: boolean = true;
|
27 | const httpPort: number = parseInt(program.port || 5000);
|
28 | const wsPort: number = httpPort + 1;
|
29 | const jsTarget: string = program.target || 'ES2015';
|
30 | const exclude: string | undefined = program.exclude;
|
31 | const include: string | undefined = program.include;
|
32 | const disableSpa: boolean = program.disableSpa || false;
|
33 | const customHTTPHeadersFilePath: string | undefined = program.headers;
|
34 |
|
35 | export const commandLineOptions: Readonly<CommandLineOptions> = {
|
36 | buildStatic,
|
37 | watchFiles,
|
38 | httpPort,
|
39 | wsPort,
|
40 | jsTarget,
|
41 | exclude,
|
42 | include,
|
43 | disableSpa,
|
44 | customHTTPHeadersFilePath
|
45 | }; |
\ | No newline at end of file |