a few changes and clean up

This commit is contained in:
dal 2025-09-12 00:42:11 -06:00
parent 11978e99a4
commit 911f859d85
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
9 changed files with 321 additions and 253 deletions

View File

@ -1,4 +1,4 @@
import { execSync } from 'node:child_process';
import { spawnSync } from 'node:child_process';
import { existsSync, readlinkSync } from 'node:fs';
import { platform } from 'node:os';
import chalk from 'chalk';
@ -47,11 +47,11 @@ export function isInstalledViaHomebrew(): boolean {
// Alternative check: see if buster formula is installed
try {
const result = execSync('brew list buster 2>/dev/null', {
const result = spawnSync('brew', ['list', 'buster'], {
encoding: 'utf-8',
stdio: ['ignore', 'pipe', 'ignore'],
});
return result.length > 0;
return result.status === 0 && (result.stdout?.length ?? 0) > 0;
} catch {
// brew command failed or buster not installed via brew
return false;

View File

@ -1,11 +1,10 @@
import { execSync, spawn } from 'node:child_process';
import { spawn } from 'node:child_process';
import { createHash } from 'node:crypto';
import { createWriteStream, existsSync } from 'node:fs';
import { chmod, mkdir, rename, unlink } from 'node:fs/promises';
import { arch, platform, tmpdir } from 'node:os';
import { join } from 'node:path';
import { pipeline } from 'node:stream/promises';
import { promisify } from 'node:util';
import chalk from 'chalk';
import { checkForUpdate, formatVersion } from '../../utils/version/index';
import { isInstalledViaHomebrew } from './homebrew-detection';
@ -232,7 +231,8 @@ export async function updateHandler(options: UpdateOptions): Promise<UpdateResul
// Check if installed via Homebrew
const isHomebrew = isInstalledViaHomebrew();
if (isHomebrew && !validated.force) {
// If just checking for updates, always proceed regardless of installation method
if (isHomebrew && !validated.check && !validated.force) {
return {
success: false,
message: `Buster was installed via Homebrew. Please use:\n\n ${chalk.cyan('brew upgrade buster')}\n\nto update to the latest version.`,
@ -322,13 +322,13 @@ export async function updateHandler(options: UpdateOptions): Promise<UpdateResul
// Format can be either "checksum" or "checksum filename"
const checksumMatch = checksumContent.match(/^([a-f0-9]{64})/i);
if (!checksumMatch) {
if (!checksumMatch || !checksumMatch[1]) {
throw new Error(
`Invalid checksum format in file. Expected SHA256 hash, got: ${checksumContent.substring(0, 100)}`
);
}
const expectedChecksum = checksumMatch[1]!.toLowerCase();
const expectedChecksum = checksumMatch[1].toLowerCase();
// Verify checksum
console.info(chalk.blue('Verifying download...'));

View File

@ -16,6 +16,9 @@ export function UpdateCommand({ check, force, yes }: UpdateCommandProps) {
try {
setStatus(check ? 'checking' : 'updating');
// Defer the execution to avoid React render cycle conflicts
await new Promise(resolve => setTimeout(resolve, 0));
const result = await updateHandler({ check, force, yes });
setMessage(result.message);

View File

@ -10,13 +10,20 @@ const USER_AGENT = 'buster-cli';
*/
export async function fetchLatestRelease(): Promise<GitHubRelease | null> {
try {
// Add timeout to prevent hanging
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000); // 5 second timeout
const response = await fetch(GITHUB_API_URL, {
headers: {
'User-Agent': USER_AGENT,
Accept: 'application/vnd.github.v3+json',
},
signal: controller.signal,
});
clearTimeout(timeoutId);
if (!response.ok) {
// Silently fail - don't disrupt user experience
return null;

View File

@ -152,22 +152,20 @@ describe('GET /api/v2/users/:id/suggested-prompts', () => {
});
it('should return cached prompts even if updated time is just a few minutes ago today', async () => {
// Create a date that is definitely today by using local date methods
const now = new Date();
const todayAt2HoursAgo = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate(),
now.getHours() - 2,
now.getMinutes(),
now.getSeconds()
);
// Create a date that is definitely today - just 5 minutes ago
// This ensures we're testing the "same day" logic properly
const fiveMinutesAgo = new Date(Date.now() - 5 * 60 * 1000);
const recentPrompts = {
...mockTodayPrompts,
updatedAt: todayAt2HoursAgo.toISOString(),
updatedAt: fiveMinutesAgo.toISOString(),
};
(getUserSuggestedPrompts as Mock).mockResolvedValue(recentPrompts);
// Also need to mock what would happen if it DID generate
// (though it shouldn't in this test)
(generateSuggestedMessages as Mock).mockResolvedValue(mockGeneratedPrompts);
(updateUserSuggestedPrompts as Mock).mockResolvedValue(mockUpdatedPrompts);
const testApp = createTestApp();
@ -179,6 +177,7 @@ describe('GET /api/v2/users/:id/suggested-prompts', () => {
const body = await response.json();
expect(body).toEqual(recentPrompts);
expect(generateSuggestedMessages).not.toHaveBeenCalled();
expect(updateUserSuggestedPrompts).not.toHaveBeenCalled();
});
});

View File

@ -55,7 +55,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@types/node": "^22.11.0",
"@types/node": "^22.18.1",
"tsx": "catalog:",
"turbo": "^2.5.6",
"vitest": "catalog:"
@ -66,7 +66,9 @@
"packageManager": "pnpm@10.15.1",
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": ["shiki"],
"ignoreMissing": [
"shiki"
],
"allowedVersions": {
"shiki": "3"
}

View File

@ -277,14 +277,14 @@ No conversation history available for analysis.`,
const result: FlagChatStepResult =
llmResult.type === 'flagChat'
? {
type: 'flagChat',
summaryMessage: llmResult.summary_message || '',
summaryTitle: llmResult.summary_title || '',
}
type: 'flagChat',
summaryMessage: llmResult.summary_message || '',
summaryTitle: llmResult.summary_title || '',
}
: {
type: 'noIssuesFound',
message: llmResult.message || '',
};
type: 'noIssuesFound',
message: llmResult.message || '',
};
return result;
} catch (llmError) {

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +1,32 @@
packages:
# Core packages
- "packages/*"
# Applications
- "apps/server"
- "apps/electric-server"
- "apps/trigger"
- "apps/api"
- "apps/cli"
- "apps/web"
- packages/*
- apps/server
- apps/electric-server
- apps/trigger
- apps/api
- apps/cli
- apps/web
catalog:
'@aws-sdk/client-s3': ^3.873.0
'@electric-sql/client': ^1.0.9
'@supabase/supabase-js': ^2.57.0
'@trigger.dev/build': ^4.0.2
'@trigger.dev/sdk': ^4.0.2
'@electric-sql/client': ^1.0.9
'@types/js-yaml': ^4.0.9
'@types/react': ^19.1.12
'@types/react-dom': ^19.1.9
ai: ^5.0.39
axios: ^1.11.0
braintrust: ^0.2.4
dotenv: ^17.2.2
drizzle-orm: ^0.44.5
lodash-es: ^4.17.21
hono: ^4.9.6
js-yaml: ^4.1.0
lodash-es: ^4.17.21
pg: ^8.16.3
react: ^19.1.1
react-dom: ^19.1.1
'@types/react': ^19.1.12
'@types/react-dom': ^19.1.9
'@types/js-yaml': ^4.0.9
js-yaml: ^4.1.0
tsup: ^8.5.0
tsx: ^4.20.5
uuid: ^11.1.0