@0dai-dev/cli 1.3.1 → 2.0.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.
- package/bin/0dai.js +23 -1
- package/package.json +1 -1
package/bin/0dai.js
CHANGED
|
@@ -7,10 +7,11 @@ const fs = require("fs");
|
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const os = require("os");
|
|
9
9
|
|
|
10
|
-
const VERSION = "
|
|
10
|
+
const VERSION = "2.0.0";
|
|
11
11
|
const API_URL = process.env.ODAI_API_URL || "https://api.0dai.dev";
|
|
12
12
|
const CONFIG_DIR = path.join(os.homedir(), ".0dai");
|
|
13
13
|
const AUTH_FILE = path.join(CONFIG_DIR, "auth.json");
|
|
14
|
+
const VERSION_CHECK_FILE = path.join(CONFIG_DIR, ".version_check");
|
|
14
15
|
|
|
15
16
|
const MANIFEST_FILES = [
|
|
16
17
|
"package.json", "go.mod", "pyproject.toml", "requirements.txt",
|
|
@@ -268,6 +269,24 @@ function cmdStatus(target) {
|
|
|
268
269
|
} catch {}
|
|
269
270
|
}
|
|
270
271
|
|
|
272
|
+
async function checkVersion() {
|
|
273
|
+
try {
|
|
274
|
+
// Only check once per day
|
|
275
|
+
let lastCheck = 0;
|
|
276
|
+
try { lastCheck = parseFloat(fs.readFileSync(VERSION_CHECK_FILE, "utf8")); } catch {}
|
|
277
|
+
if (Date.now() / 1000 - lastCheck < 86400) return;
|
|
278
|
+
|
|
279
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
280
|
+
fs.writeFileSync(VERSION_CHECK_FILE, String(Date.now() / 1000));
|
|
281
|
+
|
|
282
|
+
const result = await apiCall("/v1/version");
|
|
283
|
+
if (result.version && result.version !== VERSION) {
|
|
284
|
+
console.log(`\n[0dai] Update available: ${VERSION} → ${result.version}`);
|
|
285
|
+
console.log(` Run: npm update -g @0dai-dev/cli\n`);
|
|
286
|
+
}
|
|
287
|
+
} catch {}
|
|
288
|
+
}
|
|
289
|
+
|
|
271
290
|
async function cmdAuthLogin() {
|
|
272
291
|
// Step 1: request device code
|
|
273
292
|
const result = await apiCall("/v1/auth/device", { client_id: "cli" });
|
|
@@ -338,6 +357,9 @@ async function main() {
|
|
|
338
357
|
const cmd = args[0] || "help";
|
|
339
358
|
const sub = args[1] || "";
|
|
340
359
|
|
|
360
|
+
// Non-blocking version check (runs in background, once per day)
|
|
361
|
+
checkVersion();
|
|
362
|
+
|
|
341
363
|
switch (cmd) {
|
|
342
364
|
case "init": await cmdInit(target); break;
|
|
343
365
|
case "sync": await cmdSync(target); break;
|