diff --git a/server/index.js b/server/index.js index cbf68b2..4b70cd3 100755 --- a/server/index.js +++ b/server/index.js @@ -9,6 +9,8 @@ import { dirname } from 'path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); +const installMode = fs.existsSync(path.join(__dirname, '..', '.git')) ? 'git' : 'npm'; + // ANSI color codes for terminal output const colors = { reset: '\x1b[0m', @@ -333,7 +335,8 @@ app.use(express.urlencoded({ limit: '50mb', extended: true })); app.get('/health', (req, res) => { res.json({ status: 'ok', - timestamp: new Date().toISOString() + timestamp: new Date().toISOString(), + installMode }); }); @@ -410,11 +413,13 @@ app.post('/api/system/update', authenticateToken, async (req, res) => { console.log('Starting system update from directory:', projectRoot); - // Run the update command - const updateCommand = 'git checkout main && git pull && npm install'; + // Run the update command based on install mode + const updateCommand = installMode === 'git' + ? 'git checkout main && git pull && npm install' + : 'npm install -g @siteboon/claude-code-ui@latest'; const child = spawn('sh', ['-c', updateCommand], { - cwd: projectRoot, + cwd: installMode === 'git' ? projectRoot : os.homedir(), env: process.env }); diff --git a/src/components/modals/VersionUpgradeModal.tsx b/src/components/modals/VersionUpgradeModal.tsx index 4d09dcd..e5beeb0 100644 --- a/src/components/modals/VersionUpgradeModal.tsx +++ b/src/components/modals/VersionUpgradeModal.tsx @@ -2,6 +2,7 @@ import { useCallback, useState } from "react"; import { useTranslation } from "react-i18next"; import { authenticatedFetch } from "../../utils/api"; import { ReleaseInfo } from "../../types/sharedTypes"; +import type { InstallMode } from "../../hooks/useVersionCheck"; interface VersionUpgradeModalProps { isOpen: boolean; @@ -9,6 +10,7 @@ interface VersionUpgradeModalProps { releaseInfo: ReleaseInfo | null; currentVersion: string; latestVersion: string | null; + installMode: InstallMode; } export default function VersionUpgradeModal({ @@ -16,9 +18,13 @@ export default function VersionUpgradeModal({ onClose, releaseInfo, currentVersion, - latestVersion + latestVersion, + installMode }: VersionUpgradeModalProps) { const { t } = useTranslation('common'); + const upgradeCommand = installMode === 'npm' + ? t('versionUpdate.npmUpgradeCommand') + : 'git checkout main && git pull && npm install'; const [isUpdating, setIsUpdating] = useState(false); const [updateOutput, setUpdateOutput] = useState(''); const [updateError, setUpdateError] = useState(''); @@ -150,7 +156,7 @@ export default function VersionUpgradeModal({

{t('versionUpdate.manualUpgrade')}

- git checkout main && git pull && npm install + {upgradeCommand}

@@ -171,7 +177,7 @@ export default function VersionUpgradeModal({ <>