create-volt 0.19.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 +13 -0
  2. package/index.js +34 -8
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ 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
+
7
19
  ## [0.19.0] - 2026-06-29
8
20
 
9
21
  ### Added
@@ -278,6 +290,7 @@ All notable changes to `create-volt` are documented here. The format follows
278
290
  watching and full-page hot reload. Supports `--skip-install` and `--force`,
279
291
  and auto-detects npm / pnpm / yarn / bun for the install step.
280
292
 
293
+ [0.20.0]: https://github.com/MIR-2025/volt/releases/tag/v0.20.0
281
294
  [0.19.0]: https://github.com/MIR-2025/volt/releases/tag/v0.19.0
282
295
  [0.18.0]: https://github.com/MIR-2025/volt/releases/tag/v0.18.0
283
296
  [0.17.0]: https://github.com/MIR-2025/volt/releases/tag/v0.17.0
package/index.js CHANGED
@@ -62,6 +62,7 @@ const positionals = [];
62
62
  let portArg = null;
63
63
  let templateArg = null;
64
64
  let outArg = null;
65
+ let userArg = null;
65
66
  for (let i = 0; i < argv.length; i++) {
66
67
  const a = argv[i];
67
68
  if (a === "--port") portArg = argv[++i];
@@ -70,6 +71,8 @@ for (let i = 0; i < argv.length; i++) {
70
71
  else if (a.startsWith("--template=")) templateArg = a.slice("--template=".length);
71
72
  else if (a === "--out") outArg = argv[++i];
72
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);
73
76
  else if (a.startsWith("-")) flags.add(a);
74
77
  else positionals.push(a);
75
78
  }
@@ -135,14 +138,8 @@ if (positionals[0] === "config") {
135
138
  process.exit(res.status ?? 0);
136
139
  }
137
140
 
138
- // --- `import-wxr` subcommand: import a WordPress export into markdown pages ---
139
- if (positionals[0] === "import-wxr") {
140
- const xmlPath = positionals[1];
141
- if (!xmlPath) die(`Usage: ${cyan("create-volt import-wxr <export.xml>")} [--out pages] [--drafts] [--force]`);
142
- if (!fs.existsSync(xmlPath)) die(`No such file: ${cyan(xmlPath)}`);
143
- const outDir = path.resolve(outArg || "pages");
144
- const { runImport } = await import("./lib/import-wxr.js");
145
- const { imported, stats } = runImport(fs.readFileSync(xmlPath, "utf8"), { drafts: flags.has("--drafts") });
141
+ // Write imported markdown pages to disk and print a summary (shared by both importers).
142
+ function emitImported(imported, stats, outDir) {
146
143
  fs.mkdirSync(outDir, { recursive: true });
147
144
  let written = 0;
148
145
  let skippedExisting = 0;
@@ -160,6 +157,35 @@ if (positionals[0] === "import-wxr") {
160
157
  console.log(`\n${cyan(`✓ Imported ${written}`)} page(s) → ${outDir}`);
161
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)` : ""}.`));
162
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"));
163
189
  process.exit(0);
164
190
  }
165
191
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-volt",
3
- "version": "0.19.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": {