depth-first-thinking 2.1.4 → 2.1.7
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/package.json +8 -9
- package/src/commands/update.test.ts +23 -0
- package/src/commands/update.ts +3 -13
- package/src/types/semver.d.ts +1 -0
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "depth-first-thinking",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "A terminal-based task manager with depth-first navigation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -38,18 +38,16 @@
|
|
|
38
38
|
"preinstall": "node -e \"if(process.env.npm_execpath && !process.env.npm_execpath.includes('bun')){console.error('\\x1b[31mError: Use bun to install dependencies\\x1b[0m\\n\\nInstall bun: https://bun.sh');process.exit(1)}\"",
|
|
39
39
|
"dev": "bun run --watch src/index.ts",
|
|
40
40
|
"build": "bun build src/index.ts --target bun --minify --outdir dist",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"lint
|
|
45
|
-
"check": "bunx biome check src",
|
|
46
|
-
"check:fix": "bunx biome check --write src",
|
|
41
|
+
"biome:fix": "bunx biome check --write src",
|
|
42
|
+
"biome:check": "bunx biome check src",
|
|
43
|
+
"format": "bun run biome:fix",
|
|
44
|
+
"lint": "bun run biome:check",
|
|
47
45
|
"check-types": "bunx tsc --noEmit",
|
|
48
46
|
"test": "bun test",
|
|
49
47
|
"sync-version": "bun run scripts/sync-version.ts",
|
|
50
|
-
"prepublishOnly": "bun run check && bun run check-types",
|
|
48
|
+
"prepublishOnly": "bun run biome:check && bun run check-types",
|
|
51
49
|
"prepare": "husky",
|
|
52
|
-
"ci": "bun run
|
|
50
|
+
"ci": "bun run biome:check && bun run check-types && bun run test && bun run sync-version"
|
|
53
51
|
},
|
|
54
52
|
"devDependencies": {
|
|
55
53
|
"@biomejs/biome": "^1.9.4",
|
|
@@ -61,6 +59,7 @@
|
|
|
61
59
|
"dependencies": {
|
|
62
60
|
"@opentui/core": "^0.1.74",
|
|
63
61
|
"commander": "^11.0.0",
|
|
62
|
+
"semver": "^7.6.0",
|
|
64
63
|
"uuid": "^9.0.0"
|
|
65
64
|
},
|
|
66
65
|
"publishConfig": {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { compareVersions } from "./update";
|
|
3
|
+
|
|
4
|
+
describe("compareVersions", () => {
|
|
5
|
+
test("returns 0 for equal versions", () => {
|
|
6
|
+
expect(compareVersions("2.1.4", "2.1.4")).toBe(0);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("returns -1 when current is older than latest", () => {
|
|
10
|
+
expect(compareVersions("2.1.4", "2.1.5")).toBe(-1);
|
|
11
|
+
expect(compareVersions("2.1.9", "2.2.0")).toBe(-1);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("returns 1 when current is newer than latest", () => {
|
|
15
|
+
expect(compareVersions("2.1.5", "2.1.4")).toBe(1);
|
|
16
|
+
expect(compareVersions("2.10.0", "2.2.0")).toBe(1);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("handles prerelease versions according to semver rules", () => {
|
|
20
|
+
expect(compareVersions("2.1.5-beta.1", "2.1.5")).toBe(-1);
|
|
21
|
+
expect(compareVersions("2.1.5", "2.1.5-beta.1")).toBe(1);
|
|
22
|
+
});
|
|
23
|
+
});
|
package/src/commands/update.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import semver from "semver";
|
|
1
2
|
import { ExitCodes } from "../data/types";
|
|
2
3
|
import { VERSION } from "../version";
|
|
3
4
|
|
|
@@ -14,19 +15,8 @@ async function fetchLatestVersion(): Promise<string | null> {
|
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
function compareVersions(current: string, latest: string): number {
|
|
18
|
-
|
|
19
|
-
const latestParts = latest.split(".").map(Number);
|
|
20
|
-
|
|
21
|
-
for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
|
|
22
|
-
const currentPart = currentParts[i] ?? 0;
|
|
23
|
-
const latestPart = latestParts[i] ?? 0;
|
|
24
|
-
|
|
25
|
-
if (latestPart > currentPart) return 1;
|
|
26
|
-
if (latestPart < currentPart) return -1;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return 0;
|
|
18
|
+
export function compareVersions(current: string, latest: string): number {
|
|
19
|
+
return semver.compare(current, latest);
|
|
30
20
|
}
|
|
31
21
|
|
|
32
22
|
export async function updateCommand(): Promise<void> {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "semver";
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "2.1.
|
|
1
|
+
export const VERSION = "2.1.7";
|