1 | #!/usr/bin/env node
|
2 |
|
3 | const Promise = require('bluebird');
|
4 | const settings = require('availity-workflow-settings');
|
5 |
|
6 | const yargs = require('yargs');
|
7 | const chalk = require('chalk');
|
8 | const start = require('./scripts/start');
|
9 | const test = require('./scripts/test');
|
10 | const lint = require('./scripts/lint');
|
11 | const about = require('./scripts/about');
|
12 | const build = require('./scripts/build');
|
13 | const release = require('./scripts/release');
|
14 | const profile = require('./scripts/profile');
|
15 |
|
16 | Promise.config({
|
17 | longStackTraces: true
|
18 | });
|
19 |
|
20 | settings.init();
|
21 |
|
22 |
|
23 | yargs
|
24 |
|
25 | .usage(`\nUsage: ${chalk.yellow('av')} ${chalk.green('<command>')} ${chalk.magenta('[options]')}`)
|
26 |
|
27 | .command('start', `${chalk.dim('Start the development server')}`, () => {
|
28 | start();
|
29 | })
|
30 |
|
31 | .command(
|
32 | 'lint',
|
33 | `${chalk.dim('Lint source files using ESLint')}`,
|
34 | yyargs => {
|
35 | yyargs
|
36 | .option('include', {
|
37 | alias: 'i',
|
38 | describe: 'Glob patterns to INCLUDE for ESLint scanning'
|
39 | })
|
40 | .option('fail', {
|
41 | alias: 'f',
|
42 | describe: 'Force linter to fail and exit'
|
43 | })
|
44 | .option('ignore-git-untracked', {
|
45 | alias: 'u',
|
46 | describe: 'Ignore files that are not indexed by git'
|
47 | });
|
48 | },
|
49 | () => {
|
50 | lint().catch(() => {
|
51 |
|
52 | });
|
53 | }
|
54 | )
|
55 |
|
56 | .command(
|
57 | 'test',
|
58 | `${chalk.dim(test.description)}`,
|
59 | yyargs =>
|
60 | yyargs.option('watch', {
|
61 | alias: 'w',
|
62 | describe: 'Watch files for changes and rerun tests related to changed files.'
|
63 | }),
|
64 | () => {
|
65 | test.run().catch(() => {
|
66 |
|
67 | });
|
68 | }
|
69 | )
|
70 |
|
71 | .command('profile', `${chalk.dim('Analyze Webpack bundles and find what is contributing their sizes')}`, () => {
|
72 | profile();
|
73 | })
|
74 |
|
75 | .command('build', `${chalk.dim('Bundle project for distribution (production or staging)')}`, () => {
|
76 | build();
|
77 | })
|
78 |
|
79 | .command(
|
80 | 'release',
|
81 | `${chalk.dim('Bundle project for distribution (production or staging) and create a git tag')}`,
|
82 | () => {
|
83 | release();
|
84 | }
|
85 | )
|
86 |
|
87 | .command('about', `${chalk.dim('About availity-workflow')}`, () => {
|
88 | about();
|
89 | })
|
90 |
|
91 | .demand(1, chalk.red('Must provide a valid cli command'))
|
92 |
|
93 | .showHelpOnFail(false, 'Specify --help for available options')
|
94 |
|
95 | .help('help')
|
96 | .alias('help', 'h')
|
97 |
|
98 | .version(require('./package.json').version, 'version')
|
99 | .alias('version', 'V')
|
100 |
|
101 | .example(chalk.yellow('av start'))
|
102 |
|
103 | .example(chalk.yellow('av lint')).argv;
|