chore(packages): align platform package dirs
This commit is contained in:
+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