-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile-c.ts
83 lines (74 loc) · 2.44 KB
/
plopfile-c.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import {NodePlopAPI} from 'plop';
export default function (plop: NodePlopAPI) {
var templatePath = 'plop-templates/'
var copydir = require('copy-dir')
// plop generator code
plop.setGenerator('compose-base', {
description: 'this is a skeleton plopfile',
prompts: [
{
type: 'input',
name: 'appName',
message: 'Enter application name: '
},
{
type: 'input',
name: 'packageId',
message: 'Enter package Id: ',
prefix: 'com.'
},
{
type: 'input',
name: 'applicationId',
prefix: 'com.',
message: 'Enter application Id: '
},
{
type: 'input',
name: 'appVersion',
default: "1.0.0",
message: 'Enter application version Id: '
}
],
actions: function (data) {
console.log("Dataaa", data)
let actions = [];
let packageLoc = data.packageId.split(".").join("/")
console.log("Package Loc", packageLoc)
actions.push(
{
type: "copyBase",
configProp: 'available from the config param'
}
)
return actions;
}
});
plop.setActionType('copyBase', function (answers, config, plop) {
console.log("Copy base... >",answers, config)
// do something
// doSomething(config.configProp);
// if something went wrong
// throw 'error message';
// otherwise
let packageLoc = answers.packageId.split(".").join("/")
copydir.sync('plop-templates/Compose_Base/base', `output/${answers.appName}`)
return 'success status message';
});
// or do async things inside of an action
// plop.setActionType('copyBase', function (answers, config, plop) {
// // do something
// return new Promise((resolve, reject) => {
// if (true) {
// resolve('success status message');
// } else {
// reject('error message');
// }
// });
// });
plop.setHelper('upperCase', function (text) {
return text.toUpperCase();
});
// or in es6/es2015
plop.setHelper('upperCase', (txt) => txt.toUpperCase());
};