Skip to content

Commit

Permalink
basic New Arch detection, new status and filter (#870)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simek authored Aug 31, 2022
1 parent aa4e692 commit 4ae25e9
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 8 deletions.
7 changes: 7 additions & 0 deletions components/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ export const Filters = ({ query, style, basePath = '/' }: FiltersProps) => {
title="Has TypeScript types"
basePath={basePath}
/>
<ToggleLink
key="newArchitecture"
query={query}
paramName="newArchitecture"
title="Supports New Architecture"
basePath={basePath}
/>
{isMainSearch ? (
<ToggleLink
key="isMaintained"
Expand Down
22 changes: 18 additions & 4 deletions components/Library/MetaData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Fork,
Code,
TypeScript,
ReactLogo,
} from '../Icons';
import { DirectoryScore } from './DirectoryScore';

Expand All @@ -25,7 +26,7 @@ type Props = {
};

const generateData = (library, secondary, isDark) => {
const { github } = library;
const { github, newArchitecture } = library;

if (secondary) {
const secondaryTextColor = {
Expand All @@ -34,7 +35,7 @@ const generateData = (library, secondary, isDark) => {
const iconColor = isDark ? darkColors.pewter : colors.secondary;
const paragraphStyles = [styles.secondaryText, secondaryTextColor];
const linkStyles = [...paragraphStyles, styles.mutedLink];
const hoverStyle = isDark ? { color: colors.primaryDark } : undefined;
const hoverStyle = isDark && { color: colors.primaryDark };

return [
github.urls.homepage
Expand Down Expand Up @@ -69,6 +70,20 @@ const generateData = (library, secondary, isDark) => {
content: <P style={paragraphStyles}>TypeScript Types</P>,
}
: null,
newArchitecture || github.newArchitecture
? {
id: 'newArchitecture',
icon: <ReactLogo fill={iconColor} width={17} height={17} />,
content: (
<A
href="https://reactnative.dev/docs/new-architecture-intro"
style={linkStyles}
hoverStyle={hoverStyle}>
New Architecture
</A>
),
}
: null,
library.examples && library.examples.length
? {
id: 'examples',
Expand All @@ -80,7 +95,6 @@ const generateData = (library, secondary, isDark) => {
<A
key={example}
href={example}
target="blank"
style={[...linkStyles, styles.exampleLink]}
hoverStyle={hoverStyle}>
#{index + 1}
Expand All @@ -102,7 +116,7 @@ const generateData = (library, secondary, isDark) => {
target="_self"
href="/scoring"
style={[styles.link, styles.mutedLink]}
hoverStyle={isDark ? { color: colors.primaryDark } : undefined}>
hoverStyle={isDark && { color: colors.primaryDark }}>
Directory Score
</A>
),
Expand Down
3 changes: 2 additions & 1 deletion debug-github-repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{
"githubUrl": "https://github.com/react-native-datetimepicker/datetimepicker",
"npmPkg": "@react-native-community/datetimepicker",
"expo": true
"expo": true,
"newArchitecture": true
}
]
1 change: 1 addition & 0 deletions pages/api/libraries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
isRecommended: req.query.isRecommended,
wasRecentlyUpdated: req.query.wasRecentlyUpdated,
minPopularity: req.query.minPopularity,
newArchitecture: req.query.newArchitecture,
});

const offset = req.query.offset ? parseInt(req.query.offset.toString(), 10) : 0;
Expand Down
4 changes: 2 additions & 2 deletions react-native-libraries.json
Original file line number Diff line number Diff line change
Expand Up @@ -4807,8 +4807,8 @@
"examples": ["https://github.com/xcarpentier/rn-tourguide/blob/master/App.tsx"]
},
{
"githubUrl": "https://github.com/callstack/react-native-slider/tree/master/src",
"examples": ["https://github.com/callstack/react-native-slider/tree/master/example"],
"githubUrl": "https://github.com/callstack/react-native-slider/tree/main/package",
"examples": ["https://github.com/callstack/react-native-slider/tree/main/example"],
"npmPkg": "@react-native-community/slider",
"images": [
"https://i.postimg.cc/dQTYzGD5/Screenshot-2019-03-25-at-11-24-59.png",
Expand Down
7 changes: 7 additions & 0 deletions react-native-libraries.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@
"title": "The Template Schema",
"default": false,
"examples": [true]
},
"newArchitecture": {
"$id": "#/items/properties/newArch",
"type": "boolean",
"title": "The New Architecture Support Schema",
"default": false,
"examples": [true]
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion scripts/fetch-github-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Authorization = `bearer ${process.env.GITHUB_TOKEN}`;
const licenses = {};

/**
* Fetch licenses from github to be used later to parse licenses from npm
* Fetch licenses from GitHub to be used later to parse licenses from npm
*/
export const loadGitHubLicenses = async () => {
const query = `
Expand Down Expand Up @@ -237,6 +237,8 @@ const createRepoDataWithResponse = (json, monorepo) => {
try {
const packageJson = JSON.parse(json.packageJson.text);

json.newArchitecture = Boolean(packageJson.codegenConfig);

if (monorepo) {
json.homepageUrl = packageJson.homepage;
json.name = packageJson.name;
Expand Down Expand Up @@ -307,5 +309,6 @@ const createRepoDataWithResponse = (json, monorepo) => {
license: json.licenseInfo,
lastRelease: json.lastRelease,
hasTypes: json.types,
newArchitecture: json.newArchitecture,
};
};
3 changes: 3 additions & 0 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type Query = {
isRecommended?: string;
wasRecentlyUpdated?: string;
minPopularity?: string | number;
newArchitecture?: string;
};

export type Library = {
Expand All @@ -43,6 +44,7 @@ export type Library = {
unmaintained?: boolean;
dev?: boolean;
template?: boolean;
newArchitecture?: boolean;
github: {
urls: {
repo: string;
Expand Down Expand Up @@ -82,6 +84,7 @@ export type Library = {
isPrerelease: boolean;
};
hasTypes: boolean;
newArchitecture: string;
};
npm: {
downloads: number;
Expand Down
5 changes: 5 additions & 0 deletions util/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const handleFilterLibraries = ({
isRecommended,
wasRecentlyUpdated,
minPopularity,
newArchitecture,
}) => {
const viewerHasChosenTopic = !isEmptyOrNull(queryTopic);
const viewerHasTypedSearch = !isEmptyOrNull(querySearch);
Expand Down Expand Up @@ -89,6 +90,10 @@ export const handleFilterLibraries = ({
return false;
}

if (newArchitecture && !library.newArchitecture && !library.github.newArchitecture) {
return false;
}

if (isMaintained && library.unmaintained) {
return false;
}
Expand Down

0 comments on commit 4ae25e9

Please sign in to comment.