@@ -10,11 +10,48 @@ import { TEST_CONFIG } from './testConfig';
10
10
import { TColumnTypes } from './interfaces/TColumnTypes' ;
11
11
import { IWrappedIssue } from './interfaces/IWrappedIssue' ;
12
12
import { renderIssuesBlock } from './views/renderIssuesBlock' ;
13
+ import { TRepoIssue } from './interfaces/TRepoIssue' ;
14
+ import { TProject } from './interfaces/TProject' ;
13
15
14
16
export const OWNER = 'legomushroom' ;
15
17
export const REPO = 'codespaces-board' ;
16
18
const TOKEN_NAME = 'REPO_GITHUB_PAT' ;
17
19
20
+ const renderProject = async ( projectKit : ProjectsOctoKit , project : TProject ) : Promise < string > => {
21
+ const columns = await projectKit . getColumns ( project ) ;
22
+ const issues = await projectKit . getRepoIssues ( TEST_CONFIG . repos [ 0 ] ) ;
23
+ const progressIssues = await projectKit . filterIssuesForColumnCards ( issues , columns [ TColumnTypes . InProgress ] ) ;
24
+ const doneIssues = await projectKit . filterIssuesForColumnCards ( issues , columns [ TColumnTypes . Done ] ) ;
25
+ const backlogIssues = await projectKit . filterIssuesForColumnCards ( issues , columns [ TColumnTypes . Committed ] ) ;
26
+
27
+ const wrappedProgressIssues : IWrappedIssue [ ] = progressIssues . map ( wrapIssue ( TColumnTypes . InProgress ) ) ;
28
+ const wrappedDoneIssues : IWrappedIssue [ ] = doneIssues . map ( wrapIssue ( TColumnTypes . Done ) ) ;
29
+ const wrappedIssues = [ ...wrappedProgressIssues , ...wrappedDoneIssues ] ;
30
+
31
+ const projectTitle = `### ${ project . name } ` ;
32
+ const inWorkIssuesString = renderIssuesBlock ( `🏗️ In work (${ doneIssues . length } /${ progressIssues . length + doneIssues . length } )` , wrappedIssues ) ;
33
+
34
+ const wrappedBacklogIssues : IWrappedIssue [ ] = backlogIssues . map ( wrapIssue ( TColumnTypes . Committed ) ) ;
35
+
36
+ const backlogIssuesString = renderIssuesBlock ( `📅 Backlog (${ wrappedBacklogIssues . length } )` , wrappedBacklogIssues ) ;
37
+
38
+ return [
39
+ '' ,
40
+ projectTitle ,
41
+ inWorkIssuesString ,
42
+ backlogIssuesString ,
43
+ ] . join ( '\n' ) ;
44
+ }
45
+
46
+ const wrapIssue = ( column : TColumnTypes ) => {
47
+ return ( issue : TRepoIssue ) => {
48
+ return {
49
+ column,
50
+ issue,
51
+ } ;
52
+ } ;
53
+ }
54
+
18
55
async function run ( ) : Promise < void > {
19
56
try {
20
57
const token = env ( TOKEN_NAME ) ?? core . getInput ( 'token' ) ;
@@ -25,18 +62,13 @@ async function run(): Promise<void> {
25
62
26
63
const projectKit = new ProjectsOctoKit ( token ) ;
27
64
const projects = await projectKit . getAllProjects ( TEST_CONFIG . repos ) ;
28
- const columns = await projectKit . getColumns ( projects [ 0 ] ) ;
29
- const issues = await projectKit . getRepoIssues ( TEST_CONFIG . repos [ 0 ] ) ;
30
- const columnIssues = await projectKit . filterIssuesForColumnCards ( issues , columns [ TColumnTypes . Committed ] ) ;
31
-
32
- const wrappedIssues : IWrappedIssue [ ] = columnIssues . map ( ( issue ) => {
33
- return {
34
- column : TColumnTypes . InProgress ,
35
- issue,
36
- } ;
37
- } ) ;
38
-
39
- console . log ( renderIssuesBlock ( projects [ 0 ] . name , wrappedIssues ) ) ;
65
+
66
+ const result = await Promise . all ( projects . map ( ( project ) => {
67
+ return renderProject ( projectKit , project ) ;
68
+ } ) ) ;
69
+
70
+ console . log ( result . join ( '\n' ) + '\n' ) ;
71
+
40
72
} catch ( error ) {
41
73
console . error ( error ) ;
42
74
core . setFailed ( error . message )
0 commit comments