2026-03-11 09:07:17 +01:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
/**
|
|
|
|
|
* Sync pkg/package.json version with the installed @mariozechner/pi-coding-agent version.
|
|
|
|
|
*
|
2026-04-15 14:54:20 +02:00
|
|
|
* sf-run sets PI_PACKAGE_DIR=pkg/ so that pi's config.js reads piConfig from
|
2026-04-15 15:37:12 +02:00
|
|
|
* pkg/package.json (for branding: name="sf", configDir=".sf"). However, config.js
|
2026-03-11 09:07:17 +01:00
|
|
|
* also reads `version` from that same file and uses it for the update check
|
|
|
|
|
* (comparing against npm registry). If pkg/package.json has a stale version,
|
|
|
|
|
* pi's update banner fires even when the user is already on the latest release.
|
|
|
|
|
*
|
|
|
|
|
* This script reads the actual installed pi-coding-agent version and writes it
|
|
|
|
|
* into pkg/package.json so VERSION is always correct at publish time.
|
|
|
|
|
*/
|
|
|
|
|
const { readFileSync, writeFileSync } = require('fs')
|
|
|
|
|
const { resolve, join } = require('path')
|
|
|
|
|
|
|
|
|
|
const root = resolve(__dirname, '..')
|
2026-03-12 21:55:17 -06:00
|
|
|
const piPkgPath = join(root, 'packages', 'pi-coding-agent', 'package.json')
|
2026-03-11 09:07:17 +01:00
|
|
|
const gsdPkgPath = join(root, 'pkg', 'package.json')
|
|
|
|
|
|
|
|
|
|
const piPkg = JSON.parse(readFileSync(piPkgPath, 'utf-8'))
|
|
|
|
|
const gsdPkg = JSON.parse(readFileSync(gsdPkgPath, 'utf-8'))
|
|
|
|
|
|
|
|
|
|
if (gsdPkg.version !== piPkg.version) {
|
|
|
|
|
console.log(`[sync-pkg-version] Updating pkg/package.json version: ${gsdPkg.version} → ${piPkg.version}`)
|
|
|
|
|
gsdPkg.version = piPkg.version
|
|
|
|
|
writeFileSync(gsdPkgPath, JSON.stringify(gsdPkg, null, 2) + '\n')
|
|
|
|
|
} else {
|
|
|
|
|
console.log(`[sync-pkg-version] pkg/package.json version already matches: ${piPkg.version}`)
|
|
|
|
|
}
|