Skip to content

Package Index tweaks #446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions data/packages_url_resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,5 @@
"keywords": ["rescript", "typescript"],
"urlHref": "https://github.com/reason-association/genType",
"official": true
},
{
"name": "re-schema-form",
"description": "Re-schema-form is a meta based render.",
"keywords": ["rescript"],
"urlHref": "https://github.com/jongleb/re-schema-form",
"official": false
}
]
11 changes: 5 additions & 6 deletions src/Packages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ function filterKeywords(keywords) {
}));
}

var uniqueKeywords = ((keywords) => [...new Set(keywords)]);

function isOfficial(res) {
if (res.TAG !== /* Npm */0) {
return res._0.official;
Expand All @@ -65,8 +67,7 @@ function applyNpmSearch(packages, pattern) {
shouldSort: true,
includeScore: true,
threshold: 0.2,
location: 0,
distance: 30,
ignoreLocation: true,
minMatchCharLength: 1,
keys: [
"meta.uid",
Expand All @@ -83,8 +84,7 @@ function applyUrlResourceSearch(urls, pattern) {
shouldSort: true,
includeScore: true,
threshold: 0.2,
location: 0,
distance: 30,
ignoreLocation: true,
minMatchCharLength: 1,
keys: [
"name",
Expand Down Expand Up @@ -516,13 +516,12 @@ function getStaticProps(_ctx) {
return {
name: pkg.name,
version: pkg.version,
keywords: filterKeywords(pkg.keywords),
keywords: uniqueKeywords(filterKeywords(pkg.keywords)),
description: Belt_Option.getWithDefault(pkg.description, ""),
repositoryHref: Js_null.fromOption(pkg.links.repository),
npmHref: pkg.links.npm
};
}));
console.log(pkges);
var index_data_dir = Path.join(Process.cwd(), "./data");
var urlResources = JSON.parse(Fs.readFileSync(Path.join(index_data_dir, "packages_url_resources.json"), "utf8"));
var props = {
Expand Down
12 changes: 5 additions & 7 deletions src/Packages.res
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ module Resource = {
})
}

let uniqueKeywords: array<string> => array<string> = %raw(`(keywords) => [...new Set(keywords)]`)

let isOfficial = (res: t) => {
switch res {
| Npm(pkg) =>
Expand All @@ -84,8 +86,7 @@ module Resource = {
~shouldSort=true,
~includeScore=true,
~threshold=0.2,
~location=0,
~distance=30,
~ignoreLocation=true,
~minMatchCharLength=1,
~keys=["meta.uid", "name", "keywords"],
(),
Expand All @@ -103,8 +104,7 @@ module Resource = {
~shouldSort=true,
~includeScore=true,
~threshold=0.2,
~location=0,
~distance=30,
~ignoreLocation=true,
~minMatchCharLength=1,
~keys=["name", "keywords"],
(),
Expand Down Expand Up @@ -529,15 +529,13 @@ let getStaticProps: Next.GetStaticProps.revalidate<props, unit> = _ctx => {
{
name: pkg["name"],
version: pkg["version"],
keywords: Resource.filterKeywords(pkg["keywords"]),
keywords: Resource.filterKeywords(pkg["keywords"])->Resource.uniqueKeywords,
description: Belt.Option.getWithDefault(pkg["description"], ""),
repositoryHref: Js.Null.fromOption(pkg["links"]["repository"]),
npmHref: pkg["links"]["npm"],
}
})

Js.log(pkges)

let index_data_dir = Node.Path.join2(Node.Process.cwd(), "./data")
let urlResources =
Node.Path.join2(index_data_dir, "packages_url_resources.json")
Expand Down
2 changes: 2 additions & 0 deletions src/bindings/Fuse.res
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module Options = {
@optional
distance: int,
@optional
ignoreLocation: bool,
@optional
minMatchCharLength: int,
@optional
keys: array<string>,
Expand Down