diffwiki 0.5.0-rc.202607230246.a14e916 → 0.5.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 (2) hide show
  1. package/dist/bin.js +10 -58
  2. package/package.json +2 -2
package/dist/bin.js CHANGED
@@ -3,9 +3,7 @@
3
3
  // src/cli.ts
4
4
  import { Command } from "commander";
5
5
  import {
6
- addExternalCollection,
7
6
  addTags,
8
- collectionGitStatus,
9
7
  createArticle,
10
8
  createCollection,
11
9
  doctor,
@@ -22,7 +20,6 @@ import {
22
20
  removeArticle,
23
21
  removePlugin,
24
22
  removeTags,
25
- resolveCwdCollection,
26
23
  setConfigValue,
27
24
  setTags,
28
25
  updateArticleBody
@@ -153,33 +150,6 @@ async function stopUi() {
153
150
  return state;
154
151
  }
155
152
 
156
- // src/exporter.ts
157
- import { spawn as spawn2 } from "child_process";
158
- import fs2 from "fs";
159
- import path2 from "path";
160
- import { fileURLToPath as fileURLToPath2 } from "url";
161
- function localAppExporter() {
162
- const candidates = [
163
- path2.resolve(path2.dirname(fileURLToPath2(import.meta.url)), "../../../apps/wiki/bin/export.mjs"),
164
- path2.resolve(process.cwd(), "apps/wiki/bin/export.mjs")
165
- ];
166
- return candidates.find((p) => fs2.existsSync(p));
167
- }
168
- async function runExport(opts) {
169
- const out = path2.resolve(opts.out);
170
- const local = localAppExporter();
171
- const override = process.env.DIFFWIKI_APP_CMD ?? (local ? `node ${local}` : void 0);
172
- const [cmd, ...prefix] = override ? override.split(" ") : ["npx", "-y", "diffwiki-app@latest"];
173
- const args = [...prefix, "export", "--out", out, "--base", opts.base];
174
- if (override) console.log(`Exporting via ${override}`);
175
- await new Promise((resolve, reject) => {
176
- const child = spawn2(cmd, args, { stdio: "inherit", env: process.env });
177
- child.on("error", reject);
178
- child.on("close", (code) => code === 0 ? resolve() : reject(new Error(`export failed (exit ${code})`)));
179
- });
180
- console.log(`Static site written to ${out}`);
181
- }
182
-
183
153
  // src/cli.ts
184
154
  var icon = (level) => level === "ok" ? "\u2713" : level === "warn" ? "!" : "\u2716";
185
155
  function createProgram() {
@@ -196,28 +166,17 @@ function createProgram() {
196
166
  return;
197
167
  }
198
168
  for (const c of collections) {
199
- const status = await collectionGitStatus(c);
200
- const branch = status?.branch ? ` (${status.branch})` : "";
201
- console.log(`${c.name} [${c.type}] ${c.path}${branch}`);
169
+ console.log(`${c.name} [${c.type}] ${c.path}`);
202
170
  }
203
171
  })
204
172
  );
205
- program.command("add").description("Add the current git repo as an external collection (docs dir, no diffwiki.yaml)").option("-d, --docs <dir>", "content dir relative to repo root", "docs").action(
206
- withErrors(async (opts) => {
207
- const entry = await addExternalCollection({ cwd: process.cwd(), docsDir: opts.docs });
208
- const status = await collectionGitStatus(entry);
209
- const branch = status?.branch ? ` (${status.branch})` : "";
210
- console.log(`Added "${entry.name}"${branch} \u2192 ${entry.path}`);
211
- console.log("Registered globally \u2014 discoverable via: diffwiki list");
212
- })
213
- );
214
173
  program.command("create").description("Create a new global collection").argument("<name>", "collection name").action(
215
174
  withErrors(async (name) => {
216
175
  const entry = await createCollection(name);
217
176
  console.log(`Created collection "${entry.name}" at ${entry.path}`);
218
177
  })
219
178
  );
220
- program.command("add-article").description("Add an article to a collection").requiredOption("-p, --path <target>", '"[collection:]title"').option("-t, --tag <tag>", "tag (repeatable, comma-separated)", collect, []).argument("[body]", "markdown body").action(
179
+ program.command("add").description("Add an article to a collection").requiredOption("-p, --path <target>", '"[collection:]title"').option("-t, --tag <tag>", "tag (repeatable, comma-separated)", collect, []).argument("[body]", "markdown body").action(
221
180
  withErrors(async (body, opts) => {
222
181
  const article = await createArticle({
223
182
  target: opts.path,
@@ -227,13 +186,13 @@ function createProgram() {
227
186
  console.log(article.path);
228
187
  })
229
188
  );
230
- program.command("update-article").description("Replace an article's body").requiredOption("-p, --path <target>", '"collection:path"').argument("<body>", "new markdown body").action(
189
+ program.command("update").description("Replace an article's body").requiredOption("-p, --path <target>", '"collection:path"').argument("<body>", "new markdown body").action(
231
190
  withErrors(async (body, opts) => {
232
191
  const article = await updateArticleBody(opts.path, body);
233
192
  console.log(`Updated ${article.path}`);
234
193
  })
235
194
  );
236
- program.command("remove-article").description("Delete an article").requiredOption("-p, --path <target>", '"collection:path"').action(
195
+ program.command("remove").description("Delete an article").requiredOption("-p, --path <target>", '"collection:path"').action(
237
196
  withErrors(async (opts) => {
238
197
  const removed = await removeArticle(opts.path);
239
198
  console.log(`Removed ${removed}`);
@@ -344,11 +303,6 @@ function createProgram() {
344
303
  console.log("Registered globally \u2014 discoverable via: diffwiki list");
345
304
  })
346
305
  );
347
- program.command("export").description("Generate a static site (deployable to GitHub Pages)").requiredOption("-o, --out <dir>", "output directory").option("-b, --base <path>", "base URL path (e.g. /my-repo/ for GitHub Pages)", "/").action(
348
- withErrors(async (opts) => {
349
- await runExport({ out: opts.out, base: opts.base });
350
- })
351
- );
352
306
  program.command("config-set").description("Set a config value (e.g. defaultCollection, or defaultSearch <engine[:type]>)").argument("<key>", "config key").argument("<value>", "config value").action(
353
307
  withErrors(async (key, value) => {
354
308
  await setConfigValue(key, value);
@@ -409,10 +363,8 @@ function createProgram() {
409
363
  state = await startUi(Number(opts.port));
410
364
  await waitForServer(state.url);
411
365
  }
412
- const coll = await resolveCwdCollection(process.cwd());
413
- const target = coll ? `${state.url}/${encodeURIComponent(coll.name)}` : state.url;
414
- openBrowser(target);
415
- console.log(`Opening ${target}`);
366
+ openBrowser(state.url);
367
+ console.log(`Opening ${state.url}`);
416
368
  })
417
369
  );
418
370
  return program;
@@ -421,14 +373,14 @@ function createProgram() {
421
373
  // src/logging.ts
422
374
  import { mkdirSync } from "fs";
423
375
  import os from "os";
424
- import path3 from "path";
376
+ import path2 from "path";
425
377
  import { configureSync, getConfig } from "@logtape/logtape";
426
378
  import { getRotatingFileSink } from "@logtape/file";
427
379
  import { resolveLogLevel } from "diffwiki-core";
428
380
  var configured = false;
429
381
  function diffwikiHome() {
430
382
  const override = process.env.DIFFWIKI_HOME;
431
- return override && override.length > 0 ? override : path3.join(os.homedir(), ".diffwiki");
383
+ return override && override.length > 0 ? override : path2.join(os.homedir(), ".diffwiki");
432
384
  }
433
385
  function resolveCliLevel(argv) {
434
386
  if (argv.includes("-v") || argv.includes("--verbose")) return "debug";
@@ -445,9 +397,9 @@ function configureCliLogging(argv = process.argv) {
445
397
  if (configured || getConfig() != null) return;
446
398
  configured = true;
447
399
  const level = resolveCliLevel(argv);
448
- const logsDir = path3.join(diffwikiHome(), "logs");
400
+ const logsDir = path2.join(diffwikiHome(), "logs");
449
401
  mkdirSync(logsDir, { recursive: true });
450
- const logFile = path3.join(logsDir, "diffwiki.log");
402
+ const logFile = path2.join(logsDir, "diffwiki.log");
451
403
  const stderrSink = (record) => {
452
404
  process.stderr.write(formatLine(record) + "\n");
453
405
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diffwiki",
3
- "version": "0.5.0-rc.202607230246.a14e916",
3
+ "version": "0.5.0",
4
4
  "description": "diffwiki command-line interface",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  "@logtape/logtape": "^2.2.4",
18
18
  "@logtape/file": "^2.2.4",
19
19
  "commander": "^13.0.0",
20
- "diffwiki-core": "0.5.0-rc.202607230246.a14e916"
20
+ "diffwiki-core": "0.5.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "^22.0.0"