Skip to content

Commit be869f6

Browse files
Package Index tweaks (#446)
1 parent e4a0b35 commit be869f6

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

data/packages_url_resources.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,5 @@
1212
"keywords": ["rescript", "typescript"],
1313
"urlHref": "https://github.com/reason-association/genType",
1414
"official": true
15-
},
16-
{
17-
"name": "re-schema-form",
18-
"description": "Re-schema-form is a meta based render.",
19-
"keywords": ["rescript"],
20-
"urlHref": "https://github.com/jongleb/re-schema-form",
21-
"official": false
2215
}
2316
]

src/Packages.mjs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ function filterKeywords(keywords) {
4848
}));
4949
}
5050

51+
var uniqueKeywords = ((keywords) => [...new Set(keywords)]);
52+
5153
function isOfficial(res) {
5254
if (res.TAG !== /* Npm */0) {
5355
return res._0.official;
@@ -65,8 +67,7 @@ function applyNpmSearch(packages, pattern) {
6567
shouldSort: true,
6668
includeScore: true,
6769
threshold: 0.2,
68-
location: 0,
69-
distance: 30,
70+
ignoreLocation: true,
7071
minMatchCharLength: 1,
7172
keys: [
7273
"meta.uid",
@@ -83,8 +84,7 @@ function applyUrlResourceSearch(urls, pattern) {
8384
shouldSort: true,
8485
includeScore: true,
8586
threshold: 0.2,
86-
location: 0,
87-
distance: 30,
87+
ignoreLocation: true,
8888
minMatchCharLength: 1,
8989
keys: [
9090
"name",
@@ -516,13 +516,12 @@ function getStaticProps(_ctx) {
516516
return {
517517
name: pkg.name,
518518
version: pkg.version,
519-
keywords: filterKeywords(pkg.keywords),
519+
keywords: uniqueKeywords(filterKeywords(pkg.keywords)),
520520
description: Belt_Option.getWithDefault(pkg.description, ""),
521521
repositoryHref: Js_null.fromOption(pkg.links.repository),
522522
npmHref: pkg.links.npm
523523
};
524524
}));
525-
console.log(pkges);
526525
var index_data_dir = Path.join(Process.cwd(), "./data");
527526
var urlResources = JSON.parse(Fs.readFileSync(Path.join(index_data_dir, "packages_url_resources.json"), "utf8"));
528527
var props = {

src/Packages.res

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ module Resource = {
6767
})
6868
}
6969

70+
let uniqueKeywords: array<string> => array<string> = %raw(`(keywords) => [...new Set(keywords)]`)
71+
7072
let isOfficial = (res: t) => {
7173
switch res {
7274
| Npm(pkg) =>
@@ -84,8 +86,7 @@ module Resource = {
8486
~shouldSort=true,
8587
~includeScore=true,
8688
~threshold=0.2,
87-
~location=0,
88-
~distance=30,
89+
~ignoreLocation=true,
8990
~minMatchCharLength=1,
9091
~keys=["meta.uid", "name", "keywords"],
9192
(),
@@ -103,8 +104,7 @@ module Resource = {
103104
~shouldSort=true,
104105
~includeScore=true,
105106
~threshold=0.2,
106-
~location=0,
107-
~distance=30,
107+
~ignoreLocation=true,
108108
~minMatchCharLength=1,
109109
~keys=["name", "keywords"],
110110
(),
@@ -529,15 +529,13 @@ let getStaticProps: Next.GetStaticProps.revalidate<props, unit> = _ctx => {
529529
{
530530
name: pkg["name"],
531531
version: pkg["version"],
532-
keywords: Resource.filterKeywords(pkg["keywords"]),
532+
keywords: Resource.filterKeywords(pkg["keywords"])->Resource.uniqueKeywords,
533533
description: Belt.Option.getWithDefault(pkg["description"], ""),
534534
repositoryHref: Js.Null.fromOption(pkg["links"]["repository"]),
535535
npmHref: pkg["links"]["npm"],
536536
}
537537
})
538538

539-
Js.log(pkges)
540-
541539
let index_data_dir = Node.Path.join2(Node.Process.cwd(), "./data")
542540
let urlResources =
543541
Node.Path.join2(index_data_dir, "packages_url_resources.json")

src/bindings/Fuse.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ module Options = {
1212
@optional
1313
distance: int,
1414
@optional
15+
ignoreLocation: bool,
16+
@optional
1517
minMatchCharLength: int,
1618
@optional
1719
keys: array<string>,

0 commit comments

Comments
 (0)