@airfleet/generator-init 0.27.1 → 0.29.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.
@@ -99,6 +99,20 @@
99
99
  ],
100
100
  "description": "Create a JSON meta file for a block"
101
101
  },
102
+ "Airfleet Pattern Meta": {
103
+ "scope": "json",
104
+ "prefix": "afpatternmeta",
105
+ "body": [
106
+ "{",
107
+ " \"name\": \"${1|airfleet/pattern-|}${TM_FILENAME_BASE/([^.]*)(\\..+)*$/$1/}\",",
108
+ " \"title\": \"$2${TM_FILENAME_BASE/([^\\.]*)(\\.block)?$/${1:/capitalize}/}\",",
109
+ " \"description\": \"$3\",",
110
+ " \"keywords\": [\"airfleet\", \"pattern\", \"${TM_FILENAME_BASE/([^.]*)(\\..+)*$/$1/}\"$4]",
111
+ "}",
112
+ ""
113
+ ],
114
+ "description": "Create a JSON meta file for a pattern"
115
+ },
102
116
  "Airfleet Block Template (PHP)": {
103
117
  "scope": "php,html",
104
118
  "prefix": "afblockphp",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "require": {
3
- "airfleet/wordpress-framework": "^1.2.2"
3
+ "airfleet/wordpress-framework": "^1.3.0"
4
4
  },
5
5
  "config": {
6
6
  "autoloader-suffix": "<%= name.pascal %>"
@@ -4,20 +4,20 @@
4
4
  "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
5
  "This file is @generated automatically"
6
6
  ],
7
- "content-hash": "0b2bccaa99cadbec9f2d6030ab66a50d",
7
+ "content-hash": "0bc133803c8119982f80c3cdd959905e",
8
8
  "packages": [
9
9
  {
10
10
  "name": "airfleet/wordpress-framework",
11
- "version": "1.2.2",
11
+ "version": "1.3.0",
12
12
  "source": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/airfleet/airfleet-wordpress-framework-php.git",
15
- "reference": "be6465d20d331c2cd6e2f685327620a017127b90"
15
+ "reference": "4b50080dea677541b5df35dc17812b8cc93f5f9c"
16
16
  },
17
17
  "dist": {
18
18
  "type": "zip",
19
- "url": "https://api.github.com/repos/airfleet/airfleet-wordpress-framework-php/zipball/be6465d20d331c2cd6e2f685327620a017127b90",
20
- "reference": "be6465d20d331c2cd6e2f685327620a017127b90",
19
+ "url": "https://api.github.com/repos/airfleet/airfleet-wordpress-framework-php/zipball/4b50080dea677541b5df35dc17812b8cc93f5f9c",
20
+ "reference": "4b50080dea677541b5df35dc17812b8cc93f5f9c",
21
21
  "shasum": ""
22
22
  },
23
23
  "require": {
@@ -40,9 +40,9 @@
40
40
  "description": "Airfleet framework for WordPress",
41
41
  "support": {
42
42
  "issues": "https://github.com/airfleet/airfleet-wordpress-framework-php/issues",
43
- "source": "https://github.com/airfleet/airfleet-wordpress-framework-php/tree/1.2.2"
43
+ "source": "https://github.com/airfleet/airfleet-wordpress-framework-php/tree/1.3.0"
44
44
  },
45
- "time": "2024-04-15T13:43:00+00:00"
45
+ "time": "2024-04-18T11:18:51+00:00"
46
46
  },
47
47
  {
48
48
  "name": "jawira/case-converter",
@@ -111,6 +111,20 @@
111
111
  ],
112
112
  "description": "Bootstrap a PHP template for a block"
113
113
  },
114
+ "Airfleet Pattern Meta": {
115
+ "scope": "json",
116
+ "prefix": "afpatternmeta",
117
+ "body": [
118
+ "{",
119
+ " \"name\": \"${1|airfleet/pattern-,airfleet/elements-pattern-|}${TM_FILENAME_BASE/([^.]*)(\\..+)*$/$1/}\",",
120
+ " \"title\": \"$2${TM_FILENAME_BASE/([^\\.]*)(\\.pattern)?$/${1:/capitalize}/}\",",
121
+ " \"description\": \"$3\",",
122
+ " \"keywords\": [\"airfleet\", \"pattern\", \"${TM_FILENAME_BASE/([^.]*)(\\..+)*$/$1/}\"$4]",
123
+ "}",
124
+ ""
125
+ ],
126
+ "description": "Create a JSON meta file for a pattern"
127
+ },
114
128
  "Airfleet Block Template (Blade)": {
115
129
  "scope": "blade",
116
130
  "prefix": "afblock",
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  import Generator from "yeoman-generator";
3
3
 
4
- import nameCases from "../../utils/nameCases.js";
4
+ import acfData from "../../utils/acfData.js";
5
5
  import copyTemplates from "../../utils/copyTemplates.js";
6
- import title from "../../utils/log/title.js";
7
- import highlightText from "../../utils/log/text/highlightText.js";
6
+ import infoBox from "../../utils/log/boxes/infoBox.js";
8
7
  import dangerText from "../../utils/log/text/dangerText.js";
8
+ import highlightText from "../../utils/log/text/highlightText.js";
9
9
  import lines from "../../utils/log/text/lines.js";
10
- import infoBox from "../../utils/log/boxes/infoBox.js";
10
+ import title from "../../utils/log/title.js";
11
+ import nameCases from "../../utils/nameCases.js";
11
12
  import Prompts from "./prompts.js";
12
13
  import Templates from "./templates.js";
13
- import acfData from "../../utils/acfData.js";
14
14
 
15
15
  export default class extends Generator {
16
16
  constructor(args, opts) {
@@ -61,6 +61,15 @@ export default class extends Generator {
61
61
  .replaceAll('"', "")
62
62
  .split(",")
63
63
  .map((k) => k.trim()),
64
+
65
+ patternKeywords: JSON.stringify(
66
+ [
67
+ ...(this.answers.patternKeywords || '')
68
+ .replaceAll('"', "")
69
+ .split(",")
70
+ .map((k) => k.trim())
71
+ ]
72
+ )
64
73
  };
65
74
  }
66
75
 
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- import requiredText from "../../utils/validation/requiredText.js";
4
3
  import highlightText from "../../utils/log/text/highlightText.js";
4
+ import requiredText from "../../utils/validation/requiredText.js";
5
5
 
6
6
  export default class {
7
7
  constructor(generator) {
@@ -39,18 +39,32 @@ export default class {
39
39
  await this._promptNext([...this._blockPrompts()]);
40
40
  }
41
41
 
42
- if (this.answers.viewType !== "partials" && this.answers.viewType !== "templates") {
42
+ if (this.answers.viewType === "patterns") {
43
+ await this._promptNext([...this._patternPrompts()]);
44
+
45
+ if( this.answers.createPatternMetadata ) {
46
+ await this._promptNext([...this._patternMetadataPrompts()]);
47
+ }
48
+ }
49
+
50
+ if (!['partials', 'templates', 'patterns'].includes(this.answers.viewType)) {
43
51
  await this._promptNext([this._createCustomFields()]);
44
52
  }
53
+
45
54
  await this._promptNext([
46
55
  this._createTemplatePrompt(),
47
56
  this._createControllerPrompt(),
48
57
  this._createSetupPrompt(),
49
- this._stylesPrompt(),
50
- this._scriptsPrompt(),
51
58
  ]);
52
59
 
53
- if (this.answers.styles.length > 0 || this.answers.scripts.length > 0) {
60
+ if (this.answers.viewType !== "patterns") {
61
+ await this._promptNext([
62
+ this._stylesPrompt(),
63
+ this._scriptsPrompt(),
64
+ ]);
65
+ }
66
+
67
+ if (this.answers.styles?.length > 0 || this.answers.scripts?.length > 0) {
54
68
  await this._promptNext([
55
69
  this._overrideResourcesPrompt(),
56
70
  ]);
@@ -181,6 +195,10 @@ export default class {
181
195
  name: "Block",
182
196
  value: "blocks",
183
197
  },
198
+ {
199
+ name: "Pattern",
200
+ value: "patterns",
201
+ },
184
202
  {
185
203
  name: "Custom Page Template",
186
204
  value: "custom-templates",
@@ -212,6 +230,34 @@ export default class {
212
230
  ];
213
231
  }
214
232
 
233
+ _patternPrompts() {
234
+ return [
235
+ {
236
+ type: "confirm",
237
+ name: "createPatternMetadata",
238
+ message: "Create pattern metadata?",
239
+ default: true,
240
+ store: true,
241
+ }
242
+ ];
243
+ }
244
+
245
+ _patternMetadataPrompts() {
246
+ return [
247
+ {
248
+ type: "input",
249
+ name: "patternDescription",
250
+ message: "How would you describe the pattern?",
251
+ },
252
+ {
253
+ type: "input",
254
+ name: "patternKeywords",
255
+ message: `Pattern keywords? (${highlightText('separate with commas')}, e.g. "airfleet, hero")`,
256
+ store: false,
257
+ }
258
+ ];
259
+ }
260
+
215
261
  _viewNamePrompt() {
216
262
  return {
217
263
  type: "input",
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "airfleet/<%= name.slug %>",
3
+ "title": "<%= name.title %>",
4
+ "description": "<%= answers.patternDescription %>",
5
+ "keywords": <%- patternKeywords %>
6
+ }
@@ -0,0 +1 @@
1
+ <?php // keepfile ?>
@@ -12,6 +12,7 @@ export default class {
12
12
  this._setupTemplate(),
13
13
  this._acfTemplate(),
14
14
  this._blockMetaTemplate(),
15
+ this._patternMetaTemplate(),
15
16
  ...this._stylesTemplates(),
16
17
  ...this._scriptsTemplates(),
17
18
  ];
@@ -51,6 +52,14 @@ export default class {
51
52
  };
52
53
  }
53
54
 
55
+ _patternMetaTemplate() {
56
+ return {
57
+ template: `patterns/pattern.json.ejs`,
58
+ destination: `${this.generator.viewFolder}/${this.generator.name.slug}.pattern.json`,
59
+ isEnabled: this.generator.answers.createPatternMetadata,
60
+ };
61
+ }
62
+
54
63
  _controllerTemplate() {
55
64
  return {
56
65
  template: `ViewController.php.ejs`,
@@ -143,18 +152,18 @@ export default class {
143
152
  }
144
153
 
145
154
  _styleEnabled(style) {
146
- return this.generator.answers.styles.includes(style);
155
+ return this.generator.answers.styles?.includes(style);
147
156
  }
148
157
 
149
158
  _scriptEnabled(script) {
150
159
  return (
151
- this.generator.answers.scripts.includes(script) ||
160
+ this.generator.answers.scripts?.includes(script) ||
152
161
  this._shouldImportStylesForScript(script)
153
162
  );
154
163
  }
155
164
 
156
165
  _scriptTemplate(script) {
157
- if (this.generator.answers.scripts.includes(script)) {
166
+ if (this.generator.answers.scripts?.includes(script)) {
158
167
  return "script/view.js.ejs";
159
168
  }
160
169
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airfleet/generator-init",
3
3
  "description": "A Yeoman generator to scaffold common Airfleet features",
4
- "version": "0.27.1",
4
+ "version": "0.29.0",
5
5
  "scripts": {},
6
6
  "publishConfig": {
7
7
  "access": "public"