@airfleet/generator-init 0.2.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +2 -0
  2. package/generators/block/index.js +72 -3
  3. package/generators/block/templates/acf/{group.json.ejs → barebones.json.ejs} +0 -0
  4. package/generators/block/templates/acf/building-block.json.ejs +348 -0
  5. package/generators/block/templates/acf/building-repeater-block.json.ejs +547 -0
  6. package/generators/block/templates/{block.blade.php.ejs → barebones.blade.php.ejs} +2 -2
  7. package/generators/block/templates/building-block.blade.php.ejs +20 -0
  8. package/generators/block/templates/building-repeater-block.blade.php.ejs +52 -0
  9. package/generators/component/index.js +1 -1
  10. package/generators/npm/index.js +110 -0
  11. package/generators/npm/templates/.airfleet-release +1 -0
  12. package/generators/npm/templates/.editorconfig +18 -0
  13. package/generators/npm/templates/.gitattributes +11 -0
  14. package/generators/npm/templates/.gitlab-ci.yml +8 -0
  15. package/generators/npm/templates/CHANGELOG.md +10 -0
  16. package/generators/npm/templates/LICENSE.ejs +2 -0
  17. package/generators/npm/templates/README.md.ejs +20 -0
  18. package/generators/npm/templates/package.json.ejs +27 -0
  19. package/generators/plugin/index.js +144 -0
  20. package/generators/plugin/templates/.airfleet-release +1 -0
  21. package/generators/plugin/templates/.editorconfig +18 -0
  22. package/generators/plugin/templates/.gitattributes +11 -0
  23. package/generators/plugin/templates/.gitlab-ci.yml +8 -0
  24. package/generators/plugin/templates/CHANGELOG.md +10 -0
  25. package/generators/plugin/templates/LICENSE.ejs +2 -0
  26. package/generators/plugin/templates/README.md.ejs +20 -0
  27. package/generators/plugin/templates/composer.json.ejs +19 -0
  28. package/generators/plugin/templates/index.php +1 -0
  29. package/generators/plugin/templates/package.json.ejs +27 -0
  30. package/generators/plugin/templates/plugin-name.php.ejs +44 -0
  31. package/generators/plugin/templates/src/Plugin.php.ejs +45 -0
  32. package/package.json +1 -5
  33. package/utils/acfData.js +5 -2
  34. package/utils/mapFilesToTemplates.js +13 -0
  35. package/utils/nameCases.js +9 -1
package/README.md CHANGED
@@ -22,6 +22,8 @@ npm install -g @airfleet/generator-init
22
22
  | --------- | ------------------------------------- | ----------------------------------------- |
23
23
  | Block | `yo @airfleet/init:block --force` | Create a block for the Airfleet Theme |
24
24
  | Component | `yo @airfleet/init:component --force` | Create a component for the Airfleet Theme |
25
+ | npm | `yo @airfleet/init:npm` | Generate an npm package for publishing |
26
+ | Plugin | `yo @airfleet/init:plugin` | Create a WP plugin |
25
27
 
26
28
  ## Documentation
27
29
 
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  import Generator from "yeoman-generator";
3
+ import { paramCase } from "change-case";
3
4
 
4
5
  import themeFeature from "../../utils/log/themeFeature.js";
5
6
  import nameCases from "../../utils/nameCases.js";
@@ -25,6 +26,13 @@ export default class extends Generator {
25
26
  name: "blockDescription",
26
27
  message: "How would you describe the block?",
27
28
  },
29
+ {
30
+ type: "list",
31
+ name: "blockKind",
32
+ message: "What kind of block do you want to start with?",
33
+ choices: ["Barebones", "Building block", "Building repeater block"],
34
+ default: "Barebones",
35
+ },
28
36
  {
29
37
  type: "confirm",
30
38
  name: "createBlockComposer",
@@ -57,7 +65,8 @@ export default class extends Generator {
57
65
 
58
66
  this.answers = await this.prompt(prompts);
59
67
  this.name = nameCases(this.answers.blockName);
60
- this.acf = acfData({ prefix: "group_" });
68
+ this.kind = paramCase(this.answers.blockKind);
69
+ this.acf = acfData({ fields: this._acfFields(this.kind) });
61
70
  this.data = {
62
71
  answers: this.answers,
63
72
  name: this.name,
@@ -65,10 +74,70 @@ export default class extends Generator {
65
74
  };
66
75
  }
67
76
 
77
+ _acfFields(kind) {
78
+ if (kind === "building-block") {
79
+ return [
80
+ "headerTab",
81
+ "sectionHeaderGroup",
82
+ "sectionHeaderClone",
83
+ "textTab",
84
+ "textGroup",
85
+ "textClone",
86
+ "mediaTab",
87
+ "mediaGroup",
88
+ "mediaClone",
89
+ "buttonsTab",
90
+ "buttonsGroup",
91
+ "buttonsClone",
92
+ "formTab",
93
+ "formGroup",
94
+ "formClone",
95
+ "settingsTab",
96
+ "backgroundGroup",
97
+ "backgroundClone",
98
+ ];
99
+ }
100
+
101
+ if (kind === "building-repeater-block") {
102
+ return [
103
+ "headerTab",
104
+ "headerGroup",
105
+ "headerClone",
106
+ "textTab",
107
+ "showText",
108
+ "textGroup",
109
+ "textClone",
110
+ "columnsTab",
111
+ "columnsRepeater",
112
+ "columnsMediaTab",
113
+ "columnsMediaGroup",
114
+ "columnsMediaClone",
115
+ "columnsTitleTab",
116
+ "columnsTitleGroup",
117
+ "columnsTitleClone",
118
+ "columnsTextTab",
119
+ "columnsTextGroup",
120
+ "columnsTextClone",
121
+ "columnsCtaTab",
122
+ "columnsCtaGroup",
123
+ "columnsCtaClone",
124
+ "buttonsTab",
125
+ "showButtons",
126
+ "buttonsGroup",
127
+ "buttonsClone",
128
+ "settingsTab",
129
+ "backgroundGroup",
130
+ "backgroundClone",
131
+ ];
132
+ }
133
+
134
+ return [];
135
+ }
136
+
68
137
  writing() {
69
138
  const templates = [
70
139
  {
71
- template: "block.blade.php.ejs",
140
+ template: `${this.kind}.blade.php.ejs`,
72
141
  destination: `theme/blocks/${this.name.slug}.blade.php`,
73
142
  isEnabled: true,
74
143
  },
@@ -88,7 +157,7 @@ export default class extends Generator {
88
157
  isEnabled: this.answers.createBlockScript,
89
158
  },
90
159
  {
91
- template: "acf/group.json.ejs",
160
+ template: `acf/${this.kind}.json.ejs`,
92
161
  destination: `theme/acf-json/${this.acf.key}.json`,
93
162
  isEnabled: this.answers.createBlockAcf,
94
163
  },
@@ -0,0 +1,348 @@
1
+ {
2
+ "key": "<%= acf.key %>",
3
+ "title": "Block: <%= name.title %>",
4
+ "fields": [
5
+ {
6
+ "key": "<%= acf.fields.headerTab %>",
7
+ "label": "Header",
8
+ "name": "",
9
+ "type": "tab",
10
+ "instructions": "",
11
+ "required": 0,
12
+ "conditional_logic": 0,
13
+ "wrapper": {
14
+ "width": "",
15
+ "class": "",
16
+ "id": ""
17
+ },
18
+ "placement": "left",
19
+ "endpoint": 0
20
+ },
21
+ {
22
+ "key": "<%= acf.fields.sectionHeaderGroup %>",
23
+ "label": "Section Header",
24
+ "name": "section_header",
25
+ "type": "group",
26
+ "instructions": "",
27
+ "required": 0,
28
+ "conditional_logic": 0,
29
+ "wrapper": {
30
+ "width": "",
31
+ "class": "",
32
+ "id": ""
33
+ },
34
+ "layout": "block",
35
+ "sub_fields": [
36
+ {
37
+ "key": "<%= acf.fields.sectionHeaderClone %>",
38
+ "label": "Section Header",
39
+ "name": "section_header",
40
+ "type": "clone",
41
+ "instructions": "",
42
+ "required": 0,
43
+ "conditional_logic": 0,
44
+ "wrapper": {
45
+ "width": "",
46
+ "class": "",
47
+ "id": ""
48
+ },
49
+ "clone": [
50
+ "group_5d10c6c72aa88"
51
+ ],
52
+ "display": "seamless",
53
+ "layout": "block",
54
+ "prefix_label": 0,
55
+ "prefix_name": 0
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ "key": "<%= acf.fields.textTab %>",
61
+ "label": "Text",
62
+ "name": "",
63
+ "type": "tab",
64
+ "instructions": "",
65
+ "required": 0,
66
+ "conditional_logic": 0,
67
+ "wrapper": {
68
+ "width": "",
69
+ "class": "",
70
+ "id": ""
71
+ },
72
+ "placement": "top",
73
+ "endpoint": 0
74
+ },
75
+ {
76
+ "key": "<%= acf.fields.textGroup %>",
77
+ "label": "Text",
78
+ "name": "text",
79
+ "type": "group",
80
+ "instructions": "",
81
+ "required": 0,
82
+ "conditional_logic": 0,
83
+ "wrapper": {
84
+ "width": "",
85
+ "class": "",
86
+ "id": ""
87
+ },
88
+ "layout": "block",
89
+ "sub_fields": [
90
+ {
91
+ "key": "<%= acf.fields.textClone %>",
92
+ "label": "Text",
93
+ "name": "text",
94
+ "type": "clone",
95
+ "instructions": "",
96
+ "required": 0,
97
+ "conditional_logic": 0,
98
+ "wrapper": {
99
+ "width": "",
100
+ "class": "",
101
+ "id": ""
102
+ },
103
+ "clone": [
104
+ "group_5d10c3212d211"
105
+ ],
106
+ "display": "seamless",
107
+ "layout": "block",
108
+ "prefix_label": 0,
109
+ "prefix_name": 0
110
+ }
111
+ ]
112
+ },
113
+ {
114
+ "key": "<%= acf.fields.mediaTab %>",
115
+ "label": "Media",
116
+ "name": "",
117
+ "type": "tab",
118
+ "instructions": "",
119
+ "required": 0,
120
+ "conditional_logic": 0,
121
+ "wrapper": {
122
+ "width": "",
123
+ "class": "",
124
+ "id": ""
125
+ },
126
+ "placement": "top",
127
+ "endpoint": 0
128
+ },
129
+ {
130
+ "key": "<%= acf.fields.mediaGroup %>",
131
+ "label": "Media",
132
+ "name": "media",
133
+ "type": "group",
134
+ "instructions": "",
135
+ "required": 0,
136
+ "conditional_logic": 0,
137
+ "wrapper": {
138
+ "width": "",
139
+ "class": "",
140
+ "id": ""
141
+ },
142
+ "layout": "block",
143
+ "sub_fields": [
144
+ {
145
+ "key": "<%= acf.fields.mediaClone %>",
146
+ "label": "Media",
147
+ "name": "media",
148
+ "type": "clone",
149
+ "instructions": "",
150
+ "required": 0,
151
+ "conditional_logic": 0,
152
+ "wrapper": {
153
+ "width": "",
154
+ "class": "",
155
+ "id": ""
156
+ },
157
+ "clone": [
158
+ "group_5dd2ebd632e0c"
159
+ ],
160
+ "display": "seamless",
161
+ "layout": "block",
162
+ "prefix_label": 0,
163
+ "prefix_name": 0
164
+ }
165
+ ]
166
+ },
167
+ {
168
+ "key": "<%= acf.fields.buttonsTab %>",
169
+ "label": "Buttons",
170
+ "name": "",
171
+ "type": "tab",
172
+ "instructions": "",
173
+ "required": 0,
174
+ "conditional_logic": 0,
175
+ "wrapper": {
176
+ "width": "",
177
+ "class": "",
178
+ "id": ""
179
+ },
180
+ "placement": "top",
181
+ "endpoint": 0
182
+ },
183
+ {
184
+ "key": "<%= acf.fields.buttonsGroup %>",
185
+ "label": "Buttons",
186
+ "name": "buttons",
187
+ "type": "group",
188
+ "instructions": "",
189
+ "required": 0,
190
+ "conditional_logic": 0,
191
+ "wrapper": {
192
+ "width": "",
193
+ "class": "",
194
+ "id": ""
195
+ },
196
+ "layout": "block",
197
+ "sub_fields": [
198
+ {
199
+ "key": "<%= acf.fields.buttonsClone %>",
200
+ "label": "Buttons",
201
+ "name": "buttons",
202
+ "type": "clone",
203
+ "instructions": "",
204
+ "required": 0,
205
+ "conditional_logic": 0,
206
+ "wrapper": {
207
+ "width": "",
208
+ "class": "",
209
+ "id": ""
210
+ },
211
+ "clone": [
212
+ "group_5d10a747c1ff5"
213
+ ],
214
+ "display": "seamless",
215
+ "layout": "block",
216
+ "prefix_label": 0,
217
+ "prefix_name": 0
218
+ }
219
+ ]
220
+ },
221
+ {
222
+ "key": "<%= acf.fields.formTab %>",
223
+ "label": "Form",
224
+ "name": "",
225
+ "type": "tab",
226
+ "instructions": "",
227
+ "required": 0,
228
+ "conditional_logic": 0,
229
+ "wrapper": {
230
+ "width": "",
231
+ "class": "",
232
+ "id": ""
233
+ },
234
+ "placement": "top",
235
+ "endpoint": 0
236
+ },
237
+ {
238
+ "key": "<%= acf.fields.formGroup %>",
239
+ "label": "Form",
240
+ "name": "form",
241
+ "type": "group",
242
+ "instructions": "",
243
+ "required": 0,
244
+ "conditional_logic": 0,
245
+ "wrapper": {
246
+ "width": "",
247
+ "class": "",
248
+ "id": ""
249
+ },
250
+ "layout": "block",
251
+ "sub_fields": [
252
+ {
253
+ "key": "<%= acf.fields.formClone %>",
254
+ "label": "Form",
255
+ "name": "form",
256
+ "type": "clone",
257
+ "instructions": "",
258
+ "required": 0,
259
+ "conditional_logic": 0,
260
+ "wrapper": {
261
+ "width": "",
262
+ "class": "",
263
+ "id": ""
264
+ },
265
+ "clone": [
266
+ "group_5d1489f3b62ec"
267
+ ],
268
+ "display": "seamless",
269
+ "layout": "block",
270
+ "prefix_label": 0,
271
+ "prefix_name": 0
272
+ }
273
+ ]
274
+ },
275
+ {
276
+ "key": "<%= acf.fields.settingsTab %>",
277
+ "label": "Settings",
278
+ "name": "",
279
+ "type": "tab",
280
+ "instructions": "",
281
+ "required": 0,
282
+ "conditional_logic": 0,
283
+ "wrapper": {
284
+ "width": "",
285
+ "class": "",
286
+ "id": ""
287
+ },
288
+ "placement": "top",
289
+ "endpoint": 0
290
+ },
291
+ {
292
+ "key": "<%= acf.fields.backgroundGroup %>",
293
+ "label": "Background",
294
+ "name": "background",
295
+ "type": "group",
296
+ "instructions": "",
297
+ "required": 0,
298
+ "conditional_logic": 0,
299
+ "wrapper": {
300
+ "width": "",
301
+ "class": "",
302
+ "id": ""
303
+ },
304
+ "layout": "block",
305
+ "sub_fields": [
306
+ {
307
+ "key": "<%= acf.fields.backgroundClone %>",
308
+ "label": "Background",
309
+ "name": "background",
310
+ "type": "clone",
311
+ "instructions": "",
312
+ "required": 0,
313
+ "conditional_logic": 0,
314
+ "wrapper": {
315
+ "width": "",
316
+ "class": "",
317
+ "id": ""
318
+ },
319
+ "clone": [
320
+ "group_5d10cb5bb41ca"
321
+ ],
322
+ "display": "seamless",
323
+ "layout": "block",
324
+ "prefix_label": 0,
325
+ "prefix_name": 0
326
+ }
327
+ ]
328
+ }
329
+ ],
330
+ "location": [
331
+ [
332
+ {
333
+ "param": "block",
334
+ "operator": "==",
335
+ "value": "acf\/<%= name.slug %>"
336
+ }
337
+ ]
338
+ ],
339
+ "menu_order": 0,
340
+ "position": "normal",
341
+ "style": "default",
342
+ "label_placement": "top",
343
+ "instruction_placement": "label",
344
+ "hide_on_screen": "",
345
+ "active": 1,
346
+ "description": "",
347
+ "modified": <%= acf.timestamp %>
348
+ }