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