kimiflare 0.4.0 → 0.4.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/index.js +31 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2454,18 +2454,28 @@ function cachePath() {
|
|
|
2454
2454
|
const xdg = process.env.XDG_CONFIG_HOME || join3(homedir4(), ".config");
|
|
2455
2455
|
return join3(xdg, "kimiflare", "update-check.json");
|
|
2456
2456
|
}
|
|
2457
|
-
function
|
|
2458
|
-
|
|
2459
|
-
|
|
2457
|
+
async function findPackageJson(startDir) {
|
|
2458
|
+
let dir = startDir;
|
|
2459
|
+
while (true) {
|
|
2460
|
+
const candidate = join3(dir, "package.json");
|
|
2461
|
+
try {
|
|
2462
|
+
const raw = await readFile6(candidate, "utf8");
|
|
2463
|
+
const parsed = JSON.parse(raw);
|
|
2464
|
+
if (parsed.name === "kimiflare" && parsed.version) {
|
|
2465
|
+
return { path: candidate, version: parsed.version };
|
|
2466
|
+
}
|
|
2467
|
+
} catch {
|
|
2468
|
+
}
|
|
2469
|
+
const parent = dirname2(dir);
|
|
2470
|
+
if (parent === dir) break;
|
|
2471
|
+
dir = parent;
|
|
2472
|
+
}
|
|
2473
|
+
return null;
|
|
2460
2474
|
}
|
|
2461
2475
|
async function readLocalVersion() {
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
return parsed.version ?? null;
|
|
2466
|
-
} catch {
|
|
2467
|
-
return null;
|
|
2468
|
-
}
|
|
2476
|
+
const here = dirname2(fileURLToPath(import.meta.url));
|
|
2477
|
+
const found = await findPackageJson(here);
|
|
2478
|
+
return found?.version ?? null;
|
|
2469
2479
|
}
|
|
2470
2480
|
async function readCache() {
|
|
2471
2481
|
try {
|
|
@@ -2525,13 +2535,18 @@ async function checkForUpdate() {
|
|
|
2525
2535
|
return { hasUpdate, localVersion, latestVersion };
|
|
2526
2536
|
}
|
|
2527
2537
|
async function isGitRepo() {
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2538
|
+
let dir = dirname2(fileURLToPath(import.meta.url));
|
|
2539
|
+
while (true) {
|
|
2540
|
+
try {
|
|
2541
|
+
await access(join3(dir, ".git"));
|
|
2542
|
+
return true;
|
|
2543
|
+
} catch {
|
|
2544
|
+
}
|
|
2545
|
+
const parent = dirname2(dir);
|
|
2546
|
+
if (parent === dir) break;
|
|
2547
|
+
dir = parent;
|
|
2534
2548
|
}
|
|
2549
|
+
return false;
|
|
2535
2550
|
}
|
|
2536
2551
|
var CACHE_TTL_MS, NPM_REGISTRY;
|
|
2537
2552
|
var init_update_check = __esm({
|