new-s-block 1.0.8 → 1.1.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.
- package/bin/cli.js +16 -24
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -95,7 +95,7 @@ if (process.argv.includes('--version') || process.argv.includes('-v')) {
|
|
|
95
95
|
// ── Main ───────────────────────────────────────────────────────────────────
|
|
96
96
|
|
|
97
97
|
async function main() {
|
|
98
|
-
console.log('\n\uD83E\uDDF1
|
|
98
|
+
console.log('\n\uD83E\uDDF1 S-Tier Block Generator\n');
|
|
99
99
|
var updateCheck = checkForUpdate();
|
|
100
100
|
|
|
101
101
|
const rl = readline.createInterface({
|
|
@@ -134,7 +134,16 @@ async function main() {
|
|
|
134
134
|
.map(function (k) { return k.trim().toLowerCase(); })
|
|
135
135
|
.filter(Boolean);
|
|
136
136
|
|
|
137
|
-
// 6.
|
|
137
|
+
// 6. Include JS
|
|
138
|
+
var includeJs = '';
|
|
139
|
+
while (includeJs !== 'y' && includeJs !== 'n') {
|
|
140
|
+
includeJs = (await prompt(rl, 'Include block JS? (y/n): ')).trim().toLowerCase();
|
|
141
|
+
if (includeJs !== 'y' && includeJs !== 'n') {
|
|
142
|
+
console.log(' ⚠ Please answer y or n.');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 7. Blocks folder
|
|
138
147
|
const folderRaw = await prompt(rl, 'Blocks folder [blocks]: ');
|
|
139
148
|
|
|
140
149
|
rl.close();
|
|
@@ -180,7 +189,8 @@ async function main() {
|
|
|
180
189
|
' "title": "' + blockLabel + '",\n' +
|
|
181
190
|
' "description": "' + (blockDescription.trim() || blockLabel) + ' Block",\n' +
|
|
182
191
|
' "category": "' + blockCategory + '",\n' +
|
|
183
|
-
' "
|
|
192
|
+
' "style": "file:./' + blockName + '.min.css",\n' +
|
|
193
|
+
(includeJs === 'y' ? ' "viewScript": "file:./' + blockName + '.min.js",\n' : '') +
|
|
184
194
|
' "icon": ' + JSON.stringify(svgIcon) + ',\n' +
|
|
185
195
|
' "keywords": ' + keywordsJson + ',\n' +
|
|
186
196
|
' "acf": {\n' +
|
|
@@ -199,26 +209,9 @@ async function main() {
|
|
|
199
209
|
|
|
200
210
|
const innerClass = toInnerClass(blockName);
|
|
201
211
|
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
'\n' +
|
|
205
|
-
"$class = 'st_block st_" + blockName.replace(/-/g, '_') + "';\n" +
|
|
206
|
-
"if ( ! empty( $block['className'] ) ) {\n" +
|
|
207
|
-
" $class .= ' ' . $block['className'];\n" +
|
|
208
|
-
'}\n' +
|
|
209
|
-
'\n' +
|
|
210
|
-
"$anchor = '';\n" +
|
|
211
|
-
"if ( ! empty( $block['anchor'] ) ) {\n" +
|
|
212
|
-
" $anchor = 'id=\"' . esc_attr( $block['anchor'] ) . '\" ';\n" +
|
|
213
|
-
'}\n' +
|
|
214
|
-
'\n' +
|
|
215
|
-
'if ( ! empty( $padding) ) {\n' +
|
|
216
|
-
" $class .= ' ' . $padding;\n" +
|
|
217
|
-
'}\n' +
|
|
218
|
-
'\n' +
|
|
219
|
-
'?>\n' +
|
|
220
|
-
'\n' +
|
|
221
|
-
'<section <?php echo $anchor; ?> class="<?php echo esc_attr( $class ); ?>">\n' +
|
|
212
|
+
const mainClass = 'st_' + blockName.replace(/-/g, '_');
|
|
213
|
+
const renderPhp =
|
|
214
|
+
'<section <?php echo stier_block_attrs( $block, \'' + mainClass + '\'); ?>>\n' +
|
|
222
215
|
"\t<?php get_template_part('components/background'); ?>\n" +
|
|
223
216
|
'\t<div class="container ' + innerClass + '">\n' +
|
|
224
217
|
"\t\t<?php get_template_part('components/intro'); ?>\n" +
|
|
@@ -246,7 +239,6 @@ async function main() {
|
|
|
246
239
|
console.log(' \uD83D\uDCC1 ' + sassDisplay);
|
|
247
240
|
console.log(' \u2514\u2500\u2500 ' + blockName + '.scss');
|
|
248
241
|
console.log('');
|
|
249
|
-
console.log(" Don't forget to add " + cyan + "@import 'blocks/" + (subFolder ? subFolder + '/' : '') + blockName + "';" + reset + " in 'assets/sass/theme.scss'");
|
|
250
242
|
console.log(" Don't forget to add " + cyan + "register_block_type( __DIR__ . '/../blocks/" + blockRelPath + "' );" + reset + " in 'includes/template-functions.php'");
|
|
251
243
|
console.log('');
|
|
252
244
|
}
|