@airfleet/generator-init 0.28.0 → 0.29.1
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.
- package/generators/plugin/templates/.vscode/airfleet.code-snippets.ejs +15 -0
- package/generators/snippets/templates/airfleet.code-snippets.ejs +14 -0
- package/generators/view/index.js +14 -5
- package/generators/view/prompts.js +51 -5
- package/generators/view/templates/patterns/pattern.json.ejs +6 -0
- package/generators/view/templates/patterns/patterns-template.blade.php.ejs +1 -0
- package/generators/view/templates/patterns/patterns-template.php.ejs +1 -0
- package/generators/view/templates.js +12 -3
- package/package.json +1 -1
|
@@ -94,11 +94,26 @@
|
|
|
94
94
|
" \"title\": \"$2${TM_FILENAME_BASE/([^\\.]*)(\\.block)?$/${1:/capitalize}/}\",",
|
|
95
95
|
" \"description\": \"$3\",",
|
|
96
96
|
" \"keywords\": [\"airfleet\", \"${TM_FILENAME_BASE/([^.]*)(\\..+)*$/$1/}\"$4]",
|
|
97
|
+
" \"supports\": { \"anchor\": true }",
|
|
97
98
|
"}",
|
|
98
99
|
""
|
|
99
100
|
],
|
|
100
101
|
"description": "Create a JSON meta file for a block"
|
|
101
102
|
},
|
|
103
|
+
"Airfleet Pattern Meta": {
|
|
104
|
+
"scope": "json",
|
|
105
|
+
"prefix": "afpatternmeta",
|
|
106
|
+
"body": [
|
|
107
|
+
"{",
|
|
108
|
+
" \"name\": \"${1|airfleet/pattern-|}${TM_FILENAME_BASE/([^.]*)(\\..+)*$/$1/}\",",
|
|
109
|
+
" \"title\": \"$2${TM_FILENAME_BASE/([^\\.]*)(\\.block)?$/${1:/capitalize}/}\",",
|
|
110
|
+
" \"description\": \"$3\",",
|
|
111
|
+
" \"keywords\": [\"airfleet\", \"pattern\", \"${TM_FILENAME_BASE/([^.]*)(\\..+)*$/$1/}\"$4]",
|
|
112
|
+
"}",
|
|
113
|
+
""
|
|
114
|
+
],
|
|
115
|
+
"description": "Create a JSON meta file for a pattern"
|
|
116
|
+
},
|
|
102
117
|
"Airfleet Block Template (PHP)": {
|
|
103
118
|
"scope": "php,html",
|
|
104
119
|
"prefix": "afblockphp",
|
|
@@ -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",
|
package/generators/view/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import Generator from "yeoman-generator";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import acfData from "../../utils/acfData.js";
|
|
5
5
|
import copyTemplates from "../../utils/copyTemplates.js";
|
|
6
|
-
import
|
|
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
|
|
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
|
|
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.
|
|
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 @@
|
|
|
1
|
+
<?php // keepfile ?>
|
|
@@ -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
|
|
155
|
+
return this.generator.answers.styles?.includes(style);
|
|
147
156
|
}
|
|
148
157
|
|
|
149
158
|
_scriptEnabled(script) {
|
|
150
159
|
return (
|
|
151
|
-
this.generator.answers.scripts
|
|
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
|
|
166
|
+
if (this.generator.answers.scripts?.includes(script)) {
|
|
158
167
|
return "script/view.js.ejs";
|
|
159
168
|
}
|
|
160
169
|
|