fix(installer): mirror launch channel as default for external modules (#2321)
* fix(installer): mirror launch channel as default for external modules When the user runs `npx bmad-method@next install`, the installer itself runs from a prerelease, but the interactive channel gate previously hardcoded "(all stable)" — defaulting tea/community modules to stable while bmad-method itself was on next. The bleeding-edge launch did not flow through. Detect the installer's own version via semver.prerelease() and default the gate (and per-module picker) to match — "all next" for prerelease launches, "all stable" for stable. Users keep full control: hit "n" to customize per module, or pass explicit --channel / --pin / --next flags to override. * fix(installer): seed channelOptions before module picker, not gate CodeRabbit caught a label/install mismatch in the previous approach: the module picker resolves version labels via decideChannelForModule, which runs before _interactiveChannelGate. With channelOptions.global still null at picker time, labels rendered from stable tags — then the gate flipped global to 'next' and externals installed from main HEAD. Net effect on @next launches: "tea (v1.6.0)" in the picker, but install pulled HEAD. Move the launch detection up into promptInstall, immediately after parseChannelOptions. Seeding channelOptions.global = 'next' before the picker makes labels resolve from main HEAD (matching the install) and lets the existing gate's haveFlagIntent check skip cleanly — the @next user already declared their intent by typing it. Per-module customization remains available via --pin / --next / --channel flags, same as for any pre-set global.
This commit is contained in:
parent
7baa30c567
commit
04cfde1454
|
|
@ -2,6 +2,7 @@ const path = require('node:path');
|
||||||
const os = require('node:os');
|
const os = require('node:os');
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
const fs = require('./fs-native');
|
const fs = require('./fs-native');
|
||||||
|
const installerPackageJson = require('../../package.json');
|
||||||
const { CLIUtils } = require('./cli-utils');
|
const { CLIUtils } = require('./cli-utils');
|
||||||
const { ExternalModuleManager } = require('./modules/external-manager');
|
const { ExternalModuleManager } = require('./modules/external-manager');
|
||||||
const { resolveModuleVersion } = require('./modules/version-resolver');
|
const { resolveModuleVersion } = require('./modules/version-resolver');
|
||||||
|
|
@ -128,6 +129,24 @@ class UI {
|
||||||
await prompts.log.warn(warning);
|
await prompts.log.warn(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When the user launched the installer from a prerelease (npx bmad-method@next),
|
||||||
|
// mirror that intent for external modules: seed the global channel to 'next' so
|
||||||
|
// the module picker's version labels resolve from main HEAD (matching what
|
||||||
|
// actually gets installed) and the interactive channel gate skips — the user
|
||||||
|
// already declared "next" intent by typing @next. Explicit channel flags
|
||||||
|
// override this seed.
|
||||||
|
if (
|
||||||
|
semver.prerelease(installerPackageJson.version) !== null &&
|
||||||
|
!channelOptions.global &&
|
||||||
|
channelOptions.nextSet.size === 0 &&
|
||||||
|
channelOptions.pins.size === 0
|
||||||
|
) {
|
||||||
|
channelOptions.global = 'next';
|
||||||
|
await prompts.log.info(
|
||||||
|
'Launched from a prerelease — installing all external modules from main HEAD (next channel). Pass --all-stable or --pin to override.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Get directory from options or prompt
|
// Get directory from options or prompt
|
||||||
let confirmedDirectory;
|
let confirmedDirectory;
|
||||||
if (options.directory) {
|
if (options.directory) {
|
||||||
|
|
@ -332,8 +351,10 @@ class UI {
|
||||||
|
|
||||||
// Interactive channel gate: "Ready to install (all stable)? [Y/n]"
|
// Interactive channel gate: "Ready to install (all stable)? [Y/n]"
|
||||||
// Only shown for fresh installs with no channel flags and an external module
|
// Only shown for fresh installs with no channel flags and an external module
|
||||||
// selected. Non-interactive installs skip this and fall through to the
|
// selected. Skipped for prerelease launches because channelOptions.global
|
||||||
// registry default (stable) or whatever flags were supplied.
|
// was already seeded to 'next' upstream. Non-interactive installs skip this
|
||||||
|
// and fall through to the registry default (stable) or whatever flags were
|
||||||
|
// supplied.
|
||||||
await this._interactiveChannelGate({ options, channelOptions, selectedModules });
|
await this._interactiveChannelGate({ options, channelOptions, selectedModules });
|
||||||
|
|
||||||
let toolSelection = await this.promptToolSelection(confirmedDirectory, options);
|
let toolSelection = await this.promptToolSelection(confirmedDirectory, options);
|
||||||
|
|
@ -1783,7 +1804,9 @@ class UI {
|
||||||
*
|
*
|
||||||
* Skipped when:
|
* Skipped when:
|
||||||
* - running non-interactively (--yes)
|
* - running non-interactively (--yes)
|
||||||
* - the user already passed channel flags (--channel / --pin / --next)
|
* - the user already passed channel flags (--channel / --pin / --next), OR
|
||||||
|
* the installer was launched from a prerelease (which seeds
|
||||||
|
* channelOptions.global = 'next' upstream in promptInstall)
|
||||||
* - no externals/community modules are selected
|
* - no externals/community modules are selected
|
||||||
*
|
*
|
||||||
* Mutates channelOptions.pins and channelOptions.nextSet to reflect picker choices.
|
* Mutates channelOptions.pins and channelOptions.nextSet to reflect picker choices.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue