wordpress-to-kirby 0.0.2 → 0.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.
@@ -0,0 +1,13 @@
1
+ # Contributing
2
+
3
+ We welcome contributions from the community. Please open an issue before committing significant work.
4
+
5
+ All contributions to this project, in code or in prose, must be human-authored.
6
+
7
+ ## Local development
8
+
9
+ Running tests:
10
+
11
+ ```bash
12
+ npm run test
13
+ ```
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dan Burzo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -4,21 +4,115 @@ A Node.js-based command-line utility to convert a WordPress XML export to a dire
4
4
 
5
5
  ## Getting started
6
6
 
7
- Install from npm:
7
+ Install [`wordpress-to-kirby`](https://npmjs.com/package/wordpress-to-kirby/) from npm:
8
8
 
9
9
  ```bash
10
10
  npm install wordpress-to-kirby
11
11
  ```
12
12
 
13
- Or run with npx without installing:
13
+ Or run it with `npx` without installing:
14
14
 
15
15
  ```bash
16
16
  npx wordpress-to-kirby
17
17
  ```
18
18
 
19
+ Use `wordpress-to-kirby --help` for information on usage and available commands and options.
20
+
21
+ ## Commands
22
+
23
+ ### `wordpress-to-kirby generate`
24
+
25
+ Generate a Kirby CMS file structure from the provided XML file. Usage:
26
+
27
+ ```bash
28
+ wordpress-to-kirby generate [options] <wordpress-xml-file>
29
+ ```
30
+
31
+ ### `wordpress-to-kirby download`
32
+
33
+ Download the attachments found in the provided XML file. Usage:
34
+
35
+ ```bash
36
+ wordpress-to-kirby download [options] <wordpress-xml-file>
37
+ ```
38
+
19
39
  ## Options
20
40
 
21
- Use `wordpress-to-kirby --help` for a list of options.
41
+ ### General options
42
+
43
+ #### `-h, --help`
44
+
45
+ Prints out this help information.
46
+
47
+ #### `-v, --version`
48
+
49
+ Shows the program version.
50
+
51
+ #### `-o, --outdir`
52
+
53
+ Root directory to which to write the output, relative to the current working directory. Default: `wordpress-to-kirby`.
54
+
55
+ #### `--contentdir`
56
+
57
+ For the `download` command, point to the location of a `wp-content` directory from which to download attachments.
58
+
59
+ The path can be:
60
+
61
+ * an absolute or relative local path;
62
+ * a fully-qualified URL, including the `wp-content` segment, e.g. `https://mywebsite.local/wp-content/`
63
+
64
+ #### `--parse=<rules>`
65
+
66
+ Instructions to parse some fields, specified as `<key>=<parser>,<key>=<parser>,…`.
67
+
68
+ Supported parsers:
69
+
70
+ * `php`: deserialize PHP object;
71
+ * `yaml`: parse as YAML;
72
+ * `json`: parse as JSON;
73
+ * `html`: parse as HTML.
74
+
75
+ #### `--serialize=<rules>`
76
+
77
+ Instructions to serialize some fields, specified as `<key>=<serializer>,<key>=<serializer>,…`.
78
+
79
+ Supported serializers:
80
+
81
+ * `php`: serialize as PHP object;
82
+ * `yaml`: serialize as YAML;
83
+ * `json`: serialize as JSON;
84
+ * `html`: serialize as HTML.
85
+
86
+ ### `--exclude-fields=<fields>`
87
+
88
+ Exclude certain fields from the output, specified as a comma-separated list of fields.
89
+
90
+ ### `--include-fields=<fields>`
91
+
92
+ Only include certain fields from the output, specified as a comma-separated list of fields. When `--include-fields` is specified, the `--exclude-fields` option is ignored.
93
+
94
+ ### `--exclude-types=<types>`
95
+
96
+ Exclude certain post types from the output, specified as a comma-separated list of post types.
97
+
98
+ ### `--include-types=<types>`
99
+
100
+ Only include certain post types from the output, specified as a comma-separated list of post types.
101
+
102
+ When `--include-types` is specified, the `--exclude-types` option is ignored.
103
+
104
+ ## Keys extracted from the XML
105
+
106
+ The following keys are extracted from the top level of the WordPress XML export:
107
+
108
+ `title`, `link`, `pubDate`, `creator`, `guid`, `guid_isPermaLink`, `description`, `content`, `excerpt`, `post_id`, `post_date`, `post_date_gmt`, `post_modified`, `post_modified_gmt`, `comment_status`, `ping_status`, `post_name`, `status`, `post_parent`, `menu_order`, `post_type`, `post_password`, `is_sticky`, `attachment_url` (only populated for the `attachment` post type).
109
+
110
+ Fields from `<wp:postmeta>` are included in the output with the `postmeta*` prefix.
111
+
112
+ ## Keys generated from scratch
113
+
114
+ * `uuid: <string>`, containing 16 random alphanumeric characters.
115
+ * `template: 'attachment'` is added to attachments.
22
116
 
23
117
  ## Prior art
24
118
 
package/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { readFile, writeFile, mkdir } from 'node:fs/promises';
3
- import { join, dirname, relative } from 'node:path';
2
+ import { readFile, writeFile, copyFile, mkdir } from 'node:fs/promises';
3
+ import { join, dirname, extname, relative, sep } from 'node:path';
4
4
 
5
5
  import opsh from 'opsh';
6
6
  import { JSDOM } from 'jsdom';
7
- import { load } from 'js-yaml';
7
+ import { load, dump } from 'js-yaml';
8
8
  import { serialize, unserialize } from 'php-serialize';
9
9
 
10
10
  import { serialize as serialize_item } from './src/kirby-txt.js';
@@ -32,13 +32,24 @@ if (options.v || options.version) {
32
32
  process.exit();
33
33
  }
34
34
 
35
- if (operands.length !== 1) {
36
- console.error(`Exactly one operand is supported, ${operands.length} provided. Exiting.`);
35
+ const [command, ...files ] = operands;
36
+
37
+ if (command !== 'generate' && command !== 'download') {
38
+ console.error(`Supported commands: generate, download; ${command} provided. Exiting.`);
37
39
  process.exit(1);
38
40
  }
39
41
 
40
- const parsers = {};
41
- const serializers = {};
42
+ if (files.length !== 1) {
43
+ console.error(`Exactly one file is supported, ${files.length} provided. Exiting.`);
44
+ process.exit(1);
45
+ }
46
+
47
+ const parsers = {
48
+ 'postmeta_wp_attachment_metadata': 'php'
49
+ };
50
+ const serializers = {
51
+ 'postmeta_wp_attachment_metadata': 'json'
52
+ };
42
53
 
43
54
  function commasep(val) {
44
55
  return (val || '').split(/\s*,\s*/).filter(Boolean);
@@ -64,15 +75,18 @@ commasep(options.serialize).forEach(pair => {
64
75
  serializers[key] = val;
65
76
  });
66
77
 
67
- const keys_to_include = new Set(commasep(options.include));
68
- const keys_to_exclude = new Set(options.include ? [] : commasep(options.exclude));
78
+ const fields_to_include = new Set(commasep(options['include-fields']));
79
+ const fields_to_exclude = new Set(options['include-fields'] ? [] : commasep(options['exclude-fields']));
80
+
81
+ const types_to_include = new Set(commasep(options['include-types']));
82
+ const types_to_exclude = new Set(options['include-types'] ? [] : commasep(options['exclude-types']));
69
83
 
70
84
  function process_item(item) {
71
85
  let entries = Object.entries(item);
72
- if (keys_to_include.size) {
73
- entries = entries.filter(entry => keys_to_include.has(entry[0]));
74
- } else if (keys_to_exclude.size) {
75
- entries = entries.filter(entry => !keys_to_exclude.has(entry[0]));
86
+ if (fields_to_include.size) {
87
+ entries = entries.filter(entry => fields_to_include.has(entry[0]));
88
+ } else if (fields_to_exclude.size) {
89
+ entries = entries.filter(entry => !fields_to_exclude.has(entry[0]));
76
90
  }
77
91
  return Object.fromEntries(
78
92
  entries.map(entry => [
@@ -91,21 +105,30 @@ function parse_value(key, value) {
91
105
  try {
92
106
  return unserialize(value);
93
107
  } catch(err) {
94
- console.error(`Can’t serialize PHP value, skipping: ${value}`);
108
+ console.error(`Warn: Can’t serialize PHP value, skipping: ${value}`);
95
109
  return value;
96
110
  }
97
111
  case 'yaml':
98
112
  try {
99
113
  return load(value);
100
114
  } catch (err) {
101
- console.error(`Can’t serialize YAML value, skipping: ${value}`);
115
+ console.error(`Warn: Can’t serialize YAML value, skipping: ${value}`);
102
116
  return value;
103
117
  }
104
118
  case 'json':
105
119
  try {
106
120
  return JSON.parse(value);
107
121
  } catch(err) {
108
- console.error(`Can’t serialize JSON value, skipping: ${value}`);
122
+ console.error(`Warn: Can’t serialize JSON value, skipping: ${value}`);
123
+ return value;
124
+ }
125
+ case 'html':
126
+ try {
127
+ return new JSDOM(
128
+ `<!doctype html><html><head></head><body>${value}</body></html>`
129
+ ).window.document;
130
+ } catch(err) {
131
+ console.error(`Warn: Can’t serialize JSON value, skipping: ${value}`);
109
132
  return value;
110
133
  }
111
134
  default:
@@ -122,21 +145,28 @@ function serialize_value(key, value) {
122
145
  try {
123
146
  return serialize(value);
124
147
  } catch(err) {
125
- console.error(`Can’t stringify PHP value, skipping: ${value}`);
148
+ console.error(`Warn: Can’t stringify PHP value, skipping: ${value}`);
126
149
  return value;
127
150
  }
128
151
  case 'yaml':
129
152
  try {
130
153
  return dump(value);
131
154
  } catch (err) {
132
- console.error(`Can’t stringify YAML value, skipping: ${value}`);
155
+ console.error(`Warn: Can’t stringify YAML value, skipping: ${value}`);
133
156
  return value;
134
157
  }
135
158
  case 'json':
136
159
  try {
137
160
  return JSON.stringify(value);
138
161
  } catch(err) {
139
- console.error(`Can’t stringify JSON value, skipping: ${value}`);
162
+ console.error(`Warn: Can’t stringify JSON value, skipping: ${value}`);
163
+ return value;
164
+ }
165
+ case 'html':
166
+ try {
167
+ return value.body.innerHTML;
168
+ } catch(err) {
169
+ console.error(`Warn: Can’t stringify HTML value, skipping: ${value}`);
140
170
  return value;
141
171
  }
142
172
  default:
@@ -145,13 +175,22 @@ function serialize_value(key, value) {
145
175
  }
146
176
 
147
177
  const document = new JSDOM(
148
- await readFile(operands[0], 'utf8'),
178
+ await readFile(files[0], 'utf8'),
149
179
  {
150
180
  contentType: 'application/xml'
151
181
  }
152
182
  ).window.document;
153
183
 
154
- const items = Array.from(document.querySelectorAll('item')).map(extract);
184
+ const items = Array.from(document.querySelectorAll('item'))
185
+ .map(extract)
186
+ .filter(item => {
187
+ if (types_to_include.size) {
188
+ return types_to_include.has(item.post_type);
189
+ } else if (types_to_exclude.size) {
190
+ return !types_to_exclude.has(item.post_type);
191
+ }
192
+ return true;
193
+ });
155
194
 
156
195
  function extract(item) {
157
196
  const select = (sel, ns, all = false, el) => {
@@ -162,39 +201,42 @@ function extract(item) {
162
201
  }
163
202
  return (el ?? item).querySelector(sel);
164
203
  }
204
+
205
+ const post_type = parse_value('post_type', select('post_type', 'wp').textContent);
206
+
165
207
  return {
166
- title: select('title').textContent,
167
- link: select('link').textContent,
168
- pubDate: select('pubDate').textContent,
169
- creator: select('creator', 'dc').textContent,
170
- guid: select('guid').textContent,
171
- guid_isPermaLink: select('guid').getAttribute('isPermaLink'),
172
- description: select('description').textContent,
173
- content: select('encoded', 'content').textContent,
174
- excerpt: select('encoded', 'excerpt').textContent,
175
- post_id: select('post_id', 'wp').textContent,
176
- post_date: select('post_date', 'wp').textContent,
177
- post_date_gmt: select('post_date_gmt', 'wp').textContent,
178
- post_modified: select('post_modified', 'wp').textContent,
179
- post_modified_gmt: select('post_modified_gmt', 'wp').textContent,
180
- comment_status: select('comment_status', 'wp').textContent,
181
- ping_status: select('ping_status', 'wp').textContent,
182
- post_name: select('post_name', 'wp').textContent,
183
- status: select('status', 'wp').textContent,
184
- post_parent: select('post_parent', 'wp').textContent,
185
- menu_order: select('menu_order', 'wp').textContent,
186
- post_type: select('post_type', 'wp').textContent,
187
- post_password: select('post_password', 'wp').textContent,
188
- is_sticky: select('is_sticky', 'wp').textContent,
208
+ title: parse_value('title', select('title').textContent),
209
+ link: parse_value('link', select('link').textContent),
210
+ pubDate: parse_value('pubDate', select('pubDate').textContent),
211
+ creator: parse_value('creator', select('creator', 'dc').textContent),
212
+ guid: parse_value('guid', select('guid').textContent),
213
+ guid_isPermaLink: parse_value('guid_isPermaLink', select('guid').getAttribute('isPermaLink')),
214
+ description: parse_value('description', select('description').textContent),
215
+ content: parse_value('content', select('encoded', 'content').textContent),
216
+ excerpt: parse_value('excerpt', select('encoded', 'excerpt').textContent),
217
+ post_id: parse_value('post_id', select('post_id', 'wp').textContent),
218
+ post_date: parse_value('post_date', select('post_date', 'wp').textContent),
219
+ post_date_gmt: parse_value('post_date_gmt', select('post_date_gmt', 'wp').textContent),
220
+ post_modified: parse_value('post_modified', select('post_modified', 'wp').textContent),
221
+ post_modified_gmt: parse_value('post_modified_gmt', select('post_modified_gmt', 'wp').textContent),
222
+ comment_status: parse_value('comment_status', select('comment_status', 'wp').textContent),
223
+ ping_status: parse_value('ping_status', select('ping_status', 'wp').textContent),
224
+ post_name: parse_value('post_name', select('post_name', 'wp').textContent),
225
+ status: parse_value('status', select('status', 'wp').textContent),
226
+ post_parent: parse_value('post_parent', select('post_parent', 'wp').textContent),
227
+ menu_order: parse_value('menu_order', select('menu_order', 'wp').textContent),
228
+ post_type,
229
+ post_password: parse_value('post_password', select('post_password', 'wp').textContent),
230
+ attachment_url: parse_value('attachment_url', select('attachment_url', 'wp')?.textContent),
231
+ is_sticky: parse_value('is_sticky', select('is_sticky', 'wp').textContent),
189
232
  ...select('postmeta', 'wp', true).reduce((acc, it) => {
190
233
  const key = select('meta_key', 'wp', false, it).textContent;
191
234
  const value = select('meta_value', 'wp', false, it).textContent;
192
- if (!key.match(/^_/)) {
193
- acc['postmeta_' + key] = parse_value('postmeta_' + key, value);
194
- }
235
+ acc['postmeta' + key] = parse_value('postmeta' + key, value);
195
236
  return acc;
196
237
  }, {}),
197
- uuid: uuid()
238
+ uuid: uuid(),
239
+ template: post_type === 'attachment' ? 'attachment' : undefined
198
240
  }
199
241
  }
200
242
 
@@ -203,80 +245,275 @@ const outdir = options.o || options.outdir || 'wordpress-to-kirby';
203
245
  function outpath(item) {
204
246
  let parts = (new URL(item.link)).pathname.split('/').filter(Boolean);
205
247
  if (item.post_type === 'attachment') {
206
- parts = ['attachments', ...parts];
248
+ const filename = parts.pop() + (extname(item.attachment_url ?? '') ?? '') + '.txt';
249
+ return join(outdir, 'content', ...parts.filter(p => p !== 'attachment'), filename);
207
250
  }
208
251
  if (!parts.length) {
209
252
  parts = ['_unlinked', item.post_type, item.post_id, ...parts];
210
253
  }
211
- return join(outdir, ...parts, item.post_type + '.txt');
254
+ return join(outdir, 'content', ...parts, item.post_type + '.txt');
212
255
  }
213
256
 
214
- for await (let item of items) {
215
- const destination = outpath(item);
216
- await mkdir(dirname(destination), { recursive: true });
217
- await writeFile(destination, serialize_item(process_item(item)));
218
- };
219
-
220
- const metadata = {
221
- output: []
222
- };
257
+ if (command === 'generate') {
258
+ for await (let item of items) {
259
+ const destination = outpath(item);
260
+ await mkdir(dirname(destination), { recursive: true });
261
+ await writeFile(destination, serialize_item(process_item(item)));
262
+ };
263
+
264
+ const metadata = {
265
+ output: [],
266
+ types: {}
267
+ };
268
+
269
+ items.forEach(item => {
270
+ metadata.output.push({
271
+ post_id: +item.post_id,
272
+ post_type: item.post_type,
273
+ url: item.attachment_url ?? item.link,
274
+ uuid: item.uuid,
275
+ path: relative(outdir, outpath(item))
276
+ });
277
+ metadata.types[item.post_type] = (metadata.types[item.post_type] || [])
278
+ .concat(Object.keys(item));
279
+ });
223
280
 
224
- items.forEach(item => {
225
- metadata.output.push({
226
- post_id: +item.post_id,
227
- uuid: item.uuid,
228
- path: relative(outdir, outpath(item))
281
+ const blueprints_path = join(outdir, 'site', 'blueprints');
282
+ await mkdir(join(blueprints_path, 'pages'), { recursive: true });
283
+ await mkdir(join(blueprints_path, 'files'), { recursive: true });
284
+
285
+ Object.keys(metadata.types).forEach(key => {
286
+ metadata.types[key] = Array.from(new Set(metadata.types[key])).sort();
287
+ // Make blueprints
288
+ const blueprint_content = metadata.types[key].reduce((acc, curr) => {
289
+ acc[curr] = {
290
+ type: 'text'
291
+ };
292
+ return acc;
293
+ }, {});
294
+
295
+ if (key === 'attachment') {
296
+ const blueprint_dest = join(
297
+ blueprints_path,
298
+ 'files',
299
+ key + '.yml'
300
+ );
301
+
302
+ writeFile(blueprint_dest, dump({
303
+ fields: blueprint_content
304
+ }));
305
+
306
+ } else {
307
+ const blueprint_dest = join(
308
+ blueprints_path,
309
+ 'pages',
310
+ key + '.yml'
311
+ );
312
+
313
+ writeFile(blueprint_dest, dump({
314
+ tabs: {
315
+ fields: {
316
+ label: 'Fields',
317
+ sections: {
318
+ fields: {
319
+ type: 'fields',
320
+ fields: blueprint_content
321
+ }
322
+ }
323
+ },
324
+ pages: {
325
+ label: 'Pages',
326
+ sections: {
327
+ pages: {
328
+ type: 'pages'
329
+ }
330
+ }
331
+ },
332
+ files: {
333
+ label: 'Files',
334
+ sections: {
335
+ files: {
336
+ type: 'files'
337
+ }
338
+ }
339
+ }
340
+ }
341
+ }));
342
+ }
229
343
  });
230
- });
231
344
 
232
- await writeFile(join(outdir, 'metadata.json'), JSON.stringify(metadata, null, '\t'));
345
+
346
+ const default_blueprint = {
347
+ tabs: {
348
+ pages: {
349
+ label: 'Pages',
350
+ sections: {
351
+ pages: {
352
+ type: 'pages'
353
+ }
354
+ }
355
+ },
356
+ files: {
357
+ label: 'Files',
358
+ sections: {
359
+ files: {
360
+ type: 'files'
361
+ }
362
+ }
363
+ }
364
+ }
365
+ };
366
+ await writeFile(join(blueprints_path, 'pages', 'default.yml'), dump(default_blueprint));
367
+ await writeFile(join(blueprints_path, 'site.yml'), dump(default_blueprint));
368
+
369
+ await writeFile(join(outdir, 'metadata.json'), JSON.stringify(metadata, null, '\t'));
370
+ }
371
+
372
+ if (command === 'download') {
373
+
374
+ const contentdir = options.contentdir ?
375
+ (URL.canParse(options.contentdir) ?
376
+ new URL(options.contentdir) :
377
+ options.contentdir
378
+ ) : null;
379
+
380
+ const fetched = new Set();
381
+
382
+ for await (let item of items.filter(it => it.post_type === 'attachment')) {
383
+ const attachment = process_item(item);
384
+ const dest = outpath(attachment).replace(/\.txt$/, '');
385
+ if (contentdir) {
386
+ const pathname = new URL(attachment.attachment_url).pathname
387
+ .split('/')
388
+ .filter(p => p && p !== 'wp-content')
389
+ .join(sep);
390
+ if (typeof contentdir === 'string') {
391
+ await copyFile(join(contentdir, pathname), dest);
392
+ } else {
393
+ const url = new URL(pathname, contentdir);
394
+ if (fetched.has(url)) {
395
+ console.log(`Already fetched, skipping: ${url}`);
396
+ } else {
397
+ console.log(`Fetching: ${url}`);
398
+ await mkdir(dirname(dest), { recursive: true });
399
+ await writeFile(
400
+ dest,
401
+ (await fetch(url)).body
402
+ );
403
+ console.log(`Fetched: ${url}`);
404
+ fetched.add(url);
405
+ }
406
+ }
407
+ } else {
408
+ if (fetched.has(attachment.attachment_url)) {
409
+ console.log(`Already fetched, skipping: ${attachment.attachment_url}`);
410
+ } else {
411
+ console.log(`Fetching: ${attachment.attachment_url}`);
412
+ await mkdir(dirname(dest), { recursive: true });
413
+ await writeFile(
414
+ dest,
415
+ (await fetch(attachment.attachment_url)).body
416
+ );
417
+ console.log(`Fetched: ${attachment.attachment_url}`);
418
+ fetched.add(attachment.attachment_url);
419
+ }
420
+ }
421
+
422
+ }
423
+ }
233
424
 
234
425
  function printHelp() {
235
426
  console.log(`wordpress-to-kirby:
236
427
 
237
- transform a WordPress XML export
238
- into a directory of Kirby CMS files.
428
+ transform a WordPress XML export into a directory of Kirby CMS files.
239
429
 
240
430
  Usage:
241
431
 
242
- wordpress-to-kirby <options> <xml-file>
432
+ wordpress-to-kirby generate [options] <wordpress-xml-file>
433
+ wordpress-to-kirby download [options] <wordpress-xml-file>
434
+
435
+ Commands available:
243
436
 
244
- Options:
437
+ generate
438
+ Generate a Kirby CMS file structure from the provided XML file.
439
+
440
+ download
441
+ Download attachments.
442
+
443
+ Options available:
245
444
 
246
445
  -h, --help
247
- Print out this help information.
446
+
447
+ Prints out this help information.
248
448
 
249
449
  -v, --version
250
- Show the program version.
450
+
451
+ Shows the program version.
251
452
 
252
453
  -o, --outdir
253
- Root directory to output to, relative to CWD.
454
+
455
+ Root directory to which to write the output,
456
+ relative to the current working directory.
457
+
254
458
  Default: 'wordpress-to-kirby'
255
459
 
460
+ --contentdir
461
+
462
+ For the 'download' command, point to the location
463
+ of a 'wp-content' directory from which to download attachments.
464
+
465
+ The path can be:
466
+
467
+ * an absolute or relative local path;
468
+ * a fully-qualified URL, including the 'wp-content' segment,
469
+ e.g. https://mywebsite.local/wp-content/
470
+
256
471
  --parse=<rules>
257
- Instructions to parse some fields, in the form of:
472
+
473
+ Instructions to parse some fields, specified as:
258
474
  "<key>=<parser>,<key>=<parser>,…"
475
+
259
476
  Supported parsers:
260
- php: deserialize PHP object.
261
- yaml: parse as YAML.
262
- json: parse as JSON.
263
- Prefix post meta fields with "postmeta".
477
+ * php: deserialize PHP object.
478
+ * yaml: parse as YAML.
479
+ * json: parse as JSON.
480
+ * html: parse as HTML.
264
481
 
265
482
  --serialize=<rules>
266
- Instructions to serialize some fields, in the form of:
483
+
484
+ Instructions to serialize some fields, specified as:
267
485
  "<key>=<serializer>,<key>=<serializer>,…"
268
- Supported parsers:
269
- php: serialize as PHP object.
270
- yaml: serialize as YAML.
271
- json: serialize as JSON.
272
- Prefix post meta fields with "postmeta".
273
486
 
274
- --exclude=<keys>
275
- Exclude certain keys from the output. Comma-separated.
487
+ Supported serializers:
488
+ * php: serialize as PHP object.
489
+ * yaml: serialize as YAML.
490
+ * json: serialize as JSON.
491
+ * html: serialize as HTML.
492
+
493
+ --exclude-fields=<fields>
494
+
495
+ Exclude certain fields from the output, specified as a
496
+ comma-separated list of fields.
497
+
498
+ --include-fields=<fields>
499
+
500
+ Only include certain fields from the output, specified as a
501
+ comma-separated list of fields.
502
+
503
+ When '--include-fields' is specified, the '--exclude-fields'
504
+ option is ignored.
505
+
506
+ --exclude-types=<types>
507
+
508
+ Exclude certain post types from the output, specified as a
509
+ comma-separated list of post types.
510
+
511
+ --include-types=<types>
512
+ Only include certain post types from the output, specified as a
513
+ comma-separated list of post types.
276
514
 
277
- --include=<keys>
278
- Only include certain keys from the output. Comma-separated.
279
- When '--include' is specified, any '--exclude' is ignored.
515
+ When '--include-types' is specified, the '--exclude-types'
516
+ option is ignored.
280
517
 
281
518
  Keys extracted from the XML:
282
519
 
@@ -286,15 +523,17 @@ Keys extracted from the XML:
286
523
  description, content, excerpt, post_id, post_date,
287
524
  post_date_gmt, post_modified, post_modified_gmt,
288
525
  comment_status, ping_status, post_name, status,
289
- post_parent, menu_order, post_type, post_password, is_sticky
526
+ post_parent, menu_order, post_type, post_password, is_sticky,
527
+ attachment_url
290
528
 
291
529
  Post metadata:
292
530
 
293
- Fields from <wp:postmeta> not starting with an underscore
294
- are included in the output with the 'postmeta_*' prefix.
531
+ Fields from '<wp:postmeta>' are included in the output
532
+ with the 'postmeta*' prefix.
295
533
 
296
534
  Keys generated from scratch:
297
535
 
298
- uuid — sixteen random alphanumeric characters.
536
+ uuid — sixteen random alphanumeric characters.
537
+ template: 'attachment' — added to attachments only.
299
538
  `);
300
539
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wordpress-to-kirby",
3
- "version": "0.0.2",
3
+ "version": "0.2.0",
4
4
  "description": "A CLI to convert WordPress XML to Kirby CMS files",
5
5
  "homepage": "https://github.com/tocmai/wordpress-to-kirby#readme",
6
6
  "bugs": {