Skip to content
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
33 changes: 13 additions & 20 deletions bun.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/Library/UpdateAtView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { StyleSheet, View } from 'react-native';
import { A, colors, darkColors } from '~/common/styleguide';
import Tooltip from '~/components/Tooltip';
import CustomAppearanceContext from '~/context/CustomAppearanceContext';
import { parseGitHubUrl } from '~/scripts/helpers';
import { type LibraryType } from '~/types';
import { getTimeSinceToday } from '~/util/datetime';
import { parseGitHubUrl } from '~/util/parseGitHubUrl';

import { Calendar } from '../Icons';

Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"data:validate": "ajv validate -s react-native-libraries.schema.json -d react-native-libraries.json --verbose --allowUnionTypes",
"libraries:cleanup": "bun scripts/cleanup-libraries-json && bun libraries:format",
"libraries:recalculate": "bun scripts/recalculate-scores",
"libraries:format": "prettier --write react-native-libraries.json",
"libraries:format": "prettier --experimental-cli --write react-native-libraries.json",
"libraries:check": "bun scripts/check-resources",
"ci:cleanup-blobs": "bun scripts/cleanup-data-blobs",
"ci:validate": "bun scripts/validate-new-entries",
Expand All @@ -25,7 +25,7 @@
"@react-native-picker/picker": "^2.11.2",
"@sentry/react": "^10.12.0",
"@vercel/blob": "^0.27.3",
"expo": "54.0.8",
"expo": "54.0.9",
"expo-font": "^14.0.8",
"lodash": "^4.17.21",
"next": "^15.5.3",
Expand All @@ -49,9 +49,8 @@
"ajv-cli": "^5.0.0",
"browserslist": "^4.26.2",
"cheerio": "^1.1.2",
"cross-fetch": "^4.1.0",
"dotenv": "^17.2.2",
"eslint": "^9.35.0",
"eslint": "^9.36.0",
"eslint-config-next": "^15.5.3",
"eslint-config-universe": "^15.0.3",
"lint-staged": "^16.1.6",
Expand Down
1 change: 0 additions & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from 'cross-fetch';
import { NextPageContext } from 'next';
import { useRouter } from 'next/router';
import { type ParsedUrlQuery } from 'node:querystring';
Expand Down
1 change: 0 additions & 1 deletion pages/popular.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from 'cross-fetch';
import { NextPageContext } from 'next';
import { StyleSheet } from 'react-native';

Expand Down
109 changes: 50 additions & 59 deletions react-native-libraries.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions scripts/build-and-score-data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BlobAccessError, list, put } from '@vercel/blob';
import fetch from 'cross-fetch';
import { fetch } from 'bun';
import chunk from 'lodash/chunk';
import fs from 'node:fs';
import path from 'node:path';
Expand Down Expand Up @@ -37,7 +37,7 @@ const DATA_PATH = path.resolve('assets', 'data.json');
const GITHUB_RESULTS_PATH = path.join('scripts', 'raw-github-results.json');

const CHUNK_SIZE = 25;
const SLEEP_TIME = 500;
const SLEEP_TIME = 400;

const invalidRepos: string[] = [];
const mismatchedRepos: LibraryType[] = [];
Expand Down
65 changes: 32 additions & 33 deletions scripts/check-resources.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
import fetch from 'cross-fetch';
import { fetch } from 'bun';

import { LibraryDataEntryType } from '~/types';

import libraries from '../react-native-libraries.json';
import { sleep } from './helpers';

console.log('⬇️ Attempting to fetch examples and images');
async function runThrottledFetches(libraries: LibraryDataEntryType[], delayMs = 50) {
const urlList: string[] = [];

libraries.forEach(lib => {
if (lib.examples) {
lib.examples.forEach(async (example: string, index: number) => {
await sleep(500);
setTimeout(() => {
fetch(example)
.then(response => {
if (response.status !== 200) {
console.warn(`EXAMPLE: ${example} returned ${response.status}`);
}
})
.catch(error => {
console.warn(`EXAMPLE: errored! ${error}`);
});
}, 150 * index);
});
for (const lib of libraries) {
if (lib.examples) {
for (const exampleUrl of lib.examples) {
urlList.push(exampleUrl);
}
}
if (lib.images) {
for (const imgUrl of lib.images) {
urlList.push(imgUrl);
}
}
}

if (lib.images) {
lib.images.forEach(async (img: string, index: number) => {
await sleep(500);
setTimeout(() => {
fetch(img)
.then(response => {
if (response.status !== 200) {
console.warn(`IMG: ${img} returned ${response.status}`);
}
})
.catch(error => {
console.warn(`IMG: errored! ${error}`);
});
}, 150 * index);
});
console.log(`⬇️ Attempting to fetch examples and images (${urlList.length} URLs)`);

for (const url of urlList) {
try {
const response = await fetch(url);
if (response.status !== 200) {
console.warn(`${url} returned ${response.status}`);
}
} catch (err: any) {
console.warn(`${url} errored!`, err);
}
await sleep(delayMs);
}
}

runThrottledFetches(libraries).catch(err => {
console.error('❌ Unexpected error in throttled fetcher:', err);
});
10 changes: 2 additions & 8 deletions scripts/fetch-github-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ import { config } from 'dotenv';

import { LibraryType } from '~/types';
import hasNativeCode from '~/util/hasNativeCode';
import { parseGitHubUrl } from '~/util/parseGitHubUrl';

import {
processTopics,
sleep,
REQUEST_SLEEP,
makeGraphqlQuery,
parseGitHubUrl,
getUpdatedUrl,
} from './helpers';
import { processTopics, sleep, REQUEST_SLEEP, makeGraphqlQuery, getUpdatedUrl } from './helpers';
import GitHubLicensesQuery from './queries/GitHubLicensesQuery';
import GitHubRepositoryQuery from './queries/GitHubRepositoryQuery';

Expand Down
2 changes: 1 addition & 1 deletion scripts/fetch-npm-download-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetch from 'cross-fetch';
import { fetch } from 'bun';

import { LibraryType } from '~/types';

Expand Down
2 changes: 1 addition & 1 deletion scripts/fetch-npm-registry-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetch from 'cross-fetch';
import { fetch } from 'bun';

import { LibraryType } from '~/types';

Expand Down
2 changes: 1 addition & 1 deletion scripts/fetch-npm-stat-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetch from 'cross-fetch';
import { fetch } from 'bun';

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

Expand Down
2 changes: 1 addition & 1 deletion scripts/fetch-readme-images.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fetch } from 'bun';
import { Cheerio, load } from 'cheerio';
import fetch from 'cross-fetch';

import { LibraryType } from '~/types';

Expand Down
18 changes: 1 addition & 17 deletions scripts/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetch from 'cross-fetch';
import { fetch } from 'bun';

import { LibraryType } from '~/types';

Expand Down Expand Up @@ -31,22 +31,6 @@ export async function getUpdatedUrl(url: string) {
}
}

export function parseGitHubUrl(url: string) {
const [, , , repoOwner, repoName, ...path] = url.split('/');

const isMonorepo = !!(path && path.length);
const branchName = path[1];
const packagePath = isMonorepo ? path.slice(2).join('/').replace('%40', '@') : '.';

return {
repoOwner,
repoName,
isMonorepo,
branchName,
packagePath,
};
}

export function sleep(ms = 0, msMax: number | undefined = undefined) {
return new Promise(r =>
setTimeout(r, msMax ? Math.floor(Math.random() * (msMax - ms)) + ms : ms)
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate-new-entries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetch from 'cross-fetch';
import { fetch } from 'bun';
import differenceWith from 'lodash/differenceWith';
import isEqual from 'lodash/isEqual';

Expand Down
15 changes: 15 additions & 0 deletions util/parseGitHubUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export function parseGitHubUrl(url: string) {
const [, , , repoOwner, repoName, ...path] = url.split('/');

const isMonorepo = !!(path && path.length);
const branchName = path[1];
const packagePath = isMonorepo ? path.slice(2).join('/').replace('%40', '@') : '.';

return {
repoOwner,
repoName,
isMonorepo,
branchName,
packagePath,
};
}