-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplopfile.mjs
More file actions
56 lines (53 loc) · 1.42 KB
/
plopfile.mjs
File metadata and controls
56 lines (53 loc) · 1.42 KB
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
function camelize (str) {
return str
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
return index === 0 ? word.toLowerCase() : word.toUpperCase();
})
.replace(/\s+/g, '');
}
function pascalize (str) {
return str
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
return word.toUpperCase();
})
.replace(/\s+/g, '');
}
export default function (
/** @type {import('plop').NodePlopAPI} */
plop
) {
plop.setHelper('camelize', camelize);
plop.setHelper('pascalize', pascalize);
/**
* scaffolding structure
*/
plop.setGenerator('component', {
description: 'Create a new component',
prompts: [
{
type: 'list',
name: 'componentType',
message: 'Select component type:',
choices: ['layouts', 'objects', 'ui']
},
{
type: 'input',
name: 'componentName',
message: 'Component name (Auto-converted to PascalCase):',
filter: pascalize
}
],
actions: [
{
type: 'add',
path: 'src/components/{{componentType}}/{{pascalize componentName}}/{{pascalize componentName}}.astro',
templateFile: 'plop-templates/component.astro.hbs'
},
{
type: 'add',
path: 'src/components/{{componentType}}/{{pascalize componentName}}/{{pascalize componentName}}.module.scss',
templateFile: 'plop-templates/style.module.scss.hbs'
}
]
});
}