@@ -5,7 +5,8 @@ class DefinitelyTyped extends Repo
55{
66 protected $ id = 'dt ' ;
77 protected $ url = 'https://definitelytyped.org ' ;
8- protected $ search_url = 'https://api.npms.io/v2/search?q=scope:types+ ' ;
8+ protected $ search_url = 'https://api.npms.io/v2/search ' ;
9+ protected $ npm_scope = 'types ' ;
910
1011 public function search ($ query )
1112 {
@@ -16,18 +17,22 @@ public function search($query)
1617 $ this ->pkgs = $ this ->cache ->get_query_json (
1718 $ this ->id ,
1819 $ query ,
19- "{$ this ->search_url }{$ query }&size= {$ this ->max_return }"
20+ "{$ this ->search_url }?q=scope: { $ this -> npm_scope } + {$ query }&size= {$ this ->max_return }"
2021 );
2122
2223 foreach ($ this ->pkgs ->results as $ pkg ) {
2324 $ p = $ pkg ->package ;
24- $ name = $ p ->name ;
25+ $ scope_prefix = "@ {$ this ->npm_scope }/ " ;
26+ $ is_deprecated = !empty ($ pkg ->flags ->deprecated );
27+ $ name = $ is_deprecated ? str_replace ($ scope_prefix , "" , $ p ->name ) : $ p ->name ;
28+ $ description = $ is_deprecated ? "[!] {$ p ->name } has been deprecated: {$ pkg ->flags ->deprecated }" : $ p ->description ;
29+ $ link = $ is_deprecated ? str_replace (urlencode ($ scope_prefix ), "" , $ p ->links ->npm ) : $ p ->links ->npm ;
2530
2631 $ this ->cache ->w ->result (
2732 $ this ->id ,
28- $ this ->makeArg ($ name , $ p -> links -> npm , "{$ p ->name }: {$ p ->version }" ),
33+ $ this ->makeArg ($ name , $ link , "{$ p ->name }: {$ p ->version }" ),
2934 $ name ,
30- $ p -> description ,
35+ $ description ,
3136 "icon-cache/ {$ this ->id }.png "
3237 );
3338
0 commit comments