@airfleet/generator-init 0.1.0 → 0.4.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 (33) hide show
  1. package/README.md +9 -0
  2. package/generators/app/index.js +5 -0
  3. package/generators/block/index.js +184 -0
  4. package/generators/block/templates/acf/barebones.json.ejs +23 -0
  5. package/generators/block/templates/acf/building-block.json.ejs +348 -0
  6. package/generators/block/templates/acf/building-repeater-block.json.ejs +547 -0
  7. package/generators/block/templates/barebones.blade.php.ejs +8 -0
  8. package/generators/block/templates/building-block.blade.php.ejs +20 -0
  9. package/generators/block/templates/building-repeater-block.blade.php.ejs +52 -0
  10. package/generators/block/templates/composer.php.ejs +16 -0
  11. package/generators/block/templates/scripts/block.js.ejs +9 -0
  12. package/generators/block/templates/styles/_block.scss.ejs +3 -0
  13. package/generators/block/templates/styles/index.scss.ejs +1 -0
  14. package/generators/component/index.js +14 -14
  15. package/generators/component/templates/component.blade.php.ejs +2 -2
  16. package/generators/component/templates/{controller.php.ejs → composer.php.ejs} +0 -0
  17. package/generators/component/templates/scripts/component.js.ejs +1 -1
  18. package/generators/component/templates/styles/_component.scss.ejs +1 -1
  19. package/generators/npm/index.js +110 -0
  20. package/generators/npm/templates/.airfleet-release +1 -0
  21. package/generators/npm/templates/.editorconfig +18 -0
  22. package/generators/npm/templates/.gitattributes +11 -0
  23. package/generators/npm/templates/.gitlab-ci.yml +8 -0
  24. package/generators/npm/templates/CHANGELOG.md +10 -0
  25. package/generators/npm/templates/LICENSE.ejs +2 -0
  26. package/generators/npm/templates/README.md.ejs +20 -0
  27. package/generators/npm/templates/package.json.ejs +27 -0
  28. package/package.json +3 -7
  29. package/utils/acfData.js +5 -2
  30. package/utils/log/boxes/infoBox.js +9 -0
  31. package/utils/log/themeFeature.js +0 -2
  32. package/utils/mapFilesToTemplates.js +13 -0
  33. package/utils/nameCases.js +4 -1
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Airfleet Generator
2
2
 
3
+ ![npm](https://img.shields.io/npm/v/@airfleet/generator-init)
4
+ [![pipeline status](https://gitlab.com/codersclan/tools/airfleet-generator/badges/main/pipeline.svg)](https://gitlab.com/codersclan/tools/airfleet-generator/-/commits/main)
5
+
3
6
  A Yeoman generator to scaffold common Airfleet features.
4
7
 
5
8
  ## Requirements
@@ -17,7 +20,13 @@ npm install -g @airfleet/generator-init
17
20
 
18
21
  | Generator | Command | Description |
19
22
  | --------- | ------------------------------------- | ----------------------------------------- |
23
+ | Block | `yo @airfleet/init:block --force` | Create a block for the Airfleet Theme |
20
24
  | Component | `yo @airfleet/init:component --force` | Create a component for the Airfleet Theme |
25
+ | npm | `yo @airfleet/init:npm --force` | Generate an npm package for publishing |
26
+
27
+ ## Documentation
28
+
29
+ - [Documentation](https://www.notion.so/codersclan/Airfleet-Generator-cb340bfda8354ec9a2d1ddebfac58795).
21
30
 
22
31
  ## License
23
32
 
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  import Generator from "yeoman-generator";
3
+ import chalk from "chalk";
3
4
 
4
5
  import title from "../../utils/log/title.js";
6
+ import infoBox from "../../utils/log/boxes/infoBox.js";
5
7
 
6
8
  export default class extends Generator {
7
9
  async prompting() {
8
10
  this.log(title("Hi! Please run one of the available sub-generators."));
11
+ this.log(
12
+ infoBox(`Read the documentation at ${chalk.blue("https://bit.ly/3DyMMC5")}`)
13
+ );
9
14
  }
10
15
  }
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ import Generator from "yeoman-generator";
3
+ import { paramCase } from "change-case";
4
+
5
+ import themeFeature from "../../utils/log/themeFeature.js";
6
+ import nameCases from "../../utils/nameCases.js";
7
+ import copyTemplates from "../../utils/copyTemplates.js";
8
+ import appendTemplates from "../../utils/appendTemplates.js";
9
+ import addThemeScript from "../../utils/codemod/addThemeScript.js";
10
+ import requiredText from "../../utils/validation/requiredText.js";
11
+ import acfData from "../../utils/acfData.js";
12
+
13
+ export default class extends Generator {
14
+ async prompting() {
15
+ this.log(themeFeature("Block"));
16
+
17
+ const prompts = [
18
+ {
19
+ type: "input",
20
+ name: "blockName",
21
+ message: "What is the name of the block?",
22
+ validate: requiredText("Please enter a name"),
23
+ },
24
+ {
25
+ type: "input",
26
+ name: "blockDescription",
27
+ message: "How would you describe the block?",
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
+ },
36
+ {
37
+ type: "confirm",
38
+ name: "createBlockComposer",
39
+ message: "Create composer (controller)?",
40
+ default: true,
41
+ store: true,
42
+ },
43
+ {
44
+ type: "confirm",
45
+ name: "createBlockStyles",
46
+ message: "Create SCSS stylesheet?",
47
+ default: true,
48
+ store: true,
49
+ },
50
+ {
51
+ type: "confirm",
52
+ name: "createBlockScript",
53
+ message: "Create JavaScript file?",
54
+ default: false,
55
+ store: true,
56
+ },
57
+ {
58
+ type: "confirm",
59
+ name: "createBlockAcf",
60
+ message: "Create custom fields?",
61
+ default: false,
62
+ store: true,
63
+ },
64
+ ];
65
+
66
+ this.answers = await this.prompt(prompts);
67
+ this.name = nameCases(this.answers.blockName);
68
+ this.kind = paramCase(this.answers.blockKind);
69
+ this.acf = acfData({ fields: this._acfFields(this.kind) });
70
+ this.data = {
71
+ answers: this.answers,
72
+ name: this.name,
73
+ acf: this.acf,
74
+ };
75
+ }
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
+
137
+ writing() {
138
+ const templates = [
139
+ {
140
+ template: `${this.kind}.blade.php.ejs`,
141
+ destination: `theme/blocks/${this.name.slug}.blade.php`,
142
+ isEnabled: true,
143
+ },
144
+ {
145
+ template: "composer.php.ejs",
146
+ destination: `app/src/Blocks/${this.name.pascal}Block.php`,
147
+ isEnabled: this.answers.createBlockComposer,
148
+ },
149
+ {
150
+ template: "styles/_block.scss.ejs",
151
+ destination: `resources/styles/theme/blocks/_${this.name.slug}.scss`,
152
+ isEnabled: this.answers.createBlockStyles,
153
+ },
154
+ {
155
+ template: "scripts/block.js.ejs",
156
+ destination: `resources/scripts/theme/blocks/${this.name.camel}.js`,
157
+ isEnabled: this.answers.createBlockScript,
158
+ },
159
+ {
160
+ template: `acf/${this.kind}.json.ejs`,
161
+ destination: `theme/acf-json/${this.acf.key}.json`,
162
+ isEnabled: this.answers.createBlockAcf,
163
+ },
164
+ ];
165
+ const appends = [
166
+ {
167
+ template: "styles/index.scss.ejs",
168
+ destination: "resources/styles/theme/blocks/index.scss",
169
+ isEnabled: this.answers.createBlockStyles,
170
+ },
171
+ ];
172
+
173
+ copyTemplates(this, templates, this.data);
174
+ appendTemplates(this, appends, this.data);
175
+
176
+ if (this.answers.createBlockScript) {
177
+ addThemeScript(this, {
178
+ indexPath: "resources/scripts/theme/index.js",
179
+ importName: this.name.pascal,
180
+ importPath: `./blocks/${this.name.camel}`,
181
+ });
182
+ }
183
+ }
184
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "key": "<%= acf.key %>",
3
+ "title": "Block: <%= name.title %>",
4
+ "fields": [],
5
+ "location": [
6
+ [
7
+ {
8
+ "param": "block",
9
+ "operator": "==",
10
+ "value": "acf\/<%= name.slug %>"
11
+ }
12
+ ]
13
+ ],
14
+ "menu_order": 0,
15
+ "position": "normal",
16
+ "style": "default",
17
+ "label_placement": "top",
18
+ "instruction_placement": "label",
19
+ "hide_on_screen": "",
20
+ "active": 1,
21
+ "description": "",
22
+ "modified": <%= acf.timestamp %>
23
+ }
@@ -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
+ }