1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const yargs = require("yargs");
|
4 | const fs = require("fs-extra");
|
5 | const os = require("os");
|
6 | const updateNotifier = require("update-notifier");
|
7 | initEnvVars();
|
8 | const pathHelper_1 = require("./helpers/pathHelper");
|
9 | const init_1 = require("./scripts/init");
|
10 | const install_1 = require("./scripts/install");
|
11 | const build_1 = require("./scripts/build");
|
12 | const serve_1 = require("./scripts/serve");
|
13 | const deploy_1 = require("./scripts/deploy");
|
14 | const extras_1 = require("./scripts/extras");
|
15 | const seed_1 = require("./scripts/seed");
|
16 | let commands = ['init', 'install', 'seed', 'build', 'serve', 'deploy'];
|
17 | let epilog = [
|
18 | 'You can see specific help for each command. Run app-scripts <command> --help.',
|
19 | 'You can use napp as shorter alias for app-scripts.'
|
20 | ].join(os.EOL);
|
21 | let pkg = fs.readJSONSync(pathHelper_1.default.moduleRelative('./package.json'));
|
22 | updateNotifier({ pkg }).notify();
|
23 | yargs
|
24 | .usage('Usage: app-scripts <command> [options]')
|
25 | .command(init_1.default)
|
26 | .command(install_1.default)
|
27 | .command(build_1.default)
|
28 | .command(serve_1.default)
|
29 | .command(deploy_1.default)
|
30 | .command(extras_1.default)
|
31 | .command(seed_1.default)
|
32 | .command('*', '', () => { }, argv => {
|
33 | let command = argv.command;
|
34 | if (!command) {
|
35 | console.log('Please, specify valid command name.');
|
36 | logAvailableCommands();
|
37 | }
|
38 | else {
|
39 | console.log(`Unknown command "${command}".`);
|
40 | console.log('Perhaps you need to update app-scripts?');
|
41 | logAvailableCommands();
|
42 | }
|
43 | })
|
44 | .help()
|
45 | .alias('h', 'help')
|
46 | .epilog(epilog)
|
47 | .version(pkg.version).argv;
|
48 | function logAvailableCommands() {
|
49 | console.log(`Available options are: ${commands.join(', ')}.`);
|
50 | console.log('Run app-scripts with --help option to see available commands.');
|
51 | }
|
52 | function initEnvVars() {
|
53 | if (!process.env.APP_DIR) {
|
54 | process.env.APP_DIR = fs.realpathSync(process.cwd());
|
55 | }
|
56 | process.env.NODE_ENV = 'production';
|
57 | }
|
58 |
|
\ | No newline at end of file |