File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import type { CommandModule } from "yargs"
2+ import { createGitHubService } from "../../github"
3+ import { createCacheProvider , createConfig , createReporter } from "../util"
4+
5+ const command : CommandModule = {
6+ command : "topics" ,
7+ describe : "List customer topics in a GitHub organization" ,
8+ builder : ( yargs ) =>
9+ yargs . options ( "org" , {
10+ alias : "o" ,
11+ default : "capralifecycle" ,
12+ requiresArg : true ,
13+ describe : "GitHub organization" ,
14+ type : "string" ,
15+ } ) ,
16+ handler : async ( argv ) => {
17+ const config = createConfig ( )
18+ const reporter = createReporter ( )
19+ const github = await createGitHubService ( {
20+ cache : createCacheProvider ( config , argv ) ,
21+ } )
22+
23+ const repos = await github . getOrgRepoList ( { org : argv . org as string } )
24+
25+ const topics = new Set < string > ( )
26+ for ( const repo of repos ) {
27+ for ( const edge of repo . repositoryTopics . edges ) {
28+ const name = edge . node . topic . name
29+ if ( name . startsWith ( "customer-" ) ) {
30+ topics . add ( name )
31+ }
32+ }
33+ }
34+
35+ const sorted = [ ...topics ] . sort ( ( a , b ) => a . localeCompare ( b ) )
36+ for ( const topic of sorted ) {
37+ reporter . log ( topic )
38+ }
39+ } ,
40+ }
41+
42+ export default command
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import clone from "./commands/clone"
77import groups from "./commands/groups"
88import repos from "./commands/repos"
99import sync from "./commands/sync"
10+ import topics from "./commands/topics"
1011
1112declare const BUILD_TIMESTAMP : string
1213
@@ -52,6 +53,7 @@ Before using, authenticate with: cals auth`)
5253 . command ( groups )
5354 . command ( repos )
5455 . command ( sync )
56+ . command ( topics )
5557 . version ( version )
5658 . demandCommand ( )
5759 . option ( "no-cache" , {
@@ -61,6 +63,7 @@ Before using, authenticate with: cals auth`)
6163 . example ( "cals auth" , "Set GitHub token" )
6264 . example ( "cals repos" , "List repositories" )
6365 . example ( "cals groups" , "List repository groups" )
66+ . example ( "cals topics" , "List customer topics" )
6467 . example ( "cals clone --all | bash" , "Clone all repos" )
6568 . example ( "cals sync" , "Pull latest changes" )
6669 . parse ( )
You can’t perform that action at this time.
0 commit comments