-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprompts.js
67 lines (64 loc) · 1.75 KB
/
prompts.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
// Attempt to guess the module or theme that the pdb_vue blocks are being
// created in.
const parts = process.cwd().split('/')
const possibleDrupalModule = parts[parts.length - 2]
module.exports = (packageConfig) => {
const pdbVue = (packageConfig.pdbVue) ? packageConfig.pdbVue : {}
const drupalModule = (pdbVue.drupalModule) ? packageConfig.pdbVue.drupalModule : possibleDrupalModule
const mode = (pdbVue.mode) ? packageConfig.pdbVue.mode : 'instances'
const generate = (pdbVue.mode) ? 'block' : 'whole'
return [
{
name: 'generate',
type: 'list',
message: 'What do you want to generate?',
choices: [
{
name: 'Initial framework and first block',
value: 'whole',
},
{
name: 'New block',
value: 'block',
},
],
default: generate,
},
{
name: 'mode',
type: 'list',
message: 'Choose the Framework Mode type of PDB blocks to create?',
choices: [
{
name: 'Mode: Individual Per-block Vue instances',
value: 'instances',
},
{
name: 'Mode: SPA single page app',
value: 'spa',
},
],
default: mode,
},
{
name: 'blockName',
type: 'input',
message: 'Block name (human readable)',
default: 'Hello World',
},
{
name: 'blockMachineName',
type: 'input',
message: 'Block machine name (snake_case)',
default: (answers) => {
return answers.blockName.replace(' ', '_').toLowerCase()
},
},
{
name: 'drupalModuleMachineName',
type: 'input',
message: 'Machine name for the Drupal module or theme these files will be created within',
default: drupalModule,
},
]
}