/
index.ts
46 lines (41 loc) · 1.44 KB
/
index.ts
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
import { initGenerator } from '@webpack-cli/generators';
import { modifyHelperUtil, npmPackagesExists } from '@webpack-cli/utils';
class InitCommand {
async apply(cli): Promise<void> {
await cli.makeCommand(
{
name: 'init [scaffold...]',
alias: 'c',
description: 'Initialize a new webpack configuration.',
usage: '[scaffold...] [options]',
pkg: '@webpack-cli/init',
},
[
{
name: 'auto',
type: Boolean,
description: 'To generate default config',
},
{
name: 'force',
type: Boolean,
description: 'To force config generation',
},
{
name: 'generation-path',
type: String,
description: 'To scaffold in a specified path',
},
],
async (scaffold, program) => {
const options = program.opts();
if (scaffold && scaffold.length > 0) {
await npmPackagesExists(scaffold);
return;
}
modifyHelperUtil('init', initGenerator, null, null, options.auto, options.force, options.generationPath);
},
);
}
}
export default InitCommand;