Files
qqq-cli/scripts/update-packaging.mjs
T
james.maesandClaude Fable 5.1 654fb08c83 packaging: a ready-to-copy QRun-IO/homebrew-tap and the with-UI artifact
docs/packaging/homebrew-tap/ is the whole tap repository (formula,
README, LICENSE, qqq-orb homebrew-tap profile); the formula moves there
as the single source, installs only bin/qqq with completions, says qqq ui
is bundled, and its test fails on a binary without the UI. The binary is
chmod 0755 before install: Homebrew downloads arrive without the
execute bit and the completion step runs the binary (found by installing
the formula in the homebrew/brew container, where it then installed,
passed brew test and wrote the three completion files). The Scoop
manifest describes the with-UI binary and notes the ConPTY requirement.
The packaging README covers Gatekeeper without notarization and the
xattr workaround, SmartScreen, and what is still unverified.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-31 19:19:13 -05:00

46 lines
2.0 KiB
JavaScript

#!/usr/bin/env node
/*
* Copyright 2026 QRun.IO, Inc.
* Licensed under the Apache License, Version 2.0 (see LICENSE).
*/
/**
* Fills the version and sha256 values of the packaging files (docs/packaging/homebrew-tap/Formula/qqq.rb for Homebrew,
* docs/packaging/qqq.json for Scoop) from packages/cli/package.json and a release's SHA256SUMS.
* Run it on the binaries that were uploaded to the GitHub release, not on a local rebuild: the
* commit is stamped into each binary, so every build has different checksums.
*
* Usage: node scripts/update-packaging.mjs [dist/SHA256SUMS]
*/
import { readFileSync, writeFileSync } from 'node:fs'
import { join, resolve } from 'node:path'
const root = resolve(import.meta.dirname, '..')
const sumsPath = resolve(process.argv[2] ?? join(root, 'dist/SHA256SUMS'))
const version = JSON.parse(readFileSync(join(root, 'packages/cli/package.json'), 'utf8')).version
const sums = new Map(readFileSync(sumsPath, 'utf8').trim().split('\n').map((line) => line.split(/\s+/).reverse()))
function sum(file) {
const hash = sums.get(file)
if (!hash) {
console.error(`update-packaging: ${sumsPath} has no ${file}`)
process.exit(1)
}
return hash
}
const formulaPath = join(root, 'docs/packaging/homebrew-tap/Formula/qqq.rb')
let formula = readFileSync(formulaPath, 'utf8').replace(/^(\s*version ")[^"]+"/m, `$1${version}"`)
formula = formula.replace(/(url "[^"]*\/(qqq-[a-z0-9-]+)"\n\s*sha256 ")[0-9a-f]{64}"/g, (_, head, file) => `${head}${sum(file)}"`)
writeFileSync(formulaPath, formula)
const manifestPath = join(root, 'docs/packaging/qqq.json')
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
manifest.version = version
manifest.architecture['64bit'].url = `https://github.com/QRun-IO/qqq-cli/releases/download/cli-v${version}/qqq-windows-x64.exe`
manifest.architecture['64bit'].hash = sum('qqq-windows-x64.exe')
writeFileSync(manifestPath, JSON.stringify(manifest, null, 4) + '\n')
console.log(`docs/packaging/homebrew-tap/Formula/qqq.rb and docs/packaging/qqq.json now name ${version} with the sums from ${sumsPath}`)