1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | const { valid, satisfies, validRange } = require('semver');
|
17 | const {
|
18 | engines: { node: version }
|
19 | } = require('./package.json');
|
20 |
|
21 | const expected = validRange(version);
|
22 | const actual = valid(process.version);
|
23 |
|
24 | if (!satisfies(actual, expected)) {
|
25 | console.error(`Expected node ${expected}, but found ${actual}`);
|
26 | process.exit(1);
|
27 | }
|
28 |
|
29 | const _argv = require('yargs')
|
30 | .version()
|
31 | .usage('Usage: $0 <command> [options]')
|
32 | .command(['new [dir]', 'init', 'n'], 'Create new project', require('./cli/init'))
|
33 | .example('$0 new my-project', 'Create and initialize `my-project` directory')
|
34 | .command(['setup [name]'], 'Setup an integration', require('./cli/setup'))
|
35 | .command(['start', 'start', 's'], 'Start the application', require('./cli/start'))
|
36 | .example('$0 start', 'Start the application')
|
37 | .command(['client', 'client', 'c'], 'Start only the client', require('./cli/client'))
|
38 | .example('$0 client', 'Start only the client')
|
39 | .command(['server [dir]', 'serve', 'se'], 'Serve the directory', require('./cli/server'))
|
40 | .example('$0 server --port 4000', 'Serve the directory at the port 4000')
|
41 | .command(
|
42 | ['build', 'build', 'b'],
|
43 | 'Build the application for production',
|
44 | require('./cli/build')
|
45 | )
|
46 | .example('$0 build', 'Build the application for production')
|
47 | .command(['database [command]', 'db'], 'Database operations', require('./cli/database'))
|
48 | .command(['deploy', 'deploy', 'de'], 'Deploy the application', require('./cli/deploy'))
|
49 | .example('$0 deploy', 'Deploy the application')
|
50 | .command(['generate [command]', 'g'], 'Generate various artifacts', require('./cli/generate'))
|
51 | .command(['routes', 'r'], 'Display routes', require('./cli/routes'))
|
52 | .command(['migrate', 'm'], 'Run database migrations', require('./cli/migrate'))
|
53 | .command(['background', 'bg'], 'Run background processing', require('./cli/background'))
|
54 | .demandCommand(1, 'You need at least one command before moving on')
|
55 | .help('h')
|
56 | .alias('h', 'help')
|
57 | .epilogue('for more information, find the documentation at https://huncwot.org').argv;
|