/
help.js
67 lines (59 loc) · 2.03 KB
/
help.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const chalk = require('chalk');
class HelpGroup {
b() {
const b = chalk.blue;
}
l() {
const c = chalk.cyan;
}
outputHelp() {
process.stdout.write(this.run().outputOptions.help);
process.stdout.write('\n Made with ♥️ by the webpack team \n');
}
outputVersion() {
const pkgJSON = require('../../package.json');
const webpack = require('webpack');
process.stdout.write(`\nwebpack-cli ${pkgJSON.version}`);
process.stdout.write(`\nwebpack ${webpack.version}\n`);
}
run() {
const b = s => chalk.blue(s);
const l = s => chalk.white(s);
const o = s => chalk.keyword('orange')(s);
const commandLineUsage = require('command-line-usage');
const options = require('../utils/cli-flags');
const title = chalk.white.bold('⬡ ') + chalk.white.underline('webpack') + chalk.white.bold(' ⬡');
const desc = 'The build tool for modern web applications';
const websitelink = ' ' + chalk.white.underline('https://webpack.js.org');
const usage = chalk.white.bold('Usage') + ': ' + '`' + o('webpack [...options] | <command>') + '`';
const examples = chalk.white.bold('Example') + ': ' + '`' + o('webpack help --flag | <command>') + '`';
const hh = ` ${title}\n
${websitelink}\n
${desc}\n
${usage}\n
${examples}\n
`;
const sections = commandLineUsage([
{
content: hh,
raw: true,
},
{
header: 'Available Commands',
content: options.commands.map(e => {
return { name: e.name, summary: e.description };
}),
},
{
header: 'Options',
optionList: options.core,
},
]);
return {
outputOptions: {
help: sections,
},
};
}
}
module.exports = HelpGroup;