@@ -29,18 +29,19 @@ type npmPackage = {
29
29
}
30
30
31
31
module Resource = {
32
- type t = Npm (npmPackage ) | Url (urlResource )
32
+ type t = Npm (npmPackage ) | Url (urlResource ) | Outdated ( npmPackage )
33
33
34
34
let getId = (res : t ) => {
35
35
switch res {
36
36
| Npm ({name })
37
+ | Outdated ({name })
37
38
| Url ({name }) => name
38
39
}
39
40
}
40
41
41
42
let shouldFilter = (res : t ) => {
42
43
switch res {
43
- | Npm (pkg ) =>
44
+ | Npm (pkg ) | Outdated ( pkg ) =>
44
45
if pkg .name -> Js .String2 .startsWith ("@elm-react" ) {
45
46
true
46
47
} else if pkg .name -> Js .String2 .startsWith ("bs-" ) {
@@ -74,7 +75,7 @@ module Resource = {
74
75
75
76
let isOfficial = (res : t ) => {
76
77
switch res {
77
- | Npm (pkg ) =>
78
+ | Npm (pkg ) | Outdated ( pkg ) =>
78
79
pkg .name === "rescript" ||
79
80
pkg .name -> Js .String2 .startsWith ("@rescript/" ) ||
80
81
pkg .name === "gentype"
@@ -121,35 +122,41 @@ module Resource = {
121
122
}
122
123
123
124
let applySearch = (resources : array <t >, pattern : string ): array <t > => {
124
- let (allNpms , allUrls ) = Belt .Array .reduce (resources , ([], []), (acc , next ) => {
125
- let (npms , resources ) = acc
125
+ let (allNpms , allUrls , allOutDated ) = Belt .Array .reduce (resources , ([], [], []), (
126
+ acc ,
127
+ next ,
128
+ ) => {
129
+ let (npms , resources , outdated ) = acc
126
130
127
131
switch next {
128
132
| Npm (pkg ) => Js .Array2 .push (npms , pkg )-> ignore
129
133
| Url (res ) => Js .Array2 .push (resources , res )-> ignore
134
+ | Outdated (pkg ) => Js .Array2 .push (outdated , pkg )-> ignore
130
135
}
131
- (npms , resources )
136
+ (npms , resources , outdated )
132
137
})
133
138
134
139
let filteredNpm = applyNpmSearch (allNpms , pattern )-> Belt .Array .map (m => Npm (m ["item" ]))
135
140
let filteredUrls = applyUrlResourceSearch (allUrls , pattern )-> Belt .Array .map (m => Url (m ["item" ]))
141
+ let filteredOutdated =
142
+ applyNpmSearch (allOutDated , pattern )-> Belt .Array .map (m => Outdated (m ["item" ]))
136
143
137
- Belt .Array .concat (filteredNpm , filteredUrls )
144
+ Belt .Array .concat (filteredNpm , filteredUrls )-> Belt . Array . concat ( filteredOutdated )
138
145
}
139
146
}
140
147
141
148
module Card = {
142
149
@react.component
143
150
let make = (~value : Resource .t , ~onKeywordSelect : option <string => unit >= ?) => {
144
151
let icon = switch value {
145
- | Npm (_ ) => <Icon .Npm className = "w-8 opacity-50" />
152
+ | Npm (_ ) | Outdated ( _ ) => <Icon .Npm className = "w-8 opacity-50" />
146
153
| Url (_ ) =>
147
154
<span >
148
155
<Icon .Hyperlink className = "w-8 opacity-50" />
149
156
</span >
150
157
}
151
158
let linkBox = switch value {
152
- | Npm (pkg ) =>
159
+ | Npm (pkg ) | Outdated ( pkg ) =>
153
160
let repositoryHref = Js .Null .toOption (pkg .repositoryHref )
154
161
let repoEl = switch repositoryHref {
155
162
| Some (href ) =>
@@ -174,12 +181,14 @@ module Card = {
174
181
}
175
182
176
183
let titleHref = switch value {
177
- | Npm (pkg ) => pkg .repositoryHref -> Js .Null .toOption -> Belt .Option .getWithDefault (pkg .npmHref )
184
+ | Npm (pkg ) | Outdated (pkg ) =>
185
+ pkg .repositoryHref -> Js .Null .toOption -> Belt .Option .getWithDefault (pkg .npmHref )
178
186
| Url (res ) => res .urlHref
179
187
}
180
188
181
189
let (title , description , keywords ) = switch value {
182
190
| Npm ({name , description , keywords })
191
+ | Outdated ({name , description , keywords })
183
192
| Url ({name , description , keywords }) => (name , description , keywords )
184
193
}
185
194
@@ -243,6 +252,7 @@ module Filter = {
243
252
includeCommunity : bool ,
244
253
includeNpm : bool ,
245
254
includeUrlResource : bool ,
255
+ includeOutdated : bool ,
246
256
}
247
257
}
248
258
@@ -268,7 +278,7 @@ module InfoSidebar = {
268
278
269
279
<aside className = " border-l-2 p-4 py-12 border-fire-30 space-y-16" >
270
280
<div >
271
- <h2 className = h2 > {React .string ("Filter for " )} </h2 >
281
+ <h2 className = h2 > {React .string ("Include " )} </h2 >
272
282
<div className = "space-y-2" >
273
283
<Toggle
274
284
enabled = {filter .includeOfficial }
@@ -306,6 +316,15 @@ module InfoSidebar = {
306
316
}}>
307
317
{React .string ("URL resources" )}
308
318
</Toggle >
319
+ <Toggle
320
+ enabled = {filter .includeOutdated }
321
+ toggle = {() => {
322
+ setFilter (prev => {
323
+ {... prev , Filter .includeOutdated : ! filter .includeOutdated }
324
+ })
325
+ }}>
326
+ {React .string ("Outdated" )}
327
+ </Toggle >
309
328
</div >
310
329
</div >
311
330
<div >
@@ -325,7 +344,11 @@ module InfoSidebar = {
325
344
}
326
345
}
327
346
328
- type props = {"packages" : array <npmPackage >, "urlResources" : array <urlResource >}
347
+ type props = {
348
+ "packages" : array <npmPackage >,
349
+ "urlResources" : array <urlResource >,
350
+ "unmaintained" : array <npmPackage >,
351
+ }
329
352
330
353
type state =
331
354
| All
@@ -351,13 +374,14 @@ let default = (props: props) => {
351
374
includeCommunity : true ,
352
375
includeNpm : true ,
353
376
includeUrlResource : true ,
377
+ includeOutdated : false ,
354
378
})
355
379
356
380
let allResources = {
357
381
let npms = props ["packages" ]-> Belt .Array .map (pkg => Resource .Npm (pkg ))
358
382
let urls = props ["urlResources" ]-> Belt .Array .map (res => Resource .Url (res ))
359
-
360
- Belt .Array .concat (npms , urls )
383
+ let outdated = props [ "unmaintained" ] -> Belt . Array . map ( pkg => Resource . Outdated ( pkg ))
384
+ Belt .Array .concat (npms , urls )-> Belt . Array . concat ( outdated )
361
385
}
362
386
363
387
let resources = switch state {
@@ -391,6 +415,7 @@ let default = (props: props) => {
391
415
let isResourceIncluded = switch next {
392
416
| Npm (_ ) => filter .includeNpm
393
417
| Url (_ ) => filter .includeUrlResource
418
+ | Outdated (_ ) => filter .includeOutdated
394
419
}
395
420
if ! isResourceIncluded {
396
421
()
@@ -440,7 +465,6 @@ let default = (props: props) => {
440
465
441
466
React .useEffect (() => {
442
467
firstRenderDone .current = true
443
-
444
468
None
445
469
}, [])
446
470
@@ -563,6 +587,8 @@ let getStaticProps: Next.GetStaticProps.revalidate<props, unit> = async _ctx =>
563
587
three -> Response .json ,
564
588
))
565
589
590
+ let unmaintained = []
591
+
566
592
let pkges =
567
593
parsePkgs (data1 )
568
594
-> Js .Array2 .concat (parsePkgs (data2 ))
@@ -572,7 +598,8 @@ let getStaticProps: Next.GetStaticProps.revalidate<props, unit> = async _ctx =>
572
598
true
573
599
} else if pkg .name -> Js .String2 .includes ("reason" ) {
574
600
false
575
- } else if pkg .maintenanceScore < 0.09 {
601
+ } else if pkg .maintenanceScore < 0.3 {
602
+ let _ = unmaintained -> Js .Array2 .push (pkg )
576
603
false
577
604
} else {
578
605
true
@@ -587,6 +614,7 @@ let getStaticProps: Next.GetStaticProps.revalidate<props, unit> = async _ctx =>
587
614
-> unsafeToUrlResource
588
615
let props : props = {
589
616
"packages" : pkges ,
617
+ "unmaintained" : unmaintained ,
590
618
"urlResources" : urlResources ,
591
619
}
592
620
0 commit comments