Skip to content

Commit

Permalink
Merge pull request #495 from Simek/merge-topics
Browse files Browse the repository at this point in the history
merge package.json and GitHub topics, update and cleanup libraries
  • Loading branch information
brentvatne authored Nov 9, 2020
2 parents 81fa78e + 4ba5979 commit f54c15c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"data:update": "babel-node scripts/build-and-score-data.js --presets @babel/preset-env",
"data:test": "babel-node scripts/validate-libraries.js --presets @babel/preset-env",
"data:validate": "ajv validate -s react-native-libraries.schema.json -d react-native-libraries.json --verbose",
"libraries:cleanup": "babel-node scripts/cleanup-libraries-json.js --presets @babel/preset-env"
"libraries:cleanup": "babel-node scripts/cleanup-libraries-json.js --presets @babel/preset-env && yarn libraries:format",
"libraries:format": "prettier --write react-native-libraries.json"
},
"dependencies": {
"@expo/html-elements": "^0.0.0",
Expand Down
24 changes: 15 additions & 9 deletions react-native-libraries.json
Original file line number Diff line number Diff line change
Expand Up @@ -1880,12 +1880,6 @@
"expo": true,
"unmaintained": true
},
{
"githubUrl": "https://github.com/joao-alberto/react-native-tilt",
"ios": true,
"android": true,
"expo": true
},
{
"githubUrl": "https://github.com/Polidea/react-native-ble-plx",
"ios": true,
Expand Down Expand Up @@ -3121,10 +3115,20 @@
"windows": true
},
{
"githubUrl": "https://github.com/microsoft/react-native-dualscreen",
"githubUrl": "https://github.com/microsoft/react-native-dualscreen/tree/master/dualscreeninfo",
"android": true,
"npmPkg": "react-native-dualscreeninfo"
},
{
"githubUrl": "https://github.com/microsoft/react-native-dualscreen/tree/master/twopane-navigation",
"android": true,
"npmPkg": "react-native-twopane-navigation"
},
{
"githubUrl": "https://github.com/microsoft/react-native-dualscreen/tree/master/twopaneview",
"android": true,
"npmPkg": "react-native-twopaneview"
},
{
"githubUrl": "https://github.com/expo/expo/tree/master/packages/expo-splash-screen",
"ios": true,
Expand Down Expand Up @@ -3743,7 +3747,8 @@
{
"githubUrl": "https://github.com/luggit/react-native-config",
"ios": true,
"android": true
"android": true,
"windows": true
},
{
"githubUrl": "https://github.com/luisfcofv/react-native-deep-linking",
Expand Down Expand Up @@ -4222,7 +4227,8 @@
"unmaintained": true
},
{
"githubUrl": "https://github.com/uxcam/react-native-ux-cam",
"githubUrl": "https://github.com/uxcam/react-native-ux-cam/tree/master/uxcam-react-wrapper",
"npmPkg": "react-native-ux-cam",
"ios": true,
"android": true
},
Expand Down
23 changes: 12 additions & 11 deletions scripts/fetch-github-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,29 +224,33 @@ const getLicenseFromPackageJson = packageJson => {
}
};

const processTopics = topics =>
(topics || []).map(topic => topic.replace(/([ _])/g, '-').toLowerCase());

const createRepoDataWithResponse = (json, monorepo) => {
if (json.packageJson) {
const packageJson = JSON.parse(json.packageJson.text);

if (monorepo) {
json.homepageUrl = packageJson.homepage;
json.name = packageJson.name;
json.topics = packageJson.keywords;
json.topics = processTopics(packageJson.keywords);
json.description = packageJson.description;
json.licenseInfo = getLicenseFromPackageJson(packageJson);
}

if (!monorepo) {
json.topics = json.repositoryTopics.nodes.map(({ topic }) => topic.name);
json.topics = [
...new Set([
...processTopics(packageJson.keywords),
...processTopics(json.repositoryTopics.nodes.map(({ topic }) => topic.name)),
]),
];

if (!json.description) {
json.description = packageJson.description;
}

if (json.topics.length === 0) {
json.topics = packageJson.keywords;
}

if (!json.licenseInfo || (json.licenseInfo && json.licenseInfo.key === 'other')) {
json.licenseInfo = getLicenseFromPackageJson(packageJson) || json.licenseInfo;
}
Expand All @@ -266,9 +270,6 @@ const createRepoDataWithResponse = (json, monorepo) => {

const lastCommitAt = json.defaultBranchRef.target.history.nodes[0].committedDate;

const hasTopics = json.topics && json.topics.length > 0;
const topics = hasTopics ? json.topics.map(topic => topic.toLowerCase()) : [];

return {
urls: {
repo: json.url,
Expand All @@ -280,7 +281,7 @@ const createRepoDataWithResponse = (json, monorepo) => {
hasWiki: json.hasWikiEnabled,
hasPages: json.deployments.totalCount > 0,
hasDownloads: true,
hasTopics,
hasTopics: json.topics.length > 0,
updatedAt: lastCommitAt,
createdAt: json.createdAt,
pushedAt: lastCommitAt,
Expand All @@ -292,7 +293,7 @@ const createRepoDataWithResponse = (json, monorepo) => {
name: json.name,
fullName: json.nameWithOwner,
description: json.description,
topics,
topics: json.topics,
license: json.licenseInfo,
lastRelease: json.lastRelease,
hasTypes: json.types,
Expand Down

0 comments on commit f54c15c

Please sign in to comment.