UNPKG

2.07 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const yargs = require("yargs");
4const fs = require("fs-extra");
5const os = require("os");
6const updateNotifier = require("update-notifier");
7initEnvVars();
8const pathHelper_1 = require("./helpers/pathHelper");
9const init_1 = require("./scripts/init");
10const install_1 = require("./scripts/install");
11const build_1 = require("./scripts/build");
12const serve_1 = require("./scripts/serve");
13const deploy_1 = require("./scripts/deploy");
14const extras_1 = require("./scripts/extras");
15const seed_1 = require("./scripts/seed");
16let commands = ['init', 'install', 'seed', 'build', 'serve', 'deploy'];
17let 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);
21let pkg = fs.readJSONSync(pathHelper_1.default.moduleRelative('./package.json'));
22updateNotifier({ pkg }).notify();
23yargs
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;
48function logAvailableCommands() {
49 console.log(`Available options are: ${commands.join(', ')}.`);
50 console.log('Run app-scripts with --help option to see available commands.');
51}
52function 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//# sourceMappingURL=index.js.map
\No newline at end of file