@@ -11,7 +11,7 @@ import {
11
11
loadFile ,
12
12
filePath ,
13
13
prepareWeights ,
14
- sortByLinesDesc
14
+ sortByLinesDesc ,
15
15
} from "./utils.js" ;
16
16
import { listFiles } from "./git.js" ;
17
17
import calculate from "./index.js" ;
@@ -29,12 +29,12 @@ function renderTable(header, columns, rows) {
29
29
joinBody : colors . gray ( `─` ) ,
30
30
joinLeft : `` ,
31
31
joinRight : `` ,
32
- joinJoin : colors . gray ( `┼` )
32
+ joinJoin : colors . gray ( `┼` ) ,
33
33
} ,
34
34
drawHorizontalLine ( index ) {
35
35
return index === 1 ;
36
36
} ,
37
- columns
37
+ columns,
38
38
} ;
39
39
40
40
return table ( [ header ] . concat ( rows ) , options ) ;
@@ -51,25 +51,25 @@ function renderFresh(result, maxResults) {
51
51
name ,
52
52
toPct ( lines ) ,
53
53
toPct ( freshLines ) ,
54
- toPct ( fadingLines )
54
+ toPct ( fadingLines ) ,
55
55
] ) ;
56
56
57
57
const columns = {
58
58
0 : {
59
- alignment : "left"
59
+ alignment : "left" ,
60
60
} ,
61
61
1 : {
62
62
alignment : "right" ,
63
- width : 8
63
+ width : 8 ,
64
64
} ,
65
65
2 : {
66
66
alignment : "right" ,
67
- width : 8
67
+ width : 8 ,
68
68
} ,
69
69
3 : {
70
70
alignment : "right" ,
71
- width : 8
72
- }
71
+ width : 8 ,
72
+ } ,
73
73
} ;
74
74
75
75
console . log ( renderTable ( [ "Name" , "Total" , "Fresh" , "Fading" ] , columns , rows ) ) ;
@@ -86,12 +86,12 @@ function renderLost(result, maxLostContributors) {
86
86
87
87
const columns = {
88
88
0 : {
89
- alignment : "left"
89
+ alignment : "left" ,
90
90
} ,
91
91
1 : {
92
92
alignment : "right" ,
93
- width : 8
94
- }
93
+ width : 8 ,
94
+ } ,
95
95
} ;
96
96
97
97
console . log ( renderTable ( [ "Name" , "Total" ] , columns , rows ) ) ;
@@ -105,26 +105,26 @@ function renderBigFiles(fileData) {
105
105
total +
106
106
Object . values ( fileContributors ) . reduce (
107
107
( subTotal , contributor ) => subTotal + contributor ,
108
- 0
108
+ 0 ,
109
109
) ,
110
- 0
110
+ 0 ,
111
111
) ;
112
112
113
113
acc . push ( { name, lines } ) ;
114
114
115
115
return acc ;
116
- } , [ ] )
116
+ } , [ ] ) ,
117
117
)
118
118
. slice ( 0 , 5 )
119
119
. map ( ( { name, lines } ) => [ name , lines ] ) ;
120
120
121
121
const columns = {
122
122
0 : {
123
- alignment : "left"
123
+ alignment : "left" ,
124
124
} ,
125
125
1 : {
126
- alignment : "right"
127
- }
126
+ alignment : "right" ,
127
+ } ,
128
128
} ;
129
129
130
130
console . log ( renderTable ( [ "File" , "Lines" ] , columns , rows ) ) ;
@@ -139,7 +139,7 @@ function renderTitle(title) {
139
139
function commandRepositoryConfig ( config ) {
140
140
config . positional ( "repository" , {
141
141
describe : "The repository to scan" ,
142
- type : "string"
142
+ type : "string" ,
143
143
} ) ;
144
144
}
145
145
@@ -149,7 +149,7 @@ yargs(hideBin(process.argv))
149
149
"list-files <repository>" ,
150
150
"List all files and their weights" ,
151
151
commandRepositoryConfig ,
152
- async argv => {
152
+ async ( argv ) => {
153
153
const repository = argv . repository ;
154
154
const weights = argv . weights ? await loadFile ( argv . weights ) : { } ;
155
155
const withMedia = argv . withMedia ;
@@ -163,15 +163,15 @@ yargs(hideBin(process.argv))
163
163
( filename , hash ) => {
164
164
console . log ( ` ${ filename } ${ getWeight ( filename ) } ` ) ;
165
165
} ,
166
- branch
166
+ branch ,
167
167
) ;
168
- }
168
+ } ,
169
169
)
170
170
. command (
171
171
[ "calculate <repository>" , "$0 <repository>" ] ,
172
172
"Calculate absorption" ,
173
173
commandRepositoryConfig ,
174
- async argv => {
174
+ async ( argv ) => {
175
175
const contributors = argv . contributors
176
176
? await loadFile ( argv . contributors )
177
177
: [ ] ;
@@ -191,7 +191,7 @@ yargs(hideBin(process.argv))
191
191
threshold ,
192
192
repository ,
193
193
verbose ,
194
- branch
194
+ branch ,
195
195
) ;
196
196
197
197
if ( argv . json ) {
@@ -207,7 +207,7 @@ yargs(hideBin(process.argv))
207
207
208
208
console . log ( ) ;
209
209
console . log (
210
- `The repository's absorption score is ${ result . absorption . fresh } % fresh, ${ result . absorption . fading } % fading and ${ result . absorption . lost } % lost`
210
+ `The repository's absorption score is ${ result . absorption . fresh } % fresh, ${ result . absorption . fading } % fading and ${ result . absorption . lost } % lost` ,
211
211
) ;
212
212
213
213
renderTitle ( "Fresh/Fading knowledge" ) ;
@@ -222,60 +222,60 @@ yargs(hideBin(process.argv))
222
222
renderLost ( result , maxLostContributors ) ;
223
223
} else {
224
224
console . log (
225
- "It seems this repository has no lost knowledge, congratulations !"
225
+ "It seems this repository has no lost knowledge, congratulations !" ,
226
226
) ;
227
227
}
228
228
229
229
renderTitle ( "Biggest files" ) ;
230
230
console . log (
231
- "Big files can skew the results (static test data, media files...), here are the biggest files found in this repository."
231
+ "Big files can skew the results (static test data, media files...), here are the biggest files found in this repository." ,
232
232
) ;
233
233
console . log ( ) ;
234
234
235
235
renderBigFiles ( result . fileData ) ;
236
- }
236
+ } ,
237
237
)
238
238
. option ( "json" , {
239
239
describe : "Output to a JSON file" ,
240
- type : "string"
240
+ type : "string" ,
241
241
} )
242
242
. option ( "threshold" , {
243
243
describe :
244
244
"start with a number, followed by 'd' for days, 'w' for weeks, 'm' for months or 'y' for years (1y, 6m, 9w)" ,
245
245
default : "1y" ,
246
- type : "string"
246
+ type : "string" ,
247
247
} )
248
248
. option ( "max-contributors" , {
249
249
describe : "Max number of active contributors" ,
250
250
type : "integer" ,
251
- default : 10
251
+ default : 10 ,
252
252
} )
253
253
. option ( "max-lost-contributors" , {
254
254
describe : "Max number of lost contributors" ,
255
255
type : "integer" ,
256
- default : 10
256
+ default : 10 ,
257
257
} )
258
258
. option ( "contributors" , {
259
259
describe : "Add complementary contributors data, through a JSON file" ,
260
- type : "string"
260
+ type : "string" ,
261
261
} )
262
262
. option ( "weights" , {
263
263
describe : "Change the weight of each file, through a JSON file" ,
264
- type : "string"
264
+ type : "string" ,
265
265
} )
266
266
. option ( "with-media" , {
267
267
describe : "Media files are ignored by default, this restores them" ,
268
268
type : "boolean" ,
269
- default : false
269
+ default : false ,
270
270
} )
271
271
. option ( "branch" , {
272
272
describe : "The branch to scan" ,
273
273
type : "string" ,
274
- default : "master"
274
+ default : "master" ,
275
275
} )
276
276
. option ( "verbose" , {
277
277
type : "boolean" ,
278
- default : false
278
+ default : false ,
279
279
} )
280
280
//.example("$0 calculate -f foo.js", "count the lines in the given file")
281
281
. help ( "h" )
0 commit comments