fix(installer): check correct dist-tag in checkForUpdate
The update check used a `beta` dist-tag that doesn't exist on this package — it only publishes `latest` and `next`. Substring matching on `Beta/beta/alpha/rc` also missed the actual prerelease format (`-next.N`). Switch to `semver.prerelease()` for detection, query `@next` for prerelease users, and check both `@next` and `@latest` so a user stuck on a stale `@next` is still steered to the higher version. Refs #2317 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
88b9a1c842
commit
e040312850
|
|
@ -23,27 +23,37 @@ checkForUpdate().catch(() => {
|
||||||
|
|
||||||
async function checkForUpdate() {
|
async function checkForUpdate() {
|
||||||
try {
|
try {
|
||||||
// For beta versions, check the beta tag; otherwise check latest
|
// Prereleases are tracked under @next; stable releases under @latest.
|
||||||
const isBeta =
|
// Check both for prerelease users so they're prompted to switch tracks
|
||||||
packageJson.version.includes('Beta') ||
|
// if @latest has surpassed their current prerelease.
|
||||||
packageJson.version.includes('beta') ||
|
const isPrerelease = semver.prerelease(packageJson.version) !== null;
|
||||||
packageJson.version.includes('alpha') ||
|
const tagsToCheck = isPrerelease ? ['next', 'latest'] : ['latest'];
|
||||||
packageJson.version.includes('rc');
|
|
||||||
const tag = isBeta ? 'beta' : 'latest';
|
|
||||||
|
|
||||||
const result = execSync(`npm view ${packageName}@${tag} version`, {
|
let bestVersion = null;
|
||||||
encoding: 'utf8',
|
let bestTag = null;
|
||||||
stdio: 'pipe',
|
for (const tag of tagsToCheck) {
|
||||||
timeout: 5000,
|
try {
|
||||||
}).trim();
|
const v = execSync(`npm view ${packageName}@${tag} version`, {
|
||||||
|
encoding: 'utf8',
|
||||||
|
stdio: 'pipe',
|
||||||
|
timeout: 5000,
|
||||||
|
}).trim();
|
||||||
|
if (v && (!bestVersion || semver.gt(v, bestVersion))) {
|
||||||
|
bestVersion = v;
|
||||||
|
bestTag = tag;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Skip this tag — registry may not have it or network may be flaky.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (result && semver.gt(result, packageJson.version)) {
|
if (bestVersion && semver.gt(bestVersion, packageJson.version)) {
|
||||||
const color = await prompts.getColor();
|
const color = await prompts.getColor();
|
||||||
const updateMsg = [
|
const updateMsg = [
|
||||||
`You are using version ${packageJson.version} but ${result} is available.`,
|
`You are using version ${packageJson.version} but ${bestVersion} is available.`,
|
||||||
'',
|
'',
|
||||||
'To update, exit and first run:',
|
'To update, exit and first run:',
|
||||||
` npm cache clean --force && npx bmad-method@${tag} install`,
|
` npm cache clean --force && npx bmad-method@${bestTag} install`,
|
||||||
].join('\n');
|
].join('\n');
|
||||||
await prompts.box(updateMsg, 'Update Available', {
|
await prompts.box(updateMsg, 'Update Available', {
|
||||||
rounded: true,
|
rounded: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue