{"action":"created","comment":{"url":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/comments/226005428","pull_request_review_id":165722818,"id":226005428,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjAwNTQyOA==","diff_hunk":"@@ -0,0 +1,223 @@\n+//\n+// Dev Hub\n+//\n+// Copyright \u0003© 2018 Province of British Columbia\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+//\n+// Created by Patrick Simonian on 2018-10-12.\n+//\n+const {\n+  GITHUB_API_ENDPOINT,\n+  FILETYPES,\n+  PROCESSABLE_EXTENSIONS,\n+  MEDIATYPES,\n+  DEFUALT_IGNORES,\n+} = require('./constants');\n+const { TypeCheck } = require('@bcgov/common-web-utils'); // eslint-disable-line \n+const { Base64 } = require('js-base64'); // eslint-disable-line\n+const fetch = require('node-fetch'); // eslint-disable-line\n+const ignore = require('ignore');\n+/**\n+ * returns extension of a file name\n+ * can handle linux type files (which require no extension)\n+ * @param {String} name \n+ * @returns {String} 'readme.md' => md, '.gitignore' => ''\n+ */\n+const getExtensionFromName = name =>\n+  name.slice((Math.max(0, name.lastIndexOf('.')) || Infinity) + 1);\n+/** returns the name of the file type by its extension\n+ * if it is an extensionless file, returns ''\n+ * @param {String} fileName\n+ * @returns {String} 'the more verbose name'.. 'md' => 'Markdown'\n+ */\n+const getNameOfExtensionVerbose = fileName => {\n+  const ext = getExtensionFromName(fileName);\n+  return FILETYPES[ext] ? FILETYPES[ext] : '';\n+};\n+/**\n+ * returns media type from extension\n+ * @param {String} extension \n+ */\n+const getMediaTypeByExtension = extension =>\n+  MEDIATYPES[extension] ? MEDIATYPES[extension] : '';\n+/**\n+ * Using the recursion param, this\n+ * function attempts to retrieve all directories/files from a repo\n+ * there is a limit on how deep it can go down a tree\n+ * as per https://developer.github.com/v3/git/trees/#get-a-tree-recursively\n+ * @param {String} repo\n+ * @param {String} owner\n+ * @param {String} token\n+ */\n+const fetchGithubTree = async (repo, owner, token) => {\n+  try {\n+    const result = await fetch(\n+      `${GITHUB_API_ENDPOINT}/repos/${owner}/${repo}/git/trees/master?recursive=1`,\n+      {\n+        method: 'GET',\n+        headers: {\n+          Authorization: `Bearer ${token}`,\n+        },\n+      }\n+    );\n+    return await result.json();\n+  } catch (e) {\n+    throw e;\n+  }\n+};\n+/**\n+ * Fetches contents from file\n+ * note the media type header, it converts what would have been a\n+ * b64 encoded string of the file contents into either raw string data or json\n+ * @param {String} repo \n+ * @param {String} owner \n+ * @param {String} path \n+ * @param {String} token \n+ */\n+const fetchFile = async (repo, owner, path, token) => {\n+  try {\n+    const result = await fetch(\n+      `https://api.github.com/repos/${owner}/${repo}/contents/${path}`,","path":"app-web/plugins/gatsby-source-github-all/utils/github-api.js","position":91,"original_position":91,"commit_id":"280aa15a8dc426f4c13ac2e30ac3da3c687ac349","original_commit_id":"280aa15a8dc426f4c13ac2e30ac3da3c687ac349","user":{"login":"ShellyXueHan","id":36056216,"node_id":"MDQ6VXNlcjM2MDU2MjE2","avatar_url":"https://avatars3.githubusercontent.com/u/36056216?v=4","gravatar_id":"","url":"https://api.github.com/users/ShellyXueHan","html_url":"https://github.com/ShellyXueHan","followers_url":"https://api.github.com/users/ShellyXueHan/followers","following_url":"https://api.github.com/users/ShellyXueHan/following{/other_user}","gists_url":"https://api.github.com/users/ShellyXueHan/gists{/gist_id}","starred_url":"https://api.github.com/users/ShellyXueHan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShellyXueHan/subscriptions","organizations_url":"https://api.github.com/users/ShellyXueHan/orgs","repos_url":"https://api.github.com/users/ShellyXueHan/repos","events_url":"https://api.github.com/users/ShellyXueHan/events{/privacy}","received_events_url":"https://api.github.com/users/ShellyXueHan/received_events","type":"User","site_admin":false},"body":"use constant","created_at":"2018-10-17T16:30:06Z","updated_at":"2018-10-17T16:35:34Z","html_url":"https://github.com/bcgov/devhub-app-web/pull/43#discussion_r226005428","pull_request_url":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/43","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/comments/226005428"},"html":{"href":"https://github.com/bcgov/devhub-app-web/pull/43#discussion_r226005428"},"pull_request":{"href":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/43"}}},"pull_request":{"url":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/43","id":223397991,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzMzk3OTkx","html_url":"https://github.com/bcgov/devhub-app-web/pull/43","diff_url":"https://github.com/bcgov/devhub-app-web/pull/43.diff","patch_url":"https://github.com/bcgov/devhub-app-web/pull/43.patch","issue_url":"https://api.github.com/repos/bcgov/devhub-app-web/issues/43","number":43,"state":"open","locked":false,"title":"Local Gatsby Source Plugin for retrieving files from repos","user":{"login":"patricksimonian","id":21046727,"node_id":"MDQ6VXNlcjIxMDQ2NzI3","avatar_url":"https://avatars1.githubusercontent.com/u/21046727?v=4","gravatar_id":"","url":"https://api.github.com/users/patricksimonian","html_url":"https://github.com/patricksimonian","followers_url":"https://api.github.com/users/patricksimonian/followers","following_url":"https://api.github.com/users/patricksimonian/following{/other_user}","gists_url":"https://api.github.com/users/patricksimonian/gists{/gist_id}","starred_url":"https://api.github.com/users/patricksimonian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patricksimonian/subscriptions","organizations_url":"https://api.github.com/users/patricksimonian/orgs","repos_url":"https://api.github.com/users/patricksimonian/repos","events_url":"https://api.github.com/users/patricksimonian/events{/privacy}","received_events_url":"https://api.github.com/users/patricksimonian/received_events","type":"User","site_admin":false},"body":"Several file changes are just formatting changes from Prettier js","created_at":"2018-10-16T21:12:49Z","updated_at":"2018-10-17T16:35:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e69845af4f95d08e0083b0e18d5b20b24c9e6cc7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/43/commits","review_comments_url":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/43/comments","review_comment_url":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bcgov/devhub-app-web/issues/43/comments","statuses_url":"https://api.github.com/repos/bcgov/devhub-app-web/statuses/280aa15a8dc426f4c13ac2e30ac3da3c687ac349","head":{"label":"bcgov:github-file-sourcer","ref":"github-file-sourcer","sha":"280aa15a8dc426f4c13ac2e30ac3da3c687ac349","user":{"login":"bcgov","id":916280,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNjI4MA==","avatar_url":"https://avatars1.githubusercontent.com/u/916280?v=4","gravatar_id":"","url":"https://api.github.com/users/bcgov","html_url":"https://github.com/bcgov","followers_url":"https://api.github.com/users/bcgov/followers","following_url":"https://api.github.com/users/bcgov/following{/other_user}","gists_url":"https://api.github.com/users/bcgov/gists{/gist_id}","starred_url":"https://api.github.com/users/bcgov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcgov/subscriptions","organizations_url":"https://api.github.com/users/bcgov/orgs","repos_url":"https://api.github.com/users/bcgov/repos","events_url":"https://api.github.com/users/bcgov/events{/privacy}","received_events_url":"https://api.github.com/users/bcgov/received_events","type":"Organization","site_admin":false},"repo":{"id":148679594,"node_id":"MDEwOlJlcG9zaXRvcnkxNDg2Nzk1OTQ=","name":"devhub-app-web","full_name":"bcgov/devhub-app-web","private":false,"owner":{"login":"bcgov","id":916280,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNjI4MA==","avatar_url":"https://avatars1.githubusercontent.com/u/916280?v=4","gravatar_id":"","url":"https://api.github.com/users/bcgov","html_url":"https://github.com/bcgov","followers_url":"https://api.github.com/users/bcgov/followers","following_url":"https://api.github.com/users/bcgov/following{/other_user}","gists_url":"https://api.github.com/users/bcgov/gists{/gist_id}","starred_url":"https://api.github.com/users/bcgov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcgov/subscriptions","organizations_url":"https://api.github.com/users/bcgov/orgs","repos_url":"https://api.github.com/users/bcgov/repos","events_url":"https://api.github.com/users/bcgov/events{/privacy}","received_events_url":"https://api.github.com/users/bcgov/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/bcgov/devhub-app-web","description":"Web application for the DevHub (aka developer.gov.bc.ca)","fork":false,"url":"https://api.github.com/repos/bcgov/devhub-app-web","forks_url":"https://api.github.com/repos/bcgov/devhub-app-web/forks","keys_url":"https://api.github.com/repos/bcgov/devhub-app-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bcgov/devhub-app-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bcgov/devhub-app-web/teams","hooks_url":"https://api.github.com/repos/bcgov/devhub-app-web/hooks","issue_events_url":"https://api.github.com/repos/bcgov/devhub-app-web/issues/events{/number}","events_url":"https://api.github.com/repos/bcgov/devhub-app-web/events","assignees_url":"https://api.github.com/repos/bcgov/devhub-app-web/assignees{/user}","branches_url":"https://api.github.com/repos/bcgov/devhub-app-web/branches{/branch}","tags_url":"https://api.github.com/repos/bcgov/devhub-app-web/tags","blobs_url":"https://api.github.com/repos/bcgov/devhub-app-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bcgov/devhub-app-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bcgov/devhub-app-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/bcgov/devhub-app-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bcgov/devhub-app-web/statuses/{sha}","languages_url":"https://api.github.com/repos/bcgov/devhub-app-web/languages","stargazers_url":"https://api.github.com/repos/bcgov/devhub-app-web/stargazers","contributors_url":"https://api.github.com/repos/bcgov/devhub-app-web/contributors","subscribers_url":"https://api.github.com/repos/bcgov/devhub-app-web/subscribers","subscription_url":"https://api.github.com/repos/bcgov/devhub-app-web/subscription","commits_url":"https://api.github.com/repos/bcgov/devhub-app-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/bcgov/devhub-app-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/bcgov/devhub-app-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/bcgov/devhub-app-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/bcgov/devhub-app-web/contents/{+path}","compare_url":"https://api.github.com/repos/bcgov/devhub-app-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bcgov/devhub-app-web/merges","archive_url":"https://api.github.com/repos/bcgov/devhub-app-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bcgov/devhub-app-web/downloads","issues_url":"https://api.github.com/repos/bcgov/devhub-app-web/issues{/number}","pulls_url":"https://api.github.com/repos/bcgov/devhub-app-web/pulls{/number}","milestones_url":"https://api.github.com/repos/bcgov/devhub-app-web/milestones{/number}","notifications_url":"https://api.github.com/repos/bcgov/devhub-app-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bcgov/devhub-app-web/labels{/name}","releases_url":"https://api.github.com/repos/bcgov/devhub-app-web/releases{/id}","deployments_url":"https://api.github.com/repos/bcgov/devhub-app-web/deployments","created_at":"2018-09-13T18:20:12Z","updated_at":"2018-10-11T17:05:11Z","pushed_at":"2018-10-17T16:01:53Z","git_url":"git://github.com/bcgov/devhub-app-web.git","ssh_url":"git@github.com:bcgov/devhub-app-web.git","clone_url":"https://github.com/bcgov/devhub-app-web.git","svn_url":"https://github.com/bcgov/devhub-app-web","homepage":null,"size":2235,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2,"open_issues":4,"watchers":1,"default_branch":"master"}},"base":{"label":"bcgov:sprint-3","ref":"sprint-3","sha":"67feb5833a73036fa27bf3c101d794eb425d8029","user":{"login":"bcgov","id":916280,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNjI4MA==","avatar_url":"https://avatars1.githubusercontent.com/u/916280?v=4","gravatar_id":"","url":"https://api.github.com/users/bcgov","html_url":"https://github.com/bcgov","followers_url":"https://api.github.com/users/bcgov/followers","following_url":"https://api.github.com/users/bcgov/following{/other_user}","gists_url":"https://api.github.com/users/bcgov/gists{/gist_id}","starred_url":"https://api.github.com/users/bcgov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcgov/subscriptions","organizations_url":"https://api.github.com/users/bcgov/orgs","repos_url":"https://api.github.com/users/bcgov/repos","events_url":"https://api.github.com/users/bcgov/events{/privacy}","received_events_url":"https://api.github.com/users/bcgov/received_events","type":"Organization","site_admin":false},"repo":{"id":148679594,"node_id":"MDEwOlJlcG9zaXRvcnkxNDg2Nzk1OTQ=","name":"devhub-app-web","full_name":"bcgov/devhub-app-web","private":false,"owner":{"login":"bcgov","id":916280,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNjI4MA==","avatar_url":"https://avatars1.githubusercontent.com/u/916280?v=4","gravatar_id":"","url":"https://api.github.com/users/bcgov","html_url":"https://github.com/bcgov","followers_url":"https://api.github.com/users/bcgov/followers","following_url":"https://api.github.com/users/bcgov/following{/other_user}","gists_url":"https://api.github.com/users/bcgov/gists{/gist_id}","starred_url":"https://api.github.com/users/bcgov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcgov/subscriptions","organizations_url":"https://api.github.com/users/bcgov/orgs","repos_url":"https://api.github.com/users/bcgov/repos","events_url":"https://api.github.com/users/bcgov/events{/privacy}","received_events_url":"https://api.github.com/users/bcgov/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/bcgov/devhub-app-web","description":"Web application for the DevHub (aka developer.gov.bc.ca)","fork":false,"url":"https://api.github.com/repos/bcgov/devhub-app-web","forks_url":"https://api.github.com/repos/bcgov/devhub-app-web/forks","keys_url":"https://api.github.com/repos/bcgov/devhub-app-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bcgov/devhub-app-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bcgov/devhub-app-web/teams","hooks_url":"https://api.github.com/repos/bcgov/devhub-app-web/hooks","issue_events_url":"https://api.github.com/repos/bcgov/devhub-app-web/issues/events{/number}","events_url":"https://api.github.com/repos/bcgov/devhub-app-web/events","assignees_url":"https://api.github.com/repos/bcgov/devhub-app-web/assignees{/user}","branches_url":"https://api.github.com/repos/bcgov/devhub-app-web/branches{/branch}","tags_url":"https://api.github.com/repos/bcgov/devhub-app-web/tags","blobs_url":"https://api.github.com/repos/bcgov/devhub-app-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bcgov/devhub-app-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bcgov/devhub-app-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/bcgov/devhub-app-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bcgov/devhub-app-web/statuses/{sha}","languages_url":"https://api.github.com/repos/bcgov/devhub-app-web/languages","stargazers_url":"https://api.github.com/repos/bcgov/devhub-app-web/stargazers","contributors_url":"https://api.github.com/repos/bcgov/devhub-app-web/contributors","subscribers_url":"https://api.github.com/repos/bcgov/devhub-app-web/subscribers","subscription_url":"https://api.github.com/repos/bcgov/devhub-app-web/subscription","commits_url":"https://api.github.com/repos/bcgov/devhub-app-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/bcgov/devhub-app-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/bcgov/devhub-app-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/bcgov/devhub-app-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/bcgov/devhub-app-web/contents/{+path}","compare_url":"https://api.github.com/repos/bcgov/devhub-app-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bcgov/devhub-app-web/merges","archive_url":"https://api.github.com/repos/bcgov/devhub-app-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bcgov/devhub-app-web/downloads","issues_url":"https://api.github.com/repos/bcgov/devhub-app-web/issues{/number}","pulls_url":"https://api.github.com/repos/bcgov/devhub-app-web/pulls{/number}","milestones_url":"https://api.github.com/repos/bcgov/devhub-app-web/milestones{/number}","notifications_url":"https://api.github.com/repos/bcgov/devhub-app-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bcgov/devhub-app-web/labels{/name}","releases_url":"https://api.github.com/repos/bcgov/devhub-app-web/releases{/id}","deployments_url":"https://api.github.com/repos/bcgov/devhub-app-web/deployments","created_at":"2018-09-13T18:20:12Z","updated_at":"2018-10-11T17:05:11Z","pushed_at":"2018-10-17T16:01:53Z","git_url":"git://github.com/bcgov/devhub-app-web.git","ssh_url":"git@github.com:bcgov/devhub-app-web.git","clone_url":"https://github.com/bcgov/devhub-app-web.git","svn_url":"https://github.com/bcgov/devhub-app-web","homepage":null,"size":2235,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/43"},"html":{"href":"https://github.com/bcgov/devhub-app-web/pull/43"},"issue":{"href":"https://api.github.com/repos/bcgov/devhub-app-web/issues/43"},"comments":{"href":"https://api.github.com/repos/bcgov/devhub-app-web/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bcgov/devhub-app-web/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/bcgov/devhub-app-web/statuses/280aa15a8dc426f4c13ac2e30ac3da3c687ac349"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ShellyXueHan"}}