chore(packages): align platform package dirs
This commit is contained in:
@@ -32,26 +32,27 @@ describe("build-binaries", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("has correct directory names for baseline platforms", async () => {
|
||||
it("uses exact package names as platform package directories", async () => {
|
||||
// given
|
||||
const module = await import("./build-binaries.ts");
|
||||
const platforms = (module as { PLATFORMS: { dir: string; target: string }[] }).PLATFORMS;
|
||||
const platforms = (module as { PLATFORMS: { packageName: string; packageDir: string }[] }).PLATFORMS;
|
||||
|
||||
// when
|
||||
const baselinePlatforms = platforms.filter((p) => p.target.includes("baseline"));
|
||||
const packageNames = platforms.map((p) => p.packageName);
|
||||
const packageDirs = platforms.map((p) => p.packageDir);
|
||||
|
||||
// then
|
||||
expect(baselinePlatforms.length).toBe(4);
|
||||
expect(baselinePlatforms.map((p) => p.dir)).toContain("linux-x64-baseline");
|
||||
expect(baselinePlatforms.map((p) => p.dir)).toContain("linux-x64-musl-baseline");
|
||||
expect(baselinePlatforms.map((p) => p.dir)).toContain("darwin-x64-baseline");
|
||||
expect(baselinePlatforms.map((p) => p.dir)).toContain("windows-x64-baseline");
|
||||
expect(packageDirs).toEqual(packageNames);
|
||||
expect(packageDirs).toContain("oh-my-opencode-linux-x64-baseline");
|
||||
expect(packageDirs).toContain("oh-my-opencode-linux-x64-musl-baseline");
|
||||
expect(packageDirs).toContain("oh-my-opencode-darwin-x64-baseline");
|
||||
expect(packageDirs).toContain("oh-my-opencode-windows-x64-baseline");
|
||||
});
|
||||
|
||||
it("has correct binary names for baseline platforms", async () => {
|
||||
// given
|
||||
const module = await import("./build-binaries.ts");
|
||||
const platforms = (module as { PLATFORMS: { dir: string; target: string; binary: string }[] }).PLATFORMS;
|
||||
const platforms = (module as { PLATFORMS: { packageDir: string; target: string; binary: string }[] }).PLATFORMS;
|
||||
|
||||
// when
|
||||
const windowsBaseline = platforms.find((p) => p.target === "bun-windows-x64-baseline");
|
||||
|
||||
+15
-13
@@ -7,30 +7,32 @@ import { existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
interface PlatformTarget {
|
||||
dir: string;
|
||||
platform: string;
|
||||
packageName: string;
|
||||
packageDir: string;
|
||||
target: string;
|
||||
binary: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export const PLATFORMS: PlatformTarget[] = [
|
||||
{ dir: "darwin-arm64", target: "bun-darwin-arm64", binary: "oh-my-opencode", description: "macOS ARM64" },
|
||||
{ dir: "darwin-x64", target: "bun-darwin-x64", binary: "oh-my-opencode", description: "macOS x64" },
|
||||
{ dir: "darwin-x64-baseline", target: "bun-darwin-x64-baseline", binary: "oh-my-opencode", description: "macOS x64 (no AVX2)" },
|
||||
{ dir: "linux-x64", target: "bun-linux-x64", binary: "oh-my-opencode", description: "Linux x64 (glibc)" },
|
||||
{ dir: "linux-x64-baseline", target: "bun-linux-x64-baseline", binary: "oh-my-opencode", description: "Linux x64 (glibc, no AVX2)" },
|
||||
{ dir: "linux-arm64", target: "bun-linux-arm64", binary: "oh-my-opencode", description: "Linux ARM64 (glibc)" },
|
||||
{ dir: "linux-x64-musl", target: "bun-linux-x64-musl", binary: "oh-my-opencode", description: "Linux x64 (musl)" },
|
||||
{ dir: "linux-x64-musl-baseline", target: "bun-linux-x64-musl-baseline", binary: "oh-my-opencode", description: "Linux x64 (musl, no AVX2)" },
|
||||
{ dir: "linux-arm64-musl", target: "bun-linux-arm64-musl", binary: "oh-my-opencode", description: "Linux ARM64 (musl)" },
|
||||
{ dir: "windows-x64", target: "bun-windows-x64", binary: "oh-my-opencode.exe", description: "Windows x64" },
|
||||
{ dir: "windows-x64-baseline", target: "bun-windows-x64-baseline", binary: "oh-my-opencode.exe", description: "Windows x64 (no AVX2)" },
|
||||
{ platform: "darwin-arm64", packageName: "oh-my-opencode-darwin-arm64", packageDir: "oh-my-opencode-darwin-arm64", target: "bun-darwin-arm64", binary: "oh-my-opencode", description: "macOS ARM64" },
|
||||
{ platform: "darwin-x64", packageName: "oh-my-opencode-darwin-x64", packageDir: "oh-my-opencode-darwin-x64", target: "bun-darwin-x64", binary: "oh-my-opencode", description: "macOS x64" },
|
||||
{ platform: "darwin-x64-baseline", packageName: "oh-my-opencode-darwin-x64-baseline", packageDir: "oh-my-opencode-darwin-x64-baseline", target: "bun-darwin-x64-baseline", binary: "oh-my-opencode", description: "macOS x64 (no AVX2)" },
|
||||
{ platform: "linux-x64", packageName: "oh-my-opencode-linux-x64", packageDir: "oh-my-opencode-linux-x64", target: "bun-linux-x64", binary: "oh-my-opencode", description: "Linux x64 (glibc)" },
|
||||
{ platform: "linux-x64-baseline", packageName: "oh-my-opencode-linux-x64-baseline", packageDir: "oh-my-opencode-linux-x64-baseline", target: "bun-linux-x64-baseline", binary: "oh-my-opencode", description: "Linux x64 (glibc, no AVX2)" },
|
||||
{ platform: "linux-arm64", packageName: "oh-my-opencode-linux-arm64", packageDir: "oh-my-opencode-linux-arm64", target: "bun-linux-arm64", binary: "oh-my-opencode", description: "Linux ARM64 (glibc)" },
|
||||
{ platform: "linux-x64-musl", packageName: "oh-my-opencode-linux-x64-musl", packageDir: "oh-my-opencode-linux-x64-musl", target: "bun-linux-x64-musl", binary: "oh-my-opencode", description: "Linux x64 (musl)" },
|
||||
{ platform: "linux-x64-musl-baseline", packageName: "oh-my-opencode-linux-x64-musl-baseline", packageDir: "oh-my-opencode-linux-x64-musl-baseline", target: "bun-linux-x64-musl-baseline", binary: "oh-my-opencode", description: "Linux x64 (musl, no AVX2)" },
|
||||
{ platform: "linux-arm64-musl", packageName: "oh-my-opencode-linux-arm64-musl", packageDir: "oh-my-opencode-linux-arm64-musl", target: "bun-linux-arm64-musl", binary: "oh-my-opencode", description: "Linux ARM64 (musl)" },
|
||||
{ platform: "windows-x64", packageName: "oh-my-opencode-windows-x64", packageDir: "oh-my-opencode-windows-x64", target: "bun-windows-x64", binary: "oh-my-opencode.exe", description: "Windows x64" },
|
||||
{ platform: "windows-x64-baseline", packageName: "oh-my-opencode-windows-x64-baseline", packageDir: "oh-my-opencode-windows-x64-baseline", target: "bun-windows-x64-baseline", binary: "oh-my-opencode.exe", description: "Windows x64 (no AVX2)" },
|
||||
];
|
||||
|
||||
const ENTRY_POINT = "src/cli/index.ts";
|
||||
|
||||
async function buildPlatform(platform: PlatformTarget): Promise<boolean> {
|
||||
const outfile = join("packages", platform.dir, "bin", platform.binary);
|
||||
const outfile = join("packages", platform.packageDir, "bin", platform.binary);
|
||||
|
||||
console.log(`\n📦 Building ${platform.description}...`);
|
||||
console.log(` Target: ${platform.target}`);
|
||||
|
||||
+23
-14
@@ -10,15 +10,24 @@ const versionOverride = process.env.VERSION
|
||||
const republishMode = process.env.REPUBLISH === "true"
|
||||
const prepareOnly = process.argv.includes("--prepare-only")
|
||||
|
||||
const PLATFORM_PACKAGES = [
|
||||
const PLATFORM_PACKAGE_IDS = [
|
||||
"darwin-arm64",
|
||||
"darwin-x64",
|
||||
"darwin-x64-baseline",
|
||||
"linux-x64",
|
||||
"linux-x64-baseline",
|
||||
"linux-arm64",
|
||||
"linux-x64-musl",
|
||||
"linux-x64-musl-baseline",
|
||||
"linux-arm64-musl",
|
||||
"windows-x64",
|
||||
]
|
||||
] as const
|
||||
|
||||
const PLATFORM_PACKAGES = PLATFORM_PACKAGE_IDS.map((platform) => ({
|
||||
platform,
|
||||
packageName: `${PACKAGE_NAME}-${platform}`,
|
||||
packageDir: `${PACKAGE_NAME}-${platform}`,
|
||||
}))
|
||||
|
||||
console.log("=== Publishing oh-my-opencode (multi-package) ===\n")
|
||||
|
||||
@@ -65,8 +74,8 @@ async function updateAllPackageVersions(newVersion: string): Promise<void> {
|
||||
|
||||
// Update optionalDependencies versions in main package.json
|
||||
let mainPkg = await Bun.file(mainPkgPath).text()
|
||||
for (const platform of PLATFORM_PACKAGES) {
|
||||
const pkgName = `oh-my-opencode-${platform}`
|
||||
for (const platformPackage of PLATFORM_PACKAGES) {
|
||||
const pkgName = platformPackage.packageName
|
||||
mainPkg = mainPkg.replace(
|
||||
new RegExp(`"${pkgName}": "[^"]+"`),
|
||||
`"${pkgName}": "${newVersion}"`
|
||||
@@ -75,8 +84,8 @@ async function updateAllPackageVersions(newVersion: string): Promise<void> {
|
||||
await Bun.write(mainPkgPath, mainPkg)
|
||||
|
||||
// Update each platform package.json
|
||||
for (const platform of PLATFORM_PACKAGES) {
|
||||
const pkgPath = new URL(`../packages/${platform}/package.json`, import.meta.url).pathname
|
||||
for (const platformPackage of PLATFORM_PACKAGES) {
|
||||
const pkgPath = new URL(`../packages/${platformPackage.packageDir}/package.json`, import.meta.url).pathname
|
||||
if (existsSync(pkgPath)) {
|
||||
await updatePackageVersion(pkgPath, newVersion)
|
||||
} else {
|
||||
@@ -266,16 +275,16 @@ async function publishAllPackages(version: string): Promise<void> {
|
||||
const batchNum = Math.floor(i / BATCH_SIZE) + 1
|
||||
const totalBatches = Math.ceil(PLATFORM_PACKAGES.length / BATCH_SIZE)
|
||||
|
||||
console.log(`\n Batch ${batchNum}/${totalBatches}: ${batch.join(", ")}`)
|
||||
console.log(`\n Batch ${batchNum}/${totalBatches}: ${batch.map((platformPackage) => platformPackage.platform).join(", ")}`)
|
||||
|
||||
const publishPromises = batch.map(async (platform) => {
|
||||
const pkgDir = join(process.cwd(), "packages", platform)
|
||||
const pkgName = `oh-my-opencode-${platform}`
|
||||
const publishPromises = batch.map(async (platformPackage) => {
|
||||
const pkgDir = join(process.cwd(), "packages", platformPackage.packageDir)
|
||||
const pkgName = platformPackage.packageName
|
||||
|
||||
console.log(` Starting ${pkgName}...`)
|
||||
const result = await publishPackage(pkgDir, distTag, false, pkgName, version)
|
||||
|
||||
return { platform, pkgName, result }
|
||||
return { platform: platformPackage.platform, pkgName, result }
|
||||
})
|
||||
|
||||
const results = await Promise.all(publishPromises)
|
||||
@@ -338,8 +347,8 @@ async function gitTagAndRelease(newVersion: string, notes: string[]): Promise<vo
|
||||
|
||||
// Add all package.json files
|
||||
await $`git add package.json assets/oh-my-opencode.schema.json`
|
||||
for (const platform of PLATFORM_PACKAGES) {
|
||||
await $`git add packages/${platform}/package.json`.nothrow()
|
||||
for (const platformPackage of PLATFORM_PACKAGES) {
|
||||
await $`git add packages/${platformPackage.packageDir}/package.json`.nothrow()
|
||||
}
|
||||
|
||||
const hasStagedChanges = await $`git diff --cached --quiet`.nothrow()
|
||||
@@ -417,7 +426,7 @@ async function main() {
|
||||
await publishAllPackages(newVersion)
|
||||
await gitTagAndRelease(newVersion, notes)
|
||||
|
||||
console.log(`\n=== Successfully published ${PACKAGE_NAME}@${newVersion} (8 packages) ===`)
|
||||
console.log(`\n=== Successfully published ${PACKAGE_NAME}@${newVersion} (${PLATFORM_PACKAGES.length + 1} packages) ===`)
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user