-
Notifications
You must be signed in to change notification settings - Fork 1
/
plopfile.cjs
59 lines (59 loc) · 1.54 KB
/
plopfile.cjs
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
module.exports = function (plop) {
plop.setHelper('ifEquals', function (arg1, arg2, options) {
return arg1 == arg2 ? options.fn(this) : options.inverse(this);
});
plop.setHelper('ifNotEquals', function (arg1, arg2, options) {
return arg1 != arg2 ? options.fn(this) : options.inverse(this);
});
plop.setGenerator('packet', {
description: 'InSim packet',
prompts: [
{
type: 'input',
name: 'name',
message: 'Packet name without "IS_" (e.g. BTN)',
},
{
type: 'input',
name: 'type',
message: 'Packet type number',
},
{
type: 'input',
name: 'size',
message: 'Packet size in bytes',
},
{
type: 'list',
name: 'variant',
choices: ['instruction', 'info', 'both ways'],
message: 'Is the packet sendable / receivable / both?',
},
],
actions: [
{
type: 'add',
path: 'src/packets/IS_{{name}}.ts',
templateFile: 'generators/packet.hbs',
},
{
type: 'add',
path: 'src/packets/IS_{{name}}.test.ts',
templateFile: 'generators/packet-test.hbs',
},
{
type: 'append',
path: 'src/packets/index.ts',
templateFile: 'generators/packet-index.hbs',
},
{
type: 'append',
path: 'src/packets/enums/PacketType.ts',
pattern: 'export enum PacketType {',
template: ` /* * TODO move it to the correct enum position */
ISP_{{ name }},
`,
},
],
});
};