docs-i18n 0.7.2 → 0.7.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 +24 -10
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6,11 +6,12 @@ import "./chunk-PNKVD2UK.js";
|
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
import { createRequire } from "module";
|
|
9
|
+
var require2 = createRequire(import.meta.url);
|
|
10
|
+
var pkg = require2("../package.json");
|
|
11
|
+
var version = pkg.version;
|
|
9
12
|
var args = process.argv.slice(2);
|
|
10
13
|
if (args[0] === "--version" || args[0] === "-v") {
|
|
11
|
-
|
|
12
|
-
const pkg = require2("../package.json");
|
|
13
|
-
console.log(pkg.version);
|
|
14
|
+
console.log(version);
|
|
14
15
|
process.exit(0);
|
|
15
16
|
}
|
|
16
17
|
var command = args[0];
|
|
@@ -22,6 +23,7 @@ function hasFlag(name) {
|
|
|
22
23
|
return args.includes(`--${name}`);
|
|
23
24
|
}
|
|
24
25
|
async function handleSiteCommand() {
|
|
26
|
+
console.log(`docs-i18n v${version}`);
|
|
25
27
|
const validSub = /* @__PURE__ */ new Set(["dev", "build", "upload", "deploy"]);
|
|
26
28
|
const subCommand = args.slice(1).find((a) => validSub.has(a));
|
|
27
29
|
const port = Number(getOpt("port", "3000"));
|
|
@@ -187,19 +189,31 @@ Options:
|
|
|
187
189
|
break;
|
|
188
190
|
}
|
|
189
191
|
case "admin": {
|
|
192
|
+
console.log(`docs-i18n v${version}`);
|
|
190
193
|
const port = Number(getOpt("port", "3456"));
|
|
191
194
|
const { resolve: res, dirname: dn } = await import("path");
|
|
192
195
|
const { fileURLToPath: toPath } = await import("url");
|
|
193
|
-
const { existsSync: ex, realpathSync: rp } = await import("fs");
|
|
196
|
+
const { existsSync: ex, realpathSync: rp, writeFileSync: wf } = await import("fs");
|
|
197
|
+
const { spawn: sp } = await import("child_process");
|
|
198
|
+
const { tmpdir: tmp } = await import("os");
|
|
194
199
|
const coreRoot = res(dn(toPath(import.meta.url)), "..");
|
|
195
200
|
const adminNm = res(coreRoot, "node_modules", "@docs-i18n", "admin");
|
|
196
201
|
const adminRoot = ex(adminNm) ? rp(adminNm) : res(coreRoot, "admin");
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
wf(res(tmp(), "docs-i18n-project-root"), process.cwd());
|
|
203
|
+
const { execSync: execS } = await import("child_process");
|
|
204
|
+
if (!ex(res(adminRoot, "node_modules"))) {
|
|
205
|
+
console.log("Installing admin dependencies...");
|
|
206
|
+
execS("npm install --no-audit --no-fund", { cwd: adminRoot, stdio: "inherit" });
|
|
207
|
+
}
|
|
208
|
+
const adminVite = res(adminRoot, "node_modules", ".bin", "vite");
|
|
209
|
+
const child = sp(adminVite, ["--port", String(port)], {
|
|
210
|
+
cwd: adminRoot,
|
|
211
|
+
stdio: "inherit",
|
|
212
|
+
env: { ...process.env, DOCS_I18N_PROJECT_ROOT: process.cwd() }
|
|
213
|
+
});
|
|
214
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
215
|
+
await new Promise(() => {
|
|
216
|
+
});
|
|
203
217
|
}
|
|
204
218
|
default:
|
|
205
219
|
console.error(`Unknown command: ${command}`);
|