new-s-block 1.1.0 → 1.2.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 +14 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -164,6 +164,9 @@ async function main() {
|
|
|
164
164
|
const scssFile = subFolder
|
|
165
165
|
? path.join(cwd, 'assets', 'sass', 'blocks', subFolder, blockName + '.scss')
|
|
166
166
|
: path.join(cwd, 'assets', 'sass', 'blocks', blockName + '.scss');
|
|
167
|
+
const jsFile = subFolder
|
|
168
|
+
? path.join(cwd, 'assets', 'js', 'blocks', subFolder, blockName + '.js')
|
|
169
|
+
: path.join(cwd, 'assets', 'js', 'blocks', blockName + '.js');
|
|
167
170
|
|
|
168
171
|
if (fs.existsSync(blockDir)) {
|
|
169
172
|
console.error('\n\u274C Block folder already exists: ' + path.relative(cwd, blockDir) + '\n');
|
|
@@ -194,7 +197,6 @@ async function main() {
|
|
|
194
197
|
' "icon": ' + JSON.stringify(svgIcon) + ',\n' +
|
|
195
198
|
' "keywords": ' + keywordsJson + ',\n' +
|
|
196
199
|
' "acf": {\n' +
|
|
197
|
-
' "blockVersion": 3,\n' +
|
|
198
200
|
' "renderTemplate": "' + blockName + '.php"\n' +
|
|
199
201
|
' },\n' +
|
|
200
202
|
' "supports": {\n' +
|
|
@@ -226,6 +228,12 @@ async function main() {
|
|
|
226
228
|
|
|
227
229
|
writeFile(scssFile, scssContent);
|
|
228
230
|
|
|
231
|
+
// ── block-name.js (optional) ─────────────────────────────────────────────
|
|
232
|
+
|
|
233
|
+
if (includeJs === 'y') {
|
|
234
|
+
writeFile(jsFile, '');
|
|
235
|
+
}
|
|
236
|
+
|
|
229
237
|
// ── Summary ──────────────────────────────────────────────────────────────
|
|
230
238
|
|
|
231
239
|
var cyan = '\x1b[36m';
|
|
@@ -238,6 +246,11 @@ async function main() {
|
|
|
238
246
|
var sassDisplay = subFolder ? 'assets/sass/blocks/' + subFolder + '/' : 'assets/sass/blocks/';
|
|
239
247
|
console.log(' \uD83D\uDCC1 ' + sassDisplay);
|
|
240
248
|
console.log(' \u2514\u2500\u2500 ' + blockName + '.scss');
|
|
249
|
+
if (includeJs === 'y') {
|
|
250
|
+
var jsDisplay = subFolder ? 'assets/js/blocks/' + subFolder + '/' : 'assets/js/blocks/';
|
|
251
|
+
console.log(' \uD83D\uDCC1 ' + jsDisplay);
|
|
252
|
+
console.log(' \u2514\u2500\u2500 ' + blockName + '.js');
|
|
253
|
+
}
|
|
241
254
|
console.log('');
|
|
242
255
|
console.log(" Don't forget to add " + cyan + "register_block_type( __DIR__ . '/../blocks/" + blockRelPath + "' );" + reset + " in 'includes/template-functions.php'");
|
|
243
256
|
console.log('');
|