depth-first-thinking 2.0.9 → 2.1.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/package.json +1 -1
- package/src/commands/update.ts +16 -9
package/package.json
CHANGED
package/src/commands/update.ts
CHANGED
|
@@ -2,17 +2,16 @@ import { ExitCodes } from "../data/types";
|
|
|
2
2
|
|
|
3
3
|
async function getCurrentVersion(): Promise<string> {
|
|
4
4
|
try {
|
|
5
|
-
|
|
5
|
+
// Resolve the package.json that belongs to this installed package,
|
|
6
|
+
// regardless of the current working directory.
|
|
7
|
+
const packageUrl = new URL("../../package.json", import.meta.url);
|
|
8
|
+
const packageJsonFile = Bun.file(packageUrl);
|
|
9
|
+
|
|
6
10
|
if (await packageJsonFile.exists()) {
|
|
7
|
-
const packageJson = (await packageJsonFile.json()) as { version
|
|
8
|
-
return packageJson.version;
|
|
9
|
-
}
|
|
10
|
-
// Fallback: try relative to src/commands
|
|
11
|
-
const fallbackFile = Bun.file("../../package.json");
|
|
12
|
-
if (await fallbackFile.exists()) {
|
|
13
|
-
const packageJson = (await fallbackFile.json()) as { version: string };
|
|
14
|
-
return packageJson.version;
|
|
11
|
+
const packageJson = (await packageJsonFile.json()) as { version?: string };
|
|
12
|
+
return packageJson.version ?? "unknown";
|
|
15
13
|
}
|
|
14
|
+
|
|
16
15
|
return "unknown";
|
|
17
16
|
} catch {
|
|
18
17
|
return "unknown";
|
|
@@ -51,6 +50,14 @@ export async function updateCommand(): Promise<void> {
|
|
|
51
50
|
const currentVersion = await getCurrentVersion();
|
|
52
51
|
console.log(`Current version: ${currentVersion}`);
|
|
53
52
|
|
|
53
|
+
if (currentVersion === "unknown") {
|
|
54
|
+
console.log(
|
|
55
|
+
"Could not determine the current version. Please make sure dft is installed correctly.",
|
|
56
|
+
);
|
|
57
|
+
process.exit(ExitCodes.FILESYSTEM_ERROR);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
54
61
|
const latestVersion = await fetchLatestVersion();
|
|
55
62
|
|
|
56
63
|
if (!latestVersion) {
|