(rootDir: string, opts: VersionOptions = {})
| 18 | } |
| 19 | |
| 20 | export async function versionCommand(rootDir: string, opts: VersionOptions = {}): Promise<void> { |
| 21 | const config = await loadConfig(rootDir); |
| 22 | |
| 23 | const channel = resolveActiveChannel(rootDir, config, opts.channel); |
| 24 | if (channel) { |
| 25 | await channelVersion(rootDir, config, channel, { commit: opts.commit }); |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | const packages = await discoverPackages(rootDir, config); |
| 30 | const depGraph = new DependencyGraph(packages); |
| 31 | // Include channel subdirs — bump files that shipped as prereleases are pending |
| 32 | // for the stable release (promotion consumes them). |
| 33 | const { bumpFiles, errors: parseErrors } = await readBumpFiles(rootDir, { channels: channelNames(config) }); |
| 34 | |
| 35 | if (parseErrors.length > 0) { |
| 36 | for (const err of parseErrors) { |
| 37 | log.error(err); |
| 38 | } |
| 39 | throw new Error('Bump file parse errors must be fixed before versioning.'); |
| 40 | } |
| 41 | |
| 42 | if (bumpFiles.length === 0) { |
| 43 | log.info('No pending bump files.'); |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | const plan = assembleReleasePlan(bumpFiles, packages, depGraph, config); |
| 48 | |
| 49 | if (plan.releases.length === 0) { |
| 50 | log.warn('Bump files found but no packages would be released.'); |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | // Show warnings from the release plan |
| 55 | if (plan.warnings.length > 0) { |
| 56 | for (const w of plan.warnings) { |
| 57 | log.warn(w); |
| 58 | } |
| 59 | console.log(); |
| 60 | } |
| 61 | |
| 62 | // Show what will happen |
| 63 | log.step('Applying version bumps:'); |
| 64 | for (const r of plan.releases) { |
| 65 | const tag = r.isDependencyBump ? ' (dep)' : r.isCascadeBump ? ' (cascade)' : ''; |
| 66 | console.log(` ${r.name}: ${r.oldVersion} → ${colorize(r.newVersion, 'cyan')}${tag}`); |
| 67 | } |
| 68 | |
| 69 | // Apply the plan |
| 70 | await applyReleasePlan(plan, packages, rootDir, config); |
| 71 | |
| 72 | log.success(`🐸 Updated ${plan.releases.length} package(s)`); |
| 73 | log.dim(` Deleted ${bumpFiles.length} bump file(s)`); |
| 74 | |
| 75 | // Update lockfile so it stays in sync with bumped versions |
| 76 | await updateLockfile(rootDir); |
| 77 |
no test coverage detected
searching dependent graphs…