docs-i18n 0.5.2 → 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,7 +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 {
|
|
15
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
16
|
+
import { resolve as resolve2, dirname } from "path";
|
|
17
|
+
import { fileURLToPath } from "url";
|
|
16
18
|
import { Hono as Hono4 } from "hono";
|
|
17
19
|
|
|
18
20
|
// src/admin/server/services/status.ts
|
|
@@ -473,9 +475,26 @@ app3.post("/:version/rescan", (c) => {
|
|
|
473
475
|
var status_default = app3;
|
|
474
476
|
|
|
475
477
|
// src/admin/server/index.ts
|
|
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();
|
|
476
494
|
async function startAdmin(config, port = 3456) {
|
|
477
495
|
initStatus(config);
|
|
478
496
|
const app4 = new Hono4();
|
|
497
|
+
app4.get("/api/version", (c) => c.json({ version: PKG_VERSION }));
|
|
479
498
|
app4.route("/api/status", status_default);
|
|
480
499
|
app4.route("/api/jobs", jobs_default);
|
|
481
500
|
app4.route("/api/models", models_default);
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { spawn as nodeSpawn } from 'node:child_process';
|
|
2
2
|
import { createServer } from 'node:http';
|
|
3
|
-
import {
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { resolve, dirname } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
4
6
|
import { Hono } from 'hono';
|
|
5
7
|
import type { DocsI18nConfig } from '../../config';
|
|
6
8
|
import { initStatus } from './services/status';
|
|
@@ -8,10 +10,27 @@ import jobRoutes from './routes/jobs';
|
|
|
8
10
|
import modelRoutes from './routes/models';
|
|
9
11
|
import statusRoutes from './routes/status';
|
|
10
12
|
|
|
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();
|
|
28
|
+
|
|
11
29
|
export async function startAdmin(config: DocsI18nConfig, port = 3456) {
|
|
12
30
|
initStatus(config);
|
|
13
31
|
|
|
14
32
|
const app = new Hono();
|
|
33
|
+
app.get('/api/version', (c) => c.json({ version: PKG_VERSION }));
|
|
15
34
|
app.route('/api/status', statusRoutes);
|
|
16
35
|
app.route('/api/jobs', jobRoutes);
|
|
17
36
|
app.route('/api/models', modelRoutes);
|
package/src/admin/ui/App.tsx
CHANGED
|
@@ -152,6 +152,12 @@ export function App() {
|
|
|
152
152
|
queryFn: api.status,
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
+
const { data: versionInfo } = useQuery({
|
|
156
|
+
queryKey: ['version'],
|
|
157
|
+
queryFn: api.version,
|
|
158
|
+
staleTime: Number.POSITIVE_INFINITY,
|
|
159
|
+
});
|
|
160
|
+
|
|
155
161
|
const { data: files } = useQuery({
|
|
156
162
|
queryKey: ['files', version, lang],
|
|
157
163
|
queryFn: () => api.fileCoverage(version, lang as string),
|
|
@@ -206,7 +212,7 @@ export function App() {
|
|
|
206
212
|
return (
|
|
207
213
|
<>
|
|
208
214
|
<nav>
|
|
209
|
-
<h1>🌐 Translation Admin</h1>
|
|
215
|
+
<h1>🌐 Translation Admin {versionInfo?.version && <span className="version-badge">v{versionInfo.version}</span>}</h1>
|
|
210
216
|
<span className="spacer" />
|
|
211
217
|
<button type="button" className="btn" onClick={handleNewJob}>
|
|
212
218
|
+ New Job
|
package/src/admin/ui/lib/api.ts
CHANGED
package/src/admin/ui/styles.css
CHANGED
|
@@ -60,6 +60,19 @@ nav {
|
|
|
60
60
|
nav h1 {
|
|
61
61
|
font-size: 1.1rem;
|
|
62
62
|
font-weight: 700;
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
gap: 0.5rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.version-badge {
|
|
69
|
+
font-size: 0.7rem;
|
|
70
|
+
font-weight: 500;
|
|
71
|
+
padding: 0.15em 0.5em;
|
|
72
|
+
border-radius: 4px;
|
|
73
|
+
background: var(--accent);
|
|
74
|
+
color: var(--bg);
|
|
75
|
+
opacity: 0.8;
|
|
63
76
|
}
|
|
64
77
|
|
|
65
78
|
/* Utilities */
|