From 6886fe746b96f6d260ef9cc8b3178eed2653f138 Mon Sep 17 00:00:00 2001 From: Bulat Yapparov Date: Sat, 11 Apr 2026 23:00:15 +0100 Subject: [PATCH] chore: remove dead packages/cli/script/publish.ts (#54) This script was a parallel publish orchestration that wrote the package under name `@aictrl/cli-ai` (note the -ai suffix) and was never invoked by any workflow or npm script. The real publish pipeline lives in .github/workflows/publish.yml. Removing it eliminates a foot-gun where running it accidentally would publish a parallel @aictrl/cli-ai package. Closes #54 Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli/script/publish.ts | 181 --------------------------------- 1 file changed, 181 deletions(-) delete mode 100755 packages/cli/script/publish.ts diff --git a/packages/cli/script/publish.ts b/packages/cli/script/publish.ts deleted file mode 100755 index 1a91ce0..0000000 --- a/packages/cli/script/publish.ts +++ /dev/null @@ -1,181 +0,0 @@ -#!/usr/bin/env bun -import { $ } from "bun" -import pkg from "../package.json" -import { Script } from "@aictrl/script" -import { fileURLToPath } from "url" - -const dir = fileURLToPath(new URL("..", import.meta.url)) -process.chdir(dir) - -const binaries: Record = {} -for (const filepath of new Bun.Glob("*/package.json").scanSync({ cwd: "./dist" })) { - const pkg = await Bun.file(`./dist/${filepath}`).json() - binaries[pkg.name] = pkg.version -} -console.log("binaries", binaries) -const version = Object.values(binaries)[0] - -await $`mkdir -p ./dist/${pkg.name}` -await $`cp -r ./bin ./dist/${pkg.name}/bin` -await $`cp ./script/postinstall.mjs ./dist/${pkg.name}/postinstall.mjs` -await Bun.file(`./dist/${pkg.name}/LICENSE`).write(await Bun.file("../../LICENSE").text()) - -await Bun.file(`./dist/${pkg.name}/package.json`).write( - JSON.stringify( - { - name: pkg.name + "-ai", - bin: { - [pkg.name]: `./bin/${pkg.name}`, - }, - scripts: { - postinstall: "bun ./postinstall.mjs || node ./postinstall.mjs", - }, - version: version, - license: pkg.license, - optionalDependencies: binaries, - }, - null, - 2, - ), -) - -const tasks = Object.entries(binaries).map(async ([name]) => { - if (process.platform !== "win32") { - await $`chmod -R 755 .`.cwd(`./dist/${name}`) - } - await $`bun pm pack`.cwd(`./dist/${name}`) - await $`npm publish *.tgz --access public --tag ${Script.channel}`.cwd(`./dist/${name}`) -}) -await Promise.all(tasks) -await $`cd ./dist/${pkg.name} && bun pm pack && npm publish *.tgz --access public --tag ${Script.channel}` - -const image = "ghcr.io/anomalyco/aictrl" -const platforms = "linux/amd64,linux/arm64" -const tags = [`${image}:${version}`, `${image}:${Script.channel}`] -const tagFlags = tags.flatMap((t) => ["-t", t]) -await $`docker buildx build --platform ${platforms} ${tagFlags} --push .` - -// registries -if (!Script.preview) { - // Calculate SHA values - const arm64Sha = await $`sha256sum ./dist/aictrl-linux-arm64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim()) - const x64Sha = await $`sha256sum ./dist/aictrl-linux-x64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim()) - const macX64Sha = await $`sha256sum ./dist/aictrl-darwin-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) - const macArm64Sha = await $`sha256sum ./dist/aictrl-darwin-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) - - const [pkgver, _subver = ""] = Script.version.split(/(-.*)/, 2) - - // arch - const binaryPkgbuild = [ - "# Maintainer: dax", - "# Maintainer: adam", - "", - "pkgname='aictrl-bin'", - `pkgver=${pkgver}`, - `_subver=${_subver}`, - "options=('!debug' '!strip')", - "pkgrel=1", - "pkgdesc='The AI coding agent built for the terminal.'", - "url='https://github.com/anomalyco/aictrl'", - "arch=('aarch64' 'x86_64')", - "license=('MIT')", - "provides=('aictrl')", - "conflicts=('aictrl')", - "depends=('ripgrep')", - "", - `source_aarch64=("\${pkgname}_\${pkgver}_aarch64.tar.gz::https://github.com/anomalyco/aictrl/releases/download/v\${pkgver}\${_subver}/aictrl-linux-arm64.tar.gz")`, - `sha256sums_aarch64=('${arm64Sha}')`, - - `source_x86_64=("\${pkgname}_\${pkgver}_x86_64.tar.gz::https://github.com/anomalyco/aictrl/releases/download/v\${pkgver}\${_subver}/aictrl-linux-x64.tar.gz")`, - `sha256sums_x86_64=('${x64Sha}')`, - "", - "package() {", - ' install -Dm755 ./aictrl "${pkgdir}/usr/bin/aictrl"', - "}", - "", - ].join("\n") - - for (const [pkg, pkgbuild] of [["aictrl-bin", binaryPkgbuild]]) { - for (let i = 0; i < 30; i++) { - try { - await $`rm -rf ./dist/aur-${pkg}` - await $`git clone ssh://aur@aur.archlinux.org/${pkg}.git ./dist/aur-${pkg}` - await $`cd ./dist/aur-${pkg} && git checkout master` - await Bun.file(`./dist/aur-${pkg}/PKGBUILD`).write(pkgbuild) - await $`cd ./dist/aur-${pkg} && makepkg --printsrcinfo > .SRCINFO` - await $`cd ./dist/aur-${pkg} && git add PKGBUILD .SRCINFO` - await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${Script.version}"` - await $`cd ./dist/aur-${pkg} && git push` - break - } catch (e) { - continue - } - } - } - - // Homebrew formula - const homebrewFormula = [ - "# typed: false", - "# frozen_string_literal: true", - "", - "# This file was generated by GoReleaser. DO NOT EDIT.", - "class Opencode < Formula", - ` desc "The AI coding agent built for the terminal."`, - ` homepage "https://github.com/anomalyco/aictrl"`, - ` version "${Script.version.split("-")[0]}"`, - "", - ` depends_on "ripgrep"`, - "", - " on_macos do", - " if Hardware::CPU.intel?", - ` url "https://github.com/anomalyco/aictrl/releases/download/v${Script.version}/aictrl-darwin-x64.zip"`, - ` sha256 "${macX64Sha}"`, - "", - " def install", - ' bin.install "aictrl"', - " end", - " end", - " if Hardware::CPU.arm?", - ` url "https://github.com/anomalyco/aictrl/releases/download/v${Script.version}/aictrl-darwin-arm64.zip"`, - ` sha256 "${macArm64Sha}"`, - "", - " def install", - ' bin.install "aictrl"', - " end", - " end", - " end", - "", - " on_linux do", - " if Hardware::CPU.intel? and Hardware::CPU.is_64_bit?", - ` url "https://github.com/anomalyco/aictrl/releases/download/v${Script.version}/aictrl-linux-x64.tar.gz"`, - ` sha256 "${x64Sha}"`, - " def install", - ' bin.install "aictrl"', - " end", - " end", - " if Hardware::CPU.arm? and Hardware::CPU.is_64_bit?", - ` url "https://github.com/anomalyco/aictrl/releases/download/v${Script.version}/aictrl-linux-arm64.tar.gz"`, - ` sha256 "${arm64Sha}"`, - " def install", - ' bin.install "aictrl"', - " end", - " end", - " end", - "end", - "", - "", - ].join("\n") - - const token = process.env.GITHUB_TOKEN - if (!token) { - console.error("GITHUB_TOKEN is required to update homebrew tap") - process.exit(1) - } - const tap = `https://x-access-token:${token}@github.com/anomalyco/homebrew-tap.git` - await $`rm -rf ./dist/homebrew-tap` - await $`git clone ${tap} ./dist/homebrew-tap` - await Bun.file("./dist/homebrew-tap/aictrl.rb").write(homebrewFormula) - await $`cd ./dist/homebrew-tap && git add aictrl.rb` - await $`cd ./dist/homebrew-tap && git commit -m "Update to v${Script.version}"` - await $`cd ./dist/homebrew-tap && git push` -}