@caweb/cli 1.14.6 → 1.14.8
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/env/shell.js +2 -2
- package/commands/sync/index.js +43 -14
- package/commands/webpack/webpack.js +3 -1
- package/lib/cli.js +5 -0
- package/package.json +4 -4
package/commands/env/shell.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import WPEnv from '@wordpress/env';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -21,7 +21,7 @@ export default async function shell({
|
|
|
21
21
|
debug
|
|
22
22
|
}) {
|
|
23
23
|
|
|
24
|
-
await run({
|
|
24
|
+
await WPEnv.run({
|
|
25
25
|
container: 'tests' === environment ? 'tests-cli' : 'cli',
|
|
26
26
|
command: ['bash'],
|
|
27
27
|
"": "",
|
package/commands/sync/index.js
CHANGED
|
@@ -153,6 +153,10 @@ function getStaticNavItems(navJson, destUrl){
|
|
|
153
153
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
function uniqueArray(arr) {
|
|
157
|
+
return arr.filter((obj, index, self) => index === self.findIndex(item => item.id === obj.id ));
|
|
158
|
+
}
|
|
159
|
+
|
|
156
160
|
/**
|
|
157
161
|
* Sync Environments.
|
|
158
162
|
*
|
|
@@ -183,8 +187,6 @@ export default async function sync({
|
|
|
183
187
|
// read caweb configuration file.
|
|
184
188
|
let serviceConfig = fs.existsSync(configFile) ? JSON.parse( fs.readFileSync(configFile) ) : { sync: {} };
|
|
185
189
|
|
|
186
|
-
// process.env.WP_CLI_CONFIG_PATH = path.join(workDirectoryPath, 'config.yml');
|
|
187
|
-
|
|
188
190
|
target = serviceConfig.sync[target];
|
|
189
191
|
dest = serviceConfig.sync[dest];
|
|
190
192
|
|
|
@@ -214,8 +216,6 @@ export default async function sync({
|
|
|
214
216
|
}
|
|
215
217
|
}
|
|
216
218
|
|
|
217
|
-
console.log( target)
|
|
218
|
-
console.log( dest )
|
|
219
219
|
/**
|
|
220
220
|
* each instance has to have a url, user, pwd property
|
|
221
221
|
*/
|
|
@@ -284,6 +284,31 @@ export default async function sync({
|
|
|
284
284
|
|
|
285
285
|
spinner.start()
|
|
286
286
|
|
|
287
|
+
}else{
|
|
288
|
+
|
|
289
|
+
// if no other flags were specified, we sync whatever is in tax
|
|
290
|
+
tax = ! mediaIds && ! menuIds && ! pageIds && ! postIds ? tax : []
|
|
291
|
+
|
|
292
|
+
// if pages ids were specified, we have to sync pages and media
|
|
293
|
+
if( pageIds && pageIds.length ){
|
|
294
|
+
tax.push('pages');
|
|
295
|
+
// tax.push('pages', 'media');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// if post ids were specified, we have to sync posts and media
|
|
299
|
+
if( postIds && postIds.length ){
|
|
300
|
+
tax.push('posts');
|
|
301
|
+
// tax.push('posts', 'media');
|
|
302
|
+
}
|
|
303
|
+
// if media ids were specified, we have to sync media
|
|
304
|
+
if( mediaIds && mediaIds.length ){
|
|
305
|
+
tax.push('media');
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// if menu ids were specified, we have to sync menus.
|
|
309
|
+
if( menuIds && menuIds.length ){
|
|
310
|
+
tax.push('menus');
|
|
311
|
+
}
|
|
287
312
|
}
|
|
288
313
|
|
|
289
314
|
// if the request is going from static,
|
|
@@ -424,7 +449,6 @@ export default async function sync({
|
|
|
424
449
|
}
|
|
425
450
|
|
|
426
451
|
}else{
|
|
427
|
-
|
|
428
452
|
// Media Library.
|
|
429
453
|
if( tax.includes('media', 'pages', 'posts') ){
|
|
430
454
|
spinner.text = `Collecting Media Library ${target.url}`;
|
|
@@ -446,6 +470,8 @@ export default async function sync({
|
|
|
446
470
|
'media',
|
|
447
471
|
debug
|
|
448
472
|
);
|
|
473
|
+
|
|
474
|
+
mediaLibrary = uniqueArray(mediaLibrary);
|
|
449
475
|
}
|
|
450
476
|
|
|
451
477
|
// Site Settings.
|
|
@@ -485,9 +511,10 @@ export default async function sync({
|
|
|
485
511
|
'pages',
|
|
486
512
|
debug
|
|
487
513
|
)
|
|
488
|
-
|
|
489
|
-
}
|
|
490
514
|
|
|
515
|
+
pages = uniqueArray(pages);
|
|
516
|
+
}
|
|
517
|
+
|
|
491
518
|
// Posts.
|
|
492
519
|
if( tax.includes('posts') ){
|
|
493
520
|
// get all pages/posts
|
|
@@ -503,11 +530,13 @@ export default async function sync({
|
|
|
503
530
|
|
|
504
531
|
// posts can be nested so we have to collect any parent items.
|
|
505
532
|
posts = await getParentItems(
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
533
|
+
posts,
|
|
534
|
+
targetOptions,
|
|
535
|
+
'posts',
|
|
536
|
+
debug
|
|
537
|
+
)
|
|
538
|
+
|
|
539
|
+
posts = uniqueArray(posts);
|
|
511
540
|
}
|
|
512
541
|
|
|
513
542
|
/**
|
|
@@ -726,8 +755,8 @@ export default async function sync({
|
|
|
726
755
|
spinner.text = `Creating all pages to ${dest.url}`;
|
|
727
756
|
createdPages = await createTaxonomies( pages, destOptions, 'pages', spinner );
|
|
728
757
|
}
|
|
729
|
-
|
|
730
|
-
|
|
758
|
+
|
|
759
|
+
// Posts.
|
|
731
760
|
if( posts ){
|
|
732
761
|
spinner.text = `Creating all posts to ${dest.url}`;
|
|
733
762
|
await createTaxonomies( posts, destOptions, 'posts', spinner );
|
|
@@ -25,7 +25,8 @@ export default async function webpack({
|
|
|
25
25
|
spinner,
|
|
26
26
|
debug,
|
|
27
27
|
scheme,
|
|
28
|
-
template
|
|
28
|
+
template,
|
|
29
|
+
noExternals
|
|
29
30
|
} ) {
|
|
30
31
|
const webpackCommand = 'build' === process.argv[2] ? 'build' : 'serve' ;
|
|
31
32
|
|
|
@@ -35,6 +36,7 @@ export default async function webpack({
|
|
|
35
36
|
// Since we use @wordpress/scripts webpack config we can leverage
|
|
36
37
|
// the environment variables as well.
|
|
37
38
|
process.env.WP_COPY_PHP_FILES_TO_DIST = true;
|
|
39
|
+
process.env.WP_NO_EXTERNALS = noExternals;
|
|
38
40
|
|
|
39
41
|
// add our default config as an extension.
|
|
40
42
|
// users can overwrite any values by creating a webconfig of their own.
|
package/lib/cli.js
CHANGED
|
@@ -49,6 +49,11 @@ function addWebpackCmds(){
|
|
|
49
49
|
// Build Command.
|
|
50
50
|
program.command('build')
|
|
51
51
|
.description('Builds the current project.')
|
|
52
|
+
.option(
|
|
53
|
+
'--no-externals',
|
|
54
|
+
'Bundles all dependencies into the build, ignoring externals.',
|
|
55
|
+
false
|
|
56
|
+
)
|
|
52
57
|
.allowUnknownOption(true)
|
|
53
58
|
.allowExcessArguments(true)
|
|
54
59
|
.action(env.webpack)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/cli",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.8",
|
|
4
4
|
"description": "CAWebPublishing Command Line Interface.",
|
|
5
5
|
"exports": "./lib/env.js",
|
|
6
6
|
"type": "module",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@caweb/webpack": "^1.5.
|
|
66
|
+
"@caweb/webpack": "^1.5.8",
|
|
67
67
|
"@inquirer/prompts": "^7.9.0",
|
|
68
68
|
"@wordpress/create-block": "^4.77.0",
|
|
69
69
|
"@wordpress/env": "^10.34.0",
|
|
@@ -78,11 +78,11 @@
|
|
|
78
78
|
"fs-extra": "^11.3.2",
|
|
79
79
|
"html-to-json-parser": "^2.0.1",
|
|
80
80
|
"inquirer-select-pro": "^1.0.0-alpha.9",
|
|
81
|
-
"jsdom": "^27.0
|
|
81
|
+
"jsdom": "^27.1.0",
|
|
82
82
|
"node-html-parser": "^7.0.1",
|
|
83
83
|
"ora": "^9.0.0",
|
|
84
84
|
"resolve-bin": "^1.0.1",
|
|
85
|
-
"rimraf": "^6.0
|
|
85
|
+
"rimraf": "^6.1.0",
|
|
86
86
|
"terminal-link": "^5.0.0"
|
|
87
87
|
}
|
|
88
88
|
}
|