-
-
Notifications
You must be signed in to change notification settings - Fork 591
/
plugin-generator.ts
36 lines (35 loc) · 1.11 KB
/
plugin-generator.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
import path from 'path';
import addonGenerator from './addon-generator';
import { toKebabCase, toUpperCamelCase } from './utils/helpers';
/**
* A yeoman generator class for creating a webpack
* plugin project. It adds some starter plugin code
* and runs `webpack-defaults`.
*
* @class PluginGenerator
* @extends {Generator}
*/
const PluginGenerator = addonGenerator(
[
{
default: 'my-webpack-plugin',
filter: toKebabCase,
message: 'Plugin name',
name: 'name',
type: 'input',
validate: (str: string): boolean => str.length > 0,
},
],
path.resolve(__dirname, '../../generate-plugin/templates'),
[
'src/cjs.js.tpl',
'test/test-utils.js.tpl',
'test/functional.test.js.tpl',
'examples/simple/src/index.js.tpl',
'examples/simple/src/lazy-module.js.tpl',
'examples/simple/src/static-esm-module.js.tpl',
],
['src/_index.js.tpl', 'examples/simple/_webpack.config.js.tpl'],
(gen): object => ({ name: toUpperCamelCase(gen.props.name) }),
);
export default PluginGenerator;