mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
|
import fs from 'fs/promises';
|
||
|
import got from 'got';
|
||
|
import path from 'path';
|
||
|
|
||
|
(async () => {
|
||
|
const data = require('../website/src/components/EcosystemSearch/addons.json');
|
||
|
for (let item of data.addons) {
|
||
|
try {
|
||
|
const d = await got(`https://registry.npmjs.org/${item.name}`).json();
|
||
|
const apiDownloads = await got(
|
||
|
`https://api.npmjs.org/downloads/point/last-month/${item.name}`
|
||
|
).json();
|
||
|
// @ts-ignore
|
||
|
item.description = d.description;
|
||
|
item.url = `https://www.npmjs.org/${item.name}`;
|
||
|
item.registry = `https://registry.npmjs.org/${item.name}`;
|
||
|
item.bundled = typeof item.bundled === 'boolean' ? item.bundled : false;
|
||
|
item.origin = item.origin ? item.origin : 'community';
|
||
|
item.category = item.category ? item.category : 'authentication';
|
||
|
// @ts-ignore
|
||
|
item.latest = d['dist-tags'].latest;
|
||
|
// @ts-ignore
|
||
|
item.downloads = apiDownloads.downloads;
|
||
|
// console.log('d', item);
|
||
|
} catch (err) {
|
||
|
// eslint-disable-next-line no-console
|
||
|
console.error('error for %s', item.name, err);
|
||
|
}
|
||
|
}
|
||
|
await fs.writeFile(
|
||
|
path.join(__dirname, '../website/src/components/EcosystemSearch/addons.json'),
|
||
|
JSON.stringify({ ...data }, null, 4)
|
||
|
);
|
||
|
})();
|