fix: check for updates does not look for commit.json now (#861)
Browse files
app/components/settings/debug/DebugTab.tsx
CHANGED
|
@@ -56,8 +56,25 @@ const versionTag = connitJson.version;
|
|
| 56 |
const GITHUB_URLS = {
|
| 57 |
original: 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main',
|
| 58 |
fork: 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main',
|
| 59 |
-
commitJson: (branch: string) =>
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
};
|
| 62 |
|
| 63 |
function getSystemInfo(): SystemInfo {
|
|
@@ -373,14 +390,9 @@ export default function DebugTab() {
|
|
| 373 |
const branchToCheck = isLatestBranch ? 'main' : 'stable';
|
| 374 |
console.log(`[Debug] Checking for updates against ${branchToCheck} branch`);
|
| 375 |
|
| 376 |
-
const
|
| 377 |
-
|
| 378 |
-
if (!localCommitResponse.ok) {
|
| 379 |
-
throw new Error('Failed to fetch local commit info');
|
| 380 |
-
}
|
| 381 |
|
| 382 |
-
const
|
| 383 |
-
const remoteCommitHash = localCommitData.commit;
|
| 384 |
const currentCommitHash = versionHash;
|
| 385 |
|
| 386 |
if (remoteCommitHash !== currentCommitHash) {
|
|
|
|
| 56 |
const GITHUB_URLS = {
|
| 57 |
original: 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main',
|
| 58 |
fork: 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main',
|
| 59 |
+
commitJson: async (branch: string) => {
|
| 60 |
+
try {
|
| 61 |
+
const response = await fetch(`https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/${branch}`);
|
| 62 |
+
const data: { sha: string } = await response.json();
|
| 63 |
+
|
| 64 |
+
const packageJsonResp = await fetch(
|
| 65 |
+
`https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/${branch}/package.json`,
|
| 66 |
+
);
|
| 67 |
+
const packageJson: { version: string } = await packageJsonResp.json();
|
| 68 |
+
|
| 69 |
+
return {
|
| 70 |
+
commit: data.sha.slice(0, 7),
|
| 71 |
+
version: packageJson.version,
|
| 72 |
+
};
|
| 73 |
+
} catch (error) {
|
| 74 |
+
console.log('Failed to fetch local commit info:', error);
|
| 75 |
+
throw new Error('Failed to fetch local commit info');
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
};
|
| 79 |
|
| 80 |
function getSystemInfo(): SystemInfo {
|
|
|
|
| 390 |
const branchToCheck = isLatestBranch ? 'main' : 'stable';
|
| 391 |
console.log(`[Debug] Checking for updates against ${branchToCheck} branch`);
|
| 392 |
|
| 393 |
+
const latestCommitResp = await GITHUB_URLS.commitJson(branchToCheck);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 394 |
|
| 395 |
+
const remoteCommitHash = latestCommitResp.commit;
|
|
|
|
| 396 |
const currentCommitHash = versionHash;
|
| 397 |
|
| 398 |
if (remoteCommitHash !== currentCommitHash) {
|
app/lib/hooks/useSettings.tsx
CHANGED
|
@@ -35,18 +35,12 @@ export function useSettings() {
|
|
| 35 |
// Function to check if we're on stable version
|
| 36 |
const checkIsStableVersion = async () => {
|
| 37 |
try {
|
| 38 |
-
const
|
| 39 |
-
`https://
|
| 40 |
);
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
-
console.warn('Failed to fetch stable commit info');
|
| 44 |
-
return false;
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
const stableData = (await stableResponse.json()) as CommitData;
|
| 48 |
-
|
| 49 |
-
return versionData.commit === stableData.commit;
|
| 50 |
} catch (error) {
|
| 51 |
console.warn('Error checking stable version:', error);
|
| 52 |
return false;
|
|
|
|
| 35 |
// Function to check if we're on stable version
|
| 36 |
const checkIsStableVersion = async () => {
|
| 37 |
try {
|
| 38 |
+
const response = await fetch(
|
| 39 |
+
`https://api.github.com/repos/stackblitz-labs/bolt.diy/git/refs/tags/v${versionData.version}`,
|
| 40 |
);
|
| 41 |
+
const data: { object: { sha: string } } = await response.json();
|
| 42 |
|
| 43 |
+
return versionData.commit.slice(0, 7) === data.object.sha.slice(0, 7);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
} catch (error) {
|
| 45 |
console.warn('Error checking stable version:', error);
|
| 46 |
return false;
|