create-volt 0.18.0 → 0.20.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/index.js +57 -0
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,29 @@ All notable changes to `create-volt` are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/), and this project adheres to
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.20.0] - 2026-06-29
8
+
9
+ ### Added
10
+ - **`import-wp` — fully-automated WordPress import over the REST API.**
11
+ `npx create-volt import-wp <https://site>` pulls published posts + pages
12
+ directly (paginated) into markdown `pages/` — no export file, and **no
13
+ credentials for public content**. Drafts/private need an Application Password
14
+ via `WP_USER` + `WP_APP_PASSWORD` (Basic auth, **sent only over HTTPS, never
15
+ logged**). Falls back to `import-wxr` if the REST API is disabled. Reuses the
16
+ WXR→markdown converter; unit-tested with a mocked fetch. `/docs/migrate`
17
+ updated to lead with the automated path.
18
+
19
+ ## [0.19.0] - 2026-06-29
20
+
21
+ ### Added
22
+ - **`import-wxr` — WordPress importer.** `npx create-volt import-wxr <export.xml>`
23
+ converts a WordPress WXR export into markdown pages: published pages + posts →
24
+ `pages/<slug>.md` with front-matter (title, date, tags), Gutenberg block
25
+ comments stripped, body kept as HTML/markdown; drafts + attachments skipped;
26
+ slugs sanitized + de-duplicated. Flags: `--out <dir>`, `--drafts`, `--force`.
27
+ Zero-dep parser (WXR is a consistent format); unit-tested. Lowers the cost of
28
+ moving off WordPress. New `/docs/migrate`.
29
+
7
30
  ## [0.18.0] - 2026-06-29
8
31
 
9
32
  ### Added
@@ -267,6 +290,8 @@ All notable changes to `create-volt` are documented here. The format follows
267
290
  watching and full-page hot reload. Supports `--skip-install` and `--force`,
268
291
  and auto-detects npm / pnpm / yarn / bun for the install step.
269
292
 
293
+ [0.20.0]: https://github.com/MIR-2025/volt/releases/tag/v0.20.0
294
+ [0.19.0]: https://github.com/MIR-2025/volt/releases/tag/v0.19.0
270
295
  [0.18.0]: https://github.com/MIR-2025/volt/releases/tag/v0.18.0
271
296
  [0.17.0]: https://github.com/MIR-2025/volt/releases/tag/v0.17.0
272
297
  [0.16.0]: https://github.com/MIR-2025/volt/releases/tag/v0.16.0
package/index.js CHANGED
@@ -61,12 +61,18 @@ const flags = new Set();
61
61
  const positionals = [];
62
62
  let portArg = null;
63
63
  let templateArg = null;
64
+ let outArg = null;
65
+ let userArg = null;
64
66
  for (let i = 0; i < argv.length; i++) {
65
67
  const a = argv[i];
66
68
  if (a === "--port") portArg = argv[++i];
67
69
  else if (a.startsWith("--port=")) portArg = a.slice("--port=".length);
68
70
  else if (a === "--template") templateArg = argv[++i];
69
71
  else if (a.startsWith("--template=")) templateArg = a.slice("--template=".length);
72
+ else if (a === "--out") outArg = argv[++i];
73
+ else if (a.startsWith("--out=")) outArg = a.slice("--out=".length);
74
+ else if (a === "--user") userArg = argv[++i];
75
+ else if (a.startsWith("--user=")) userArg = a.slice("--user=".length);
70
76
  else if (a.startsWith("-")) flags.add(a);
71
77
  else positionals.push(a);
72
78
  }
@@ -132,6 +138,57 @@ if (positionals[0] === "config") {
132
138
  process.exit(res.status ?? 0);
133
139
  }
134
140
 
141
+ // Write imported markdown pages to disk and print a summary (shared by both importers).
142
+ function emitImported(imported, stats, outDir) {
143
+ fs.mkdirSync(outDir, { recursive: true });
144
+ let written = 0;
145
+ let skippedExisting = 0;
146
+ for (const d of imported) {
147
+ const dest = path.join(outDir, d.filename);
148
+ if (fs.existsSync(dest) && !flags.has("--force")) {
149
+ skippedExisting++;
150
+ continue;
151
+ }
152
+ fs.writeFileSync(dest, d.markdown);
153
+ written++;
154
+ console.log(" " + dim(path.relative(process.cwd(), dest)));
155
+ }
156
+ const types = Object.entries(stats.byType).map(([t, n]) => `${n} ${t}`).join(", ");
157
+ console.log(`\n${cyan(`✓ Imported ${written}`)} page(s) → ${outDir}`);
158
+ console.log(dim(` source: ${stats.total} items (${types}); skipped ${stats.draftsSkipped} draft(s), ${stats.otherTypeSkipped} non-page/post item(s)${skippedExisting ? `, ${skippedExisting} already-present (use --force)` : ""}.`));
159
+ console.log(dim(" Enable the pages add-on to serve them: npm run dev -- --edit"));
160
+ }
161
+
162
+ // --- `import-wxr` subcommand: import an offline WordPress export (WXR file) ---
163
+ if (positionals[0] === "import-wxr") {
164
+ const xmlPath = positionals[1];
165
+ if (!xmlPath) die(`Usage: ${cyan("create-volt import-wxr <export.xml>")} [--out pages] [--drafts] [--force]`);
166
+ if (!fs.existsSync(xmlPath)) die(`No such file: ${cyan(xmlPath)}`);
167
+ const { runImport } = await import("./lib/import-wxr.js");
168
+ const { imported, stats } = runImport(fs.readFileSync(xmlPath, "utf8"), { drafts: flags.has("--drafts") });
169
+ emitImported(imported, stats, path.resolve(outArg || "pages"));
170
+ process.exit(0);
171
+ }
172
+
173
+ // --- `import-wp` subcommand: pull a live WordPress site over the REST API ---
174
+ if (positionals[0] === "import-wp") {
175
+ const site = positionals[1];
176
+ if (!site || !/^https?:\/\//i.test(site)) die(`Usage: ${cyan("create-volt import-wp <https://site.com>")} [--out pages] [--drafts] [--user U]\n Credentials (for drafts/private): set ${cyan("WP_APP_PASSWORD")} (an Application Password) and ${cyan("WP_USER")} or --user.`);
177
+ const user = userArg || process.env.WP_USER;
178
+ const appPassword = process.env.WP_APP_PASSWORD;
179
+ if ((user || appPassword) && !/^https:\/\//i.test(site)) die("Refusing to send credentials over a non-HTTPS URL.");
180
+ const { runImportFromWP } = await import("./lib/import-wxr.js");
181
+ console.log(dim(`Fetching ${site} via the WordPress REST API…${appPassword ? " (authenticated)" : ""}`));
182
+ let result;
183
+ try {
184
+ result = await runImportFromWP(site, { user, appPassword, drafts: flags.has("--drafts") });
185
+ } catch (e) {
186
+ die(`${e.message}\n If the REST API is disabled, export a WXR file and use ${cyan("create-volt import-wxr <export.xml>")}.`);
187
+ }
188
+ emitImported(result.imported, result.stats, path.resolve(outArg || "pages"));
189
+ process.exit(0);
190
+ }
191
+
135
192
  // --- `studio` subcommand: ephemeral, localhost-only data browser (server.js --studio) ---
136
193
  if (positionals[0] === "studio") {
137
194
  const cwd = process.cwd();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-volt",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "Scaffold a new Volt app — no-build, signals-based UI with Socket.io hot reload.",
5
5
  "type": "module",
6
6
  "bin": {