fix(#2849): resolve platform binaries using current package name
The installer wrapper and postinstall script still hardcoded the old oh-my-opencode-* platform package family. When users installed the renamed npm package oh-my-openagent (for example via npx oh-my-openagent install on WSL2/Linux), the main package installed correctly but the wrapper looked for nonexistent optional binaries like oh-my-opencode-linux-x64. Fix: - derive packageBaseName from package.json at runtime in wrapper/postinstall - thread packageBaseName through platform package candidate resolution - keep legacy oh-my-opencode default as fallback - add regression test for renamed package family
This commit is contained in:
+13
-13
@@ -3,11 +3,11 @@
|
||||
|
||||
/**
|
||||
* Get the platform-specific package name
|
||||
* @param {{ platform: string, arch: string, libcFamily?: string | null }} options
|
||||
* @param {{ platform: string, arch: string, libcFamily?: string | null, packageBaseName?: string }} options
|
||||
* @returns {string} Package name like "oh-my-opencode-darwin-arm64"
|
||||
* @throws {Error} If libc cannot be detected on Linux
|
||||
*/
|
||||
export function getPlatformPackage({ platform, arch, libcFamily }) {
|
||||
export function getPlatformPackage({ platform, arch, libcFamily, packageBaseName = "oh-my-opencode" }) {
|
||||
let suffix = "";
|
||||
if (platform === "linux") {
|
||||
if (libcFamily === null || libcFamily === undefined) {
|
||||
@@ -23,13 +23,13 @@ export function getPlatformPackage({ platform, arch, libcFamily }) {
|
||||
|
||||
// Map platform names: win32 -> windows (for package name)
|
||||
const os = platform === "win32" ? "windows" : platform;
|
||||
return `oh-my-opencode-${os}-${arch}${suffix}`;
|
||||
return `${packageBaseName}-${os}-${arch}${suffix}`;
|
||||
}
|
||||
|
||||
/** @param {{ platform: string, arch: string, libcFamily?: string | null, preferBaseline?: boolean }} options */
|
||||
export function getPlatformPackageCandidates({ platform, arch, libcFamily, preferBaseline = false }) {
|
||||
const primaryPackage = getPlatformPackage({ platform, arch, libcFamily });
|
||||
const baselinePackage = getBaselinePlatformPackage({ platform, arch, libcFamily });
|
||||
/** @param {{ platform: string, arch: string, libcFamily?: string | null, preferBaseline?: boolean, packageBaseName?: string }} options */
|
||||
export function getPlatformPackageCandidates({ platform, arch, libcFamily, preferBaseline = false, packageBaseName = "oh-my-opencode" }) {
|
||||
const primaryPackage = getPlatformPackage({ platform, arch, libcFamily, packageBaseName });
|
||||
const baselinePackage = getBaselinePlatformPackage({ platform, arch, libcFamily, packageBaseName });
|
||||
|
||||
if (!baselinePackage) {
|
||||
return [primaryPackage];
|
||||
@@ -38,18 +38,18 @@ export function getPlatformPackageCandidates({ platform, arch, libcFamily, prefe
|
||||
return preferBaseline ? [baselinePackage, primaryPackage] : [primaryPackage, baselinePackage];
|
||||
}
|
||||
|
||||
/** @param {{ platform: string, arch: string, libcFamily?: string | null }} options */
|
||||
function getBaselinePlatformPackage({ platform, arch, libcFamily }) {
|
||||
/** @param {{ platform: string, arch: string, libcFamily?: string | null, packageBaseName?: string }} options */
|
||||
function getBaselinePlatformPackage({ platform, arch, libcFamily, packageBaseName = "oh-my-opencode" }) {
|
||||
if (arch !== "x64") {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (platform === "darwin") {
|
||||
return "oh-my-opencode-darwin-x64-baseline";
|
||||
return `${packageBaseName}-darwin-x64-baseline`;
|
||||
}
|
||||
|
||||
if (platform === "win32") {
|
||||
return "oh-my-opencode-windows-x64-baseline";
|
||||
return `${packageBaseName}-windows-x64-baseline`;
|
||||
}
|
||||
|
||||
if (platform === "linux") {
|
||||
@@ -61,10 +61,10 @@ function getBaselinePlatformPackage({ platform, arch, libcFamily }) {
|
||||
}
|
||||
|
||||
if (libcFamily === "musl") {
|
||||
return "oh-my-opencode-linux-x64-musl-baseline";
|
||||
return `${packageBaseName}-linux-x64-musl-baseline`;
|
||||
}
|
||||
|
||||
return "oh-my-opencode-linux-x64-baseline";
|
||||
return `${packageBaseName}-linux-x64-baseline`;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user