|
| 1 | +#!/usr/bin/env ts-node |
| 2 | +import { loadReleaseCandidates, loadAllPackages } from "../src/release-candidates"; |
| 3 | + |
| 4 | +async function main(): Promise<void> { |
| 5 | + const args = process.argv.slice(2); |
| 6 | + const command = args[0]; |
| 7 | + |
| 8 | + try { |
| 9 | + if (command === "--candidates" || command === "-c") { |
| 10 | + // List only packages with unreleased changes |
| 11 | + const candidates = await loadReleaseCandidates(); |
| 12 | + console.log(JSON.stringify(candidates, null, 2)); |
| 13 | + } else if (command === "--all" || command === "-a") { |
| 14 | + // List all packages (including those without changes) |
| 15 | + const allPackages = await loadAllPackages(); |
| 16 | + console.log(JSON.stringify(allPackages, null, 2)); |
| 17 | + } else if (command === "--summary" || command === "-s") { |
| 18 | + // Summary view |
| 19 | + const candidates = await loadReleaseCandidates(); |
| 20 | + const summary = { |
| 21 | + totalCandidates: candidates.length, |
| 22 | + widgets: candidates.filter(c => c.packageType === "widget").length, |
| 23 | + modules: candidates.filter(c => c.packageType === "module").length, |
| 24 | + packages: candidates.map(c => ({ |
| 25 | + name: c.name, |
| 26 | + packageType: c.packageType, |
| 27 | + hasDependencies: c.hasDependencies, |
| 28 | + version: c.currentVersion, |
| 29 | + hasChanges: c.hasUnreleasedChanges, |
| 30 | + dependentWidgetsWithChanges: c.hasDependencies |
| 31 | + ? c.dependentWidgets!.filter(w => w.hasUnreleasedChanges).length |
| 32 | + : undefined |
| 33 | + })) |
| 34 | + }; |
| 35 | + console.log(JSON.stringify(summary, null, 2)); |
| 36 | + } else if (command === "--help" || command === "-h" || !command) { |
| 37 | + printHelp(); |
| 38 | + } else { |
| 39 | + console.error(`Unknown command: ${command}`); |
| 40 | + console.error("Use --help for usage information"); |
| 41 | + process.exit(1); |
| 42 | + } |
| 43 | + } catch (error) { |
| 44 | + console.error("Error:", error instanceof Error ? error.message : String(error)); |
| 45 | + process.exit(1); |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +function printHelp(): void { |
| 50 | + console.log(` |
| 51 | +rui-release-info - Query release candidates in the monorepo |
| 52 | +
|
| 53 | +Commands: |
| 54 | + -c, --candidates List packages with unreleased changes (release candidates) |
| 55 | + Returns detailed JSON with changelog entries |
| 56 | +
|
| 57 | + -a, --all List all packages (including those without changes) |
| 58 | + Useful for seeing complete package structure |
| 59 | +
|
| 60 | + -s, --summary Show summary statistics and package list |
| 61 | + Concise view with counts and basic info |
| 62 | +
|
| 63 | + -h, --help Show this help message |
| 64 | +`); |
| 65 | +} |
| 66 | + |
| 67 | +main(); |
0 commit comments