Files
oh-my-opencode/src/cli/config-manager/plugin-name-with-version.ts
T
YeonGyu-Kim f31f50abec fix(release): revert package identity to oh-my-opencode
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>
2026-03-16 10:38:55 +09:00

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)
}