UNPKG

2.68 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3// Copyright 2019 Zaiste & contributors. All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16const { valid, satisfies, validRange } = require('semver');
17const {
18 engines: { node: version }
19} = require('./package.json');
20
21const expected = validRange(version);
22const actual = valid(process.version);
23
24if (!satisfies(actual, expected)) {
25 console.error(`Expected node ${expected}, but found ${actual}`);
26 process.exit(1);
27}
28
29const _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;