Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/app/src/renderer/components/PackageSetupCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ function StepRow({ packageId, step, onChanged }: { packageId: string; step: Setu
}

return (
<div className="flex items-center gap-2 py-1 min-h-[24px]">
<StatusIcon status={step.status} />
<div className="flex items-start gap-2 py-1 min-h-[24px]">
<span className="flex items-center h-[18px]">
<StatusIcon status={step.status} />
</span>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-1.5">
<KindIcon kind={step.kind} />
Expand All @@ -140,7 +142,7 @@ function StepRow({ packageId, step, onChanged }: { packageId: string; step: Setu
<div className="text-[10px] text-warm-faint dark:text-dark-faint mt-0.5">{step.hint}</div>
)}
</div>
<div className="flex-shrink-0">{renderAction()}</div>
<div className="flex-shrink-0 flex items-center h-[18px]">{renderAction()}</div>
{install?.kind === 'browser-extension' && install.manual && (
<ManualInstallModal
open={manualOpen}
Expand Down
36 changes: 36 additions & 0 deletions packages/core/src/connectors/prerequisites.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,42 @@ describe('PrerequisiteChecker', () => {
expect(steps[0].status).toBe('missing')
})

it('accepts zero-padded CalVer (e.g. yt-dlp 2026.03.17) by stripping leading zeros', async () => {
const exec = { run: vi.fn().mockResolvedValue({ exitCode: 0, stdout: '2026.03.17\n', stderr: '' }) }
const checker = new PrerequisiteChecker(exec as any)
const pkg = mkPkg('p1', [
{
id: 'yt-dlp',
name: 'yt-dlp',
kind: 'cli',
detect: { type: 'exec', command: 'yt-dlp', args: ['--version'], versionRegex: '(\\d{4}\\.\\d{2}\\.\\d{2})' },
minVersion: '2024.01.01',
install: { kind: 'cli', command: { darwin: 'brew install yt-dlp' } },
},
])
const steps = await checker.check(pkg)
expect(steps[0].status).toBe('ok')
expect(steps[0].detectedVersion).toBe('2026.03.17')
})

it('correctly compares zero-padded CalVer across years/months', async () => {
const exec = { run: vi.fn().mockResolvedValue({ exitCode: 0, stdout: '2024.02.05\n', stderr: '' }) }
const checker = new PrerequisiteChecker(exec as any)
const pkg = mkPkg('p1', [
{
id: 'yt-dlp',
name: 'yt-dlp',
kind: 'cli',
detect: { type: 'exec', command: 'yt-dlp', args: ['--version'], versionRegex: '(\\d{4}\\.\\d{2}\\.\\d{2})' },
minVersion: '2024.03.01',
install: { kind: 'cli', command: { darwin: 'brew install yt-dlp' } },
},
])
const steps = await checker.check(pkg)
expect(steps[0].status).toBe('outdated')
expect(steps[0].detectedVersion).toBe('2024.02.05')
})

it('marks outdated when version is below minVersion', async () => {
const exec = { run: vi.fn().mockResolvedValue({ exitCode: 0, stdout: 'v0.2.1\n', stderr: '' }) }
const checker = new PrerequisiteChecker(exec as any)
Expand Down
13 changes: 11 additions & 2 deletions packages/core/src/connectors/prerequisites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,15 @@ export class PrerequisiteChecker {
return baseStep(p, 'error', { hint: 'Could not parse version' })
}
const detectedVersion = vm[1]
if (!valid(detectedVersion)) {
// Normalize for semver: strip leading zeros from numeric segments so
// zero-padded CalVer (yt-dlp, Ubuntu, Postgres) like `2026.03.17`
// validates as `2026.3.17`. Ordering is preserved.
const normalizedDetected = stripLeadingZeros(detectedVersion)
const normalizedMin = stripLeadingZeros(p.minVersion)
if (!valid(normalizedDetected)) {
return baseStep(p, 'error', { hint: 'Could not parse detected version' })
}
if (gte(detectedVersion, p.minVersion)) {
if (gte(normalizedDetected, normalizedMin)) {
return baseStep(p, 'ok', { detectedVersion })
}
return baseStep(p, 'outdated', {
Expand All @@ -104,3 +109,7 @@ export class PrerequisiteChecker {
return result.exitCode === 0 ? baseStep(p, 'ok') : baseStep(p, 'missing')
}
}

function stripLeadingZeros(version: string): string {
return version.replace(/(^|\.)0+(\d)/g, '$1$2')
}