Skip to content

Commit c6c64c8

Browse files
committed
chore: add release info code and cli tool to get releasable widgets/modules
1 parent 1e5abe7 commit c6c64c8

7 files changed

Lines changed: 1307 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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();

automation/utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"rui-include-oss-in-artifact": "bin/rui-include-oss-in-artifact.ts",
1212
"rui-prepare-release": "bin/rui-prepare-release.ts",
1313
"rui-publish-marketplace": "bin/rui-publish-marketplace.ts",
14+
"rui-release-info": "bin/rui-release-info.ts",
1415
"rui-update-changelog-module": "bin/rui-update-changelog-module.ts",
1516
"rui-update-changelog-widget": "bin/rui-update-changelog-widget.ts",
1617
"rui-verify-package-format": "bin/rui-verify-package-format.ts"

automation/utils/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ export * from "./mpk";
66
export * from "./changelog-parser";
77
export * from "./monorepo";
88
export * from "./build-config";
9+
export * from "./release-candidates";
10+
export * from "./io/filesystem";
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { access, readdir, readFile, writeFile } from "fs/promises";
2+
3+
/**
4+
* Abstraction layer for filesystem operations
5+
* Allows for testing and alternative implementations (e.g., MCP, in-memory)
6+
*/
7+
export interface FileSystem {
8+
readFile(path: string): Promise<string>;
9+
writeFile(path: string, content: string): Promise<void>;
10+
exists(path: string): Promise<boolean>;
11+
readdir(path: string): Promise<string[]>;
12+
}
13+
14+
/**
15+
* Default Node.js filesystem implementation
16+
*/
17+
export class NodeFileSystem implements FileSystem {
18+
async readFile(path: string): Promise<string> {
19+
return readFile(path, "utf-8");
20+
}
21+
22+
async writeFile(path: string, content: string): Promise<void> {
23+
await writeFile(path, content, "utf-8");
24+
}
25+
26+
async exists(path: string): Promise<boolean> {
27+
try {
28+
await access(path);
29+
return true;
30+
} catch {
31+
return false;
32+
}
33+
}
34+
35+
async readdir(path: string): Promise<string[]> {
36+
return readdir(path);
37+
}
38+
}
39+
40+
/**
41+
* Default filesystem instance for convenience
42+
*/
43+
export const defaultFS = new NodeFileSystem();

0 commit comments

Comments
 (0)