Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | import chalk from 'chalk';
import { discoverPackages } from '../lib/workspace.js';
import { classifyTier, tierLabel, isTier1 } from '../lib/tier.js';
import { getLastTagForPackage, getCommitsSince } from '../lib/git.js';
import { getConfig } from '../lib/config.js';
import { isDevelopBranch, isPatchBranch } from '../lib/branch.js';
import { resolveBump } from '../lib/bump.js';
import { heading, info } from '../lib/log.js';
export function registerStatusCommand(program) {
program
.command('status')
.description('List packages, versions, tiers, and changes since last tag')
.action(async () => {
await runStatus();
});
}
async function runStatus() {
const packages = discoverPackages();
const config = getConfig();
const showReleaseCycle = isDevelopBranch() || isPatchBranch();
heading('Package Status');
const rows = [];
for (const pkg of packages) {
const tier = classifyTier(pkg);
const lastTag = getLastTagForPackage(pkg.name);
const commits = getCommitsSince(lastTag, [pkg.relativePath], config.ignoreChanges);
let nextVersion = '';
if (showReleaseCycle && isTier1(pkg)) {
try {
nextVersion = resolveBump(pkg, 'release-cycle');
} catch {
nextVersion = chalk.dim('(unable to compute)');
}
}
rows.push({
Package: pkg.name,
Version: pkg.version,
Tier: `${tier}`,
'Last Tag': lastTag || chalk.dim('none'),
Commits: commits.length,
...(showReleaseCycle && isTier1(pkg) ? { 'Next (release-cycle)': nextVersion } : {}),
});
}
const hasTier1 = rows.some((r) => r.Tier === '1');
for (const row of rows) {
const tierColor = row.Tier === '1' ? chalk.cyan : row.Tier === '3' ? chalk.gray : chalk.white;
const commitColor = row.Commits > 0 ? chalk.green : chalk.dim;
info(
`${tierColor(`[Tier ${row.Tier}]`)} ${chalk.bold(row.Package)} ` +
`${chalk.dim(`v${row.Version}`)} ` +
`${chalk.dim('tag:')} ${row['Last Tag']} ` +
`${commitColor(`${row.Commits} commits`)}` +
(row['Next (release-cycle)']
? ` ${chalk.yellow('→')} ${chalk.yellow(row['Next (release-cycle)'])}`
: ''),
);
}
info(`\n${chalk.dim(`${rows.length} packages total`)}`);
}
|