mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
chore(opencode): move the OpenCode pin to 2.2.5 from a workspace catalog
Manager builds against and requires OpenCode 2.2.5. Every @opencode package, plus effect and the OpenTUI/solid dependencies they share, resolves from one pnpm workspace catalog instead of separate pins. The built-against version and the supported floor are now separate settings, so a future OpenCode release can move the pin before raising the floor. Docker and the dev setup script read the floor from its own argument. ocm-cli moves to 0.6.0 on the same 2.2.5 and OpenTUI 0.8 baseline. A linked server on a different version is still connectable and now shows a neutral version notice instead of an unsupported badge.
This commit is contained in:
1 parent
dc0220843e
commit
807c7cb896
20 files changed
+583
-562
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { parseSemver } from '@opencode-manager/shared/utils'
|
||||
import { compareSemver, parseSemver } from '@opencode-manager/shared/utils'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
interface PackageManifest {
|
||||
@@ -20,21 +20,40 @@ function readManifest(path: string): PackageManifest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Derives the minor-line peer range for a plugin's exact dependency pin.
|
||||
* Reads the version of a dependency installed in ocm-cli's node_modules.
|
||||
*/
|
||||
function installedVersion(name: string): string {
|
||||
return readManifest(join(__dirname, '..', 'node_modules', name, 'package.json')).version
|
||||
}
|
||||
|
||||
/**
|
||||
* Derives the minor-line peer range for an exact dependency version.
|
||||
*
|
||||
* A `0.x.y` pin is constrained to its minor line; a pin at major `1` or above
|
||||
* A `0.x.y` version is constrained to its minor line; a version at major `1` or above
|
||||
* is constrained to its major line.
|
||||
*/
|
||||
function deriveMinorLineRange(pin: string): string {
|
||||
const parsed = parseSemver(pin)
|
||||
function deriveMinorLineRange(version: string): string {
|
||||
const parsed = parseSemver(version)
|
||||
if (!parsed || parsed.prerelease.length > 0) {
|
||||
throw new Error(`Cannot derive a peer range from pin "${pin}"`)
|
||||
throw new Error(`Cannot derive a peer range from version "${version}"`)
|
||||
}
|
||||
const { major, minor } = parsed
|
||||
if (major === 0) {
|
||||
return `>=0.${minor}.0 <0.${minor + 1}.0`
|
||||
}
|
||||
return `>=${pin} <${major + 1}.0.0`
|
||||
return `>=${version} <${major + 1}.0.0`
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that an installed version satisfies a plugin peer declaration,
|
||||
* accepting both an exact peer pin and an open `>=` floor.
|
||||
*/
|
||||
function expectVersionSatisfiesPeer(version: string, peer: string): void {
|
||||
if (peer.startsWith('>=')) {
|
||||
expect(compareSemver(version, peer.slice(2).trim())).toBeGreaterThanOrEqual(0)
|
||||
return
|
||||
}
|
||||
expect(version).toBe(peer)
|
||||
}
|
||||
|
||||
const ocmManifest = readManifest(join(__dirname, '..', 'package.json'))
|
||||
@@ -44,15 +63,16 @@ const pluginManifest = readManifest(
|
||||
|
||||
describe('ocm-cli package compatibility with the installed @opencode/plugin', () => {
|
||||
for (const name of PINNED_PACKAGES) {
|
||||
it(`${name} matches the plugin peer pin`, () => {
|
||||
const pluginPin = pluginManifest.peerDependencies[name]
|
||||
expect(ocmManifest.devDependencies[name]).toBe(pluginPin)
|
||||
expect(ocmManifest.peerDependencies[name]).toBe(deriveMinorLineRange(pluginPin))
|
||||
it(`${name} satisfies the plugin peer and derives the published peer range`, () => {
|
||||
const version = installedVersion(name)
|
||||
expectVersionSatisfiesPeer(version, pluginManifest.peerDependencies[name]!)
|
||||
expect(ocmManifest.devDependencies[name]).toBe('catalog:')
|
||||
expect(ocmManifest.peerDependencies[name]).toBe(deriveMinorLineRange(version))
|
||||
expect(ocmManifest.peerDependenciesMeta[name]?.optional).toBe(true)
|
||||
})
|
||||
}
|
||||
|
||||
it('@opencode/plugin devDependency matches the installed plugin version', () => {
|
||||
expect(ocmManifest.devDependencies['@opencode/plugin']).toBe(pluginManifest.version)
|
||||
it('resolves @opencode/plugin from the workspace catalog', () => {
|
||||
expect(ocmManifest.devDependencies['@opencode/plugin']).toBe('catalog:')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user