refactor: updated vite config to inject add version metadata into the app on build (#841)
* refactor: removes commit.json and used vite.config to load these variables * updated precommit hook * updated the pre start script * updated the workflows
This commit is contained in:
@@ -1 +0,0 @@
|
||||
{ "commit": "ab5cde30a126f6540f0afb4d6d6e6be6a764ddca", "version": "0.0.3" }
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { useSettings } from '~/lib/hooks/useSettings';
|
||||
import commit from '~/commit.json';
|
||||
import { toast } from 'react-toastify';
|
||||
import { providerBaseUrlEnvKeys } from '~/utils/constants';
|
||||
|
||||
@@ -44,11 +43,16 @@ interface CommitData {
|
||||
version?: string;
|
||||
}
|
||||
|
||||
const connitJson: CommitData = commit;
|
||||
const connitJson: CommitData = {
|
||||
commit: __COMMIT_HASH,
|
||||
version: __APP_VERSION,
|
||||
};
|
||||
|
||||
const LOCAL_PROVIDERS = ['Ollama', 'LMStudio', 'OpenAILike'];
|
||||
|
||||
const versionHash = connitJson.commit;
|
||||
const versionTag = connitJson.version;
|
||||
|
||||
const GITHUB_URLS = {
|
||||
original: 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main',
|
||||
fork: 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main',
|
||||
@@ -524,7 +528,7 @@ export default function DebugTab() {
|
||||
<div className="mt-3 pt-3 border-t border-bolt-elements-surface-hover">
|
||||
<p className="text-xs text-bolt-elements-textSecondary">Version</p>
|
||||
<p className="text-sm font-medium text-bolt-elements-textPrimary font-mono">
|
||||
{versionHash.slice(0, 7)}
|
||||
{connitJson.commit.slice(0, 7)}
|
||||
<span className="ml-2 text-xs text-bolt-elements-textSecondary">
|
||||
(v{versionTag || '0.0.1'}) - {isLatestBranch ? 'nightly' : 'stable'}
|
||||
</span>
|
||||
|
||||
@@ -35,8 +35,8 @@ export default function ProvidersTab() {
|
||||
newFilteredProviders.sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
// Split providers into regular and URL-configurable
|
||||
const regular = newFilteredProviders.filter(p => !URL_CONFIGURABLE_PROVIDERS.includes(p.name));
|
||||
const urlConfigurable = newFilteredProviders.filter(p => URL_CONFIGURABLE_PROVIDERS.includes(p.name));
|
||||
const regular = newFilteredProviders.filter((p) => !URL_CONFIGURABLE_PROVIDERS.includes(p.name));
|
||||
const urlConfigurable = newFilteredProviders.filter((p) => URL_CONFIGURABLE_PROVIDERS.includes(p.name));
|
||||
|
||||
setFilteredProviders([...regular, ...urlConfigurable]);
|
||||
}, [providers, searchTerm, isLocalModel]);
|
||||
@@ -112,8 +112,8 @@ export default function ProvidersTab() {
|
||||
);
|
||||
};
|
||||
|
||||
const regularProviders = filteredProviders.filter(p => !URL_CONFIGURABLE_PROVIDERS.includes(p.name));
|
||||
const urlConfigurableProviders = filteredProviders.filter(p => URL_CONFIGURABLE_PROVIDERS.includes(p.name));
|
||||
const regularProviders = filteredProviders.filter((p) => !URL_CONFIGURABLE_PROVIDERS.includes(p.name));
|
||||
const urlConfigurableProviders = filteredProviders.filter((p) => URL_CONFIGURABLE_PROVIDERS.includes(p.name));
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
@@ -128,22 +128,19 @@ export default function ProvidersTab() {
|
||||
</div>
|
||||
|
||||
{/* Regular Providers Grid */}
|
||||
<div className="grid grid-cols-2 gap-4 mb-8">
|
||||
{regularProviders.map(renderProviderCard)}
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4 mb-8">{regularProviders.map(renderProviderCard)}</div>
|
||||
|
||||
{/* URL Configurable Providers Section */}
|
||||
{urlConfigurableProviders.length > 0 && (
|
||||
<div className="mt-8">
|
||||
<h3 className="text-lg font-semibold mb-2 text-bolt-elements-textPrimary">Experimental Providers</h3>
|
||||
<p className="text-sm text-bolt-elements-textSecondary mb-4">
|
||||
These providers are experimental and allow you to run AI models locally or connect to your own infrastructure. They require additional setup but offer more flexibility.
|
||||
These providers are experimental and allow you to run AI models locally or connect to your own
|
||||
infrastructure. They require additional setup but offer more flexibility.
|
||||
</p>
|
||||
<div className="space-y-4">
|
||||
{urlConfigurableProviders.map(renderProviderCard)}
|
||||
</div>
|
||||
<div className="space-y-4">{urlConfigurableProviders.map(renderProviderCard)}</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,14 +12,16 @@ import { useCallback, useEffect, useState } from 'react';
|
||||
import Cookies from 'js-cookie';
|
||||
import type { IProviderSetting, ProviderInfo } from '~/types/model';
|
||||
import { logStore } from '~/lib/stores/logs'; // assuming logStore is imported from this location
|
||||
import commit from '~/commit.json';
|
||||
|
||||
interface CommitData {
|
||||
commit: string;
|
||||
version?: string;
|
||||
}
|
||||
|
||||
const commitJson: CommitData = commit;
|
||||
const versionData: CommitData = {
|
||||
commit: __COMMIT_HASH,
|
||||
version: __APP_VERSION,
|
||||
};
|
||||
|
||||
export function useSettings() {
|
||||
const providers = useStore(providersStore);
|
||||
@@ -34,7 +36,7 @@ export function useSettings() {
|
||||
const checkIsStableVersion = async () => {
|
||||
try {
|
||||
const stableResponse = await fetch(
|
||||
`https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/refs/tags/v${commitJson.version}/app/commit.json`,
|
||||
`https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/refs/tags/v${versionData.version}/app/commit.json`,
|
||||
);
|
||||
|
||||
if (!stableResponse.ok) {
|
||||
@@ -44,7 +46,7 @@ export function useSettings() {
|
||||
|
||||
const stableData = (await stableResponse.json()) as CommitData;
|
||||
|
||||
return commit.commit === stableData.commit;
|
||||
return versionData.commit === stableData.commit;
|
||||
} catch (error) {
|
||||
console.warn('Error checking stable version:', error);
|
||||
return false;
|
||||
@@ -105,16 +107,16 @@ export function useSettings() {
|
||||
let checkCommit = Cookies.get('commitHash');
|
||||
|
||||
if (checkCommit === undefined) {
|
||||
checkCommit = commit.commit;
|
||||
checkCommit = versionData.commit;
|
||||
}
|
||||
|
||||
if (savedLatestBranch === undefined || checkCommit !== commit.commit) {
|
||||
if (savedLatestBranch === undefined || checkCommit !== versionData.commit) {
|
||||
// If setting hasn't been set by user, check version
|
||||
checkIsStableVersion().then((isStable) => {
|
||||
const shouldUseLatest = !isStable;
|
||||
latestBranchStore.set(shouldUseLatest);
|
||||
Cookies.set('isLatestBranch', String(shouldUseLatest));
|
||||
Cookies.set('commitHash', String(commit.commit));
|
||||
Cookies.set('commitHash', String(versionData.commit));
|
||||
});
|
||||
} else {
|
||||
latestBranchStore.set(savedLatestBranch === 'true');
|
||||
|
||||
2
app/vite-env.d.ts
vendored
Normal file
2
app/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const __COMMIT_HASH: string;
|
||||
declare const __APP_VERSION: string;
|
||||
Reference in New Issue
Block a user