docs-i18n 0.2.1 → 0.2.3

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/dist/cli.js CHANGED
@@ -88,7 +88,7 @@ Options:
88
88
  }
89
89
  case "admin": {
90
90
  const port = Number(getOpt("port", "3456"));
91
- const { startAdmin } = await import("./server-HNVJP43X.js");
91
+ const { startAdmin } = await import("./server-U4KHO7JR.js");
92
92
  await startAdmin(config, port);
93
93
  break;
94
94
  }
@@ -2357,6 +2357,7 @@ var streamSSE = (c, cb, onError) => {
2357
2357
  // src/admin/server/services/job-manager.ts
2358
2358
  import { spawn } from "child_process";
2359
2359
  var PROJECT_ROOT = process.cwd();
2360
+ var CLI_BIN = process.argv[1] ?? "docs-i18n";
2360
2361
  var JobManager = class {
2361
2362
  jobs = /* @__PURE__ */ new Map();
2362
2363
  processes = /* @__PURE__ */ new Map();
@@ -2384,8 +2385,7 @@ var JobManager = class {
2384
2385
  };
2385
2386
  this.jobs.set(id, job);
2386
2387
  const args = [
2387
- "src/cli.ts",
2388
- // In dev; in production would be the installed bin
2388
+ CLI_BIN,
2389
2389
  "translate",
2390
2390
  "--lang",
2391
2391
  opts.lang,
@@ -2399,7 +2399,7 @@ var JobManager = class {
2399
2399
  if (opts.project) args.push("--project", opts.project);
2400
2400
  if (opts.model) args.push("--model", opts.model);
2401
2401
  if (opts.files?.length) args.push("--files", opts.files.join(","));
2402
- const proc = spawn("bun", args, {
2402
+ const proc = spawn("node", args, {
2403
2403
  cwd: PROJECT_ROOT,
2404
2404
  stdio: ["ignore", "pipe", "pipe"],
2405
2405
  env: { ...process.env, NO_TTY: "1", FORCE_COLOR: "0" }
@@ -2694,7 +2694,9 @@ async function startAdmin(config, port = 3456) {
2694
2694
  Bun.spawn([fallback, fullPath], { stdio: ["ignore", "ignore", "ignore"] });
2695
2695
  return c.json({ opened: fullPath, editor: fallback });
2696
2696
  });
2697
- const adminRoot = resolve2(import.meta.dir, "..");
2697
+ const thisFile = new URL(import.meta.url).pathname;
2698
+ const pkgRoot = resolve2(thisFile, "..", "..");
2699
+ const adminRoot = resolve2(pkgRoot, "src", "admin");
2698
2700
  try {
2699
2701
  const { createServer: createViteServer } = await import("vite");
2700
2702
  const vite = await createViteServer({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docs-i18n",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Universal documentation translation engine — parse, translate, cache, assemble, manage.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,7 +38,12 @@ export async function startAdmin(config: DocsI18nConfig, port = 3456) {
38
38
  return c.json({ opened: fullPath, editor: fallback });
39
39
  });
40
40
 
41
- const adminRoot = resolve(import.meta.dir, '..');
41
+ // Resolve admin UI root — works both in dev (src/admin/) and installed (node_modules/docs-i18n/src/admin/)
42
+ const thisFile = new URL(import.meta.url).pathname;
43
+ // In bundled dist: thisFile is like .../dist/cli.js or .../dist/server-XXX.js
44
+ // Admin UI source is at .../src/admin/
45
+ const pkgRoot = resolve(thisFile, '..', '..');
46
+ const adminRoot = resolve(pkgRoot, 'src', 'admin');
42
47
 
43
48
  // Try to load Vite for dev mode (SPA)
44
49
  try {
@@ -2,6 +2,8 @@ import { type ChildProcess, spawn } from 'node:child_process';
2
2
  import { resolve } from 'node:path';
3
3
 
4
4
  const PROJECT_ROOT = process.cwd();
5
+ // CLI binary path — reuse the same entry that started this process
6
+ const CLI_BIN = process.argv[1] ?? 'docs-i18n';
5
7
 
6
8
  export interface Job {
7
9
  id: string;
@@ -64,9 +66,8 @@ export class JobManager {
64
66
  };
65
67
  this.jobs.set(id, job);
66
68
 
67
- // Build CLI args — call docs-i18n translate
68
69
  const args = [
69
- 'src/cli.ts', // In dev; in production would be the installed bin
70
+ CLI_BIN,
70
71
  'translate',
71
72
  '--lang', opts.lang,
72
73
  '--version', opts.version,
@@ -78,7 +79,7 @@ export class JobManager {
78
79
  if (opts.model) args.push('--model', opts.model);
79
80
  if (opts.files?.length) args.push('--files', opts.files.join(','));
80
81
 
81
- const proc = spawn('bun', args, {
82
+ const proc = spawn('node', args, {
82
83
  cwd: PROJECT_ROOT,
83
84
  stdio: ['ignore', 'pipe', 'pipe'],
84
85
  env: { ...process.env, NO_TTY: '1', FORCE_COLOR: '0' },