@@ -29,18 +29,19 @@ type npmPackage = {
2929}
3030
3131module Resource = {
32- type t = Npm (npmPackage ) | Url (urlResource )
32+ type t = Npm (npmPackage ) | Url (urlResource ) | Outdated ( npmPackage )
3333
3434 let getId = (res : t ) => {
3535 switch res {
3636 | Npm ({name })
37+ | Outdated ({name })
3738 | Url ({name }) => name
3839 }
3940 }
4041
4142 let shouldFilter = (res : t ) => {
4243 switch res {
43- | Npm (pkg ) =>
44+ | Npm (pkg ) | Outdated ( pkg ) =>
4445 if pkg .name -> Js .String2 .startsWith ("@elm-react" ) {
4546 true
4647 } else if pkg .name -> Js .String2 .startsWith ("bs-" ) {
@@ -74,7 +75,7 @@ module Resource = {
7475
7576 let isOfficial = (res : t ) => {
7677 switch res {
77- | Npm (pkg ) =>
78+ | Npm (pkg ) | Outdated ( pkg ) =>
7879 pkg .name === "rescript" ||
7980 pkg .name -> Js .String2 .startsWith ("@rescript/" ) ||
8081 pkg .name === "gentype"
@@ -121,35 +122,41 @@ module Resource = {
121122 }
122123
123124 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
126130
127131 switch next {
128132 | Npm (pkg ) => Js .Array2 .push (npms , pkg )-> ignore
129133 | Url (res ) => Js .Array2 .push (resources , res )-> ignore
134+ | Outdated (pkg ) => Js .Array2 .push (outdated , pkg )-> ignore
130135 }
131- (npms , resources )
136+ (npms , resources , outdated )
132137 })
133138
134139 let filteredNpm = applyNpmSearch (allNpms , pattern )-> Belt .Array .map (m => Npm (m ["item" ]))
135140 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" ]))
136143
137- Belt .Array .concat (filteredNpm , filteredUrls )
144+ Belt .Array .concat (filteredNpm , filteredUrls )-> Belt . Array . concat ( filteredOutdated )
138145 }
139146}
140147
141148module Card = {
142149 @react.component
143150 let make = (~value : Resource .t , ~onKeywordSelect : option <string => unit >= ?) => {
144151 let icon = switch value {
145- | Npm (_ ) => <Icon .Npm className = "w-8 opacity-50" />
152+ | Npm (_ ) | Outdated ( _ ) => <Icon .Npm className = "w-8 opacity-50" />
146153 | Url (_ ) =>
147154 <span >
148155 <Icon .Hyperlink className = "w-8 opacity-50" />
149156 </span >
150157 }
151158 let linkBox = switch value {
152- | Npm (pkg ) =>
159+ | Npm (pkg ) | Outdated ( pkg ) =>
153160 let repositoryHref = Js .Null .toOption (pkg .repositoryHref )
154161 let repoEl = switch repositoryHref {
155162 | Some (href ) =>
@@ -174,12 +181,14 @@ module Card = {
174181 }
175182
176183 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 )
178186 | Url (res ) => res .urlHref
179187 }
180188
181189 let (title , description , keywords ) = switch value {
182190 | Npm ({name , description , keywords })
191+ | Outdated ({name , description , keywords })
183192 | Url ({name , description , keywords }) => (name , description , keywords )
184193 }
185194
@@ -243,6 +252,7 @@ module Filter = {
243252 includeCommunity : bool ,
244253 includeNpm : bool ,
245254 includeUrlResource : bool ,
255+ includeOutdated : bool ,
246256 }
247257}
248258
@@ -268,7 +278,7 @@ module InfoSidebar = {
268278
269279 <aside className = " border-l-2 p-4 py-12 border-fire-30 space-y-16" >
270280 <div >
271- <h2 className = h2 > {React .string ("Filter for " )} </h2 >
281+ <h2 className = h2 > {React .string ("Include " )} </h2 >
272282 <div className = "space-y-2" >
273283 <Toggle
274284 enabled = {filter .includeOfficial }
@@ -306,6 +316,15 @@ module InfoSidebar = {
306316 }}>
307317 {React .string ("URL resources" )}
308318 </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 >
309328 </div >
310329 </div >
311330 <div >
@@ -325,7 +344,11 @@ module InfoSidebar = {
325344 }
326345}
327346
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+ }
329352
330353type state =
331354 | All
@@ -351,13 +374,14 @@ let default = (props: props) => {
351374 includeCommunity : true ,
352375 includeNpm : true ,
353376 includeUrlResource : true ,
377+ includeOutdated : false ,
354378 })
355379
356380 let allResources = {
357381 let npms = props ["packages" ]-> Belt .Array .map (pkg => Resource .Npm (pkg ))
358382 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 )
361385 }
362386
363387 let resources = switch state {
@@ -391,6 +415,7 @@ let default = (props: props) => {
391415 let isResourceIncluded = switch next {
392416 | Npm (_ ) => filter .includeNpm
393417 | Url (_ ) => filter .includeUrlResource
418+ | Outdated (_ ) => filter .includeOutdated
394419 }
395420 if ! isResourceIncluded {
396421 ()
@@ -440,7 +465,6 @@ let default = (props: props) => {
440465
441466 React .useEffect (() => {
442467 firstRenderDone .current = true
443-
444468 None
445469 }, [])
446470
@@ -563,6 +587,8 @@ let getStaticProps: Next.GetStaticProps.revalidate<props, unit> = async _ctx =>
563587 three -> Response .json ,
564588 ))
565589
590+ let unmaintained = []
591+
566592 let pkges =
567593 parsePkgs (data1 )
568594 -> Js .Array2 .concat (parsePkgs (data2 ))
@@ -572,7 +598,8 @@ let getStaticProps: Next.GetStaticProps.revalidate<props, unit> = async _ctx =>
572598 true
573599 } else if pkg .name -> Js .String2 .includes ("reason" ) {
574600 false
575- } else if pkg .maintenanceScore < 0.09 {
601+ } else if pkg .maintenanceScore < 0.3 {
602+ let _ = unmaintained -> Js .Array2 .push (pkg )
576603 false
577604 } else {
578605 true
@@ -587,6 +614,7 @@ let getStaticProps: Next.GetStaticProps.revalidate<props, unit> = async _ctx =>
587614 -> unsafeToUrlResource
588615 let props : props = {
589616 "packages" : pkges ,
617+ "unmaintained" : unmaintained ,
590618 "urlResources" : urlResources ,
591619 }
592620
0 commit comments