skillwiki 0.2.0-beta.8 → 0.2.1-beta.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.
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+ #!/usr/bin/env node
3
+ import {
4
+ semverGt
5
+ } from "./chunk-XM5IYZX7.js";
6
+
7
+ // src/auto-update-bg.ts
8
+ import { execSync } from "child_process";
9
+ import { writeFileSync, mkdirSync } from "fs";
10
+ import { join, dirname } from "path";
11
+ var home = process.argv[2];
12
+ var currentVersion = process.argv[3];
13
+ if (!home || !currentVersion) process.exit(0);
14
+ var cacheFile = join(home, ".skillwiki", ".update-cache.json");
15
+ setTimeout(() => process.exit(0), 3e4);
16
+ try {
17
+ const latest = execSync("npm view skillwiki@beta version", {
18
+ encoding: "utf8",
19
+ timeout: 15e3
20
+ }).trim();
21
+ mkdirSync(dirname(cacheFile), { recursive: true });
22
+ const cache = {
23
+ lastCheck: Date.now(),
24
+ latestVersion: latest,
25
+ currentVersion
26
+ };
27
+ if (semverGt(latest, currentVersion)) {
28
+ execSync("npm install -g skillwiki@beta", {
29
+ stdio: "ignore",
30
+ timeout: 6e4
31
+ });
32
+ writeFileSync(cacheFile, JSON.stringify({ ...cache, updateAppliedAt: Date.now() }, null, 2));
33
+ } else {
34
+ writeFileSync(cacheFile, JSON.stringify(cache, null, 2));
35
+ }
36
+ } catch {
37
+ try {
38
+ mkdirSync(dirname(cacheFile), { recursive: true });
39
+ writeFileSync(cacheFile, JSON.stringify({ lastCheck: Date.now(), latestVersion: "", currentVersion }, null, 2));
40
+ } catch {
41
+ }
42
+ }
43
+ process.exit(0);
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/utils/semver.ts
4
+ function semverGt(a, b) {
5
+ const pa = parseSemver(a);
6
+ const pb = parseSemver(b);
7
+ if (!pa || !pb) return a > b;
8
+ if (pa.major !== pb.major) return pa.major > pb.major;
9
+ if (pa.minor !== pb.minor) return pa.minor > pb.minor;
10
+ if (pa.patch !== pb.patch) return pa.patch > pb.patch;
11
+ if (!pa.pre && pb.pre) return true;
12
+ if (pa.pre && !pb.pre) return false;
13
+ if (!pa.pre && !pb.pre) return false;
14
+ const aParts = pa.pre.split(".");
15
+ const bParts = pb.pre.split(".");
16
+ const len = Math.max(aParts.length, bParts.length);
17
+ for (let i = 0; i < len; i++) {
18
+ const ai = aParts[i];
19
+ const bi = bParts[i];
20
+ if (ai === void 0) return false;
21
+ if (bi === void 0) return true;
22
+ const aNum = parseInt(ai, 10);
23
+ const bNum = parseInt(bi, 10);
24
+ if (!isNaN(aNum) && !isNaN(bNum)) {
25
+ if (aNum !== bNum) return aNum > bNum;
26
+ } else {
27
+ if (ai !== bi) return ai > bi;
28
+ }
29
+ }
30
+ return false;
31
+ }
32
+ function parseSemver(version) {
33
+ const match = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);
34
+ if (!match) return null;
35
+ return {
36
+ major: parseInt(match[1], 10),
37
+ minor: parseInt(match[2], 10),
38
+ patch: parseInt(match[3], 10),
39
+ pre: match[4] ?? null
40
+ };
41
+ }
42
+
43
+ export {
44
+ semverGt
45
+ };