f31f50abec
Keep installer, config detection, schema generation, and publish workflows aligned with the long-lived oh-my-opencode package so this release does not split across two npm names. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
33 lines
900 B
TypeScript
33 lines
900 B
TypeScript
import { fetchNpmDistTags } from "./npm-dist-tags"
|
|
|
|
const DEFAULT_PACKAGE_NAME = "oh-my-opencode"
|
|
const PRIORITIZED_TAGS = ["latest", "beta", "next"] as const
|
|
|
|
function getFallbackEntry(version: string, packageName: string): string {
|
|
const prereleaseMatch = version.match(/-([a-zA-Z][a-zA-Z0-9-]*)(?:\.|$)/)
|
|
if (prereleaseMatch) {
|
|
return `${packageName}@${prereleaseMatch[1]}`
|
|
}
|
|
|
|
return packageName
|
|
}
|
|
|
|
export async function getPluginNameWithVersion(
|
|
currentVersion: string,
|
|
packageName: string = DEFAULT_PACKAGE_NAME
|
|
): Promise<string> {
|
|
const distTags = await fetchNpmDistTags(packageName)
|
|
|
|
|
|
if (distTags) {
|
|
const allTags = new Set([...PRIORITIZED_TAGS, ...Object.keys(distTags)])
|
|
for (const tag of allTags) {
|
|
if (distTags[tag] === currentVersion) {
|
|
return `${packageName}@${tag}`
|
|
}
|
|
}
|
|
}
|
|
|
|
return getFallbackEntry(currentVersion, packageName)
|
|
}
|