@caweb/cli 1.3.5 → 1.3.7
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.js +13 -7
- package/lib/cli.js +2 -2
- package/package.json +2 -2
package/commands/sync.js
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
getTaxonomies,
|
|
15
15
|
createTaxonomies
|
|
16
16
|
} from '../lib/index.js';
|
|
17
|
-
import { get } from 'http';
|
|
18
17
|
|
|
19
18
|
const errors = [];
|
|
20
19
|
|
|
@@ -29,7 +28,7 @@ const errors = [];
|
|
|
29
28
|
*/
|
|
30
29
|
async function getParentItems( objects, request, tax = 'pages' ){
|
|
31
30
|
let parentItemsObjects = [];
|
|
32
|
-
let objectParentIds = objects.map((obj) => { return obj.parent; });
|
|
31
|
+
let objectParentIds = objects.map((obj) => { return obj.parent; }).filter(n => n);
|
|
33
32
|
|
|
34
33
|
while( objectParentIds.length > 0 ){
|
|
35
34
|
|
|
@@ -174,6 +173,8 @@ export default async function sync({
|
|
|
174
173
|
settings = await getTaxonomies({
|
|
175
174
|
...fromOptions,
|
|
176
175
|
fields: [
|
|
176
|
+
'title',
|
|
177
|
+
'description',
|
|
177
178
|
'show_on_front',
|
|
178
179
|
'page_on_front',
|
|
179
180
|
'posts_per_page'
|
|
@@ -238,11 +239,16 @@ export default async function sync({
|
|
|
238
239
|
* 3) save any linked media in the content of pages and posts.
|
|
239
240
|
*/
|
|
240
241
|
for( let m of mediaLibrary ){
|
|
242
|
+
// remove any new line characters.
|
|
243
|
+
m.source_url = m.source_url.replace('\n','');
|
|
244
|
+
|
|
241
245
|
// check if the media is attached to a page.
|
|
242
246
|
// if tax is undefined, we collect all media attached to posts and pages.
|
|
243
|
-
// if tax is defined,
|
|
247
|
+
// if tax is defined, if include is undefined or media is matches post/page, we collect the media.
|
|
244
248
|
if( ( ! tax && m.post ) ||
|
|
245
|
-
|
|
249
|
+
( tax &&
|
|
250
|
+
( undefined === include || include.includes( m.id.toString() ) )
|
|
251
|
+
) ){
|
|
246
252
|
media.push( m );
|
|
247
253
|
|
|
248
254
|
// we don't have to check any further.
|
|
@@ -253,11 +259,11 @@ export default async function sync({
|
|
|
253
259
|
// if the media is featured on a post or linked in the content.
|
|
254
260
|
if( p.featured_media === m.id ||
|
|
255
261
|
p.content.rendered.match( new RegExp(`src=”(${m.source_url}.*)”`, 'g') )){
|
|
256
|
-
|
|
257
|
-
|
|
262
|
+
media.push( m );
|
|
263
|
+
}
|
|
258
264
|
}
|
|
259
265
|
}
|
|
260
|
-
|
|
266
|
+
|
|
261
267
|
// filter any duplicate media.
|
|
262
268
|
media = media.filter((m, index, self) => { return index === self.findIndex((t) => { return t.id === m.id; })} );
|
|
263
269
|
|
package/lib/cli.js
CHANGED
|
@@ -272,12 +272,12 @@ export default function cli() {
|
|
|
272
272
|
|
|
273
273
|
// Test Command.
|
|
274
274
|
// Ensure this is commented out.
|
|
275
|
-
program.command('test')
|
|
275
|
+
/*program.command('test')
|
|
276
276
|
.description('Test commands on a WordPress environment')
|
|
277
277
|
//.addArgument(envArg)
|
|
278
278
|
.allowUnknownOption(true)
|
|
279
279
|
.action(withSpinner(env.test))
|
|
280
|
-
|
|
280
|
+
*/
|
|
281
281
|
addWPEnvCommands();
|
|
282
282
|
|
|
283
283
|
return program;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caweb/cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"description": "CAWebPublishing Command Line Interface.",
|
|
5
5
|
"exports": "./lib/env.js",
|
|
6
6
|
"type": "module",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"WP_DEBUG_DISPLAY": false,
|
|
49
49
|
"WP_MEMORY_LIMIT": "256M",
|
|
50
50
|
"WP_MAX_MEMORY_LIMIT": "512M",
|
|
51
|
-
"WP_PERMALINK": "/%postname%/",
|
|
51
|
+
"WP_PERMALINK": "/%year%/%monthnum%/%postname%/",
|
|
52
52
|
"ADMIN_COOKIE_PATH": "/",
|
|
53
53
|
"COOKIE_DOMAIN": "",
|
|
54
54
|
"COOKIEPATH": "",
|