1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00
verdaccio/scripts/addon-update.ts
Juan Picado 3d158a195a
chore(website): plugin search ui (#3539)
* chore: plugin search ui

chore: progress

chore: format code

chore: progress

chore: @verdaccio-ui/copy-clipboard

chore: search finish

* chore: ui-components

* Update ToolList.tsx

* xss protection

* Update static-data.yml

* Update AddonCard.tsx
2022-12-25 18:48:18 +01:00

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)
);
})();