Skip to content
Closed
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
18 changes: 6 additions & 12 deletions scripts/build-and-score-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,16 @@ async function buildAndScoreData() {
const topicCounts: Record<string, number> = missingOnly ? (topics ?? {}) : {};

data.forEach((project, index, projectList) => {
let topicSearchString = '';
const topics = new Set<string>();

if (project.github.topics) {
project.github.topics.forEach(topic => {
topicSearchString = `${topicSearchString} ${topic}`;
project.github.topics?.forEach(topic => topics.add(topic));
project.npm?.keywords?.forEach(keyword => topics.add(keyword));

if (!topicCounts[topic]) {
topicCounts[topic] = 1;
return;
}

topicCounts[topic] += 1;
});
for (const topic of topics) {
topicCounts[topic] = (topicCounts[topic] ?? 0) + 1;
}

projectList[index].topicSearchString = topicSearchString.trim();
projectList[index].topicSearchString = [...topics].join(' ');
});

if (invalidRepos.length) {
Expand Down
3 changes: 2 additions & 1 deletion scripts/fetch-npm-registry-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fetch } from 'bun';

import { type LibraryType, type NpmRegistryData } from '~/types';

import { REQUEST_SLEEP, sleep } from './helpers';
import { processTopics, REQUEST_SLEEP, sleep } from './helpers';

const ATTEMPTS_LIMIT = 2;

Expand Down Expand Up @@ -53,6 +53,7 @@ export async function fetchNpmRegistryData(
'deprecated' in registryData.versions[latestRelease] ? true : pkgData.unmaintained,
npm: {
...pkgData.npm,
keywords: processTopics(registryData.keywords),
size: registryData.versions[latestRelease].dist.unpackedSize,
versionsCount: Object.keys(registryData.versions).length,
latestRelease,
Expand Down
1 change: 1 addition & 0 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export type LibraryType = LibraryDataEntryType & {
npm?: {
downloads?: number;
weekDownloads?: number;
keywords?: string[];
size?: number;
versionsCount?: number;
latestRelease?: string;
Expand Down