Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic New Arch detection and new status #870

Merged
merged 4 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
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
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