Skip to content

Commit

Permalink
Merge branch '519-add-licenses-page-to-app'
Browse files Browse the repository at this point in the history
  • Loading branch information
lil5 committed Jul 24, 2023
2 parents 2a956a6 + e98c18e commit f9b0440
Show file tree
Hide file tree
Showing 19 changed files with 408 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ yarn-error.log*

# Optional eslint cache
.eslintcache

# generated files
/public/open_source_licenses.json
26 changes: 26 additions & 0 deletions app/generate-open-source-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pkg from 'nlf';
import * as fs from "fs";

pkg.find({directory: './', reach: 1}, function (err, data) {
let result = {};
data.forEach(d => {
d?.licenseSources.package.sources.forEach(ls => {
if (result[ls.license] === undefined) {
result[ls.license] = new Set;
}
result[ls.license].add(d?.name);
})
})
for (let ls in result) {
result[ls] = [...result[ls]];
}
fs.writeFile(
"public/open_source_licenses.json",
JSON.stringify(result, null, 4),
{flag: "w"},
function (err) {
if (err) {
return console.log(err);
}
});
});
Loading

0 comments on commit f9b0440

Please sign in to comment.