1
- import parseArgs from ' minimist' ;
1
+ import parseArgs from " minimist" ;
2
2
3
3
enum Providers {
4
- GITHUB = ' github' ,
4
+ GITHUB = " github" ,
5
5
}
6
6
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7
8
interface Workflow {
8
9
id : number ;
9
10
jobs_url : string ;
@@ -13,6 +14,7 @@ interface Workflow {
13
14
created_at : string ;
14
15
}
15
16
17
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
18
interface Job {
17
19
total_count : number ;
18
20
workflow : {
@@ -32,21 +34,34 @@ interface Job {
32
34
} [ ] ;
33
35
}
34
36
37
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
38
interface ScriptParameters {
36
39
saveCsv : boolean ;
37
40
}
38
41
39
- const getParameters = (
40
- env : Record < string , unknown >
41
- ) : { owner : string , repo : string , token : string , max : number , provider : Providers } => {
42
- const { owner, repo, token, max, provider } = parseArgs ( process . argv , { alias : { o : 'owner' , r : 'repo' , t : 'token' , m : 'max' , p : 'provider' } , string : [ 'owner' , 'repo' , 'token' , 'max' ] , default : { provider : Providers . GITHUB } } ) ;
42
+ interface Config {
43
+ owner : string ;
44
+ repo : string ;
45
+ token : string ;
46
+ max : number ;
47
+ provider : Providers ;
48
+ }
49
+
50
+ const getParameters = ( ) : Config => {
51
+ const { owner, repo, token, max, provider } = parseArgs <
52
+ Omit < Config , "max" > & { max : string }
53
+ > ( process . argv , {
54
+ alias : { o : "owner" , r : "repo" , t : "token" , m : "max" , p : "provider" } ,
55
+ string : [ "owner" , "repo" , "token" , "max" ] ,
56
+ default : { provider : Providers . GITHUB } ,
57
+ } ) ;
43
58
44
59
if (
45
60
owner !== "" &&
46
61
repo !== "" &&
47
62
token !== "" &&
48
63
max !== "" &&
49
- ! isNaN ( parseInt ( max ) ) &&
64
+ ! isNaN ( parseInt ( max ) ) &&
50
65
Object . values ( Providers ) . includes ( provider )
51
66
) {
52
67
return { owner, repo, token, max : parseInt ( max ) , provider } ;
@@ -57,7 +72,7 @@ const getParameters = (
57
72
58
73
const { owner, repo, token, max, provider } = getParameters ( process . env ) ;
59
74
60
- if ( provider !== Providers . GITHUB ) {
75
+ if ( provider !== Providers . GITHUB ) {
61
76
throw new Error ( "Only github is supported for now" ) ;
62
77
}
63
78
@@ -69,4 +84,4 @@ const MAX_NUMBER_OF_NEW_WORKFLOWS = max;
69
84
70
85
const doAll = async ( ) => { } ;
71
86
72
- void doAll ( ) ;
87
+ void doAll ( ) ;
0 commit comments