1
1
import * as core from '@actions/core'
2
- import { env } from './utils/env' ;
2
+ import { env } from './utils/env'
3
3
4
4
// add .env file support
5
- require ( 'dotenv' ) . config ( ) ;
6
-
7
- import { AuthorizationError } from './errors/AuthorizationError' ;
8
- import { ProjectsOctoKit } from './octokit/ProjectsOctoKit' ;
9
- import { TEST_CONFIG } from './testConfig' ;
10
- import { TColumnTypes } from './interfaces/TColumnTypes' ;
11
- import { IWrappedIssue } from './interfaces/IWrappedIssue' ;
12
- import { renderIssuesBlock } from './views/renderIssuesBlock' ;
13
- import { TRepoIssue } from './interfaces/TRepoIssue' ;
14
- import { TProject } from './interfaces/TProject' ;
15
-
16
- export const OWNER = 'legomushroom' ;
17
- export const REPO = 'codespaces-board' ;
18
- const TOKEN_NAME = 'REPO_GITHUB_PAT' ;
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' ) ;
5
+ require ( 'dotenv' ) . config ( )
6
+
7
+ import { AuthorizationError } from './errors/AuthorizationError'
8
+ import { ProjectsOctoKit } from './octokit/ProjectsOctoKit'
9
+ import { TEST_CONFIG } from './testConfig'
10
+ import { TColumnTypes } from './interfaces/TColumnTypes'
11
+ import { IWrappedIssue } from './interfaces/IWrappedIssue'
12
+ import { renderIssuesBlock } from './views/renderIssuesBlock'
13
+ import { TRepoIssue } from './interfaces/TRepoIssue'
14
+ import { TProject } from './interfaces/TProject'
15
+ import { IRepoSourceConfig } from './interfaces/IRepoSourceConfig'
16
+
17
+ export const OWNER = 'legomushroom'
18
+ export const REPO = 'codespaces-board'
19
+ const TOKEN_NAME = 'REPO_GITHUB_PAT'
20
+
21
+ const renderProject = async (
22
+ projectKit : ProjectsOctoKit ,
23
+ repo : IRepoSourceConfig ,
24
+ project : TProject
25
+ ) : Promise < string > => {
26
+ const columns = await projectKit . getColumns ( project )
27
+ const issues = await projectKit . getRepoIssues ( repo )
28
+ const progressIssues = await projectKit . filterIssuesForColumnCards (
29
+ issues ,
30
+ columns [ TColumnTypes . InProgress ]
31
+ )
32
+ const doneIssues = await projectKit . filterIssuesForColumnCards (
33
+ issues ,
34
+ columns [ TColumnTypes . Done ]
35
+ )
36
+ const backlogIssues = await projectKit . filterIssuesForColumnCards (
37
+ issues ,
38
+ columns [ TColumnTypes . Committed ]
39
+ )
40
+
41
+ const wrappedProgressIssues : IWrappedIssue [ ] = progressIssues . map (
42
+ wrapIssue ( TColumnTypes . InProgress )
43
+ )
44
+ const wrappedDoneIssues : IWrappedIssue [ ] = doneIssues . map (
45
+ wrapIssue ( TColumnTypes . Done )
46
+ )
47
+ const wrappedIssues = [ ...wrappedProgressIssues , ...wrappedDoneIssues ]
48
+
49
+ const projectTitle = `### ${ project . name } `
50
+ const inWorkIssuesString = renderIssuesBlock (
51
+ `🏗️ In work (${ doneIssues . length } /${
52
+ progressIssues . length + doneIssues . length
53
+ } )`,
54
+ wrappedIssues
55
+ )
56
+
57
+ const wrappedBacklogIssues : IWrappedIssue [ ] = backlogIssues . map (
58
+ wrapIssue ( TColumnTypes . Committed )
59
+ )
60
+
61
+ const backlogIssuesString = renderIssuesBlock (
62
+ `📅 Backlog (${ wrappedBacklogIssues . length } )` ,
63
+ wrappedBacklogIssues
64
+ )
65
+
66
+ return [ '' , projectTitle , inWorkIssuesString , backlogIssuesString ] . join ( '\n' )
44
67
}
45
68
46
69
const wrapIssue = ( column : TColumnTypes ) => {
47
70
return ( issue : TRepoIssue ) => {
48
71
return {
49
72
column,
50
- issue,
51
- } ;
52
- } ;
73
+ issue
74
+ }
75
+ }
53
76
}
54
77
55
78
async function run ( ) : Promise < void > {
@@ -61,18 +84,21 @@ async function run(): Promise<void> {
61
84
}
62
85
63
86
const projectKit = new ProjectsOctoKit ( token ) ;
64
- const projects = await projectKit . getAllProjects ( TEST_CONFIG . repos ) ;
87
+ const repoProjects = await projectKit . getAllProjects ( TEST_CONFIG . repos ) ;
65
88
66
- const result = await Promise . all ( projects . map ( ( project ) => {
67
- return renderProject ( projectKit , project ) ;
68
- } ) ) ;
69
-
70
- console . log ( result . join ( '\n' ) + '\n' ) ;
89
+ for ( let { repo, projects } of repoProjects ) {
90
+ const result = await Promise . all (
91
+ projects . map ( project => {
92
+ return renderProject ( projectKit , repo , project )
93
+ } )
94
+ )
71
95
96
+ console . log ( result . join ( '\n' ) + '\n' ) ;
97
+ }
72
98
} catch ( error ) {
73
99
console . error ( error ) ;
74
- core . setFailed ( error . message )
100
+ core . setFailed ( error . message ) ;
75
101
}
76
102
}
77
103
78
- run ( ) ;
104
+ run ( )
0 commit comments