@caweb/cli 1.5.7 → 1.5.9
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/commands/sync/index.js +27 -15
- package/commands/webpack/webpack.js +7 -2
- package/lib/cli.js +6 -0
- package/lib/wordpress/api.js +5 -2
- package/package.json +2 -2
package/commands/sync/index.js
CHANGED
|
@@ -41,7 +41,7 @@ const configFile = path.join(appPath, 'caweb.json');
|
|
|
41
41
|
* @param {string} [tax='pages']
|
|
42
42
|
* @returns {unknown}
|
|
43
43
|
*/
|
|
44
|
-
async function getParentItems( objects, request, tax = 'pages' ){
|
|
44
|
+
async function getParentItems( objects, request, tax = 'pages', debug = false ){
|
|
45
45
|
let parentItemsObjects = [];
|
|
46
46
|
let objectParentIds = objects.map((obj) => { return obj.parent; }).filter(n => n);
|
|
47
47
|
|
|
@@ -53,7 +53,7 @@ async function getParentItems( objects, request, tax = 'pages' ){
|
|
|
53
53
|
orderby: 'parent',
|
|
54
54
|
embed: true,
|
|
55
55
|
include: objectParentIds
|
|
56
|
-
}, tax);
|
|
56
|
+
}, tax, debug);
|
|
57
57
|
|
|
58
58
|
// if we have parent items, we have to add to the items array.
|
|
59
59
|
if( parentItems ){
|
|
@@ -260,7 +260,8 @@ export default async function sync({
|
|
|
260
260
|
],
|
|
261
261
|
include: mediaIds && mediaIds.length ? mediaIds.join(',') : null
|
|
262
262
|
},
|
|
263
|
-
'media'
|
|
263
|
+
'media',
|
|
264
|
+
debug
|
|
264
265
|
);
|
|
265
266
|
}
|
|
266
267
|
|
|
@@ -276,7 +277,7 @@ export default async function sync({
|
|
|
276
277
|
'page_on_front',
|
|
277
278
|
'posts_per_page'
|
|
278
279
|
],
|
|
279
|
-
}, 'settings')
|
|
280
|
+
}, 'settings', debug )
|
|
280
281
|
|
|
281
282
|
}
|
|
282
283
|
|
|
@@ -290,14 +291,19 @@ export default async function sync({
|
|
|
290
291
|
embed: true,
|
|
291
292
|
include: pageIds && pageIds.length ? pageIds.join(',') : null
|
|
292
293
|
},
|
|
293
|
-
'pages'
|
|
294
|
+
'pages',
|
|
295
|
+
debug
|
|
294
296
|
);
|
|
295
297
|
|
|
298
|
+
console.log( debug );
|
|
299
|
+
console.log( pages );
|
|
300
|
+
console.log( pageIds );
|
|
296
301
|
// pages can be nested so we have to collect any parent items.
|
|
297
302
|
pages = await getParentItems(
|
|
298
303
|
pages,
|
|
299
304
|
targetOptions,
|
|
300
|
-
'pages'
|
|
305
|
+
'pages',
|
|
306
|
+
debug
|
|
301
307
|
)
|
|
302
308
|
}
|
|
303
309
|
|
|
@@ -310,14 +316,16 @@ export default async function sync({
|
|
|
310
316
|
orderby: 'parent',
|
|
311
317
|
include: postIds && postIds.length ? postIds.join(',') : null
|
|
312
318
|
},
|
|
313
|
-
'posts'
|
|
319
|
+
'posts',
|
|
320
|
+
debug
|
|
314
321
|
);
|
|
315
322
|
|
|
316
323
|
// posts can be nested so we have to collect any parent items.
|
|
317
324
|
posts = await getParentItems(
|
|
318
325
|
posts,
|
|
319
326
|
targetOptions,
|
|
320
|
-
'posts'
|
|
327
|
+
'posts',
|
|
328
|
+
debug
|
|
321
329
|
)
|
|
322
330
|
}
|
|
323
331
|
|
|
@@ -398,7 +406,6 @@ export default async function sync({
|
|
|
398
406
|
p.content.rendered = p.content.rendered.replace( new RegExp(target.url, 'g'), dest.url );
|
|
399
407
|
}
|
|
400
408
|
|
|
401
|
-
|
|
402
409
|
// Menu and Nav Items.
|
|
403
410
|
if( tax.includes('menus')){
|
|
404
411
|
spinner.text = `Collecting assigned navigation menus from ${target.url}`;
|
|
@@ -414,7 +421,7 @@ export default async function sync({
|
|
|
414
421
|
'locations'
|
|
415
422
|
],
|
|
416
423
|
include: menuIds && menuIds.length ? menuIds.join(',') : null
|
|
417
|
-
}, 'menus');
|
|
424
|
+
}, 'menus', debug);
|
|
418
425
|
|
|
419
426
|
menuNavItems = await getTaxonomies(
|
|
420
427
|
{
|
|
@@ -440,7 +447,8 @@ export default async function sync({
|
|
|
440
447
|
],
|
|
441
448
|
menus: menus.map((menu) => { return menu.id; })
|
|
442
449
|
},
|
|
443
|
-
'menu-items'
|
|
450
|
+
'menu-items',
|
|
451
|
+
debug
|
|
444
452
|
)
|
|
445
453
|
|
|
446
454
|
let missingPages = [];
|
|
@@ -464,14 +472,16 @@ export default async function sync({
|
|
|
464
472
|
embed: true,
|
|
465
473
|
include: missingPages.join(',')
|
|
466
474
|
},
|
|
467
|
-
'pages'
|
|
475
|
+
'pages',
|
|
476
|
+
debug
|
|
468
477
|
);
|
|
469
478
|
|
|
470
479
|
// pages can be nested so we have to collect any parent items.
|
|
471
480
|
missingPages = await getParentItems(
|
|
472
481
|
missingPages,
|
|
473
482
|
targetOptions,
|
|
474
|
-
'pages'
|
|
483
|
+
'pages',
|
|
484
|
+
debug
|
|
475
485
|
);
|
|
476
486
|
|
|
477
487
|
// add the missing pages to the pages array
|
|
@@ -487,14 +497,16 @@ export default async function sync({
|
|
|
487
497
|
orderby: 'parent',
|
|
488
498
|
include: missingPosts.join(',')
|
|
489
499
|
},
|
|
490
|
-
'posts'
|
|
500
|
+
'posts',
|
|
501
|
+
debug
|
|
491
502
|
);
|
|
492
503
|
|
|
493
504
|
// posts can be nested so we have to collect any parent items.
|
|
494
505
|
missingPosts = await getParentItems(
|
|
495
506
|
missingPosts,
|
|
496
507
|
targetOptions,
|
|
497
|
-
'posts'
|
|
508
|
+
'posts',
|
|
509
|
+
debug
|
|
498
510
|
)
|
|
499
511
|
|
|
500
512
|
// add the missing posts to the posts array
|
|
@@ -20,10 +20,12 @@ import {
|
|
|
20
20
|
* @param {Object} options
|
|
21
21
|
* @param {boolean} options.debug True if debug mode is enabled.
|
|
22
22
|
* @param {boolean} options.audit Add CSS-Audit Page to pages served.
|
|
23
|
+
* @param {boolean} options.template Serves the project using templating.
|
|
23
24
|
*/
|
|
24
25
|
export default async function webpack({
|
|
25
26
|
spinner,
|
|
26
|
-
debug,
|
|
27
|
+
debug,
|
|
28
|
+
template
|
|
27
29
|
} ) {
|
|
28
30
|
const webpackCommand = 'build' === process.argv[2] ? 'build' : 'serve' ;
|
|
29
31
|
|
|
@@ -67,7 +69,10 @@ export default async function webpack({
|
|
|
67
69
|
if( customConfig.length ){
|
|
68
70
|
webpackConfig = deepmerge(webpackConfig.default, customConfig.default);
|
|
69
71
|
}
|
|
70
|
-
|
|
72
|
+
|
|
73
|
+
// add the template flag to the node options
|
|
74
|
+
process.env.NODE_OPTIONS = `${process.env.NODE_OPTIONS} --template ${template}`;
|
|
75
|
+
|
|
71
76
|
// run the webpackCommand command.
|
|
72
77
|
await runCmd(
|
|
73
78
|
'webpack',
|
package/lib/cli.js
CHANGED
|
@@ -55,6 +55,7 @@ function addWebpackCmds(){
|
|
|
55
55
|
// Serve Command.
|
|
56
56
|
program.command('serve')
|
|
57
57
|
.description('Serve the current project')
|
|
58
|
+
.addOption(new Option('--template <template>', 'Serves the project using templating.').choices(['default', 'blank']).default('default'))
|
|
58
59
|
.option( '--audit', 'Performs WordPress CSS-Audit.', true )
|
|
59
60
|
.option( '--no-audit', 'Skips WordPress CSS-Audit.', false )
|
|
60
61
|
.option( '--a11y', 'Performs IBM Accessibility Checker.', true )
|
|
@@ -336,6 +337,11 @@ export default function cli() {
|
|
|
336
337
|
'--post-ids <ids...>',
|
|
337
338
|
'Sync specific Post IDs.'
|
|
338
339
|
))
|
|
340
|
+
.option(
|
|
341
|
+
'--debug',
|
|
342
|
+
'Enable debug output.',
|
|
343
|
+
false
|
|
344
|
+
)
|
|
339
345
|
.allowUnknownOption(true)
|
|
340
346
|
.action( withSpinner(env.sync) )
|
|
341
347
|
|
package/lib/wordpress/api.js
CHANGED
|
@@ -59,7 +59,7 @@ function processUrlParam( param ){
|
|
|
59
59
|
* @param {string} [tax='pages'] Taxonomy of the request made. Default pages, available choices: pages,posts,menus,menu-items,settings,media
|
|
60
60
|
* @returns {unknown}
|
|
61
61
|
*/
|
|
62
|
-
async function getTaxonomies( request, tax = 'pages' ){
|
|
62
|
+
async function getTaxonomies( request, tax = 'pages', debug = false ){
|
|
63
63
|
const fields = request.fields ? request.fields : [
|
|
64
64
|
'id',
|
|
65
65
|
'type',
|
|
@@ -161,7 +161,10 @@ async function getTaxonomies( request, tax = 'pages' ){
|
|
|
161
161
|
collection = collection.concat( res.data );
|
|
162
162
|
return true
|
|
163
163
|
}).catch(
|
|
164
|
-
(
|
|
164
|
+
({response}) => {
|
|
165
|
+
if( debug ){
|
|
166
|
+
console.log( `\n${response.data.message}` );
|
|
167
|
+
}
|
|
165
168
|
return false
|
|
166
169
|
}
|
|
167
170
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9",
|
|
4
4
|
"description": "CAWebPublishing Command Line Interface.",
|
|
5
5
|
"exports": "./lib/env.js",
|
|
6
6
|
"type": "module",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@caweb/webpack": "^1.
|
|
59
|
+
"@caweb/webpack": "^1.1.3",
|
|
60
60
|
"@inquirer/prompts": "^5.3.2",
|
|
61
61
|
"@wordpress/create-block": "^4.46.0",
|
|
62
62
|
"@wordpress/env": "^10.3.0",
|