File tree Expand file tree Collapse file tree 4 files changed +51
-3
lines changed Expand file tree Collapse file tree 4 files changed +51
-3
lines changed Original file line number Diff line number Diff line change 1+ name : Build Library
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+
8+ jobs :
9+ build :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout code
14+ uses : actions/checkout@v4
15+
16+ - name : Setup Node.js
17+ uses : actions/setup-node@v4
18+ with :
19+ node-version : ' 22.x'
20+ cache : ' yarn'
21+
22+ - name : Install deps
23+ run : yarn
24+
25+ - name : Build project
26+ run : yarn build
Original file line number Diff line number Diff line change 1616 node-version : " 20.x"
1717 registry-url : " https://registry.npmjs.org"
1818
19- - run : yarn build
20- - run : npm publish --provenance --access public
19+ - name : Build library
20+ run : yarn build
21+
22+ - name : Publish to NPM
23+ run : npm publish --provenance --access public
2124 env :
2225 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
Original file line number Diff line number Diff line change 11{
22 "name" : " @acm-uiuc/js-shared" ,
3- "version" : " 3.0.1 " ,
3+ "version" : " 3.1.0 " ,
44 "description" : " ACM UIUC Shared JS code" ,
55 "main" : " dist/index.js" ,
66 "module" : " dist/index.js" ,
Original file line number Diff line number Diff line change @@ -42,6 +42,25 @@ export type OrganizationId = keyof typeof Organizations;
4242export type Organization = ( typeof Organizations ) [ OrganizationId ] ;
4343export type OrganizationName = Organization [ "name" ] ;
4444
45+ // Create a reverse lookup map from name to ID
46+ export const OrganizationsByName = Object . entries ( Organizations ) . reduce (
47+ ( acc , [ id , org ] ) => {
48+ if ( acc [ org . name ] ) {
49+ throw new Error ( `Duplicate organization name: ${ org . name } ` ) ;
50+ }
51+ acc [ org . name ] = id as OrganizationId ;
52+ return acc ;
53+ } ,
54+ { } as Record < OrganizationName , OrganizationId >
55+ ) ;
56+
57+ export function getOrgByName ( name : OrganizationName ) : ( Organization & { id : OrganizationId } ) | undefined {
58+ const id = OrganizationsByName [ name ] ;
59+ if ( ! id ) return undefined ;
60+
61+ return { ...Organizations [ id ] , id } ;
62+ }
63+
4564export function getOrgsByType ( type : OrgType ) : Array < Organization & { id : OrganizationId } > {
4665 return ( Object . entries ( Organizations ) as Array < [ OrganizationId , Organization ] > )
4766 . filter ( ( [ _ , org ] ) => org . type === type )
You can’t perform that action at this time.
0 commit comments