1c54fdad26
- Add legacy plugin startup warning when oh-my-opencode config detected - Update CLI installer and TUI installer for new package name - Split monolithic config-manager.test.ts into focused test modules - Add plugin config detection tests for legacy name fallback - Update processed-command-store to use plugin-identity constants - Add claude-code-plugin-loader discovery test for both config names - Update chat-params and ultrawork-db tests for plugin identity Part of #2823
34 lines
938 B
TypeScript
34 lines
938 B
TypeScript
import { PLUGIN_NAME } from "../../shared"
|
|
import { fetchNpmDistTags } from "./npm-dist-tags"
|
|
|
|
const DEFAULT_PACKAGE_NAME = PLUGIN_NAME
|
|
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)
|
|
}
|