From 6c7ec531904adf3c64ed7cba23c58052c0823740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Peignier?= Date: Fri, 9 Sep 2016 18:49:13 -0700 Subject: [PATCH 1/2] Infer reviewers from recents commits authors --- __mocks__/cookieJar.js | 10 - __tests__/data/1.diff | 7 - __tests__/data/23.webhook | 423 -- __tests__/data/3119.diff | 58 - __tests__/data/3229.diff | 366 -- __tests__/data/3238.diff | 99 - ...a5aa76233b3fbe541f3fa1756705900ee919c.diff | 24 - __tests__/data/MapView.js.blame | 3003 --------------- __tests__/github-mention-test.js | 307 +- ...r-Libraries-ReactIOS-NativeMethodsMixin.js | 2232 ----------- ...aster-Libraries-WebSocket-WebSocket.ios.js | 1 - ...aster-Libraries-WebSocket-WebSocketBase.js | 1293 ------- ...s-WebSocket-__mocks__-event-target-shim.js | 431 --- ...ries-WebSocket-__tests__-Websocket-test.js | 1 - ...blame-master-website-server-extractDocs.js | 3419 ----------------- ...b.com-facebook-react-native-pull-3229.diff | 366 -- ...b.com-facebook-react-native-pull-3238.diff | 99 - ...es-bot-testing-blame-master-hello-world.js | 1 - ...hub.com-fbsamples-bot-testing-pull-95.diff | 7 - cookieJar.js | 67 - githubAuthCookies.js | 95 - mention-bot.js | 372 +- package.json | 5 +- server.js | 19 +- 24 files changed, 154 insertions(+), 12551 deletions(-) delete mode 100644 __mocks__/cookieJar.js delete mode 100644 __tests__/data/1.diff delete mode 100644 __tests__/data/23.webhook delete mode 100644 __tests__/data/3119.diff delete mode 100644 __tests__/data/3229.diff delete mode 100644 __tests__/data/3238.diff delete mode 100644 __tests__/data/35fa5aa76233b3fbe541f3fa1756705900ee919c.diff delete mode 100644 __tests__/data/MapView.js.blame delete mode 100644 cache/https---github.com-facebook-react-native-blame-master-Libraries-ReactIOS-NativeMethodsMixin.js delete mode 100644 cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-WebSocket.ios.js delete mode 100644 cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-WebSocketBase.js delete mode 100644 cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-__mocks__-event-target-shim.js delete mode 100644 cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-__tests__-Websocket-test.js delete mode 100644 cache/https---github.com-facebook-react-native-blame-master-website-server-extractDocs.js delete mode 100644 cache/https---github.com-facebook-react-native-pull-3229.diff delete mode 100644 cache/https---github.com-facebook-react-native-pull-3238.diff delete mode 100644 cache/https---github.com-fbsamples-bot-testing-blame-master-hello-world.js delete mode 100644 cache/https---github.com-fbsamples-bot-testing-pull-95.diff delete mode 100644 cookieJar.js delete mode 100644 githubAuthCookies.js diff --git a/__mocks__/cookieJar.js b/__mocks__/cookieJar.js deleted file mode 100644 index 9d72a83..0000000 --- a/__mocks__/cookieJar.js +++ /dev/null @@ -1,10 +0,0 @@ -var cookieJarMock = jest.genMockFromModule('../cookieJar.js'); -cookieJarMock.mockImplementation(() => { - return { - cookies: {}, - get: () => { return {}; }, - parseHeaders: () => { return {}; } - }; -}); - -module.exports = cookieJarMock; diff --git a/__tests__/data/1.diff b/__tests__/data/1.diff deleted file mode 100644 index cf472a1..0000000 --- a/__tests__/data/1.diff +++ /dev/null @@ -1,7 +0,0 @@ -diff --git a/README.md b/README.md -index a176de3..088d8a2 100644 ---- a/README.md -+++ b/README.md -@@ -1 +1,2 @@ - This repository is a testing ground for our various integrations with GitHub. There isn't anything useful to see here! -+2 diff --git a/__tests__/data/23.webhook b/__tests__/data/23.webhook deleted file mode 100644 index 9463100..0000000 --- a/__tests__/data/23.webhook +++ /dev/null @@ -1,423 +0,0 @@ -{ - "action": "opened", - "number": 23, - "pull_request": { - "url": "https://api.github.com/repos/fbsamples/bot-testing/pulls/23", - "id": 50050832, - "html_url": "https://github.com/fbsamples/bot-testing/pull/23", - "diff_url": "https://github.com/fbsamples/bot-testing/pull/23.diff", - "patch_url": "https://github.com/fbsamples/bot-testing/pull/23.patch", - "issue_url": "https://api.github.com/repos/fbsamples/bot-testing/issues/23", - "number": 23, - "state": "open", - "locked": false, - "title": "github-mention-bot testing ground", - "user": { - "login": "vjeux", - "id": 197597, - "avatar_url": "https://avatars.githubusercontent.com/u/197597?v=3", - "gravatar_id": "", - "url": "https://api.github.com/users/vjeux", - "html_url": "https://github.com/vjeux", - "followers_url": "https://api.github.com/users/vjeux/followers", - "following_url": "https://api.github.com/users/vjeux/following{/other_user}", - "gists_url": "https://api.github.com/users/vjeux/gists{/gist_id}", - "starred_url": "https://api.github.com/users/vjeux/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/vjeux/subscriptions", - "organizations_url": "https://api.github.com/users/vjeux/orgs", - "repos_url": "https://api.github.com/users/vjeux/repos", - "events_url": "https://api.github.com/users/vjeux/events{/privacy}", - "received_events_url": "https://api.github.com/users/vjeux/received_events", - "type": "User", - "site_admin": false - }, - "body": "", - "created_at": "2015-11-08T02:09:38Z", - "updated_at": "2015-11-08T02:09:38Z", - "closed_at": null, - "merged_at": null, - "merge_commit_sha": null, - "assignee": null, - "milestone": null, - "commits_url": "https://api.github.com/repos/fbsamples/bot-testing/pulls/23/commits", - "review_comments_url": "https://api.github.com/repos/fbsamples/bot-testing/pulls/23/comments", - "review_comment_url": "https://api.github.com/repos/fbsamples/bot-testing/pulls/comments{/number}", - "comments_url": "https://api.github.com/repos/fbsamples/bot-testing/issues/23/comments", - "statuses_url": "https://api.github.com/repos/fbsamples/bot-testing/statuses/d4bc10d67c55a6753557f0251bd92a2ad0a26997", - "head": { - "label": "fbsamples:vjeux-patch-22-1", - "ref": "vjeux-patch-22-1", - "sha": "d4bc10d67c55a6753557f0251bd92a2ad0a26997", - "user": { - "login": "fbsamples", - "id": 1541324, - "avatar_url": "https://avatars.githubusercontent.com/u/1541324?v=3", - "gravatar_id": "", - "url": "https://api.github.com/users/fbsamples", - "html_url": "https://github.com/fbsamples", - "followers_url": "https://api.github.com/users/fbsamples/followers", - "following_url": "https://api.github.com/users/fbsamples/following{/other_user}", - "gists_url": "https://api.github.com/users/fbsamples/gists{/gist_id}", - "starred_url": "https://api.github.com/users/fbsamples/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/fbsamples/subscriptions", - "organizations_url": "https://api.github.com/users/fbsamples/orgs", - "repos_url": "https://api.github.com/users/fbsamples/repos", - "events_url": "https://api.github.com/users/fbsamples/events{/privacy}", - "received_events_url": "https://api.github.com/users/fbsamples/received_events", - "type": "Organization", - "site_admin": false - }, - "repo": { - "id": 43833565, - "name": "bot-testing", - "full_name": "fbsamples/bot-testing", - "owner": { - "login": "fbsamples", - "id": 1541324, - "avatar_url": "https://avatars.githubusercontent.com/u/1541324?v=3", - "gravatar_id": "", - "url": "https://api.github.com/users/fbsamples", - "html_url": "https://github.com/fbsamples", - "followers_url": "https://api.github.com/users/fbsamples/followers", - "following_url": "https://api.github.com/users/fbsamples/following{/other_user}", - "gists_url": "https://api.github.com/users/fbsamples/gists{/gist_id}", - "starred_url": "https://api.github.com/users/fbsamples/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/fbsamples/subscriptions", - "organizations_url": "https://api.github.com/users/fbsamples/orgs", - "repos_url": "https://api.github.com/users/fbsamples/repos", - "events_url": "https://api.github.com/users/fbsamples/events{/privacy}", - "received_events_url": "https://api.github.com/users/fbsamples/received_events", - "type": "Organization", - "site_admin": false - }, - "private": false, - "html_url": "https://github.com/fbsamples/bot-testing", - "description": "This repository is a testing ground for our various GitHub automated bots. This doesn't contain any useful code.", - "fork": false, - "url": "https://api.github.com/repos/fbsamples/bot-testing", - "forks_url": "https://api.github.com/repos/fbsamples/bot-testing/forks", - "keys_url": "https://api.github.com/repos/fbsamples/bot-testing/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/fbsamples/bot-testing/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/fbsamples/bot-testing/teams", - "hooks_url": "https://api.github.com/repos/fbsamples/bot-testing/hooks", - "issue_events_url": "https://api.github.com/repos/fbsamples/bot-testing/issues/events{/number}", - "events_url": "https://api.github.com/repos/fbsamples/bot-testing/events", - "assignees_url": "https://api.github.com/repos/fbsamples/bot-testing/assignees{/user}", - "branches_url": "https://api.github.com/repos/fbsamples/bot-testing/branches{/branch}", - "tags_url": "https://api.github.com/repos/fbsamples/bot-testing/tags", - "blobs_url": "https://api.github.com/repos/fbsamples/bot-testing/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/fbsamples/bot-testing/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/fbsamples/bot-testing/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/fbsamples/bot-testing/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/fbsamples/bot-testing/statuses/{sha}", - "languages_url": "https://api.github.com/repos/fbsamples/bot-testing/languages", - "stargazers_url": "https://api.github.com/repos/fbsamples/bot-testing/stargazers", - "contributors_url": "https://api.github.com/repos/fbsamples/bot-testing/contributors", - "subscribers_url": "https://api.github.com/repos/fbsamples/bot-testing/subscribers", - "subscription_url": "https://api.github.com/repos/fbsamples/bot-testing/subscription", - "commits_url": "https://api.github.com/repos/fbsamples/bot-testing/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/fbsamples/bot-testing/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/fbsamples/bot-testing/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/fbsamples/bot-testing/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/fbsamples/bot-testing/contents/{+path}", - "compare_url": "https://api.github.com/repos/fbsamples/bot-testing/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/fbsamples/bot-testing/merges", - "archive_url": "https://api.github.com/repos/fbsamples/bot-testing/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/fbsamples/bot-testing/downloads", - "issues_url": "https://api.github.com/repos/fbsamples/bot-testing/issues{/number}", - "pulls_url": "https://api.github.com/repos/fbsamples/bot-testing/pulls{/number}", - "milestones_url": "https://api.github.com/repos/fbsamples/bot-testing/milestones{/number}", - "notifications_url": "https://api.github.com/repos/fbsamples/bot-testing/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/fbsamples/bot-testing/labels{/name}", - "releases_url": "https://api.github.com/repos/fbsamples/bot-testing/releases{/id}", - "created_at": "2015-10-07T17:41:12Z", - "updated_at": "2015-10-07T17:43:58Z", - "pushed_at": "2015-11-08T02:09:36Z", - "git_url": "git://github.com/fbsamples/bot-testing.git", - "ssh_url": "git@github.com:fbsamples/bot-testing.git", - "clone_url": "https://github.com/fbsamples/bot-testing.git", - "svn_url": "https://github.com/fbsamples/bot-testing", - "homepage": null, - "size": 264, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": true, - "has_downloads": true, - "has_wiki": false, - "has_pages": false, - "forks_count": 0, - "mirror_url": null, - "open_issues_count": 8, - "forks": 0, - "open_issues": 8, - "watchers": 0, - "default_branch": "master" - } - }, - "base": { - "label": "fbsamples:master", - "ref": "master", - "sha": "a72662b641dbaa4c12f86fd7c5f3e50148df3d0e", - "user": { - "login": "fbsamples", - "id": 1541324, - "avatar_url": "https://avatars.githubusercontent.com/u/1541324?v=3", - "gravatar_id": "", - "url": "https://api.github.com/users/fbsamples", - "html_url": "https://github.com/fbsamples", - "followers_url": "https://api.github.com/users/fbsamples/followers", - "following_url": "https://api.github.com/users/fbsamples/following{/other_user}", - "gists_url": "https://api.github.com/users/fbsamples/gists{/gist_id}", - "starred_url": "https://api.github.com/users/fbsamples/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/fbsamples/subscriptions", - "organizations_url": "https://api.github.com/users/fbsamples/orgs", - "repos_url": "https://api.github.com/users/fbsamples/repos", - "events_url": "https://api.github.com/users/fbsamples/events{/privacy}", - "received_events_url": "https://api.github.com/users/fbsamples/received_events", - "type": "Organization", - "site_admin": false - }, - "repo": { - "id": 43833565, - "name": "bot-testing", - "full_name": "fbsamples/bot-testing", - "owner": { - "login": "fbsamples", - "id": 1541324, - "avatar_url": "https://avatars.githubusercontent.com/u/1541324?v=3", - "gravatar_id": "", - "url": "https://api.github.com/users/fbsamples", - "html_url": "https://github.com/fbsamples", - "followers_url": "https://api.github.com/users/fbsamples/followers", - "following_url": "https://api.github.com/users/fbsamples/following{/other_user}", - "gists_url": "https://api.github.com/users/fbsamples/gists{/gist_id}", - "starred_url": "https://api.github.com/users/fbsamples/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/fbsamples/subscriptions", - "organizations_url": "https://api.github.com/users/fbsamples/orgs", - "repos_url": "https://api.github.com/users/fbsamples/repos", - "events_url": "https://api.github.com/users/fbsamples/events{/privacy}", - "received_events_url": "https://api.github.com/users/fbsamples/received_events", - "type": "Organization", - "site_admin": false - }, - "private": false, - "html_url": "https://github.com/fbsamples/bot-testing", - "description": "This repository is a testing ground for our various GitHub automated bots. This doesn't contain any useful code.", - "fork": false, - "url": "https://api.github.com/repos/fbsamples/bot-testing", - "forks_url": "https://api.github.com/repos/fbsamples/bot-testing/forks", - "keys_url": "https://api.github.com/repos/fbsamples/bot-testing/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/fbsamples/bot-testing/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/fbsamples/bot-testing/teams", - "hooks_url": "https://api.github.com/repos/fbsamples/bot-testing/hooks", - "issue_events_url": "https://api.github.com/repos/fbsamples/bot-testing/issues/events{/number}", - "events_url": "https://api.github.com/repos/fbsamples/bot-testing/events", - "assignees_url": "https://api.github.com/repos/fbsamples/bot-testing/assignees{/user}", - "branches_url": "https://api.github.com/repos/fbsamples/bot-testing/branches{/branch}", - "tags_url": "https://api.github.com/repos/fbsamples/bot-testing/tags", - "blobs_url": "https://api.github.com/repos/fbsamples/bot-testing/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/fbsamples/bot-testing/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/fbsamples/bot-testing/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/fbsamples/bot-testing/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/fbsamples/bot-testing/statuses/{sha}", - "languages_url": "https://api.github.com/repos/fbsamples/bot-testing/languages", - "stargazers_url": "https://api.github.com/repos/fbsamples/bot-testing/stargazers", - "contributors_url": "https://api.github.com/repos/fbsamples/bot-testing/contributors", - "subscribers_url": "https://api.github.com/repos/fbsamples/bot-testing/subscribers", - "subscription_url": "https://api.github.com/repos/fbsamples/bot-testing/subscription", - "commits_url": "https://api.github.com/repos/fbsamples/bot-testing/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/fbsamples/bot-testing/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/fbsamples/bot-testing/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/fbsamples/bot-testing/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/fbsamples/bot-testing/contents/{+path}", - "compare_url": "https://api.github.com/repos/fbsamples/bot-testing/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/fbsamples/bot-testing/merges", - "archive_url": "https://api.github.com/repos/fbsamples/bot-testing/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/fbsamples/bot-testing/downloads", - "issues_url": "https://api.github.com/repos/fbsamples/bot-testing/issues{/number}", - "pulls_url": "https://api.github.com/repos/fbsamples/bot-testing/pulls{/number}", - "milestones_url": "https://api.github.com/repos/fbsamples/bot-testing/milestones{/number}", - "notifications_url": "https://api.github.com/repos/fbsamples/bot-testing/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/fbsamples/bot-testing/labels{/name}", - "releases_url": "https://api.github.com/repos/fbsamples/bot-testing/releases{/id}", - "created_at": "2015-10-07T17:41:12Z", - "updated_at": "2015-10-07T17:43:58Z", - "pushed_at": "2015-11-08T02:09:36Z", - "git_url": "git://github.com/fbsamples/bot-testing.git", - "ssh_url": "git@github.com:fbsamples/bot-testing.git", - "clone_url": "https://github.com/fbsamples/bot-testing.git", - "svn_url": "https://github.com/fbsamples/bot-testing", - "homepage": null, - "size": 264, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": true, - "has_downloads": true, - "has_wiki": false, - "has_pages": false, - "forks_count": 0, - "mirror_url": null, - "open_issues_count": 8, - "forks": 0, - "open_issues": 8, - "watchers": 0, - "default_branch": "master" - } - }, - "_links": { - "self": { - "href": "https://api.github.com/repos/fbsamples/bot-testing/pulls/23" - }, - "html": { - "href": "https://github.com/fbsamples/bot-testing/pull/23" - }, - "issue": { - "href": "https://api.github.com/repos/fbsamples/bot-testing/issues/23" - }, - "comments": { - "href": "https://api.github.com/repos/fbsamples/bot-testing/issues/23/comments" - }, - "review_comments": { - "href": "https://api.github.com/repos/fbsamples/bot-testing/pulls/23/comments" - }, - "review_comment": { - "href": "https://api.github.com/repos/fbsamples/bot-testing/pulls/comments{/number}" - }, - "commits": { - "href": "https://api.github.com/repos/fbsamples/bot-testing/pulls/23/commits" - }, - "statuses": { - "href": "https://api.github.com/repos/fbsamples/bot-testing/statuses/d4bc10d67c55a6753557f0251bd92a2ad0a26997" - } - }, - "merged": false, - "mergeable": null, - "mergeable_state": "unknown", - "merged_by": null, - "comments": 0, - "review_comments": 0, - "commits": 1, - "additions": 1, - "deletions": 1, - "changed_files": 1 - }, - "repository": { - "id": 43833565, - "name": "bot-testing", - "full_name": "fbsamples/bot-testing", - "owner": { - "login": "fbsamples", - "id": 1541324, - "avatar_url": "https://avatars.githubusercontent.com/u/1541324?v=3", - "gravatar_id": "", - "url": "https://api.github.com/users/fbsamples", - "html_url": "https://github.com/fbsamples", - "followers_url": "https://api.github.com/users/fbsamples/followers", - "following_url": "https://api.github.com/users/fbsamples/following{/other_user}", - "gists_url": "https://api.github.com/users/fbsamples/gists{/gist_id}", - "starred_url": "https://api.github.com/users/fbsamples/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/fbsamples/subscriptions", - "organizations_url": "https://api.github.com/users/fbsamples/orgs", - "repos_url": "https://api.github.com/users/fbsamples/repos", - "events_url": "https://api.github.com/users/fbsamples/events{/privacy}", - "received_events_url": "https://api.github.com/users/fbsamples/received_events", - "type": "Organization", - "site_admin": false - }, - "private": false, - "html_url": "https://github.com/fbsamples/bot-testing", - "description": "This repository is a testing ground for our various GitHub automated bots. This doesn't contain any useful code.", - "fork": false, - "url": "https://api.github.com/repos/fbsamples/bot-testing", - "forks_url": "https://api.github.com/repos/fbsamples/bot-testing/forks", - "keys_url": "https://api.github.com/repos/fbsamples/bot-testing/keys{/key_id}", - "collaborators_url": "https://api.github.com/repos/fbsamples/bot-testing/collaborators{/collaborator}", - "teams_url": "https://api.github.com/repos/fbsamples/bot-testing/teams", - "hooks_url": "https://api.github.com/repos/fbsamples/bot-testing/hooks", - "issue_events_url": "https://api.github.com/repos/fbsamples/bot-testing/issues/events{/number}", - "events_url": "https://api.github.com/repos/fbsamples/bot-testing/events", - "assignees_url": "https://api.github.com/repos/fbsamples/bot-testing/assignees{/user}", - "branches_url": "https://api.github.com/repos/fbsamples/bot-testing/branches{/branch}", - "tags_url": "https://api.github.com/repos/fbsamples/bot-testing/tags", - "blobs_url": "https://api.github.com/repos/fbsamples/bot-testing/git/blobs{/sha}", - "git_tags_url": "https://api.github.com/repos/fbsamples/bot-testing/git/tags{/sha}", - "git_refs_url": "https://api.github.com/repos/fbsamples/bot-testing/git/refs{/sha}", - "trees_url": "https://api.github.com/repos/fbsamples/bot-testing/git/trees{/sha}", - "statuses_url": "https://api.github.com/repos/fbsamples/bot-testing/statuses/{sha}", - "languages_url": "https://api.github.com/repos/fbsamples/bot-testing/languages", - "stargazers_url": "https://api.github.com/repos/fbsamples/bot-testing/stargazers", - "contributors_url": "https://api.github.com/repos/fbsamples/bot-testing/contributors", - "subscribers_url": "https://api.github.com/repos/fbsamples/bot-testing/subscribers", - "subscription_url": "https://api.github.com/repos/fbsamples/bot-testing/subscription", - "commits_url": "https://api.github.com/repos/fbsamples/bot-testing/commits{/sha}", - "git_commits_url": "https://api.github.com/repos/fbsamples/bot-testing/git/commits{/sha}", - "comments_url": "https://api.github.com/repos/fbsamples/bot-testing/comments{/number}", - "issue_comment_url": "https://api.github.com/repos/fbsamples/bot-testing/issues/comments{/number}", - "contents_url": "https://api.github.com/repos/fbsamples/bot-testing/contents/{+path}", - "compare_url": "https://api.github.com/repos/fbsamples/bot-testing/compare/{base}...{head}", - "merges_url": "https://api.github.com/repos/fbsamples/bot-testing/merges", - "archive_url": "https://api.github.com/repos/fbsamples/bot-testing/{archive_format}{/ref}", - "downloads_url": "https://api.github.com/repos/fbsamples/bot-testing/downloads", - "issues_url": "https://api.github.com/repos/fbsamples/bot-testing/issues{/number}", - "pulls_url": "https://api.github.com/repos/fbsamples/bot-testing/pulls{/number}", - "milestones_url": "https://api.github.com/repos/fbsamples/bot-testing/milestones{/number}", - "notifications_url": "https://api.github.com/repos/fbsamples/bot-testing/notifications{?since,all,participating}", - "labels_url": "https://api.github.com/repos/fbsamples/bot-testing/labels{/name}", - "releases_url": "https://api.github.com/repos/fbsamples/bot-testing/releases{/id}", - "created_at": "2015-10-07T17:41:12Z", - "updated_at": "2015-10-07T17:43:58Z", - "pushed_at": "2015-11-08T02:09:36Z", - "git_url": "git://github.com/fbsamples/bot-testing.git", - "ssh_url": "git@github.com:fbsamples/bot-testing.git", - "clone_url": "https://github.com/fbsamples/bot-testing.git", - "svn_url": "https://github.com/fbsamples/bot-testing", - "homepage": null, - "size": 264, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": true, - "has_downloads": true, - "has_wiki": false, - "has_pages": false, - "forks_count": 0, - "mirror_url": null, - "open_issues_count": 8, - "forks": 0, - "open_issues": 8, - "watchers": 0, - "default_branch": "master" - }, - "organization": { - "login": "fbsamples", - "id": 1541324, - "url": "https://api.github.com/orgs/fbsamples", - "repos_url": "https://api.github.com/orgs/fbsamples/repos", - "events_url": "https://api.github.com/orgs/fbsamples/events", - "members_url": "https://api.github.com/orgs/fbsamples/members{/member}", - "public_members_url": "https://api.github.com/orgs/fbsamples/public_members{/member}", - "avatar_url": "https://avatars.githubusercontent.com/u/1541324?v=3", - "description": "" - }, - "sender": { - "login": "vjeux", - "id": 197597, - "avatar_url": "https://avatars.githubusercontent.com/u/197597?v=3", - "gravatar_id": "", - "url": "https://api.github.com/users/vjeux", - "html_url": "https://github.com/vjeux", - "followers_url": "https://api.github.com/users/vjeux/followers", - "following_url": "https://api.github.com/users/vjeux/following{/other_user}", - "gists_url": "https://api.github.com/users/vjeux/gists{/gist_id}", - "starred_url": "https://api.github.com/users/vjeux/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/vjeux/subscriptions", - "organizations_url": "https://api.github.com/users/vjeux/orgs", - "repos_url": "https://api.github.com/users/vjeux/repos", - "events_url": "https://api.github.com/users/vjeux/events{/privacy}", - "received_events_url": "https://api.github.com/users/vjeux/received_events", - "type": "User", - "site_admin": false - } -} diff --git a/__tests__/data/3119.diff b/__tests__/data/3119.diff deleted file mode 100644 index 1d19db9..0000000 --- a/__tests__/data/3119.diff +++ /dev/null @@ -1,58 +0,0 @@ -diff --git a/Libraries/Components/MapView/MapView.js b/Libraries/Components/MapView/MapView.js -index ac715e8..7c2bb5f 100644 ---- a/Libraries/Components/MapView/MapView.js -+++ b/Libraries/Components/MapView/MapView.js -@@ -71,7 +71,7 @@ var MapView = React.createClass({ - style: View.propTypes.style, - - /** -- * If `true` the app will ask for the user's location and focus on it. -+ * If `true` the app will ask for the user's location and display it. - * Default value is `false`. - * - * **NOTE**: You need to add NSLocationWhenInUseUsageDescription key in -@@ -81,6 +81,14 @@ var MapView = React.createClass({ - showsUserLocation: React.PropTypes.bool, - - /** -+ * If `true` the app will and focus on the user's location -+ * Default value is `false`. -+ * **NOTE**: You need to set to `true` showsUserLocation -+ * -+ */ -+ followUserLocation: React.PropTypes.bool, -+ -+ /** - * If `false` the user won't be able to pinch/zoom the map. - * Default value is `true`. - */ -diff --git a/React/Views/RCTMap.m b/React/Views/RCTMap.m -index 1620895..c25094e 100644 ---- a/React/Views/RCTMap.m -+++ b/React/Views/RCTMap.m -@@ -87,9 +87,11 @@ - (void)setShowsUserLocation:(BOOL)showsUserLocation - } - super.showsUserLocation = showsUserLocation; - -- // If it needs to show user location, force map view centered -+ // If it needs to follow user location, force map view centered - // on user's current location on user location updates -- _followUserLocation = showsUserLocation; -+ if(self.followUserLocation){ -+ _followUserLocation = showsUserLocation; -+ } - } - } - -diff --git a/React/Views/RCTMapManager.m b/React/Views/RCTMapManager.m -index f4ee06f..6566dc4 100644 ---- a/React/Views/RCTMapManager.m -+++ b/React/Views/RCTMapManager.m -@@ -37,6 +37,7 @@ - (UIView *)view - } - - RCT_EXPORT_VIEW_PROPERTY(showsUserLocation, BOOL) -+RCT_EXPORT_VIEW_PROPERTY(followUserLocation, BOOL) - RCT_EXPORT_VIEW_PROPERTY(zoomEnabled, BOOL) - RCT_EXPORT_VIEW_PROPERTY(rotateEnabled, BOOL) - RCT_EXPORT_VIEW_PROPERTY(pitchEnabled, BOOL) diff --git a/__tests__/data/3229.diff b/__tests__/data/3229.diff deleted file mode 100644 index fafed78..0000000 --- a/__tests__/data/3229.diff +++ /dev/null @@ -1,366 +0,0 @@ -diff --git a/Libraries/WebSocket/WebSocket.ios.js b/Libraries/WebSocket/WebSocket.ios.js -index c2318b4..c09b931 100644 ---- a/Libraries/WebSocket/WebSocket.ios.js -+++ b/Libraries/WebSocket/WebSocket.ios.js -@@ -16,16 +16,12 @@ var RCTWebSocketManager = require('NativeModules').WebSocketManager; - - var WebSocketBase = require('WebSocketBase'); - --class Event { -- constructor(type) { -- this.type = type.toString(); -- } --} -- --class MessageEvent extends Event { -+class WebsocketEvent { - constructor(type, eventInitDict) { -- super(type); -- Object.assign(this, eventInitDict); -+ this.type = type.toString(); -+ if (typeof eventInitDict === 'object') { -+ Object.assign(this, eventInitDict); -+ } - } - } - -@@ -67,56 +63,60 @@ class WebSocket extends WebSocketBase { - this._subs = [ - RCTDeviceEventEmitter.addListener( - 'websocketMessage', -- function(ev) { -+ ev => { - if (ev.id !== id) { - return; - } -- var event = new MessageEvent('message', { -- data: ev.data -+ var event = new WebsocketEvent('message', { -+ data: ev.data, - }); -- this.onmessage && this.onmessage(event); - this.dispatchEvent(event); -- }.bind(this) -+ }, - ), - RCTDeviceEventEmitter.addListener( - 'websocketOpen', -- function(ev) { -+ ev => { - if (ev.id !== id) { - return; - } - this.readyState = this.OPEN; -- var event = new Event('open'); -- this.onopen && this.onopen(event); -+ var event = new WebsocketEvent('open'); - this.dispatchEvent(event); -- }.bind(this) -+ } - ), - RCTDeviceEventEmitter.addListener( - 'websocketClosed', -- function(ev) { -+ (ev) => { - if (ev.id !== id) { - return; - } - this.readyState = this.CLOSED; -- var event = new Event('close'); -- this.onclose && this.onclose(event); -+ var event = new WebsocketEvent('close'); - this.dispatchEvent(event); -+ - this._unregisterEvents(); - RCTWebSocketManager.close(id); -- }.bind(this) -+ } - ), - RCTDeviceEventEmitter.addListener( - 'websocketFailed', -- function(ev) { -+ (ev) => { - if (ev.id !== id) { - return; - } -- var event = new Event('error'); -- event.message = ev.message; -- this.onerror && this.onerror(event); -- this.dispatchEvent(event); -+ this.readyState = this.CLOSED; -+ -+ var closeEvent = new WebsocketEvent('close'); -+ this.dispatchEvent(closeEvent); -+ -+ var errorEvent = new WebsocketEvent('error', { -+ message: ev.message, -+ }); -+ this.dispatchEvent(errorEvent); -+ - this._unregisterEvents(); - RCTWebSocketManager.close(id); -- }.bind(this) -+ } - ) - ]; - } -diff --git a/Libraries/WebSocket/WebSocketBase.js b/Libraries/WebSocket/WebSocketBase.js -index a4cca41..f6cff0e 100644 ---- a/Libraries/WebSocket/WebSocketBase.js -+++ b/Libraries/WebSocket/WebSocketBase.js -@@ -16,17 +16,12 @@ var EventTarget = require('event-target-shim'); - /** - * Shared base for platform-specific WebSocket implementations. - */ --class WebSocketBase extends EventTarget { -+class WebSocketBase extends EventTarget('close', 'error', 'message', 'open') { - CONNECTING: number; - OPEN: number; - CLOSING: number; - CLOSED: number; - -- onclose: ?Function; -- onerror: ?Function; -- onmessage: ?Function; -- onopen: ?Function; -- - binaryType: ?string; - bufferedAmount: number; - extension: ?string; -@@ -41,6 +36,8 @@ class WebSocketBase extends EventTarget { - this.CLOSING = 2; - this.CLOSED = 3; - -+ this.readyState = this.CONNECTING; -+ - if (!protocols) { - protocols = []; - } -diff --git a/Libraries/WebSocket/__mocks__/event-target-shim.js b/Libraries/WebSocket/__mocks__/event-target-shim.js -deleted file mode 100644 -index 3b566fc..0000000 ---- a/Libraries/WebSocket/__mocks__/event-target-shim.js -+++ /dev/null -@@ -1,9 +0,0 @@ --// Jest fatals for the following statement (minimal repro case) --// --// exports.something = Symbol; --// --// Until it is fixed, mocking the entire node module makes the --// problem go away. -- --'use strict'; --module.exports = function() {}; -diff --git a/Libraries/WebSocket/__tests__/Websocket-test.js b/Libraries/WebSocket/__tests__/Websocket-test.js -new file mode 100644 -index 0000000..d062ed9 ---- /dev/null -+++ b/Libraries/WebSocket/__tests__/Websocket-test.js -@@ -0,0 +1,207 @@ -+/** -+ * Copyright (c) 2015-present, Facebook, Inc. -+ * All rights reserved. -+ * -+ * This source code is licensed under the BSD-style license found in the -+ * LICENSE file in the root directory of this source tree. An additional grant -+ * of patent rights can be found in the PATENTS file in the same directory. -+ */ -+'use strict'; -+ -+jest -+ .autoMockOff() -+ .mock('ErrorUtils') -+ .setMock('NativeModules', { -+ WebSocketManager: { -+ connect: jest.genMockFunction(), -+ close: jest.genMockFunction(), -+ send: jest.genMockFunction(), -+ }, -+ }); -+ -+var readyStates = { -+ CONNECTING: 0, -+ OPEN: 1, -+ CLOSING: 2, -+ CLOSED: 3, -+}; -+ -+var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -+var RCTWebSocketManager = require('NativeModules').WebSocketManager; -+ -+var WebSocket = require('WebSocket'); -+ -+// Small utils to keep it DRY -+var simulateEvent = (ws, event, data = {}) => { -+ RCTDeviceEventEmitter.emit(event, {id: ws._socketId, ...data}); -+}; -+var expectOneCall = fn => expect(fn.mock.calls.length).toBe(1); -+var getSocket = () => new WebSocket('ws://echo.websocket.org'); -+ -+describe('WebSockets', () => { -+ beforeEach(() => { -+ // Reset RCTWebSocketManager calls -+ Object.assign(RCTWebSocketManager, { -+ connect: jest.genMockFunction(), -+ close: jest.genMockFunction(), -+ send: jest.genMockFunction(), -+ }); -+ }); -+ -+ it('should have readyState CONNECTING initialy', () => { -+ var ws = getSocket(); -+ expect(ws.readyState).toBe(readyStates.CONNECTING); -+ }); -+ -+ // Open event -+ it('Should call native connect when connecting', () => { -+ var ws = getSocket(); -+ ws.onopen = jest.genMockFunction(); -+ -+ expectOneCall(RCTWebSocketManager.connect); -+ }); -+ -+ it('should have readyState OPEN when connected', () => { -+ var ws = getSocket(); -+ simulateEvent(ws, 'websocketOpen'); -+ expect(ws.readyState).toBe(readyStates.OPEN); -+ }); -+ -+ it('should call onopen when connected', () => { -+ var ws = getSocket(); -+ ws.onopen = jest.genMockFunction(); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ -+ expectOneCall(ws.onopen); -+ }); -+ -+ it('should trigger listener when connected', () => { -+ var ws = getSocket(); -+ var listener = jest.genMockFunction(); -+ ws.addEventListener('open', listener); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ -+ expectOneCall(listener); -+ }); -+ -+ // Sending message -+ it('should call native send when sending a message', () => { -+ var ws = getSocket(); -+ simulateEvent(ws, 'websocketOpen'); -+ var message = 'Hello websocket!'; -+ -+ ws.send(message); -+ -+ expectOneCall(RCTWebSocketManager.send); -+ expect(RCTWebSocketManager.send.mock.calls[0]) -+ .toEqual([message, ws._socketId]); -+ }); -+ -+ it('should call onmessage when receiving a message', () => { -+ var ws = getSocket(); -+ var message = 'Hello listener!'; -+ ws.onmessage = jest.genMockFunction(); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketMessage', {data: message}); -+ -+ expectOneCall(ws.onmessage); -+ expect(ws.onmessage.mock.calls[0][0].data).toBe(message); -+ }); -+ -+ it('should trigger listeners when recieving a message', () => { -+ var ws = getSocket(); -+ var message = 'Hello listener!'; -+ var listener = jest.genMockFunction(); -+ ws.addEventListener('message', listener); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketMessage', {data: message}); -+ -+ expectOneCall(listener); -+ expect(listener.mock.calls[0][0].data).toBe(message); -+ }); -+ -+ // Close event -+ it('should have readyState CLOSED when closed', () => { -+ var ws = getSocket(); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketClosed'); -+ -+ expect(ws.readyState).toBe(readyStates.CLOSED); -+ }); -+ -+ it('should call onclose when closed', () => { -+ var ws = getSocket(); -+ ws.onclose = jest.genMockFunction(); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketClosed'); -+ -+ expectOneCall(ws.onclose); -+ }); -+ -+ it('should trigger listeners when closed', () => { -+ var ws = getSocket(); -+ var listener = jest.genMockFunction(); -+ ws.addEventListener('close', listener); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketClosed'); -+ -+ expectOneCall(listener); -+ }); -+ -+ it('should call native close when closed', () => { -+ var ws = getSocket(); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketClosed'); -+ -+ expectOneCall(RCTWebSocketManager.close); -+ expect(RCTWebSocketManager.close.mock.calls[0]).toEqual([ws._socketId]); -+ }); -+ -+ // Fail event -+ it('should have readyState CLOSED when failed', () => { -+ var ws = getSocket(); -+ simulateEvent(ws, 'websocketFailed'); -+ expect(ws.readyState).toBe(readyStates.CLOSED); -+ }); -+ -+ it('should call native close when failed', () => { -+ var ws = getSocket(); -+ -+ simulateEvent(ws, 'websocketFailed'); -+ -+ expectOneCall(RCTWebSocketManager.close); -+ expect(RCTWebSocketManager.close.mock.calls[0]).toEqual([ws._socketId]); -+ }); -+ -+ it('should call onerror and onclose when failed', () => { -+ var ws = getSocket(); -+ ws.onclose = jest.genMockFunction(); -+ ws.onerror = jest.genMockFunction(); -+ -+ simulateEvent(ws, 'websocketFailed'); -+ -+ expectOneCall(ws.onclose); -+ expectOneCall(ws.onerror); -+ }); -+ -+ it('should call onerror and onclose when failed', () => { -+ var ws = getSocket(); -+ var onclose = jest.genMockFunction(); -+ var onerror = jest.genMockFunction(); -+ ws.addEventListener('close', onclose); -+ ws.addEventListener('error', onerror); -+ -+ simulateEvent(ws, 'websocketFailed'); -+ -+ expectOneCall(onclose); -+ expectOneCall(onerror); -+ }); -+}); diff --git a/__tests__/data/3238.diff b/__tests__/data/3238.diff deleted file mode 100644 index 8b0507c..0000000 --- a/__tests__/data/3238.diff +++ /dev/null @@ -1,99 +0,0 @@ -diff --git a/Libraries/ReactIOS/NativeMethodsMixin.js b/Libraries/ReactIOS/NativeMethodsMixin.js -index afc79f7..59de859 100644 ---- a/Libraries/ReactIOS/NativeMethodsMixin.js -+++ b/Libraries/ReactIOS/NativeMethodsMixin.js -@@ -37,8 +37,38 @@ type MeasureLayoutOnSuccessCallback = ( - height: number - ) => void - -+/** -+ * NativeMethodsMixin provides methods that bypass the React rendering process -+ * and are passed through directly to the underlying native component. This -+ * allows side effects to be performed and actions to be taken that don't fit -+ * into the React model directly. -+ * -+ * The methods described here are available on most of the default components -+ * provided by React Native, and components that extend them. Note however that -+ * they are *not* available on composite components that aren't directly backed -+ * by a native view. This will generally include most components that you define -+ * in your own app. For more information, see [Direct -+ * Manipulation](/react-native/docs/direct-manipulation.html). -+ */ - - var NativeMethodsMixin = { -+ /** -+ * Determines the location on screen, width, and height of the given view and -+ * returns the values via an async callback. If successful, the callback will -+ * be called with the following arguments: -+ * -+ * - x -+ * - y -+ * - width -+ * - height -+ * - pageX -+ * - pageY -+ * -+ * Note that these measurements are currently not available until after the -+ * first rendering has been completed. If you need the measurements as soon as -+ * possible, consider instead using the [`onLayout` -+ * prop](/react-native/docs/view.html#onlayout). -+ */ - measure: function(callback: MeasureOnSuccessCallback) { - RCTUIManager.measure( - findNodeHandle(this), -@@ -46,6 +76,11 @@ var NativeMethodsMixin = { - ); - }, - -+ /** -+ * Like [`measure()`](#measure), but measures the view specified by tag -+ * relative to the given `relativeToNativeNode`. This means that the returned -+ * x, y are relative to the origin x, y of the ancestor view. -+ */ - measureLayout: function( - relativeToNativeNode: number, - onSuccess: MeasureLayoutOnSuccessCallback, -@@ -60,9 +95,10 @@ var NativeMethodsMixin = { - }, - - /** -- * This function sends props straight to native. They will not participate -- * in future diff process, this means that if you do not include them in the -- * next render, they will remain active. -+ * This function sends props straight to native. They will not participate in -+ * future diff process -- this means that if you do not include them in the -+ * next render, they will remain active (see [Direct -+ * Manipulation](/react-native/docs/direct-manipulation.html)). - */ - setNativeProps: function(nativeProps: Object) { - // nativeProps contains a style attribute that's going to be flattened -@@ -114,10 +150,17 @@ var NativeMethodsMixin = { - ); - }, - -+ /** -+ * Requests focus for the given input or view. The exact behavior triggered -+ * will depend on the platform and type of view. -+ */ - focus: function() { - TextInputState.focusTextInput(findNodeHandle(this)); - }, - -+ /** -+ * Blurs the given input or view. This is the opposite of `focus()`. -+ */ - blur: function() { - TextInputState.blurTextInput(findNodeHandle(this)); - } -diff --git a/website/server/extractDocs.js b/website/server/extractDocs.js -index 867fdfa..7ce11d5 100644 ---- a/website/server/extractDocs.js -+++ b/website/server/extractDocs.js -@@ -228,6 +228,7 @@ var apis = [ - '../Libraries/Interaction/InteractionManager.js', - '../Libraries/LayoutAnimation/LayoutAnimation.js', - '../Libraries/LinkingIOS/LinkingIOS.js', -+ '../Libraries/ReactIOS/NativeMethodsMixin.js', - '../Libraries/Network/NetInfo.js', - '../Libraries/vendor/react/browser/eventPlugins/PanResponder.js', - '../Libraries/Utilities/PixelRatio.js', diff --git a/__tests__/data/35fa5aa76233b3fbe541f3fa1756705900ee919c.diff b/__tests__/data/35fa5aa76233b3fbe541f3fa1756705900ee919c.diff deleted file mode 100644 index e54ea63..0000000 --- a/__tests__/data/35fa5aa76233b3fbe541f3fa1756705900ee919c.diff +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/website/src/react-native/img/TutorialFinal.png b/website/src/react-native/img/TutorialFinal.png -index 987ad30..2f05b13 100644 -Binary files a/website/src/react-native/img/TutorialFinal.png and b/website/src/react-native/img/TutorialFinal.png differ -diff --git a/website/src/react-native/img/TutorialMock.png b/website/src/react-native/img/TutorialMock.png -index 3ab8fec..6a267d0 100644 -Binary files a/website/src/react-native/img/TutorialMock.png and b/website/src/react-native/img/TutorialMock.png differ -diff --git a/website/src/react-native/img/TutorialSingleFetched.png b/website/src/react-native/img/TutorialSingleFetched.png -index bb8e021..914cb88 100644 -Binary files a/website/src/react-native/img/TutorialSingleFetched.png and b/website/src/react-native/img/TutorialSingleFetched.png differ -diff --git a/website/src/react-native/img/TutorialStyledMock.png b/website/src/react-native/img/TutorialStyledMock.png -index 1f54d3c..48fb1c5 100644 -Binary files a/website/src/react-native/img/TutorialStyledMock.png and b/website/src/react-native/img/TutorialStyledMock.png differ -diff --git a/website/src/react-native/img/chrome_breakpoint.png b/website/src/react-native/img/chrome_breakpoint.png -index 4b5f287..d37c953 100644 -Binary files a/website/src/react-native/img/chrome_breakpoint.png and b/website/src/react-native/img/chrome_breakpoint.png differ -diff --git a/website/src/react-native/img/favicon.png b/website/src/react-native/img/favicon.png -index 6670ea2..22c120d 100644 -Binary files a/website/src/react-native/img/favicon.png and b/website/src/react-native/img/favicon.png differ -diff --git a/website/src/react-native/img/header_logo.png b/website/src/react-native/img/header_logo.png -index d0a4b1a..8858ffa 100644 -Binary files a/website/src/react-native/img/header_logo.png and b/website/src/react-native/img/header_logo.png differ -diff --git a/website/src/react-native/img/opengraph.png b/website/src/react-native/img/opengraph.png -index 56edaa3..0e9e1d3 100644 -Binary files a/website/src/react-native/img/opengraph.png and b/website/src/react-native/img/opengraph.png differ diff --git a/__tests__/data/MapView.js.blame b/__tests__/data/MapView.js.blame deleted file mode 100644 index 4645ed5..0000000 --- a/__tests__/data/MapView.js.blame +++ /dev/null @@ -1,3003 +0,0 @@ - - - - - - - - - - - - - - react-native/Libraries/Components/MapView/MapView.js at master · facebook/react-native - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to content - - - - - - - - - - - - - - -
- -
-
- - -
-
-
- -
- -
- -
    - -
  • -
    - -
    - - - - Watch - - - - -
    - -
    -
    -
    -
  • - -
  • - -
    - -
    - - -
    -
    - - -
    - -
  • - -
  • - - - Fork - - - - - -
  • -
- -

- - /react-native - - - - - -

- -
-
-
- -
-
-
- - - -
- -
-

HTTPS clone URL

-
- - - - -
-
- - -
-

SSH clone URL

-
- - - - -
-
- - -
-

Subversion checkout URL

-
- - - - -
-
- - - -
You can clone with -
,
, or
. - - - -
- - - Clone in Desktop - - - - - Download ZIP - -
-
-
- - - - - - -
- Newer -
    -
  1. -
  2. -
  3. -
  4. -
  5. -
  6. -
  7. -
  8. -
  9. -
  10. -
- Older -
- -
-
-
- -
- - - -
- - 100644 - - 286 lines (245 sloc) - - 8.08 KB -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
1/**
- e1ef032 - @vjeux - [ReactNative] Expanded license on js files -
- vjeux authored - -
-
2 * Copyright (c) 2015-present, Facebook, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
8 *
9 * @providesModule MapView
- 95deed5 - @bhosmer - flowified Libraries from Avik -
- bhosmer authored - -
-
10 * @flow
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
11 */
12'use strict';
13
14var EdgeInsetsPropType = require('EdgeInsetsPropType');
15var NativeMethodsMixin = require('NativeMethodsMixin');
- 58a550f - @sahrens - [ReactNative] use requireNativeComponent to clean up a bunch of boile… -
- sahrens authored - -
-
16var Platform = require('Platform');
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
17var React = require('React');
- ff00e14 - @kmagiera - [ReactNative] Rename ReactIOS JS module (and relatives) to ReactNative. -
- kmagiera authored - -
-
18var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
19var View = require('View');
20
- ff00e14 - @kmagiera - [ReactNative] Rename ReactIOS JS module (and relatives) to ReactNative. -
- kmagiera authored - -
-
21var createReactNativeComponentClass = require('createReactNativeComponentClass');
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
22var deepDiffer = require('deepDiffer');
23var insetsDiffer = require('insetsDiffer');
24var merge = require('merge');
- 58a550f - @sahrens - [ReactNative] use requireNativeComponent to clean up a bunch of boile… -
- sahrens authored - -
-
25var requireNativeComponent = require('requireNativeComponent');
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
26
- 95deed5 - @bhosmer - flowified Libraries from Avik -
- bhosmer authored - -
-
27type Event = Object;
- a0db658 - @philikon - [MAdMan] flowify AdsManagerGeoUtils -
- philikon authored - -
-
28type MapRegion = {
29 latitude: number;
30 longitude: number;
31 latitudeDelta: number;
32 longitudeDelta: number;
33};
- 95deed5 - @bhosmer - flowified Libraries from Avik -
- bhosmer authored - -
-
34
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
35var MapView = React.createClass({
36 mixins: [NativeMethodsMixin],
37
- 99bc08c - @dvcrn - [MapView] Support for annotation callouts, annotation press, callout … -
- dvcrn authored - -
-
38 checkAnnotationIds: function (annotations: Array<Object>) {
39
40 var newAnnotations = annotations.map(function (annotation) {
41 if (!annotation.id) {
42 // TODO: add a base64 (or similar) encoder here
43 annotation.id = encodeURIComponent(JSON.stringify(annotation));
44 }
45
46 return annotation;
47 });
48
49 this.setState({
50 annotations: newAnnotations
51 });
52 },
53
54 componentWillMount: function() {
55 if (this.props.annotations) {
56 this.checkAnnotationIds(this.props.annotations);
57 }
58 },
59
60 componentWillReceiveProps: function(nextProps: Object) {
61 if (nextProps.annotations) {
62 this.checkAnnotationIds(nextProps.annotations);
63 }
64 },
65
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
66 propTypes: {
67 /**
68 * Used to style and layout the `MapView`. See `StyleSheet.js` and
69 * `ViewStylePropTypes.js` for more info.
70 */
71 style: View.propTypes.style,
72
73 /**
74 * If `true` the app will ask for the user's location and focus on it.
75 * Default value is `false`.
76 *
77 * **NOTE**: You need to add NSLocationWhenInUseUsageDescription key in
78 * Info.plist to enable geolocation, otherwise it is going
79 * to *fail silently*!
80 */
81 showsUserLocation: React.PropTypes.bool,
82
83 /**
84 * If `false` the user won't be able to pinch/zoom the map.
- 972ae4c - @ultralame - fix minor grammar and typo errors in comments -
- ultralame authored - -
-
85 * Default value is `true`.
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
86 */
87 zoomEnabled: React.PropTypes.bool,
88
89 /**
90 * When this property is set to `true` and a valid camera is associated with
91 * the map, the camera’s heading angle is used to rotate the plane of the
92 * map around its center point. When this property is set to `false`, the
93 * camera’s heading angle is ignored and the map is always oriented so
94 * that true north is situated at the top of the map view
95 */
96 rotateEnabled: React.PropTypes.bool,
97
98 /**
99 * When this property is set to `true` and a valid camera is associated
100 * with the map, the camera’s pitch angle is used to tilt the plane
101 * of the map. When this property is set to `false`, the camera’s pitch
102 * angle is ignored and the map is always displayed as if the user
103 * is looking straight down onto it.
104 */
105 pitchEnabled: React.PropTypes.bool,
106
107 /**
108 * If `false` the user won't be able to change the map region being displayed.
109 * Default value is `true`.
110 */
111 scrollEnabled: React.PropTypes.bool,
112
113 /**
- 04b3b52 - - Add map type property (standard, satellite, hybrid) to MapView. -
- Adam Krell authored - -
-
114 * The map type to be displayed.
- 99bc08c - @dvcrn - [MapView] Support for annotation callouts, annotation press, callout … -
- dvcrn authored - -
-
115 *
- 04b3b52 - - Add map type property (standard, satellite, hybrid) to MapView. -
- Adam Krell authored - -
-
116 * - standard: standard road map (default)
117 * - satellite: satellite view
118 * - hybrid: satellite view with roads and points of interest overlayed
119 */
120 mapType: React.PropTypes.oneOf([
- 99bc08c - @dvcrn - [MapView] Support for annotation callouts, annotation press, callout … -
- dvcrn authored - -
-
121 'standard',
122 'satellite',
- 04b3b52 - - Add map type property (standard, satellite, hybrid) to MapView. -
- Adam Krell authored - -
-
123 'hybrid',
124 ]),
125
126 /**
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
127 * The region to be displayed by the map.
128 *
129 * The region is defined by the center coordinates and the span of
130 * coordinates to display.
131 */
132 region: React.PropTypes.shape({
133 /**
134 * Coordinates for the center of the map.
135 */
136 latitude: React.PropTypes.number.isRequired,
137 longitude: React.PropTypes.number.isRequired,
138
139 /**
140 * Distance between the minimun and the maximum latitude/longitude
141 * to be displayed.
142 */
143 latitudeDelta: React.PropTypes.number.isRequired,
144 longitudeDelta: React.PropTypes.number.isRequired,
145 }),
146
147 /**
- 7a68691 - @ginamdar - MapView to support MKPointAnnotation using new attribute annotate in … -
- ginamdar authored - -
-
148 * Map annotations with title/subtitle.
149 */
150 annotations: React.PropTypes.arrayOf(React.PropTypes.shape({
151 /**
152 * The location of the annotation.
153 */
154 latitude: React.PropTypes.number.isRequired,
155 longitude: React.PropTypes.number.isRequired,
156
157 /**
- 99bc08c - @dvcrn - [MapView] Support for annotation callouts, annotation press, callout … -
- dvcrn authored - -
-
158 * Whether the pin drop should be animated or not
159 */
160 animateDrop: React.PropTypes.bool,
161
162 /**
- 7a68691 - @ginamdar - MapView to support MKPointAnnotation using new attribute annotate in … -
- ginamdar authored - -
-
163 * Annotation title/subtile.
164 */
165 title: React.PropTypes.string,
166 subtitle: React.PropTypes.string,
- 99bc08c - @dvcrn - [MapView] Support for annotation callouts, annotation press, callout … -
- dvcrn authored - -
-
167
168 /**
169 * Whether the Annotation has callout buttons.
170 */
171 hasLeftCallout: React.PropTypes.bool,
172 hasRightCallout: React.PropTypes.bool,
173
174 /**
175 * Event handlers for callout buttons.
176 */
177 onLeftCalloutPress: React.PropTypes.func,
178 onRightCalloutPress: React.PropTypes.func,
179
180 /**
181 * annotation id
182 */
183 id: React.PropTypes.string
184
- 7a68691 - @ginamdar - MapView to support MKPointAnnotation using new attribute annotate in … -
- ginamdar authored - -
-
185 })),
186
187 /**
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
188 * Maximum size of area that can be displayed.
189 */
190 maxDelta: React.PropTypes.number,
191
192 /**
193 * Minimum size of area that can be displayed.
194 */
195 minDelta: React.PropTypes.number,
196
197 /**
198 * Insets for the map's legal label, originally at bottom left of the map.
199 * See `EdgeInsetsPropType.js` for more information.
200 */
201 legalLabelInsets: EdgeInsetsPropType,
202
203 /**
204 * Callback that is called continuously when the user is dragging the map.
205 */
206 onRegionChange: React.PropTypes.func,
207
208 /**
209 * Callback that is called once, when the user is done moving the map.
210 */
211 onRegionChangeComplete: React.PropTypes.func,
- 99bc08c - @dvcrn - [MapView] Support for annotation callouts, annotation press, callout … -
- dvcrn authored - -
-
212
213 /**
- 972ae4c - @ultralame - fix minor grammar and typo errors in comments -
- ultralame authored - -
-
214 * Callback that is called once, when the user taps an annotation.
- 99bc08c - @dvcrn - [MapView] Support for annotation callouts, annotation press, callout … -
- dvcrn authored - -
-
215 */
216 onAnnotationPress: React.PropTypes.func,
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
217 },
218
- 95deed5 - @bhosmer - flowified Libraries from Avik -
- bhosmer authored - -
-
219 _onChange: function(event: Event) {
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
220 if (event.nativeEvent.continuous) {
221 this.props.onRegionChange &&
222 this.props.onRegionChange(event.nativeEvent.region);
223 } else {
224 this.props.onRegionChangeComplete &&
225 this.props.onRegionChangeComplete(event.nativeEvent.region);
226 }
227 },
228
- 99bc08c - @dvcrn - [MapView] Support for annotation callouts, annotation press, callout … -
- dvcrn authored - -
-
229 _onPress: function(event: Event) {
230 if (event.nativeEvent.action === 'annotation-click') {
231 this.props.onAnnotationPress && this.props.onAnnotationPress(event.nativeEvent.annotation);
232 }
233
234 if (event.nativeEvent.action === 'callout-click') {
235 if (!this.props.annotations) {
236 return;
237 }
238
239 // Find the annotation with the id of what has been pressed
240 for (var i = 0; i < this.props.annotations.length; i++) {
241 var annotation = this.props.annotations[i];
242 if (annotation.id === event.nativeEvent.annotationId) {
243 // Pass the right function
244 if (event.nativeEvent.side === 'left') {
245 annotation.onLeftCalloutPress && annotation.onLeftCalloutPress(event.nativeEvent);
246 } else if (event.nativeEvent.side === 'right') {
247 annotation.onRightCalloutPress && annotation.onRightCalloutPress(event.nativeEvent);
248 }
249 }
250 }
251
252 }
253 },
254
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
255 render: function() {
- 99bc08c - @dvcrn - [MapView] Support for annotation callouts, annotation press, callout … -
- dvcrn authored - -
-
256 return <RCTMap {...this.props} onPress={this._onPress} onChange={this._onChange} />;
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
257 },
258});
259
- 58a550f - @sahrens - [ReactNative] use requireNativeComponent to clean up a bunch of boile… -
- sahrens authored - -
-
260if (Platform.OS === 'android') {
- ff00e14 - @kmagiera - [ReactNative] Rename ReactIOS JS module (and relatives) to ReactNative. -
- kmagiera authored - -
-
261 var RCTMap = createReactNativeComponentClass({
- 58a550f - @sahrens - [ReactNative] use requireNativeComponent to clean up a bunch of boile… -
- sahrens authored - -
-
262 validAttributes: merge(
- ff00e14 - @kmagiera - [ReactNative] Rename ReactIOS JS module (and relatives) to ReactNative. -
- kmagiera authored - -
-
263 ReactNativeViewAttributes.UIView, {
- 3ec3312 - @fkgozali - [madman]: Fix MapView crashing problem. -
- fkgozali authored - -
-
264 active: true,
- 58a550f - @sahrens - [ReactNative] use requireNativeComponent to clean up a bunch of boile… -
- sahrens authored - -
-
265 showsUserLocation: true,
266 zoomEnabled: true,
267 rotateEnabled: true,
268 pitchEnabled: true,
269 scrollEnabled: true,
270 region: {diff: deepDiffer},
271 annotations: {diff: deepDiffer},
272 maxDelta: true,
273 minDelta: true,
274 legalLabelInsets: {diff: insetsDiffer},
275 }
276 ),
277 uiViewClassName: 'RCTMap',
278 });
279} else {
- 8488398 - @nicklockwood - Added mechanism for directly mapping JS event handlers to blocks -
- nicklockwood authored - -
-
280 var RCTMap = requireNativeComponent('RCTMap', MapView, {
281 nativeOnly: {onChange: true, onPress: true}
282 });
- 58a550f - @sahrens - [ReactNative] use requireNativeComponent to clean up a bunch of boile… -
- sahrens authored - -
-
283}
- fa87d83 - @tadeuzagallo - [ReactNative] Oss GeoMap -
- tadeuzagallo authored - -
-
284
285module.exports = MapView;
-
-
- - -
-
- -
-
- - -
- -
- -
- - - - - - - -
- - - Something went wrong with that request. Please try again. -
- - - - - - - - - diff --git a/__tests__/github-mention-test.js b/__tests__/github-mention-test.js index 0c73807..f459b24 100644 --- a/__tests__/github-mention-test.js +++ b/__tests__/github-mention-test.js @@ -9,8 +9,6 @@ jest .dontMock('../mention-bot.js') - .dontMock('download-file-sync') - .dontMock('fs') .dontMock('minimatch'); require.requireActual('babel-polyfill'); @@ -19,36 +17,11 @@ var fs = require('fs'); describe('Github Mention', function() { - function getFile(filename) { - return fs.readFileSync(__dirname + '/data/' + filename, 'utf8'); - } - - xdescribe('Debugging', function() { - // If you are working on the algorithm itself, it is useful to be able to run - // the complete flow that downloads the diff and subsequent blames. Since - // doing http requests is unreliable in tests, it is disabled by default. - xit('CompleteFlow', function() { - mentionBot.enableCachingForDebugging = true; - var prs = [3238]; - - var owners = mentionBot.guessOwnersForPullRequest( - 'https://github.com/facebook/react-native', - i, - 'mention-bot', - 'master', - {} //config - ).then(function() { - prs.forEach(function(i) { - console.log(i, owners); - }); - }); - }); - }); - describe('CompleteFlow', function() { const reactNativePR = { - repoName: 'https://github.com/facebook/react-native', + repoName: 'react-native', + repoUser: 'facebook', prNumber: 3238, prUser: 'mention-bot', prBaseBranch: 'master', @@ -56,10 +29,34 @@ describe('Github Mention', function() { org: 'facebook' } + const githubMock = { + pullRequests: { + getFiles: jest.genMockFunction().mockImplementation(function(params, cb) { + cb(null, [ + {filename: 'README.md'}, + {filename: 'package.json'}, + {filename: 'config.js'}, + {filename: 'website/server/server.js'}, + ]); + }), + }, + repos: { + getCommits: jest.genMockFunction().mockImplementation(function(params, cb) { + cb(null, [ + {author: { login: 'corbt' }}, + {author: { login: 'vjeux' }}, + {author: { login: 'sahrens' }}, + {author: { login: 'jcsmorais' }}, + {author: { login: 'ghuser' }}, + ]); + }) + } + } + pit('Gets correct users with default config options', function() { - mentionBot.enableCachingForDebugging = true; return mentionBot.guessOwnersForPullRequest( reactNativePR.repoName, + reactNativePR.repoUser, reactNativePR.prNumber, reactNativePR.prUser, reactNativePR.prBaseBranch, @@ -72,28 +69,27 @@ describe('Github Mention', function() { requiredOrgs: [], numFilesToCheck: 5, findPotentialReviewers: true, - } + }, + githubMock ).then(function(owners) { expect(owners).toEqual(['corbt', 'vjeux', 'sahrens']); }); }); pit('Filters out users that are not in the org if the repo is private', function() { - mentionBot.enableCachingForDebugging = true; - var githubMock = { - orgs: { - getMembers: jest.genMockFunction().mockImplementation(function(params, cb) { - cb(null, [ - {login: 'sahrens'}, - {login: 'not-vjeux'}, - {login: 'corbt'} - ]); - }) - } + githubMock['orgs'] = { + getMembers: jest.genMockFunction().mockImplementation(function(params, cb) { + cb(null, [ + {login: 'sahrens'}, + {login: 'not-vjeux'}, + {login: 'corbt'} + ]); + }) }; return mentionBot.guessOwnersForPullRequest( reactNativePR.repoName, + reactNativePR.repoUser, reactNativePR.prNumber, reactNativePR.prUser, reactNativePR.prBaseBranch, @@ -120,7 +116,6 @@ describe('Github Mention', function() { }); pit('Handles pagination when getting the org members', function() { - mentionBot.enableCachingForDebugging = true; var onCall = 0; //First call to the github api returns 100 results @@ -136,20 +131,19 @@ describe('Github Mention', function() { {login: 'corbt'} ]; - var githubMock = { - orgs: { - getMembers: jest.genMockFunction().mockImplementation(function(params, cb) { - if(++onCall === 1) { - cb(null, onCall1); - } else { - cb(null, onCall2); - } - }) - } + githubMock['orgs'] = { + getMembers: jest.genMockFunction().mockImplementation(function(params, cb) { + if(++onCall === 1) { + cb(null, onCall1); + } else { + cb(null, onCall2); + } + }) }; return mentionBot.guessOwnersForPullRequest( reactNativePR.repoName, + reactNativePR.repoUser, reactNativePR.prNumber, reactNativePR.prUser, reactNativePR.prBaseBranch, @@ -181,15 +175,13 @@ describe('Github Mention', function() { }); pit('Does not get the org members if there is no org', function() { - mentionBot.enableCachingForDebugging = true; - var githubMock = { - orgs: { - getMembers: jest.genMockFunction() - } + githubMock['orgs'] = { + getMembers: jest.genMockFunction() }; return mentionBot.guessOwnersForPullRequest( reactNativePR.repoName, + reactNativePR.repoUser, reactNativePR.prNumber, reactNativePR.prUser, reactNativePR.prBaseBranch, @@ -211,9 +203,9 @@ describe('Github Mention', function() { }); pit('Gets correct users if `findPotentialReviewers` option is disabled', function() { - mentionBot.enableCachingForDebugging = true; return mentionBot.guessOwnersForPullRequest( reactNativePR.repoName, + reactNativePR.repoUser, reactNativePR.prNumber, reactNativePR.prUser, reactNativePR.prBaseBranch, @@ -230,16 +222,17 @@ describe('Github Mention', function() { name: 'jcsmorais', files: ['website/server/*'] }] - } + }, + githubMock ).then(function(owners) { expect(owners).toEqual(['jcsmorais']); }); }); pit('Messages 5 users from config option maxUsersToPing', function() { - mentionBot.enableCachingForDebugging = true; return mentionBot.guessOwnersForPullRequest( reactNativePR.repoName, + reactNativePR.repoUser, reactNativePR.prNumber, reactNativePR.prUser, reactNativePR.prBaseBranch, @@ -252,16 +245,17 @@ describe('Github Mention', function() { requiredOrgs: [], numFilesToCheck: 5, findPotentialReviewers: true, - } + }, + githubMock ).then(function(owners) { expect(owners.length).toEqual(5); }); }); pit('Should contain testname in owners from whitelist', function() { - mentionBot.enableCachingForDebugging = true; return mentionBot.guessOwnersForPullRequest( reactNativePR.repoName, + reactNativePR.repoUser, reactNativePR.prNumber, reactNativePR.prUser, reactNativePR.prBaseBranch, @@ -280,14 +274,16 @@ describe('Github Mention', function() { files: ['package.json', '**/*.js', 'README.md'] } ] - } + }, + githubMock ).then(function(owners) { expect(owners.indexOf('ghuser')).toBeGreaterThan(-1); }); }); const botTestingPR = { - repoName: 'https://github.com/fbsamples/bot-testing', + repoName: 'bot-testing', + repoUser: 'fbsamples', prNumber: 95, prUser: 'mention-bot', prBaseBranch: 'master', @@ -296,9 +292,14 @@ describe('Github Mention', function() { } pit('Should contain testname in owners from fallback', function() { - mentionBot.enableCachingForDebugging = true; + githubMock['repos'] = { + getCommits: jest.genMockFunction().mockImplementation(function(params, cb) { + cb(null, []); + }) + } return mentionBot.guessOwnersForPullRequest( botTestingPR.repoName, + botTestingPR.repoUser, botTestingPR.prNumber, botTestingPR.prUser, botTestingPR.prBaseBranch, @@ -317,16 +318,17 @@ describe('Github Mention', function() { files: ['*.js'] } ] - } + }, + githubMock ).then(function(owners) { expect(owners.indexOf('ghuser')).toBeGreaterThan(-1); }); }); pit('Should not contain testname in owners from fallback when fallback is missing', function() { - mentionBot.enableCachingForDebugging = true; return mentionBot.guessOwnersForPullRequest( botTestingPR.repoName, + botTestingPR.repoUser, botTestingPR.prNumber, botTestingPR.prUser, botTestingPR.prBaseBranch, @@ -339,176 +341,11 @@ describe('Github Mention', function() { requiredOrgs: [], numFilesToCheck: 5, findPotentialReviewers: true - } + }, + githubMock ).then(function (owners) { expect(owners.indexOf('ghuser')).toEqual(-1); }); }); }); - - it('ParseDiffEmpty', function() { - expect(function() { mentionBot.parseDiff(''); }).not.toThrow(); - }); - - it('ParseBlameEmpty', function() { - expect(function() { mentionBot.parseBlame(''); }).not.toThrow(); - }); - - it('ParseDiff3119', function() { - var parsed = mentionBot.parseDiff( - // https://github.com/facebook/react-native/pull/3119.diff - getFile('3119.diff') - ); - expect(parsed).toEqual([ - { - path: 'Libraries/Components/MapView/MapView.js', - deletedLines: [ 74 ], - }, - { - path: 'React/Views/RCTMap.m', - deletedLines: [ 90, 92 ], - }, - { - path: 'React/Views/RCTMapManager.m', - deletedLines: [ ], - }, - ]); - }); - - it('ParseDiff35fa5', function() { - var parsed = mentionBot.parseDiff( - // https://github.com/facebook/react-native/commit/35fa5aa76233b3fbe541f3fa1756705900ee919c.diff - getFile('35fa5aa76233b3fbe541f3fa1756705900ee919c.diff') - ); - expect(parsed).toEqual([ - { - path: 'website/src/react-native/img/TutorialFinal.png', - deletedLines: [ ], - }, - { - path: 'website/src/react-native/img/TutorialMock.png', - deletedLines: [ ], - }, - { - path: 'website/src/react-native/img/TutorialSingleFetched.png', - deletedLines: [ ], - }, - { - path: 'website/src/react-native/img/TutorialStyledMock.png', - deletedLines: [ ], - }, - { - path: 'website/src/react-native/img/chrome_breakpoint.png', - deletedLines: [ ], - }, - { - path: 'website/src/react-native/img/favicon.png', - deletedLines: [ ], - }, - { - path: 'website/src/react-native/img/header_logo.png', - deletedLines: [ ], - }, - { - path: 'website/src/react-native/img/opengraph.png', - deletedLines: [ ], - }, - ]); - }); - - it('ParseDiff3229', function() { - var parsed = mentionBot.parseDiff( - // https://github.com/facebook/react-native/pull/3229.diff - getFile('3229.diff') - ); - expect(parsed).toEqual([ - { - path: 'Libraries/WebSocket/WebSocket.ios.js', - deletedLines: [ 19, 20, 21, 22, 23, 24, 25, 27, 28, 70, 74, 75, 77, 79, 83, 88, 89, 91, 95, 100, 101, 105, 109, 113, 114, 115, 116, 119 ], - }, - { - path: 'Libraries/WebSocket/WebSocketBase.js', - deletedLines: [ 19, 25, 26, 27, 28, 29 ], - }, - { - path: 'Libraries/WebSocket/__mocks__/event-target-shim.js', - deletedLines: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ], - }, - { - path: 'Libraries/WebSocket/__tests__/Websocket-test.js', - deletedLines: [ ], - }, - ]); - }); - - it('ParseDiff1', function() { - var parsed = mentionBot.parseDiff( - // https://github.com/fbsamples/bot-testing/pull/1.diff - getFile('1.diff') - ); - expect(parsed).toEqual([ - { - path: 'README.md', - deletedLines: [ ], - }, - ]); - }); - - it('ParseBlame1', function() { - var parsed = mentionBot.parseBlame( - // https://github.com/facebook/react-native/blame/master/Libraries/Components/MapView/MapView.js - getFile('MapView.js.blame') - ); - - expect(parsed).toEqual([ - 'tadeuzagallo', - 'vjeux', 'vjeux', 'vjeux', 'vjeux', 'vjeux', 'vjeux', - 'tadeuzagallo', 'tadeuzagallo', - 'bhosmer', - 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', - 'sahrens', - 'tadeuzagallo', - 'kmagiera', - 'tadeuzagallo', 'tadeuzagallo', - 'kmagiera', - 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', - 'sahrens', - 'tadeuzagallo', - 'bhosmer', - 'philikon', 'philikon', 'philikon', 'philikon', 'philikon', 'philikon', - 'bhosmer', - 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', - 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', - 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', - 'ultralame', - 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', - 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', - 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', - 'ginamdar', 'ginamdar', 'ginamdar', 'ginamdar', 'ginamdar', 'ginamdar', 'ginamdar', 'ginamdar', 'ginamdar', 'ginamdar', - 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', - 'ginamdar', 'ginamdar', 'ginamdar', 'ginamdar', - 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', - 'ginamdar', 'ginamdar', 'ginamdar', - 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', - 'dvcrn', 'dvcrn', - 'ultralame', - 'dvcrn', 'dvcrn', - 'tadeuzagallo', 'tadeuzagallo', - 'bhosmer', - 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', - 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', 'dvcrn', - 'tadeuzagallo', - 'dvcrn', - 'tadeuzagallo', 'tadeuzagallo', 'tadeuzagallo', - 'sahrens', - 'kmagiera', - 'sahrens', - 'kmagiera', - 'fkgozali', - 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', 'sahrens', - 'nicklockwood', 'nicklockwood', 'nicklockwood', - 'sahrens', - 'tadeuzagallo', 'tadeuzagallo', - ]); - }); }); diff --git a/cache/https---github.com-facebook-react-native-blame-master-Libraries-ReactIOS-NativeMethodsMixin.js b/cache/https---github.com-facebook-react-native-blame-master-Libraries-ReactIOS-NativeMethodsMixin.js deleted file mode 100644 index 18c9633..0000000 --- a/cache/https---github.com-facebook-react-native-blame-master-Libraries-ReactIOS-NativeMethodsMixin.js +++ /dev/null @@ -1,2232 +0,0 @@ - - - - - - - - - - - - - - react-native/Libraries/ReactIOS/NativeMethodsMixin.js at master · facebook/react-native · GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to content - - - - - - - - - - - - -
- -
-
- - -
-
-
- - - -
-
- - - - - - -
- Newer -
    -
  1. -
  2. -
  3. -
  4. -
  5. -
  6. -
  7. -
  8. -
  9. -
  10. -
- Older -
- -
-
-
- -
- - - -
- - 100644 - - 191 lines (175 sloc) - - 5.8 KB -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
1/**
- e1ef032 - @vjeux - [ReactNative] Expanded license on js files -
- vjeux authored - -
-
2 * Copyright (c) 2015-present, Facebook, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
8 *
9 * @providesModule NativeMethodsMixin
- 7ffa794 - @mroch - flowify Libraries/ReactIOS -
- mroch authored - -
-
10 * @flow
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
11 */
12'use strict';
13
- 6c5024e - @sebmarkbage - Refactor Attribute Processing (Step 1) -
- sebmarkbage authored - -
-
14var ReactNativeAttributePayload = require('ReactNativeAttributePayload');
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
15var TextInputState = require('TextInputState');
- 60db876 - @nicklockwood - Wrapped UIManager native module for better abstraction -
- nicklockwood authored - -
-
16var UIManager = require('UIManager');
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
17
- a0440da - @spicyj - [react-native] Codemod .getNodeHandle, .getNativeNode to React.findNo… -
- spicyj authored - -
-
18var findNodeHandle = require('findNodeHandle');
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
19var invariant = require('invariant');
20
- 7ffa794 - @mroch - flowify Libraries/ReactIOS -
- mroch authored - -
-
21type MeasureOnSuccessCallback = (
22 x: number,
23 y: number,
24 width: number,
25 height: number,
26 pageX: number,
27 pageY: number
28) => void
29
30type MeasureLayoutOnSuccessCallback = (
31 left: number,
32 top: number,
33 width: number,
34 height: number
35) => void
36
- 2ea3b93 - @sebmarkbage - Add warning to setNativeProps and Animated for non-nested styles -
- sebmarkbage authored - -
-
37function warnForStyleProps(props, validAttributes) {
38 for (var key in validAttributes.style) {
39 if (!(validAttributes[key] || props[key] === undefined)) {
40 console.error(
41 'You are setting the style `{ ' + key + ': ... }` as a prop. You ' +
42 'should nest it in a style object. ' +
43 'E.g. `{ style: { ' + key + ': ... } }`'
44 );
45 }
46 }
47}
48
- 381e2ac - @corbt - Document NativeMethodsMixin -
- corbt authored - -
-
49/**
50 * `NativeMethodsMixin` provides methods to access the underlying native
51 * component directly. This can be useful in cases when you want to focus
52 * a view or measure its on-screen dimensions, for example.
53 *
54 * The methods described here are available on most of the default components
55 * provided by React Native. Note, however, that they are *not* available on
56 * composite components that aren't directly backed by a native view. This will
57 * generally include most components that you define in your own app. For more
58 * information, see [Direct
59 * Manipulation](/react-native/docs/direct-manipulation.html).
60 */
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
61var NativeMethodsMixin = {
- 381e2ac - @corbt - Document NativeMethodsMixin -
- corbt authored - -
-
62 /**
63 * Determines the location on screen, width, and height of the given view and
64 * returns the values via an async callback. If successful, the callback will
65 * be called with the following arguments:
66 *
67 * - x
68 * - y
69 * - width
70 * - height
71 * - pageX
72 * - pageY
73 *
74 * Note that these measurements are not available until after the rendering
75 * has been completed in native. If you need the measurements as soon as
76 * possible, consider using the [`onLayout`
77 * prop](/react-native/docs/view.html#onlayout) instead.
78 */
- 7ffa794 - @mroch - flowify Libraries/ReactIOS -
- mroch authored - -
-
79 measure: function(callback: MeasureOnSuccessCallback) {
- 60db876 - @nicklockwood - Wrapped UIManager native module for better abstraction -
- nicklockwood authored - -
-
80 UIManager.measure(
- 6e179fb - @sahrens - [ReactNative] introduce mountSafeCallback -
- sahrens authored - -
-
81 findNodeHandle(this),
82 mountSafeCallback(this, callback)
83 );
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
84 },
85
- 381e2ac - @corbt - Document NativeMethodsMixin -
- corbt authored - -
-
86 /**
87 * Like [`measure()`](#measure), but measures the view relative an ancestor,
88 * specified as `relativeToNativeNode`. This means that the returned x, y
89 * are relative to the origin x, y of the ancestor view.
90 *
91 * As always, to obtain a native node handle for a component, you can use
92 * `React.findNodeHandle(component)`.
93 */
- 7ffa794 - @mroch - flowify Libraries/ReactIOS -
- mroch authored - -
-
94 measureLayout: function(
95 relativeToNativeNode: number,
96 onSuccess: MeasureLayoutOnSuccessCallback,
97 onFail: () => void /* currently unused */
98 ) {
- 60db876 - @nicklockwood - Wrapped UIManager native module for better abstraction -
- nicklockwood authored - -
-
99 UIManager.measureLayout(
- a0440da - @spicyj - [react-native] Codemod .getNodeHandle, .getNativeNode to React.findNo… -
- spicyj authored - -
-
100 findNodeHandle(this),
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
101 relativeToNativeNode,
- 6e179fb - @sahrens - [ReactNative] introduce mountSafeCallback -
- sahrens authored - -
-
102 mountSafeCallback(this, onFail),
103 mountSafeCallback(this, onSuccess)
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
104 );
105 },
106
107 /**
- 381e2ac - @corbt - Document NativeMethodsMixin -
- corbt authored - -
-
108 * This function sends props straight to native. They will not participate in
109 * future diff process - this means that if you do not include them in the
110 * next render, they will remain active (see [Direct
111 * Manipulation](/react-native/docs/direct-manipulation.html)).
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
112 */
- 7ffa794 - @mroch - flowify Libraries/ReactIOS -
- mroch authored - -
-
113 setNativeProps: function(nativeProps: Object) {
- 2ea3b93 - @sebmarkbage - Add warning to setNativeProps and Animated for non-nested styles -
- sebmarkbage authored - -
-
114 if (__DEV__) {
115 warnForStyleProps(nativeProps, this.viewConfig.validAttributes);
116 }
117
- 6c5024e - @sebmarkbage - Refactor Attribute Processing (Step 1) -
- sebmarkbage authored - -
-
118 var updatePayload = ReactNativeAttributePayload.create(
119 nativeProps,
- 9a2d05d - @a2 - Move color processing to JS -
- a2 authored - -
-
120 this.viewConfig.validAttributes
121 );
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
122
- 60db876 - @nicklockwood - Wrapped UIManager native module for better abstraction -
- nicklockwood authored - -
-
123 UIManager.updateView(
- a0440da - @spicyj - [react-native] Codemod .getNodeHandle, .getNativeNode to React.findNo… -
- spicyj authored - -
-
124 findNodeHandle(this),
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
125 this.viewConfig.uiViewClassName,
- 6c5024e - @sebmarkbage - Refactor Attribute Processing (Step 1) -
- sebmarkbage authored - -
-
126 updatePayload
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
127 );
128 },
129
- 381e2ac - @corbt - Document NativeMethodsMixin -
- corbt authored - -
-
130 /**
131 * Requests focus for the given input or view. The exact behavior triggered
132 * will depend on the platform and type of view.
133 */
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
134 focus: function() {
- a0440da - @spicyj - [react-native] Codemod .getNodeHandle, .getNativeNode to React.findNo… -
- spicyj authored - -
-
135 TextInputState.focusTextInput(findNodeHandle(this));
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
136 },
137
- 381e2ac - @corbt - Document NativeMethodsMixin -
- corbt authored - -
-
138 /**
139 * Removes focus from an input or view. This is the opposite of `focus()`.
140 */
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
141 blur: function() {
- a0440da - @spicyj - [react-native] Codemod .getNodeHandle, .getNativeNode to React.findNo… -
- spicyj authored - -
-
142 TextInputState.blurTextInput(findNodeHandle(this));
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
143 }
144};
145
146function throwOnStylesProp(component, props) {
147 if (props.styles !== undefined) {
148 var owner = component._owner || null;
149 var name = component.constructor.displayName;
150 var msg = '`styles` is not a supported property of `' + name + '`, did ' +
151 'you mean `style` (singular)?';
152 if (owner && owner.constructor && owner.constructor.displayName) {
153 msg += '\n\nCheck the `' + owner.constructor.displayName + '` parent ' +
154 ' component.';
155 }
156 throw new Error(msg);
157 }
158}
159if (__DEV__) {
- 7ffa794 - @mroch - flowify Libraries/ReactIOS -
- mroch authored - -
-
160 // hide this from Flow since we can't define these properties outside of
161 // __DEV__ without actually implementing them (setting them to undefined
162 // isn't allowed by ReactClass)
163 var NativeMethodsMixin_DEV = (NativeMethodsMixin: any);
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
164 invariant(
- 7ffa794 - @mroch - flowify Libraries/ReactIOS -
- mroch authored - -
-
165 !NativeMethodsMixin_DEV.componentWillMount &&
166 !NativeMethodsMixin_DEV.componentWillReceiveProps,
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
167 'Do not override existing functions.'
168 );
- 7ffa794 - @mroch - flowify Libraries/ReactIOS -
- mroch authored - -
-
169 NativeMethodsMixin_DEV.componentWillMount = function () {
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
170 throwOnStylesProp(this, this.props);
171 };
- 7ffa794 - @mroch - flowify Libraries/ReactIOS -
- mroch authored - -
-
172 NativeMethodsMixin_DEV.componentWillReceiveProps = function (newProps) {
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
173 throwOnStylesProp(this, newProps);
174 };
175}
176
- 4771806 - @sahrens - [ReactNative] Fix some mount callback issues -
- sahrens authored - -
-
177/**
178 * In the future, we should cleanup callbacks by cancelling them instead of
179 * using this.
180 */
181var mountSafeCallback = function(context: ReactComponent, callback: ?Function): any {
182 return function() {
183 if (!callback || (context.isMounted && !context.isMounted())) {
184 return;
185 }
186 return callback.apply(context, arguments);
187 };
188};
189
- efae175 - @sahrens - [react-packager][streamline oss] Move open sourced JS source to react… -
- sahrens authored - -
-
190module.exports = NativeMethodsMixin;
-
-
- - -
- -
- -
-
- -
- -
- -
- - - - - - - -
- - - Something went wrong with that request. Please try again. -
- - - - - - - - - - - diff --git a/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-WebSocket.ios.js b/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-WebSocket.ios.js deleted file mode 100644 index 59f0bef..0000000 --- a/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-WebSocket.ios.js +++ /dev/null @@ -1 +0,0 @@ -{"error":"Not Found"} \ No newline at end of file diff --git a/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-WebSocketBase.js b/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-WebSocketBase.js deleted file mode 100644 index 5f8a5c3..0000000 --- a/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-WebSocketBase.js +++ /dev/null @@ -1,1293 +0,0 @@ - - - - - - - - - - - - - - react-native/Libraries/WebSocket/WebSocketBase.js at master · facebook/react-native · GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to content - - - - - - - - - - - - -
- -
-
- - -
-
-
- - - -
-
- - - - - - -
- Newer -
    -
  1. -
  2. -
  3. -
  4. -
  5. -
  6. -
  7. -
  8. -
  9. -
  10. -
- Older -
- -
-
-
- -
- - - -
- - 100644 - - 106 lines (86 sloc) - - 2.36 KB -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- babdc21 - @hharnisc - WebSocket polyfill -
- hharnisc authored - -
-
1/**
2 * Copyright (c) 2015-present, Facebook, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
8 *
9 * @providesModule WebSocketBase
10 */
11'use strict';
12
- 626b551 - @leeyeh - Implement EventTarget interface for WebSocket. -
- leeyeh authored - -
-
13var EventTarget = require('event-target-shim');
14
- babdc21 - @hharnisc - WebSocket polyfill -
- hharnisc authored - -
-
15/**
16 * Shared base for platform-specific WebSocket implementations.
17 */
- 626b551 - @leeyeh - Implement EventTarget interface for WebSocket. -
- leeyeh authored - -
-
18class WebSocketBase extends EventTarget {
- babdc21 - @hharnisc - WebSocket polyfill -
- hharnisc authored - -
-
19 CONNECTING: number;
20 OPEN: number;
21 CLOSING: number;
22 CLOSED: number;
23
24 onclose: ?Function;
25 onerror: ?Function;
26 onmessage: ?Function;
27 onopen: ?Function;
28
29 binaryType: ?string;
30 bufferedAmount: number;
31 extension: ?string;
32 protocol: ?string;
33 readyState: number;
34 url: ?string;
35
36 constructor(url: string, protocols: ?any) {
- 626b551 - @leeyeh - Implement EventTarget interface for WebSocket. -
- leeyeh authored - -
-
37 super();
- babdc21 - @hharnisc - WebSocket polyfill -
- hharnisc authored - -
-
38 this.CONNECTING = 0;
39 this.OPEN = 1;
40 this.CLOSING = 2;
41 this.CLOSED = 3;
42
43 if (!protocols) {
44 protocols = [];
45 }
46
- e637271 - @kenwheeler - Fixes #3846 -
- kenwheeler authored - -
-
47 this.readyState = this.CONNECTING;
- babdc21 - @hharnisc - WebSocket polyfill -
- hharnisc authored - -
-
48 this.connectToSocketImpl(url);
49 }
50
51 close(): void {
- e637271 - @kenwheeler - Fixes #3846 -
- kenwheeler authored - -
-
52 if (this.readyState === this.CLOSING ||
53 this.readyState === this.CLOSED) {
- babdc21 - @hharnisc - WebSocket polyfill -
- hharnisc authored - -
-
54 return;
55 }
56
- e637271 - @kenwheeler - Fixes #3846 -
- kenwheeler authored - -
-
57 if (this.readyState === this.CONNECTING) {
- babdc21 - @hharnisc - WebSocket polyfill -
- hharnisc authored - -
-
58 this.cancelConnectionImpl();
59 }
60
- e637271 - @kenwheeler - Fixes #3846 -
- kenwheeler authored - -
-
61 this.readyState = this.CLOSING;
- babdc21 - @hharnisc - WebSocket polyfill -
- hharnisc authored - -
-
62 this.closeConnectionImpl();
63 }
64
65 send(data: any): void {
- e637271 - @kenwheeler - Fixes #3846 -
- kenwheeler authored - -
-
66 if (this.readyState === this.CONNECTING) {
- babdc21 - @hharnisc - WebSocket polyfill -
- hharnisc authored - -
-
67 throw new Error('INVALID_STATE_ERR');
68 }
69
70 if (typeof data === 'string') {
71 this.sendStringImpl(data);
72 } else if (data instanceof ArrayBuffer) {
73 this.sendArrayBufferImpl(data);
74 } else {
75 throw new Error('Not supported data type');
76 }
77 }
78
79 closeConnectionImpl(): void {
80 throw new Error('Subclass must define closeConnectionImpl method');
81 }
82
83 connectToSocketImpl(): void {
84 throw new Error('Subclass must define connectToSocketImpl method');
85 }
86
87 cancelConnectionImpl(): void {
88 throw new Error('Subclass must define cancelConnectionImpl method');
89 }
90
91 sendStringImpl(): void {
92 throw new Error('Subclass must define sendStringImpl method');
93 }
94
95 sendArrayBufferImpl(): void {
96 throw new Error('Subclass must define sendArrayBufferImpl method');
97 }
98}
99
- e637271 - @kenwheeler - Fixes #3846 -
- kenwheeler authored - -
-
100WebSocketBase.CONNECTING = 0;
101WebSocketBase.OPEN = 1;
102WebSocketBase.CLOSING = 2;
103WebSocketBase.CLOSED = 3;
104
- babdc21 - @hharnisc - WebSocket polyfill -
- hharnisc authored - -
-
105module.exports = WebSocketBase;
-
-
- - -
- -
- -
-
- -
- -
- -
- - - - - - - -
- - - Something went wrong with that request. Please try again. -
- - - - - - - - - - - diff --git a/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-__mocks__-event-target-shim.js b/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-__mocks__-event-target-shim.js deleted file mode 100644 index 7fcfe30..0000000 --- a/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-__mocks__-event-target-shim.js +++ /dev/null @@ -1,431 +0,0 @@ - - - - - - - - - - - - - - react-native/Libraries/WebSocket/__mocks__/event-target-shim.js at master · facebook/react-native · GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to content - - - - - - - - - - - - -
- -
-
- - -
-
-
- - - -
-
- - - - - - -
- Newer -
    -
  1. -
  2. -
  3. -
  4. -
  5. -
  6. -
  7. -
  8. -
  9. -
  10. -
- Older -
- -
-
-
- -
- - - -
- - 100644 - - 10 lines (8 sloc) - - 233 Bytes -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 6f84ccf - @vjeux - Fix tests related to event-target-shim -
- vjeux authored - -
-
1// Jest fatals for the following statement (minimal repro case)
2//
3// exports.something = Symbol;
4//
5// Until it is fixed, mocking the entire node module makes the
6// problem go away.
7
8'use strict';
9module.exports = function() {};
-
-
- - -
- -
- -
-
- -
- -
- -
- - - - - - - -
- - - Something went wrong with that request. Please try again. -
- - - - - - - - - - - diff --git a/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-__tests__-Websocket-test.js b/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-__tests__-Websocket-test.js deleted file mode 100644 index 59f0bef..0000000 --- a/cache/https---github.com-facebook-react-native-blame-master-Libraries-WebSocket-__tests__-Websocket-test.js +++ /dev/null @@ -1 +0,0 @@ -{"error":"Not Found"} \ No newline at end of file diff --git a/cache/https---github.com-facebook-react-native-blame-master-website-server-extractDocs.js b/cache/https---github.com-facebook-react-native-blame-master-website-server-extractDocs.js deleted file mode 100644 index daf63a9..0000000 --- a/cache/https---github.com-facebook-react-native-blame-master-website-server-extractDocs.js +++ /dev/null @@ -1,3419 +0,0 @@ - - - - - - - - - - - - - - react-native/website/server/extractDocs.js at master · facebook/react-native · GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Skip to content - - - - - - - - - - - - -
- -
-
- - -
-
-
- - - -
-
- - - - - - -
- Newer -
    -
  1. -
  2. -
  3. -
  4. -
  5. -
  6. -
  7. -
  8. -
  9. -
  10. -
- Older -
- -
-
-
- -
- - - -
- - 100644 - - 281 lines (245 sloc) - - 8.52 KB -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- e811181 - @vjeux - Add copyright header on website files -
- vjeux authored - -
-
1/**
2 * Copyright (c) 2015-present, Facebook, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
8 */
9
- d5f670d - @fkling - Add logic to show style props in docs -
- fkling authored - -
-
10var docgen = require('react-docgen');
11var docgenHelpers = require('./docgenHelpers');
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
12var fs = require('fs');
13var path = require('path');
14var slugify = require('../core/slugify');
- 28aa691 - @vjeux - Updates from Fri 13 Mar -
- vjeux authored - -
-
15var jsDocs = require('../jsdocs/jsdocs.js');
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
16
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
17var ANDROID_SUFFIX = 'android';
18var CROSS_SUFFIX = 'cross';
19var IOS_SUFFIX = 'ios';
20
21function endsWith(str, suffix) {
22 return str.indexOf(suffix, str.length - suffix.length) !== -1;
23}
24
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
25function getNameFromPath(filepath) {
26 var ext = null;
27 while (ext = path.extname(filepath)) {
28 filepath = path.basename(filepath, ext);
29 }
- b8ca4e4 - @brentvatne - Add TransformPropTypes to docs -
- brentvatne authored - -
-
30
- c676e9d - @vjeux - Rename LayoutPropTypes to Flexbox -
- vjeux authored - -
-
31 if (filepath === 'LayoutPropTypes') {
32 return 'Flexbox';
- b8ca4e4 - @brentvatne - Add TransformPropTypes to docs -
- brentvatne authored - -
-
33 } else if (filepath === 'TransformPropTypes') {
34 return 'Transforms';
35 } else if (filepath === 'TabBarItemIOS') {
- 9ee6cd6 - @brentvatne - [Docs] Add TabBarIOS.Item to docs -
- brentvatne authored - -
-
36 return 'TabBarIOS.Item';
- 00ceec9 - @vjeux - Fix website with Animated -
- vjeux authored - -
-
37 } else if (filepath === 'AnimatedImplementation') {
38 return 'Animated';
- c676e9d - @vjeux - Rename LayoutPropTypes to Flexbox -
- vjeux authored - -
-
39 }
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
40 return filepath;
41}
42
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
43function getPlatformFromPath(filepath) {
44 var ext = null;
45 while (ext = path.extname(filepath)) {
46 filepath = path.basename(filepath, ext);
47 }
- 00ceec9 - @vjeux - Fix website with Animated -
- vjeux authored - -
-
48
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
49 if (endsWith(filepath, 'Android')) {
50 return ANDROID_SUFFIX;
51 } else if (endsWith(filepath, 'IOS')) {
52 return IOS_SUFFIX;
53 }
54 return CROSS_SUFFIX;
55}
56
57function getExample(componentName, componentPlatform) {
- a4a551c - @vjeux - Add examples at the end of the doc pages -
- vjeux authored - -
-
58 var path = '../Examples/UIExplorer/' + componentName + 'Example.js';
59 if (!fs.existsSync(path)) {
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
60 path = '../Examples/UIExplorer/' + componentName + 'Example.'+ componentPlatform +'.js';
- 427d902 - @vjeux - Support .ios.js examples -
- vjeux authored - -
-
61 if (!fs.existsSync(path)) {
62 return;
63 }
- a4a551c - @vjeux - Add examples at the end of the doc pages -
- vjeux authored - -
-
64 }
65 return {
- 115b2a3 - @vjeux - fix ../ -
- vjeux authored - -
-
66 path: path.replace(/^\.\.\//, ''),
- a4a551c - @vjeux - Add examples at the end of the doc pages -
- vjeux authored - -
-
67 content: fs.readFileSync(path).toString(),
68 };
69}
70
- 5af8849 - @jsierles - [Docs] Add a 'run this example' link to AlertIOS docs, plus supportin… -
- jsierles authored - -
-
71// Determines whether a component should have a link to a runnable example
72
73function isRunnable(componentName) {
74 if (componentName === 'AlertIOS') {
75 return true;
76 }
77
78 return false;
79}
80
- debd5b0 - @brentvatne - [Docs] Remove Transforms from sidebar, add to Style -
- brentvatne authored - -
-
81// Hide a component from the sidebar by making it return false from
82// this function
83function shouldDisplayInSidebar(componentName) {
84 if (componentName === 'Transforms') {
85 return false;
86 }
87
88 return true;
89}
90
91function getNextComponent(i) {
92 var next;
93 var filepath = all[i];
94
95 if (all[i + 1]) {
96 var nextComponentName = getNameFromPath(all[i + 1]);
97
98 if (shouldDisplayInSidebar(nextComponentName)) {
99 return slugify(nextComponentName);
100 } else {
101 return getNextComponent(i + 1);
102 }
103 } else {
104 return 'network';
105 }
106}
107
- d5f670d - @fkling - Add logic to show style props in docs -
- fkling authored - -
-
108function componentsToMarkdown(type, json, filepath, i, styles) {
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
109 var componentName = getNameFromPath(filepath);
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
110 var componentPlatform = getPlatformFromPath(filepath);
- b9ab607 - @vjeux - Use docs/ComponentName.md at the end of the component docs -
- vjeux authored - -
-
111 var docFilePath = '../docs/' + componentName + '.md';
- 00ceec9 - @vjeux - Fix website with Animated -
- vjeux authored - -
-
112
- b9ab607 - @vjeux - Use docs/ComponentName.md at the end of the component docs -
- vjeux authored - -
-
113 if (fs.existsSync(docFilePath)) {
114 json.fullDescription = fs.readFileSync(docFilePath).toString();
115 }
- 33bfb32 - @vjeux - Wire up jsdocs for apis -
- vjeux authored - -
-
116 json.type = type;
- 536b466 - @vjeux - Add Edit on Github link on pages. cc @DMortens -
- - vjeux authored - -
-
117 json.filepath = filepath.replace(/^\.\.\//, '');
118 json.componentName = componentName;
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
119 json.componentPlatform = componentPlatform;
- d5f670d - @fkling - Add logic to show style props in docs -
- fkling authored - -
-
120 if (styles) {
121 json.styles = styles;
122 }
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
123 json.example = getExample(componentName, componentPlatform);
- b9ab607 - @vjeux - Use docs/ComponentName.md at the end of the component docs -
- vjeux authored - -
-
124
- debd5b0 - @brentvatne - [Docs] Remove Transforms from sidebar, add to Style -
- brentvatne authored - -
-
125 // Put Flexbox into the Polyfills category
126 var category = (type === 'style' ? 'Polyfills' : type + 's');
127 var next = getNextComponent(i);
128
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
129 var res = [
130 '---',
131 'id: ' + slugify(componentName),
132 'title: ' + componentName,
- d935f45 - @vjeux - Improvements in the docs generation -
- - vjeux authored - -
-
133 'layout: autodocs',
- debd5b0 - @brentvatne - [Docs] Remove Transforms from sidebar, add to Style -
- brentvatne authored - -
-
134 'category: ' + category,
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
135 'permalink: docs/' + slugify(componentName) + '.html',
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
136 'platform: ' + componentPlatform,
- debd5b0 - @brentvatne - [Docs] Remove Transforms from sidebar, add to Style -
- brentvatne authored - -
-
137 'next: ' + next,
138 'sidebar: ' + shouldDisplayInSidebar(componentName),
- 5af8849 - @jsierles - [Docs] Add a 'run this example' link to AlertIOS docs, plus supportin… -
- jsierles authored - -
-
139 'runnable:' + isRunnable(componentName),
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
140 '---',
- d935f45 - @vjeux - Improvements in the docs generation -
- - vjeux authored - -
-
141 JSON.stringify(json, null, 2),
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
142 ].filter(function(line) { return line; }).join('\n');
143 return res;
144}
145
- 4681da5 - @vjeux - Add geolocation polyfill -
- vjeux authored - -
-
146var n;
147
148function renderComponent(filepath) {
149 var json = docgen.parse(
150 fs.readFileSync(filepath),
151 docgenHelpers.findExportedOrFirst,
152 docgen.defaultHandlers.concat(docgenHelpers.stylePropTypeHandler)
153 );
- 731d4a0 - @brentvatne - Remove the deprecated transform propTypes -
- brentvatne authored - -
-
154
- 4681da5 - @vjeux - Add geolocation polyfill -
- vjeux authored - -
-
155 return componentsToMarkdown('component', json, filepath, n++, styleDocs);
156}
157
158function renderAPI(type) {
159 return function(filepath) {
160 var json;
161 try {
162 json = jsDocs(fs.readFileSync(filepath).toString());
163 } catch(e) {
- 126928b - @sahrens - [Docs] Expand API parsing and rendering -
- sahrens authored - -
-
164 console.error('Cannot parse file', filepath, e);
- 4681da5 - @vjeux - Add geolocation polyfill -
- vjeux authored - -
-
165 json = {};
166 }
167 return componentsToMarkdown(type, json, filepath, n++);
168 };
169}
170
171function renderStyle(filepath) {
172 var json = docgen.parse(
173 fs.readFileSync(filepath),
174 docgenHelpers.findExportedObject,
175 [docgen.handlers.propTypeHandler]
176 );
- 731d4a0 - @brentvatne - Remove the deprecated transform propTypes -
- brentvatne authored - -
-
177
- debd5b0 - @brentvatne - [Docs] Remove Transforms from sidebar, add to Style -
- brentvatne authored - -
-
178 // Remove deprecated transform props from docs
- 731d4a0 - @brentvatne - Remove the deprecated transform propTypes -
- brentvatne authored - -
-
179 if (filepath === "../Libraries/StyleSheet/TransformPropTypes.js") {
180 ['rotation', 'scaleX', 'scaleY', 'translateX', 'translateY'].forEach(function(key) {
181 delete json['props'][key];
182 });
183 }
184
- 4681da5 - @vjeux - Add geolocation polyfill -
- vjeux authored - -
-
185 return componentsToMarkdown('style', json, filepath, n++);
186}
187
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
188var components = [
- b9ab607 - @vjeux - Use docs/ComponentName.md at the end of the component docs -
- vjeux authored - -
-
189 '../Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js',
- 83581cf - @vjeux - Initial import of the lib to parse javascript code, in the same vein … -
- vjeux authored - -
-
190 '../Libraries/Components/DatePicker/DatePickerIOS.ios.js',
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
191 '../Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js',
- f77d9f8 - @fkling - Update react-docgen -
- fkling authored - -
-
192 '../Libraries/Image/Image.ios.js',
- a66fad5 - @vjeux - Updates from Fri 20 Mar -
- vjeux authored - -
-
193 '../Libraries/CustomComponents/ListView/ListView.js',
- 28aa691 - @vjeux - Updates from Fri 13 Mar -
- vjeux authored - -
-
194 '../Libraries/Components/MapView/MapView.js',
- 51b1f39 - @sahrens - Update auto gen docs -
- sahrens authored - -
-
195 '../Libraries/Modal/Modal.js',
- fab8e38 - @spicyj - Fix ABC order of docs nav -
- spicyj authored - -
-
196 '../Libraries/CustomComponents/Navigator/Navigator.js',
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
197 '../Libraries/Components/Navigation/NavigatorIOS.ios.js',
- 28aa691 - @vjeux - Updates from Fri 13 Mar -
- vjeux authored - -
-
198 '../Libraries/Picker/PickerIOS.ios.js',
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
199 '../Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js',
- 51b1f39 - @sahrens - Update auto gen docs -
- sahrens authored - -
-
200 '../Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js',
- f87b0cb - @vjeux - [Website] Add a link when composing prop types -
- vjeux authored - -
-
201 '../Libraries/Components/ScrollView/ScrollView.js',
- 1c05aff - @umhan35 - Add SegmentedControlIOS documentation to website -
- umhan35 authored - -
-
202 '../Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js',
- 5ebe0ed - @vjeux - Bust jest caching and fix tests -
- vjeux authored - -
-
203 '../Libraries/Components/SliderIOS/SliderIOS.ios.js',
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
204 '../Libraries/Components/SwitchAndroid/SwitchAndroid.android.js',
- 83581cf - @vjeux - Initial import of the lib to parse javascript code, in the same vein … -
- vjeux authored - -
-
205 '../Libraries/Components/SwitchIOS/SwitchIOS.ios.js',
206 '../Libraries/Components/TabBarIOS/TabBarIOS.ios.js',
- 9ee6cd6 - @brentvatne - [Docs] Add TabBarIOS.Item to docs -
- brentvatne authored - -
-
207 '../Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js',
- f77d9f8 - @fkling - Update react-docgen -
- fkling authored - -
-
208 '../Libraries/Text/Text.js',
- ed7b5cb - @vjeux - Fix docs -
- vjeux authored - -
-
209 '../Libraries/Components/TextInput/TextInput.js',
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
210 '../Libraries/Components/ToolbarAndroid/ToolbarAndroid.android.js',
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
211 '../Libraries/Components/Touchable/TouchableHighlight.js',
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
212 '../Libraries/Components/Touchable/TouchableNativeFeedback.android.js',
- b9ab607 - @vjeux - Use docs/ComponentName.md at the end of the component docs -
- vjeux authored - -
-
213 '../Libraries/Components/Touchable/TouchableOpacity.js',
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
214 '../Libraries/Components/Touchable/TouchableWithoutFeedback.js',
- 472c287 - @fkling - Update react-docgen and ignore pages with no header -
- fkling authored - -
-
215 '../Libraries/Components/View/View.js',
- b39b975 - @brentvatne - [Docs] Add ViewPagerAndroid to extractDocs -
- brentvatne authored - -
-
216 '../Libraries/Components/ViewPager/ViewPagerAndroid.android.js',
- 55598f9 - @vjeux - [website] Expose all the functions exported by react-native in the docs -
- vjeux authored - -
-
217 '../Libraries/Components/WebView/WebView.ios.js',
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
218];
219
- 83581cf - @vjeux - Initial import of the lib to parse javascript code, in the same vein … -
- vjeux authored - -
-
220var apis = [
- 13579d9 - @umhan35 - Add ActionSheetIOS to website -
- umhan35 authored - -
-
221 '../Libraries/ActionSheetIOS/ActionSheetIOS.js',
- 55598f9 - @vjeux - [website] Expose all the functions exported by react-native in the docs -
- vjeux authored - -
-
222 '../Libraries/Utilities/AlertIOS.js',
- 00ceec9 - @vjeux - Fix website with Animated -
- vjeux authored - -
-
223 '../Libraries/Animated/src/AnimatedImplementation.js',
- 28aa691 - @vjeux - Updates from Fri 13 Mar -
- vjeux authored - -
-
224 '../Libraries/AppRegistry/AppRegistry.js',
225 '../Libraries/AppStateIOS/AppStateIOS.ios.js',
- 38398bc - @chirag04 - fix website build after asyncstorage changes. -
- chirag04 authored - -
-
226 '../Libraries/Storage/AsyncStorage.js',
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
227 '../Libraries/Utilities/BackAndroid.android.js',
- 33bfb32 - @vjeux - Wire up jsdocs for apis -
- vjeux authored - -
-
228 '../Libraries/CameraRoll/CameraRoll.js',
- 36f015c - @brentvatne - [Docs] Add Dimensions to API docs -
- brentvatne authored - -
-
229 '../Libraries/Utilities/Dimensions.js',
- 55598f9 - @vjeux - [website] Expose all the functions exported by react-native in the docs -
- vjeux authored - -
-
230 '../Libraries/Interaction/InteractionManager.js',
- 480b5c9 - @mkonicek - [website] Fix website generation -
- mkonicek authored - -
-
231 '../Libraries/LayoutAnimation/LayoutAnimation.js',
- df7d9c2 - @tadeuzagallo - [ReactNative][Docs] Add docs to LinkingIOS -
- tadeuzagallo authored - -
-
232 '../Libraries/LinkingIOS/LinkingIOS.js',
- 2d7747e - @mkonicek - Add NativeMethodsMixin docs to website -
- - mkonicek authored - -
-
233 '../Libraries/ReactIOS/NativeMethodsMixin.js',
- 55598f9 - @vjeux - [website] Expose all the functions exported by react-native in the docs -
- vjeux authored - -
-
234 '../Libraries/Network/NetInfo.js',
- d7d7e99 - @vjeux - Add new files to docs -
- vjeux authored - -
-
235 '../Libraries/vendor/react/browser/eventPlugins/PanResponder.js',
- 33bfb32 - @vjeux - Wire up jsdocs for apis -
- vjeux authored - -
-
236 '../Libraries/Utilities/PixelRatio.js',
- d7d7e99 - @vjeux - Add new files to docs -
- vjeux authored - -
-
237 '../Libraries/PushNotificationIOS/PushNotificationIOS.js',
- 33bfb32 - @vjeux - Wire up jsdocs for apis -
- vjeux authored - -
-
238 '../Libraries/Components/StatusBar/StatusBarIOS.ios.js',
239 '../Libraries/StyleSheet/StyleSheet.js',
- 42eb546 - @mkonicek - Release React Native for Android -
- - mkonicek authored - -
-
240 '../Libraries/Components/ToastAndroid/ToastAndroid.android.js',
- 55598f9 - @vjeux - [website] Expose all the functions exported by react-native in the docs -
- vjeux authored - -
-
241 '../Libraries/Vibration/VibrationIOS.ios.js',
- 83581cf - @vjeux - Initial import of the lib to parse javascript code, in the same vein … -
- vjeux authored - -
-
242];
243
- d5f670d - @fkling - Add logic to show style props in docs -
- fkling authored - -
-
244var styles = [
245 '../Libraries/StyleSheet/LayoutPropTypes.js',
- b8ca4e4 - @brentvatne - Add TransformPropTypes to docs -
- brentvatne authored - -
-
246 '../Libraries/StyleSheet/TransformPropTypes.js',
- d5f670d - @fkling - Add logic to show style props in docs -
- fkling authored - -
-
247 '../Libraries/Components/View/ViewStylePropTypes.js',
248 '../Libraries/Text/TextStylePropTypes.js',
249 '../Libraries/Image/ImageStylePropTypes.js',
250];
251
- 4681da5 - @vjeux - Add geolocation polyfill -
- vjeux authored - -
-
252var polyfills = [
- 8465859 - @sahrens - Fix doc generation for Geolocation -
- sahrens authored - -
-
253 '../Libraries/GeoLocation/Geolocation.js',
- 4681da5 - @vjeux - Add geolocation polyfill -
- vjeux authored - -
-
254];
255
256var all = components
257 .concat(apis)
- b8ca4e4 - @brentvatne - Add TransformPropTypes to docs -
- brentvatne authored - -
-
258 .concat(styles.slice(0, 2))
- 4681da5 - @vjeux - Add geolocation polyfill -
- vjeux authored - -
-
259 .concat(polyfills);
260
- b8ca4e4 - @brentvatne - Add TransformPropTypes to docs -
- brentvatne authored - -
-
261var styleDocs = styles.slice(2).reduce(function(docs, filepath) {
- d5f670d - @fkling - Add logic to show style props in docs -
- fkling authored - -
-
262 docs[path.basename(filepath).replace(path.extname(filepath), '')] =
263 docgen.parse(
264 fs.readFileSync(filepath),
265 docgenHelpers.findExportedObject,
- 627d5a8 - @browniefed - Fix documentation by adding propTypeCompositionHandler -
- browniefed authored - -
-
266 [docgen.handlers.propTypeHandler, docgen.handlers.propTypeCompositionHandler]
- d5f670d - @fkling - Add logic to show style props in docs -
- fkling authored - -
-
267 );
- 77a3190 - @brentvatne - [Docs] Remove deprecated styleProps -
- brentvatne authored - -
-
268
- d5f670d - @fkling - Add logic to show style props in docs -
- fkling authored - -
-
269 return docs;
270}, {});
- 33bfb32 - @vjeux - Wire up jsdocs for apis -
- vjeux authored - -
-
271
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
272module.exports = function() {
- 4681da5 - @vjeux - Add geolocation polyfill -
- vjeux authored - -
-
273 n = 0;
- 33bfb32 - @vjeux - Wire up jsdocs for apis -
- vjeux authored - -
-
274 return [].concat(
- 4681da5 - @vjeux - Add geolocation polyfill -
- vjeux authored - -
-
275 components.map(renderComponent),
276 apis.map(renderAPI('api')),
- b8ca4e4 - @brentvatne - Add TransformPropTypes to docs -
- brentvatne authored - -
-
277 styles.slice(0, 2).map(renderStyle),
- 4681da5 - @vjeux - Add geolocation polyfill -
- vjeux authored - -
-
278 polyfills.map(renderAPI('Polyfill'))
- 33bfb32 - @vjeux - Wire up jsdocs for apis -
- vjeux authored - -
-
279 );
- 70f2833 - @vjeux - Initial version of the automatically generated docs -
- - vjeux authored - -
-
280};
-
-
- - -
- -
- -
-
- -
- -
- -
- - - - - - - -
- - - Something went wrong with that request. Please try again. -
- - - - - - - - - - - diff --git a/cache/https---github.com-facebook-react-native-pull-3229.diff b/cache/https---github.com-facebook-react-native-pull-3229.diff deleted file mode 100644 index d7d2850..0000000 --- a/cache/https---github.com-facebook-react-native-pull-3229.diff +++ /dev/null @@ -1,366 +0,0 @@ -diff --git a/Libraries/WebSocket/WebSocket.ios.js b/Libraries/WebSocket/WebSocket.ios.js -index c2318b4..c09b931 100644 ---- a/Libraries/WebSocket/WebSocket.ios.js -+++ b/Libraries/WebSocket/WebSocket.ios.js -@@ -16,16 +16,12 @@ var RCTWebSocketManager = require('NativeModules').WebSocketManager; - - var WebSocketBase = require('WebSocketBase'); - --class Event { -- constructor(type) { -- this.type = type.toString(); -- } --} -- --class MessageEvent extends Event { -+class WebsocketEvent { - constructor(type, eventInitDict) { -- super(type); -- Object.assign(this, eventInitDict); -+ this.type = type.toString(); -+ if (typeof eventInitDict === 'object') { -+ Object.assign(this, eventInitDict); -+ } - } - } - -@@ -67,56 +63,60 @@ class WebSocket extends WebSocketBase { - this._subs = [ - RCTDeviceEventEmitter.addListener( - 'websocketMessage', -- function(ev) { -+ ev => { - if (ev.id !== id) { - return; - } -- var event = new MessageEvent('message', { -- data: ev.data -+ var event = new WebsocketEvent('message', { -+ data: ev.data, - }); -- this.onmessage && this.onmessage(event); - this.dispatchEvent(event); -- }.bind(this) -+ }, - ), - RCTDeviceEventEmitter.addListener( - 'websocketOpen', -- function(ev) { -+ ev => { - if (ev.id !== id) { - return; - } - this.readyState = this.OPEN; -- var event = new Event('open'); -- this.onopen && this.onopen(event); -+ var event = new WebsocketEvent('open'); - this.dispatchEvent(event); -- }.bind(this) -+ } - ), - RCTDeviceEventEmitter.addListener( - 'websocketClosed', -- function(ev) { -+ (ev) => { - if (ev.id !== id) { - return; - } - this.readyState = this.CLOSED; -- var event = new Event('close'); -- this.onclose && this.onclose(event); -+ var event = new WebsocketEvent('close'); - this.dispatchEvent(event); -+ - this._unregisterEvents(); - RCTWebSocketManager.close(id); -- }.bind(this) -+ } - ), - RCTDeviceEventEmitter.addListener( - 'websocketFailed', -- function(ev) { -+ (ev) => { - if (ev.id !== id) { - return; - } -- var event = new Event('error'); -- event.message = ev.message; -- this.onerror && this.onerror(event); -- this.dispatchEvent(event); -+ this.readyState = this.CLOSED; -+ -+ var closeEvent = new WebsocketEvent('close'); -+ this.dispatchEvent(closeEvent); -+ -+ var errorEvent = new WebsocketEvent('error', { -+ message: ev.message, -+ }); -+ this.dispatchEvent(errorEvent); -+ - this._unregisterEvents(); - RCTWebSocketManager.close(id); -- }.bind(this) -+ } - ) - ]; - } -diff --git a/Libraries/WebSocket/WebSocketBase.js b/Libraries/WebSocket/WebSocketBase.js -index a4cca41..f6cff0e 100644 ---- a/Libraries/WebSocket/WebSocketBase.js -+++ b/Libraries/WebSocket/WebSocketBase.js -@@ -16,17 +16,12 @@ var EventTarget = require('event-target-shim'); - /** - * Shared base for platform-specific WebSocket implementations. - */ --class WebSocketBase extends EventTarget { -+class WebSocketBase extends EventTarget('close', 'error', 'message', 'open') { - CONNECTING: number; - OPEN: number; - CLOSING: number; - CLOSED: number; - -- onclose: ?Function; -- onerror: ?Function; -- onmessage: ?Function; -- onopen: ?Function; -- - binaryType: ?string; - bufferedAmount: number; - extension: ?string; -@@ -41,6 +36,8 @@ class WebSocketBase extends EventTarget { - this.CLOSING = 2; - this.CLOSED = 3; - -+ this.readyState = this.CONNECTING; -+ - if (!protocols) { - protocols = []; - } -diff --git a/Libraries/WebSocket/__mocks__/event-target-shim.js b/Libraries/WebSocket/__mocks__/event-target-shim.js -deleted file mode 100644 -index 3b566fc..0000000 ---- a/Libraries/WebSocket/__mocks__/event-target-shim.js -+++ /dev/null -@@ -1,9 +0,0 @@ --// Jest fatals for the following statement (minimal repro case) --// --// exports.something = Symbol; --// --// Until it is fixed, mocking the entire node module makes the --// problem go away. -- --'use strict'; --module.exports = function() {}; -diff --git a/Libraries/WebSocket/__tests__/Websocket-test.js b/Libraries/WebSocket/__tests__/Websocket-test.js -new file mode 100644 -index 0000000..d062ed9 ---- /dev/null -+++ b/Libraries/WebSocket/__tests__/Websocket-test.js -@@ -0,0 +1,207 @@ -+/** -+ * Copyright (c) 2015-present, Facebook, Inc. -+ * All rights reserved. -+ * -+ * This source code is licensed under the BSD-style license found in the -+ * LICENSE file in the root directory of this source tree. An additional grant -+ * of patent rights can be found in the PATENTS file in the same directory. -+ */ -+'use strict'; -+ -+jest -+ .autoMockOff() -+ .mock('ErrorUtils') -+ .setMock('NativeModules', { -+ WebSocketManager: { -+ connect: jest.genMockFunction(), -+ close: jest.genMockFunction(), -+ send: jest.genMockFunction(), -+ }, -+ }); -+ -+var readyStates = { -+ CONNECTING: 0, -+ OPEN: 1, -+ CLOSING: 2, -+ CLOSED: 3, -+}; -+ -+var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -+var RCTWebSocketManager = require('NativeModules').WebSocketManager; -+ -+var WebSocket = require('WebSocket'); -+ -+// Small utils to keep it DRY -+var simulateEvent = (ws, event, data = {}) => { -+ RCTDeviceEventEmitter.emit(event, {id: ws._socketId, ...data}); -+}; -+var expectOneCall = fn => expect(fn.mock.calls.length).toBe(1); -+var getSocket = () => new WebSocket('ws://echo.websocket.org'); -+ -+describe('WebSockets', () => { -+ beforeEach(() => { -+ // Reset RCTWebSocketManager calls -+ Object.assign(RCTWebSocketManager, { -+ connect: jest.genMockFunction(), -+ close: jest.genMockFunction(), -+ send: jest.genMockFunction(), -+ }); -+ }); -+ -+ it('should have readyState CONNECTING initialy', () => { -+ var ws = getSocket(); -+ expect(ws.readyState).toBe(readyStates.CONNECTING); -+ }); -+ -+ // Open event -+ it('Should call native connect when connecting', () => { -+ var ws = getSocket(); -+ ws.onopen = jest.genMockFunction(); -+ -+ expectOneCall(RCTWebSocketManager.connect); -+ }); -+ -+ it('should have readyState OPEN when connected', () => { -+ var ws = getSocket(); -+ simulateEvent(ws, 'websocketOpen'); -+ expect(ws.readyState).toBe(readyStates.OPEN); -+ }); -+ -+ it('should call onopen when connected', () => { -+ var ws = getSocket(); -+ ws.onopen = jest.genMockFunction(); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ -+ expectOneCall(ws.onopen); -+ }); -+ -+ it('should trigger listener when connected', () => { -+ var ws = getSocket(); -+ var listener = jest.genMockFunction(); -+ ws.addEventListener('open', listener); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ -+ expectOneCall(listener); -+ }); -+ -+ // Sending message -+ it('should call native send when sending a message', () => { -+ var ws = getSocket(); -+ simulateEvent(ws, 'websocketOpen'); -+ var message = 'Hello websocket!'; -+ -+ ws.send(message); -+ -+ expectOneCall(RCTWebSocketManager.send); -+ expect(RCTWebSocketManager.send.mock.calls[0]) -+ .toEqual([message, ws._socketId]); -+ }); -+ -+ it('should call onmessage when receiving a message', () => { -+ var ws = getSocket(); -+ var message = 'Hello listener!'; -+ ws.onmessage = jest.genMockFunction(); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketMessage', {data: message}); -+ -+ expectOneCall(ws.onmessage); -+ expect(ws.onmessage.mock.calls[0][0].data).toBe(message); -+ }); -+ -+ it('should trigger listeners when recieving a message', () => { -+ var ws = getSocket(); -+ var message = 'Hello listener!'; -+ var listener = jest.genMockFunction(); -+ ws.addEventListener('message', listener); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketMessage', {data: message}); -+ -+ expectOneCall(listener); -+ expect(listener.mock.calls[0][0].data).toBe(message); -+ }); -+ -+ // Close event -+ it('should have readyState CLOSED when closed', () => { -+ var ws = getSocket(); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketClosed'); -+ -+ expect(ws.readyState).toBe(readyStates.CLOSED); -+ }); -+ -+ it('should call onclose when closed', () => { -+ var ws = getSocket(); -+ ws.onclose = jest.genMockFunction(); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketClosed'); -+ -+ expectOneCall(ws.onclose); -+ }); -+ -+ it('should trigger listeners when closed', () => { -+ var ws = getSocket(); -+ var listener = jest.genMockFunction(); -+ ws.addEventListener('close', listener); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketClosed'); -+ -+ expectOneCall(listener); -+ }); -+ -+ it('should call native close when closed', () => { -+ var ws = getSocket(); -+ -+ simulateEvent(ws, 'websocketOpen'); -+ simulateEvent(ws, 'websocketClosed'); -+ -+ expectOneCall(RCTWebSocketManager.close); -+ expect(RCTWebSocketManager.close.mock.calls[0]).toEqual([ws._socketId]); -+ }); -+ -+ // Fail event -+ it('should have readyState CLOSED when failed', () => { -+ var ws = getSocket(); -+ simulateEvent(ws, 'websocketFailed'); -+ expect(ws.readyState).toBe(readyStates.CLOSED); -+ }); -+ -+ it('should call native close when failed', () => { -+ var ws = getSocket(); -+ -+ simulateEvent(ws, 'websocketFailed'); -+ -+ expectOneCall(RCTWebSocketManager.close); -+ expect(RCTWebSocketManager.close.mock.calls[0]).toEqual([ws._socketId]); -+ }); -+ -+ it('should call onerror and onclose when failed', () => { -+ var ws = getSocket(); -+ ws.onclose = jest.genMockFunction(); -+ ws.onerror = jest.genMockFunction(); -+ -+ simulateEvent(ws, 'websocketFailed'); -+ -+ expectOneCall(ws.onclose); -+ expectOneCall(ws.onerror); -+ }); -+ -+ it('should call onerror and onclose when failed', () => { -+ var ws = getSocket(); -+ var onclose = jest.genMockFunction(); -+ var onerror = jest.genMockFunction(); -+ ws.addEventListener('close', onclose); -+ ws.addEventListener('error', onerror); -+ -+ simulateEvent(ws, 'websocketFailed'); -+ -+ expectOneCall(onclose); -+ expectOneCall(onerror); -+ }); -+}); diff --git a/cache/https---github.com-facebook-react-native-pull-3238.diff b/cache/https---github.com-facebook-react-native-pull-3238.diff deleted file mode 100644 index 8b0507c..0000000 --- a/cache/https---github.com-facebook-react-native-pull-3238.diff +++ /dev/null @@ -1,99 +0,0 @@ -diff --git a/Libraries/ReactIOS/NativeMethodsMixin.js b/Libraries/ReactIOS/NativeMethodsMixin.js -index afc79f7..59de859 100644 ---- a/Libraries/ReactIOS/NativeMethodsMixin.js -+++ b/Libraries/ReactIOS/NativeMethodsMixin.js -@@ -37,8 +37,38 @@ type MeasureLayoutOnSuccessCallback = ( - height: number - ) => void - -+/** -+ * NativeMethodsMixin provides methods that bypass the React rendering process -+ * and are passed through directly to the underlying native component. This -+ * allows side effects to be performed and actions to be taken that don't fit -+ * into the React model directly. -+ * -+ * The methods described here are available on most of the default components -+ * provided by React Native, and components that extend them. Note however that -+ * they are *not* available on composite components that aren't directly backed -+ * by a native view. This will generally include most components that you define -+ * in your own app. For more information, see [Direct -+ * Manipulation](/react-native/docs/direct-manipulation.html). -+ */ - - var NativeMethodsMixin = { -+ /** -+ * Determines the location on screen, width, and height of the given view and -+ * returns the values via an async callback. If successful, the callback will -+ * be called with the following arguments: -+ * -+ * - x -+ * - y -+ * - width -+ * - height -+ * - pageX -+ * - pageY -+ * -+ * Note that these measurements are currently not available until after the -+ * first rendering has been completed. If you need the measurements as soon as -+ * possible, consider instead using the [`onLayout` -+ * prop](/react-native/docs/view.html#onlayout). -+ */ - measure: function(callback: MeasureOnSuccessCallback) { - RCTUIManager.measure( - findNodeHandle(this), -@@ -46,6 +76,11 @@ var NativeMethodsMixin = { - ); - }, - -+ /** -+ * Like [`measure()`](#measure), but measures the view specified by tag -+ * relative to the given `relativeToNativeNode`. This means that the returned -+ * x, y are relative to the origin x, y of the ancestor view. -+ */ - measureLayout: function( - relativeToNativeNode: number, - onSuccess: MeasureLayoutOnSuccessCallback, -@@ -60,9 +95,10 @@ var NativeMethodsMixin = { - }, - - /** -- * This function sends props straight to native. They will not participate -- * in future diff process, this means that if you do not include them in the -- * next render, they will remain active. -+ * This function sends props straight to native. They will not participate in -+ * future diff process -- this means that if you do not include them in the -+ * next render, they will remain active (see [Direct -+ * Manipulation](/react-native/docs/direct-manipulation.html)). - */ - setNativeProps: function(nativeProps: Object) { - // nativeProps contains a style attribute that's going to be flattened -@@ -114,10 +150,17 @@ var NativeMethodsMixin = { - ); - }, - -+ /** -+ * Requests focus for the given input or view. The exact behavior triggered -+ * will depend on the platform and type of view. -+ */ - focus: function() { - TextInputState.focusTextInput(findNodeHandle(this)); - }, - -+ /** -+ * Blurs the given input or view. This is the opposite of `focus()`. -+ */ - blur: function() { - TextInputState.blurTextInput(findNodeHandle(this)); - } -diff --git a/website/server/extractDocs.js b/website/server/extractDocs.js -index 867fdfa..7ce11d5 100644 ---- a/website/server/extractDocs.js -+++ b/website/server/extractDocs.js -@@ -228,6 +228,7 @@ var apis = [ - '../Libraries/Interaction/InteractionManager.js', - '../Libraries/LayoutAnimation/LayoutAnimation.js', - '../Libraries/LinkingIOS/LinkingIOS.js', -+ '../Libraries/ReactIOS/NativeMethodsMixin.js', - '../Libraries/Network/NetInfo.js', - '../Libraries/vendor/react/browser/eventPlugins/PanResponder.js', - '../Libraries/Utilities/PixelRatio.js', diff --git a/cache/https---github.com-fbsamples-bot-testing-blame-master-hello-world.js b/cache/https---github.com-fbsamples-bot-testing-blame-master-hello-world.js deleted file mode 100644 index 59f0bef..0000000 --- a/cache/https---github.com-fbsamples-bot-testing-blame-master-hello-world.js +++ /dev/null @@ -1 +0,0 @@ -{"error":"Not Found"} \ No newline at end of file diff --git a/cache/https---github.com-fbsamples-bot-testing-pull-95.diff b/cache/https---github.com-fbsamples-bot-testing-pull-95.diff deleted file mode 100644 index d787882..0000000 --- a/cache/https---github.com-fbsamples-bot-testing-pull-95.diff +++ /dev/null @@ -1,7 +0,0 @@ -diff --git a/hello-world.js b/hello-world.js -new file mode 100644 -index 0000000..a420803 ---- /dev/null -+++ b/hello-world.js -@@ -0,0 +1 @@ -+console.log('Hello World!'); diff --git a/cookieJar.js b/cookieJar.js deleted file mode 100644 index 691fe5b..0000000 --- a/cookieJar.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @flow - */ - -'use strict'; - -class CookieJar { - cookies: { [key: string]: string }; - - constructor() { - this.cookies = {}; - } - - /** - * Serializes stored cookies into http header format - */ - get(): string { - return Object.keys(this.cookies) - .map(function(key) { - let str = key; - if (this.cookies[key]) { - str += '=' + this.cookies[key]; - } - return str; - }, this) - .join('; '); - } - - /** - * Parses a single header line of cookie, parses them, and stores them in a hash - */ - parseCookieHeader(headerLine: string) { - headerLine.split(';') - .forEach(function(cookie) { - var pair = cookie.split('='); - this.cookies[pair[0]] = pair[1]; - }, this); - } - - /** - * Finds Set-Cookie header in resp headers and adds them to the jar - * Returns all stored cookies where the new cookies overwrite previous cookies - */ - - parseHeaders(headers: string) { - if (!headers) { - return; - } - headers.split('\n') - .filter(function(line) { - return line.split('Set-Cookie').length > 1; - }) - .forEach(function(line) { - this.parseCookieHeader(line.split('Set-Cookie: ')[1].trim()); - }, this); - return this.get(); - } -} - -module.exports = CookieJar; diff --git a/githubAuthCookies.js b/githubAuthCookies.js deleted file mode 100644 index 03e262f..0000000 --- a/githubAuthCookies.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @flow - */ - -'use strict'; -var USERNAME = process.env.GITHUB_USER; -var PASSWORD = process.env.GITHUB_PASSWORD; -var config = require('./config'); -var childProcess = require('child_process'); -var CookieJar = require('./cookieJar'); -var jar = new CookieJar(); - -var ghHost = config.github.host -var ghProtocol = config.github.protocol - -/** - * Scrape github login page - */ -var githubLogin = function() { - var output = childProcess.execSync( - `curl -v -L ${ghProtocol}://${ghHost}/login 2>&1`, - {encoding: 'utf8'} - ).toString().split(''); - - return { - headers: output[0], - body: output[1] - }; -}; - - -/** - * gets a CSRF token by hitting github's login form - * returns CSRF token - */ -var getAuthenticityToken = function() { - var login = githubLogin(); - jar.parseHeaders(login.headers); - return encodeURIComponent( - (login.body.match(/name="authenticity_token".*value="([^"]+)"/) || [''])[1] - ); -}; - -/** - * runs curl request to perform login action - * returns github response headers - */ -var getGithubLoginResponseHeaders = function(): string { - var authenticity_token = getAuthenticityToken(); - var commandArr = [ - `${ghProtocol}://${ghHost}/session`, - `--silent`, - `-v`, - `-d`, `utf8=%E2%9C%93&authenticity_token=${authenticity_token}`, - `-d`, `login=${USERNAME}`, - `--data-urlencode`, `password=${PASSWORD}`, - `-H`, `Pragma: no-cache`, - `-H`, `Origin: ${ghProtocol}://${ghHost}`, - `-H`, `Accept-Encoding: gzip, deflate`, - `-H`, `Accept-Language: en-US,en;q=0.8`, - `-H`, `Upgrade-Insecure-Requests: 1`, - `-H`, `User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36`, - `-H`, `Content-Type: application/x-www-form-urlencoded`, - `-H`, `Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8`, - `-H`, `Cache-Control: no-cache`, - `-H`, `Referer: ${ghProtocol}://${ghHost}/`, - `-H`, `Cookie: ${jar.get()}`, - `-H`, `Connection: keep-alive`, - ]; - - return childProcess.spawnSync( - 'curl', - commandArr, - {encoding: 'utf8'} - ).stderr.toString(); -}; - -if (USERNAME) { - var headers = getGithubLoginResponseHeaders(); - jar.parseHeaders(headers); - if (jar.cookies['logged_in'] === 'no') { - console.error(`Login to ${USERNAME} failed`); - } - - module.exports = jar.get(); -} else { - module.exports = null; -} diff --git a/mention-bot.js b/mention-bot.js index fd5bae4..7454809 100644 --- a/mention-bot.js +++ b/mention-bot.js @@ -11,234 +11,13 @@ 'use strict'; -var githubAuthCookies = require('./githubAuthCookies'); -var fs = require('fs'); var minimatch = require('minimatch'); -async function downloadFileAsync(url: string, cookies: ?string): Promise { - return new Promise(function(resolve, reject) { - var args = ['--silent', '-L', url]; - - if (cookies) { - args.push('-H', `Cookie: ${cookies}`); - } - - require('child_process') - .execFile('curl', args, {encoding: 'utf8', maxBuffer: 1000 * 1024 * 10}, function(error, stdout, stderr) { - if (error) { - reject(error); - } else { - resolve(stdout.toString()); - } - }); - }); -} - -async function readFileAsync(name: string, encoding: string): Promise { - return new Promise(function(resolve, reject) { - fs.readFile(name, encoding, function(err, data) { - if (err) { - reject(err); - } else { - resolve(data); - } - }); - }); -} - -type FileInfo = { - path: string, - deletedLines: Array, -}; - type WhitelistUser = { name: string, files: Array }; -function startsWith(str, start) { - return str.substr(0, start.length) === start; -} - -function parseDiffFile(lines: Array): FileInfo { - var deletedLines = []; - - // diff --git a/path b/path - var line = lines.pop(); - if (!line.match(/^diff --git a\//)) { - throw new Error('Invalid line, should start with `diff --git a/`, instead got \n' + line + '\n'); - } - var fromFile = line.replace(/^diff --git a\/(.+) b\/.+/g, '$1'); - - // index sha..sha mode - line = lines.pop(); - if (startsWith(line, 'deleted file') || - startsWith(line, 'new file')) { - line = lines.pop(); - } - - line = lines.pop(); - if (!line) { - // If the diff ends in an empty file with 0 additions or deletions, line will be null - } else if (startsWith(line, 'diff --git')) { - lines.push(line); - } else if (startsWith(line, 'Binary files')) { - // We just ignore binary files (mostly images). If we want to improve the - // precision in the future, we could look at the history of those files - // to get more names. - } else if (startsWith(line, '--- ')) { - // +++ path - line = lines.pop(); - if (!line.match(/^\+\+\+ /)) { - throw new Error('Invalid line, should start with `+++`, instead got \n' + line + '\n'); - } - - var currentFromLine = 0; - while (lines.length > 0) { - line = lines.pop(); - if (startsWith(line, 'diff --git')) { - lines.push(line); - break; - } - - // @@ -from_line,from_count +to_line,to_count @@ first line - if (startsWith(line, '@@')) { - var matches = line.match(/^\@\@ -([0-9]+),?([0-9]+)? \+([0-9]+),?([0-9]+)? \@\@/); - if (!matches) { - continue; - } - - var from_line = matches[1]; - var from_count = matches[2]; - var to_line = matches[3]; - var to_count = matches[4]; - - currentFromLine = +from_line; - continue; - } - - if (startsWith(line, '-')) { - deletedLines.push(currentFromLine); - } - if (!startsWith(line, '+')) { - currentFromLine++; - } - } - } - - return { - path: fromFile, - deletedLines: deletedLines, - }; -} - -function parseDiff(diff: string): Array { - var files = []; - // The algorithm is designed to be best effort. If the http request failed - // for some reason and we get an empty file, we should not crash. - if (!diff || !diff.match(/^diff/)) { - return files; - } - - var lines = diff.trim().split('\n'); - // Hack Array doesn't have shift/unshift to work from the beginning of the - // array, so we reverse the entire array in order to be able to use pop/add. - lines.reverse(); - - while (lines.length > 0) { - files.push(parseDiffFile(lines)); - } - - return files; -} - -/** - * Sadly, github doesn't have an API to get line by line blame for a file. - * We could git clone the repo and blame, but it's annoying to have to - * maintain a local git repo and the blame is going to be name + email instead - * of the github username, so we'll have to do a http request anyway. - * - * There are two main ways to extract information from an HTML file: - * - First is to work like a browser: parse the html, build a DOM tree and - * use a jQuery-like API to traverse the DOM and extract what you need. - * The big issue is that creating the DOM is --extremely-- slow. - * - Second is to use regex to analyze the outputted html and find whatever - * we want. - * - * I(vjeux)'ve scraped hundreds of websites using both techniques and both of - * them have the same reliability when it comes to the website updating their - * markup. If they change what you are extracting you are screwed and if they - * change something around, both are resistant to it when written properly. - * So, might as well use the fastest one of the two: regex :) - */ -function parseBlame(blame: string): Array { - // The way the document is structured is that commits and lines are - // interleaved. So every time we see a commit we grab the author's name - // and every time we see a line we log the last seen author. - var re = /(rel="(?:author|contributor)">([^<]+)<\/a> authored|)/g; - - var currentAuthor = 'none'; - var lines = []; - var match; - while (match = re.exec(blame)) { - if (match[2]) { - currentAuthor = match[2]; - } else { - lines.push(currentAuthor); - } - } - - return lines; -} - -function getDeletedOwners( - files: Array, - blames: { [key: string]: Array } -): { [key: string]: number } { - var owners = {}; - files.forEach(function(file) { - var blame = blames[file['path']]; - if (!blame) { - return; - } - file.deletedLines.forEach(function (line) { - // In a perfect world, this should never fail. However, in practice, the - // blame request may fail, the blame is checking against master and the - // pull request isn't, the blame file was too big and the curl wrapper - // only read the first n bytes... - // Since the output of the algorithm is best effort, it's better to just - // swallow errors and have a less accurate implementation than to crash. - var name = blame[line - 1]; - if (!name) { - return; - } - owners[name] = (owners[name] || 0) + 1; - }); - }); - return owners; -} - -function getAllOwners( - files: Array, - blames: { [key: string]: Array } -): { [key: string]: number } { - var owners = {}; - files.forEach(function(file) { - var blame = blames[file.path]; - if (!blame) { - return; - } - for (var i = 0; i < blame.length; ++i) { - var name = blame[i]; - if (!name) { - return; - } - owners[name] = (owners[name] || 0) + 1; - } - }); - return owners; -} - function getSortedOwners( owners: { [key: string]: number } ): Array { @@ -252,7 +31,7 @@ function getSortedOwners( } function getMatchingOwners( - files: Array, + files: Array, whitelist: Array ): Array { var owners = []; @@ -264,7 +43,7 @@ function getMatchingOwners( user.files.forEach(function(pattern) { if (!userHasChangedFile) { userHasChangedFile = files.find(function(file) { - return minimatch(file.path, pattern); + return minimatch(file, pattern); }); } }); @@ -277,28 +56,55 @@ function getMatchingOwners( return owners; } -/** - * While developing/debugging the algorithm itself, it's very important not to - * make http requests to github. Not only it's going to make the reload cycle - * much slower, it's also going to temporary/permanently ban your ip and - * you won't be able to get anymore work done when it happens :( - */ -async function fetch(url: string): Promise { - if (!module.exports.enableCachingForDebugging) { - return downloadFileAsync(url, githubAuthCookies); - } - - var cacheDir = __dirname + '/cache/'; +async function getFilesPath( + user: string, + repo: string, + number: number, + github: Object +): Promise> { + return new Promise(function(resolve, reject) { + github.pullRequests.getFiles({ + user: user, repo: repo, number: number + }, function(err, result) { + if (err) { + reject(err); + } else { + resolve(result.map(function(file) { + return file.filename; + })); + } + }); + }); +} - if (!fs.existsSync(cacheDir)) { - fs.mkdir(cacheDir); - } - var cache_key = cacheDir + url.replace(/[^a-zA-Z0-9-_\.]/g, '-'); - if (!fs.existsSync(cache_key)) { - var file = await downloadFileAsync(url, githubAuthCookies); - fs.writeFileSync(cache_key, file); - } - return readFileAsync(cache_key, 'utf8'); +async function getCommitsAuthors( + user: string, + repo: string, + path: string, + github: Object +): Promise> { + return new Promise(function(resolve, reject) { + github.repos.getCommits({ + user: user, repo: repo, path: path + }, function (err, result) { + if (err) { + reject(err); + } else { + resolve(result.reduce(function(acc, commit) { + if (!commit.author) { + // Safeguard against missing authors + return acc; + } + if (acc.has(commit.author.login)) { + acc.set(commit.author.login, acc.get(commit.author.login) + 1); + } else { + acc.set(commit.author.login, 1); + } + return acc; + }, new Map())); + } + }); + }); } async function getOwnerOrgs( @@ -418,8 +224,7 @@ async function filterPrivateRepo( * them, concat them and finally take the first 3 names. */ async function guessOwners( - files: Array, - blames: { [key: string]: Array }, + owners: { [key: string]: number }, creator: string, defaultOwners: Array, fallbackOwners: Array, @@ -428,25 +233,9 @@ async function guessOwners( config: Object, github: Object ): Promise> { - var deletedOwners = getDeletedOwners(files, blames); - var allOwners = getAllOwners(files, blames); - - deletedOwners = getSortedOwners(deletedOwners); - allOwners = getSortedOwners(allOwners); - - // Remove owners that are also in deletedOwners - var deletedOwnersSet = new Set(deletedOwners); - var allOwners = allOwners.filter(function(element) { - return !deletedOwnersSet.has(element); - }); - - var owners = [] - .concat(deletedOwners) - .concat(allOwners) - .filter(function(owner) { - return owner !== 'none'; - }) - .filter(function(owner) { + var guess = Array.from(owners.keys()).sort(function(a, b) { + return owners.get(b) - owners.get(a); + }).filter(function(owner) { return owner !== creator; }) .filter(function(owner) { @@ -454,18 +243,18 @@ async function guessOwners( }); if (config.requiredOrgs.length > 0) { - owners = await filterRequiredOrgs(owners, config, github); + guess = await filterRequiredOrgs(guess, config, github); } if (privateRepo && org != null) { - owners = await filterPrivateRepo(owners, org, github); + guess = await filterPrivateRepo(guess, org, github); } - if (owners.length === 0) { + if (guess.length === 0) { defaultOwners = defaultOwners.concat(fallbackOwners); } - return owners + return guess .slice(0, config.maxReviewers) .concat(defaultOwners) .filter(function(owner, index, ownersFound) { @@ -474,7 +263,8 @@ async function guessOwners( } async function guessOwnersForPullRequest( - repoURL: string, + repo: string, + user: string, id: number, creator: string, targetBranch: string, @@ -483,52 +273,44 @@ async function guessOwnersForPullRequest( config: Object, github: Object ): Promise> { - var diff = await fetch(repoURL + '/pull/' + id + '.diff'); - var files = parseDiff(diff); + var files = await getFilesPath(user, repo, id, github); var defaultOwners = getMatchingOwners(files, config.alwaysNotifyForPaths); var fallbackOwners = getMatchingOwners(files, config.fallbackNotifyForPaths); if (!config.findPotentialReviewers) { return defaultOwners; } - // There are going to be degenerated changes that end up modifying hundreds - // of files. In theory, it would be good to actually run the algorithm on - // all of them to get the best set of reviewers. In practice, we don't - // want to do hundreds of http requests. Using the top 5 files is enough - // to get us 3 people that may have context. - files.sort(function(a, b) { - var countA = a.deletedLines.length; - var countB = b.deletedLines.length; - return countA > countB ? -1 : (countA < countB ? 1 : 0); - }); // remove files that match any of the globs in the file blacklist config config.fileBlacklist.forEach(function(glob) { files = files.filter(function(file) { - return !minimatch(file.path, glob); + return !minimatch(file, glob); }); }); files = files.slice(0, config.numFilesToCheck); - var blames = {}; - // create blame promises (allows concurrent loading) - var promises = files.map(function(file) { - return fetch(repoURL + '/blame/' + targetBranch + '/' + file.path); + // create authors promises (allows concurrent loading) + let promises = files.map(function(file) { + return getCommitsAuthors(user, repo, file, github); }); // wait for all promises to resolve - var results = await Promise.all(promises); - results.forEach(function(result, index) { - blames[files[index].path] = parseBlame(result); - }); + let results = await Promise.all(promises); + let owners = results.reduce(function(acc, owners) { + for (let [owner, commits] of owners) { + if (acc.has(owner)) { + acc.set(owner, acc.get(owner) + commits); + } else { + acc.set(owner, commits); + } + } + return acc; + }, new Map()); // This is the line that implements the actual algorithm, all the lines // before are there to fetch and extract the data needed. - return guessOwners(files, blames, creator, defaultOwners, fallbackOwners, privateRepo, org, config, github); + return guessOwners(owners, creator, defaultOwners, fallbackOwners, privateRepo, org, config, github); } module.exports = { - enableCachingForDebugging: false, - parseDiff: parseDiff, - parseBlame: parseBlame, guessOwnersForPullRequest: guessOwnersForPullRequest, }; diff --git a/package.json b/package.json index 23a1421..78a371d 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,12 @@ "license": "BSD-3-Clause", "repository": "facebook/mention-bot", "scripts": { - "test": "flow && jest", + "test": "flow & jest", "start": "node run-server.js" }, "main": "./run-mention-bot.js", "engines": { - "node": ">=4" + "node": ">=6" }, "jest": { "scriptPreprocessor": "/node_modules/babel-jest", @@ -27,7 +27,6 @@ "babel-polyfill": "^6.1.4", "babel-preset-react": "^6.1.2", "bl": "^1.0.0", - "download-file-sync": "^1.0.3", "express": "^4.13.3", "flow-bin": "^0.18.1", "github": "^2.1.0", diff --git a/server.js b/server.js index 49be8f5..5655230 100644 --- a/server.js +++ b/server.js @@ -12,7 +12,6 @@ var bl = require('bl'); var config = require('./config'); var express = require('express'); -var fs = require('fs'); var mentionBot = require('./mention-bot.js'); var messageGenerator = require('./message.js'); var util = require('util'); @@ -36,19 +35,6 @@ if (!process.env.GITHUB_TOKEN) { process.exit(1); } -if (!process.env.GITHUB_USER) { - console.warn( - 'There was no GitHub user detected.', - 'This is fine, but mention-bot won\'t work with private repos.' - ); - console.warn( - 'To make mention-bot work with private repos, please expose', - 'GITHUB_USER and GITHUB_PASSWORD as environment variables.', - 'The username and password must have access to the private repo', - 'you want to use.' - ); -} - var github = new GitHubApi({ host: config.github.apiHost, pathPrefix: config.github.pathPrefix, @@ -138,7 +124,7 @@ async function work(body) { withLabel: '', skipCollaboratorPR: false, }; - + if (process.env.MENTION_BOT_CONFIG) { try { repoConfig = { @@ -247,7 +233,8 @@ async function work(body) { } var reviewers = await mentionBot.guessOwnersForPullRequest( - data.repository.html_url, // 'https://github.com/fbsamples/bot-testing' + data.repository.name, // 'bot-testing' + data.repository.owner.login, // 'facebook' data.pull_request.number, // 23 data.pull_request.user.login, // 'mention-bot' data.pull_request.base.ref, // 'master' From 8b9f745490c51a95bbd3ccc13893763d426ff06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Peignier?= Date: Sat, 10 Sep 2016 17:51:59 -0700 Subject: [PATCH 2/2] Only build against node v6 --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index db261f3..634adbc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,7 @@ language: node_js - cache: directories: - node_modules - $NVM_DIR - node_js: - - v5 - - v4 + - v6