docs-i18n 0.6.0 → 0.6.1
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
|
@@ -95,7 +95,7 @@ Options:
|
|
|
95
95
|
}
|
|
96
96
|
case "admin": {
|
|
97
97
|
const port = Number(getOpt("port", "3456"));
|
|
98
|
-
const { startAdmin } = await import("./server-
|
|
98
|
+
const { startAdmin } = await import("./server-ZQBTRIDY.js");
|
|
99
99
|
await startAdmin(config, port);
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
@@ -12,8 +12,9 @@ import {
|
|
|
12
12
|
// src/admin/server/index.ts
|
|
13
13
|
import { spawn as nodeSpawn } from "child_process";
|
|
14
14
|
import { createServer } from "http";
|
|
15
|
-
import {
|
|
16
|
-
import { resolve as resolve2 } from "path";
|
|
15
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
16
|
+
import { resolve as resolve2, dirname } from "path";
|
|
17
|
+
import { fileURLToPath } from "url";
|
|
17
18
|
import { Hono as Hono4 } from "hono";
|
|
18
19
|
|
|
19
20
|
// src/admin/server/services/status.ts
|
|
@@ -474,12 +475,26 @@ app3.post("/:version/rescan", (c) => {
|
|
|
474
475
|
var status_default = app3;
|
|
475
476
|
|
|
476
477
|
// src/admin/server/index.ts
|
|
477
|
-
|
|
478
|
-
|
|
478
|
+
function loadVersion() {
|
|
479
|
+
try {
|
|
480
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
481
|
+
for (let i = 0; i < 5; i++) {
|
|
482
|
+
try {
|
|
483
|
+
const pkg = JSON.parse(readFileSync2(resolve2(dir, "package.json"), "utf-8"));
|
|
484
|
+
if (pkg.name === "docs-i18n") return pkg.version;
|
|
485
|
+
} catch {
|
|
486
|
+
}
|
|
487
|
+
dir = dirname(dir);
|
|
488
|
+
}
|
|
489
|
+
} catch {
|
|
490
|
+
}
|
|
491
|
+
return "unknown";
|
|
492
|
+
}
|
|
493
|
+
var PKG_VERSION = loadVersion();
|
|
479
494
|
async function startAdmin(config, port = 3456) {
|
|
480
495
|
initStatus(config);
|
|
481
496
|
const app4 = new Hono4();
|
|
482
|
-
app4.get("/api/version", (c) => c.json({ version:
|
|
497
|
+
app4.get("/api/version", (c) => c.json({ version: PKG_VERSION }));
|
|
483
498
|
app4.route("/api/status", status_default);
|
|
484
499
|
app4.route("/api/jobs", jobs_default);
|
|
485
500
|
app4.route("/api/models", models_default);
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { spawn as nodeSpawn } from 'node:child_process';
|
|
2
2
|
import { createServer } from 'node:http';
|
|
3
|
-
import {
|
|
4
|
-
import { resolve } from 'node:path';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { resolve, dirname } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
5
6
|
import { Hono } from 'hono';
|
|
6
7
|
import type { DocsI18nConfig } from '../../config';
|
|
7
8
|
import { initStatus } from './services/status';
|
|
@@ -9,14 +10,27 @@ import jobRoutes from './routes/jobs';
|
|
|
9
10
|
import modelRoutes from './routes/models';
|
|
10
11
|
import statusRoutes from './routes/status';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
function loadVersion(): string {
|
|
14
|
+
try {
|
|
15
|
+
// Walk up from dist/ to find package.json
|
|
16
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
for (let i = 0; i < 5; i++) {
|
|
18
|
+
try {
|
|
19
|
+
const pkg = JSON.parse(readFileSync(resolve(dir, 'package.json'), 'utf-8'));
|
|
20
|
+
if (pkg.name === 'docs-i18n') return pkg.version;
|
|
21
|
+
} catch {}
|
|
22
|
+
dir = dirname(dir);
|
|
23
|
+
}
|
|
24
|
+
} catch {}
|
|
25
|
+
return 'unknown';
|
|
26
|
+
}
|
|
27
|
+
const PKG_VERSION = loadVersion();
|
|
14
28
|
|
|
15
29
|
export async function startAdmin(config: DocsI18nConfig, port = 3456) {
|
|
16
30
|
initStatus(config);
|
|
17
31
|
|
|
18
32
|
const app = new Hono();
|
|
19
|
-
app.get('/api/version', (c) => c.json({ version:
|
|
33
|
+
app.get('/api/version', (c) => c.json({ version: PKG_VERSION }));
|
|
20
34
|
app.route('/api/status', statusRoutes);
|
|
21
35
|
app.route('/api/jobs', jobRoutes);
|
|
22
36
|
app.route('/api/models', modelRoutes);
|