mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Move the OpenCode pin and supported floor to 2.3.0
This commit is contained in:
1 parent
eba86dc3fc
commit
23d9d1c945
18 files changed
+259
-342
No files matched your search
@@ -131,46 +131,46 @@ describe('resolveOpenCodeInstallTarget', () => {
|
||||
describe('installOpenCodeVersion', () => {
|
||||
it('downloads, verifies and installs the requested version', async () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const archivePath = createArchive(workDirectory, '2.2.5')
|
||||
const archivePath = createArchive(workDirectory, '2.3.0')
|
||||
const { calls, fetchFn } = createFetch(archivePath)
|
||||
|
||||
const installedPath = await installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
const installedPath = await installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
|
||||
expect(installedPath).toBe(resolveOpenCodeBinaryPath(homeDirectory))
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.2.5/opencode-linux-x64.tar.gz'])
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.3.0/opencode-linux-x64.tar.gz'])
|
||||
expect(statSync(installedPath).mode & 0o777).toBe(0o755)
|
||||
expect(readFileSync(installedPath, 'utf-8')).toContain('2.2.5')
|
||||
expect(readFileSync(installedPath, 'utf-8')).toContain('2.3.0')
|
||||
})
|
||||
|
||||
it('requests the musl asset for a musl linux target', async () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const archivePath = createArchive(workDirectory, '2.2.5')
|
||||
const archivePath = createArchive(workDirectory, '2.3.0')
|
||||
const { calls, fetchFn } = createFetch(archivePath)
|
||||
|
||||
await installOpenCodeVersion('2.2.5', {
|
||||
await installOpenCodeVersion('2.3.0', {
|
||||
fetch: fetchFn,
|
||||
homeDirectory,
|
||||
target: { platform: 'linux', arch: 'arm64', musl: true },
|
||||
})
|
||||
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.2.5/opencode-linux-arm64-musl.tar.gz'])
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.3.0/opencode-linux-arm64-musl.tar.gz'])
|
||||
})
|
||||
|
||||
it('extracts the darwin zip asset and installs it', async () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const archivePath = createDarwinArchive(workDirectory, '2.2.5')
|
||||
const archivePath = createDarwinArchive(workDirectory, '2.3.0')
|
||||
const { calls, fetchFn } = createFetch(archivePath)
|
||||
|
||||
const installedPath = await installOpenCodeVersion('2.2.5', {
|
||||
const installedPath = await installOpenCodeVersion('2.3.0', {
|
||||
fetch: fetchFn,
|
||||
homeDirectory,
|
||||
target: { platform: 'darwin', arch: 'arm64', musl: false },
|
||||
})
|
||||
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.2.5/opencode-darwin-arm64.zip'])
|
||||
expect(calls).toEqual(['https://opencode.ai/files/bin/2.3.0/opencode-darwin-arm64.zip'])
|
||||
expect(installedPath).toBe(resolveOpenCodeBinaryPath(homeDirectory))
|
||||
expect(statSync(installedPath).mode & 0o777).toBe(0o755)
|
||||
expect(readFileSync(installedPath, 'utf-8')).toContain('2.2.5')
|
||||
expect(readFileSync(installedPath, 'utf-8')).toContain('2.3.0')
|
||||
})
|
||||
|
||||
it('rejects an OpenCode 1.x version before downloading anything', async () => {
|
||||
@@ -178,18 +178,18 @@ describe('installOpenCodeVersion', () => {
|
||||
const { calls, fetchFn } = createFetch(null)
|
||||
|
||||
await expect(installOpenCodeVersion('1.18.32', { fetch: fetchFn, homeDirectory, target: linuxTarget }))
|
||||
.rejects.toThrow('OpenCode 1.18.32 is not supported; OpenCode Manager requires OpenCode >=2.2.5 <3.0.0')
|
||||
.rejects.toThrow('OpenCode 1.18.32 is not supported; OpenCode Manager requires OpenCode >=2.3.0 <3.0.0')
|
||||
expect(calls).toEqual([])
|
||||
})
|
||||
|
||||
it.each(['2.2.4', '3.0.0', '2.2.5-beta.1', '2.2.5; rm -rf /'])(
|
||||
it.each(['2.2.7', '3.0.0', '2.3.0-beta.1', '2.3.0; rm -rf /'])(
|
||||
'rejects %s outside the supported stable range before downloading anything',
|
||||
async (version) => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const { calls, fetchFn } = createFetch(null)
|
||||
|
||||
await expect(installOpenCodeVersion(version, { fetch: fetchFn, homeDirectory, target: linuxTarget }))
|
||||
.rejects.toThrow(/requires OpenCode >=2\.2\.5 <3\.0\.0/)
|
||||
.rejects.toThrow(/requires OpenCode >=2\.3\.0 <3\.0\.0/)
|
||||
expect(calls).toEqual([])
|
||||
},
|
||||
)
|
||||
@@ -198,18 +198,18 @@ describe('installOpenCodeVersion', () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const { fetchFn } = createFetch(null, 404)
|
||||
|
||||
await expect(installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget }))
|
||||
await expect(installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget }))
|
||||
.rejects.toThrow(/404/)
|
||||
expect(() => statSync(resolveOpenCodeBinaryPath(homeDirectory))).toThrow()
|
||||
})
|
||||
|
||||
it('fails and leaves no binary behind when the archive reports a different version', async () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const archivePath = createArchive(workDirectory, '2.2.6')
|
||||
const archivePath = createArchive(workDirectory, '2.3.1')
|
||||
const { fetchFn } = createFetch(archivePath)
|
||||
|
||||
await expect(installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget }))
|
||||
.rejects.toThrow(/2\.2\.5/)
|
||||
await expect(installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget }))
|
||||
.rejects.toThrow(/2\.3\.0/)
|
||||
expect(() => statSync(resolveOpenCodeBinaryPath(homeDirectory))).toThrow()
|
||||
})
|
||||
|
||||
@@ -218,21 +218,21 @@ describe('installOpenCodeVersion', () => {
|
||||
mkdirSync(join(homeDirectory, '.opencode', 'bin'), { recursive: true })
|
||||
writeFileSync(resolveOpenCodeBinaryPath(homeDirectory), '#!/bin/sh\necho "opencode v2.1.1"\n')
|
||||
|
||||
const archivePath = createArchive(workDirectory, '2.2.5')
|
||||
const archivePath = createArchive(workDirectory, '2.3.0')
|
||||
const { fetchFn } = createFetch(archivePath)
|
||||
|
||||
await installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
await installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
|
||||
expect(readFileSync(resolveOpenCodeBinaryPath(homeDirectory), 'utf-8')).toContain('2.2.5')
|
||||
expect(readFileSync(resolveOpenCodeBinaryPath(homeDirectory), 'utf-8')).toContain('2.3.0')
|
||||
})
|
||||
|
||||
it('cleans up its staging directory after a successful install', async () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const archivePath = createArchive(workDirectory, '2.2.5')
|
||||
const archivePath = createArchive(workDirectory, '2.3.0')
|
||||
const { fetchFn } = createFetch(archivePath)
|
||||
|
||||
const before = countStagingDirectories()
|
||||
await installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
await installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
|
||||
expect(countStagingDirectories()).toBe(before)
|
||||
})
|
||||
@@ -244,15 +244,15 @@ describe('listOpenCodeVersions', () => {
|
||||
'1.18.32': {},
|
||||
'2.0.14': {},
|
||||
'2.1.1': {},
|
||||
'2.2.5': {},
|
||||
'2.2.6': {},
|
||||
'2.2.5-beta.1': {},
|
||||
'2.3.0': {},
|
||||
'2.3.1': {},
|
||||
'2.3.0-beta.1': {},
|
||||
'3.0.0': {},
|
||||
'not-a-version': {},
|
||||
},
|
||||
time: {
|
||||
'2.2.5': '2026-02-01T00:00:00.000Z',
|
||||
'2.2.6': '2026-03-01T00:00:00.000Z',
|
||||
'2.3.0': '2026-02-01T00:00:00.000Z',
|
||||
'2.3.1': '2026-03-01T00:00:00.000Z',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -262,20 +262,20 @@ describe('listOpenCodeVersions', () => {
|
||||
const versions = await listOpenCodeVersions({ fetch: fetchFn })
|
||||
|
||||
expect(versions).toEqual([
|
||||
{ version: '2.2.6', publishedAt: '2026-03-01T00:00:00.000Z' },
|
||||
{ version: '2.2.5', publishedAt: '2026-02-01T00:00:00.000Z' },
|
||||
{ version: '2.3.1', publishedAt: '2026-03-01T00:00:00.000Z' },
|
||||
{ version: '2.3.0', publishedAt: '2026-02-01T00:00:00.000Z' },
|
||||
])
|
||||
expect(calls).toEqual(['https://registry.npmjs.org/@opencode/cli'])
|
||||
})
|
||||
|
||||
it('reports a null publishedAt when the registry has no timestamp for a version', async () => {
|
||||
const { fetchFn } = createRegistryFetch({
|
||||
versions: { '2.2.5': {} },
|
||||
versions: { '2.3.0': {} },
|
||||
time: {},
|
||||
})
|
||||
|
||||
await expect(listOpenCodeVersions({ fetch: fetchFn })).resolves.toEqual([
|
||||
{ version: '2.2.5', publishedAt: null },
|
||||
{ version: '2.3.0', publishedAt: null },
|
||||
])
|
||||
})
|
||||
|
||||
@@ -293,14 +293,14 @@ describe('listOpenCodeVersions', () => {
|
||||
|
||||
it('refreshes the list once the five minute cache expires', async () => {
|
||||
const stale = createRegistryFetch(registryPayload)
|
||||
const fresh = createRegistryFetch({ versions: { '2.2.7': {} }, time: {} })
|
||||
const fresh = createRegistryFetch({ versions: { '2.3.1': {} }, time: {} })
|
||||
let now = 1_000_000
|
||||
|
||||
await listOpenCodeVersions({ fetch: stale.fetchFn, now: () => now })
|
||||
now += 5 * 60 * 1000
|
||||
const refreshed = await listOpenCodeVersions({ fetch: fresh.fetchFn, now: () => now })
|
||||
|
||||
expect(refreshed).toEqual([{ version: '2.2.7', publishedAt: null }])
|
||||
expect(refreshed).toEqual([{ version: '2.3.1', publishedAt: null }])
|
||||
expect(stale.calls).toHaveLength(1)
|
||||
expect(fresh.calls).toHaveLength(1)
|
||||
})
|
||||
@@ -331,7 +331,7 @@ describe('OpenCodeInstallError swap signalling', () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
const { fetchFn } = createFetch(null, 404)
|
||||
|
||||
const promise = installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
const promise = installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
|
||||
await expect(promise).rejects.toBeInstanceOf(OpenCodeInstallError)
|
||||
await expect(promise).rejects.toMatchObject({ swapStarted: false })
|
||||
@@ -341,10 +341,10 @@ describe('OpenCodeInstallError swap signalling', () => {
|
||||
it('marks a failure while replacing the binary as having started the binary swap', async () => {
|
||||
const homeDirectory = join(workDirectory, 'home')
|
||||
mkdirSync(resolveOpenCodeBinaryPath(homeDirectory), { recursive: true })
|
||||
const archivePath = createArchive(workDirectory, '2.2.5')
|
||||
const archivePath = createArchive(workDirectory, '2.3.0')
|
||||
const { fetchFn } = createFetch(archivePath)
|
||||
|
||||
const promise = installOpenCodeVersion('2.2.5', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
const promise = installOpenCodeVersion('2.3.0', { fetch: fetchFn, homeDirectory, target: linuxTarget })
|
||||
|
||||
await expect(promise).rejects.toBeInstanceOf(OpenCodeInstallError)
|
||||
await expect(promise).rejects.toMatchObject({ swapStarted: true })
|
||||
|
||||
Reference in new issue
Block a user