From ae1682a9646a2ff6afa6785cb51171ab4054a045 Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 14:35:38 +0500 Subject: [PATCH 01/16] Redirecting to the github app link --- public/js/headlines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/headlines.js b/public/js/headlines.js index 4fcdc55..fcc7d31 100644 --- a/public/js/headlines.js +++ b/public/js/headlines.js @@ -15,7 +15,7 @@ AJS.$(window).load(function () { success: function (data) { AJS.$("a[rel='modal:close']").trigger("click"); const { link } = data; - window.open('https://github.com/organizations/Productboxpk/settings/apps/jira-git-headlines/installations', '_blank'); + window.open(link, '_blank'); } }); }) From 7d5b150f16ecb5ede94192e4a1a36a6b77d445e6 Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 14:36:20 +0500 Subject: [PATCH 02/16] added few columns. id is the primary key --- lib/models/subscriptions.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/models/subscriptions.js b/lib/models/subscriptions.js index e981809..e411b14 100644 --- a/lib/models/subscriptions.js +++ b/lib/models/subscriptions.js @@ -1,17 +1,21 @@ export const SubscriptionsModel = (sequelize, type) => { return sequelize.define("subscriptions", { + id: { + type: type.INTEGER, + primaryKey: true, + autoIncrement: true + }, jira_client_key: { type: type.STRING }, organisation: type.STRING, enterprise: type.STRING, - github_installation_id: { - type: type.INTEGER, - primaryKey: true - }, + github_installation_id: type.INTEGER, github_access_token: type.STRING, github_account: type.JSONB, repositories: type.JSONB, - action: type.STRING + action: type.STRING, + repository_selection: type.STRING, + account_type: type.STRING }); }; From 2685704e584f37b1cc75b84ba4319b51c413689f Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 14:36:48 +0500 Subject: [PATCH 03/16] added github_installation_id in installations table --- lib/models/installation.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/models/installation.js b/lib/models/installation.js index 85bf1eb..dcef4d3 100644 --- a/lib/models/installation.js +++ b/lib/models/installation.js @@ -6,6 +6,7 @@ export const InstallationsModel = (sequelize, type) => { data: type.JSONB, account_id: { type: type.STRING, primaryKey: true }, jira_token: type.JSONB, + github_installation_id: type.INTEGER, organisation: type.STRING, enabled: type.BOOLEAN }); From 96d88ce9389f6b625968a6436d8cef8398cce621 Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 14:37:00 +0500 Subject: [PATCH 04/16] removed association --- db/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/index.js b/db/index.js index ccfa6b9..bd7e457 100644 --- a/db/index.js +++ b/db/index.js @@ -26,8 +26,6 @@ if (process.env.DATABASE_URL) { const Installations = InstallationsModel(sequelize, Sequelize); const Subscriptions = SubscriptionsModel(sequelize, Sequelize); -Subscriptions.hasOne(Installations, { as: "github_installation_id" }); - sequelize.sync({ force: true }).then(() => { console.log(`Database & tables created!`); }); From 75c6ad3c6cc5f37abf46102ab5b8e540309e4bb8 Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 14:47:10 +0500 Subject: [PATCH 05/16] The code will run on user selected/allowed repositories. The can perform add/delete repo from github app settings. target_type defines what the account type is Organization/Enterprise --- routes/index.js | 99 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 30 deletions(-) diff --git a/routes/index.js b/routes/index.js index cbdd78f..ab05889 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,7 +2,7 @@ import * as _ from "lodash"; import * as jwt from "atlassian-jwt"; import { Installations, Subscriptions } from "../db"; import { token } from "../lib/jira"; -import { authorizeApp, getCurrentUserOrganizations, get } from "../lib/api/github"; +import { authorizeApp, get } from "../lib/api/github"; import { getAllProjects, getAllProjectIssues } from "../lib/api/jira"; import { findAndUpdateElseInsert } from "../lib/models/installation"; @@ -28,8 +28,7 @@ export default function routes(app, addon) { gdpr: true }, name: "Headlines for Jira", - description: - "This plugin shows the recent updated tickets and branches of all projects a user is working on", + description: "This plugin shows the recent updated tickets and branches of all projects a user is working on", key: "headlines-jira", baseUrl: `${isHttps ? "https" : "http"}://${req.get("host")}`, lifecycle: { @@ -80,9 +79,8 @@ export default function routes(app, addon) { let gitHubData = []; const allRepoNames = []; - const githubDataFromDB = await Subscriptions.findOne({ - where: { github_installation_id: clientData.github_installation_id } - }); + let githubDataFromDB; + if(clientData && clientData.github_installation_id) githubDataFromDB = await Subscriptions.findOne({ where: { github_installation_id: clientData.github_installation_id } }); if (!_.isEmpty(githubDataFromDB && githubDataFromDB.github_access_token)) { githubAccessToken = githubDataFromDB && githubDataFromDB.github_access_token; @@ -90,24 +88,25 @@ export default function routes(app, addon) { const commitsDataPromises = [] let branchesData = []; let commitsData = []; - const { data: orgs } = await getCurrentUserOrganizations(githubAccessToken); - if (orgs.length) { - const orgsReposDataPromises = _.map(orgs, (org) => { return get(githubAccessToken, org.repos_url) }); + + const allowedRepos = githubDataFromDB.repositories; + + if (allowedRepos) { + const orgsReposDataPromises = _.map(allowedRepos, (org) => { return get(githubAccessToken, `https://api.github.com/repos/${org.full_name}`) }); // full_name is like /organization/repositories let orgsData = await Promise.all(orgsReposDataPromises); - orgsData = _.first(orgsData).data; const branchsLink = []; const commitsLink = []; _.each(orgsData, (orgData) => { - allRepoNames.push(orgData.name); + allRepoNames.push(orgData.data.name); if (_.isEmpty(repoNames)) { - branchsLink.push(orgData.branches_url.slice(0, -9)); - commitsLink.push(orgData.commits_url.slice(0, -6)); + branchsLink.push(orgData.data.branches_url.slice(0, -9)); + commitsLink.push(orgData.data.commits_url.slice(0, -6)); } - if (_.includes(repoNames, orgData.name)) { - branchsLink.push(orgData.branches_url.slice(0, -9)); - commitsLink.push(orgData.commits_url.slice(0, -6)); + if (_.includes(repoNames, orgData.data.name)) { + branchsLink.push(orgData.data.branches_url.slice(0, -9)); + commitsLink.push(orgData.data.commits_url.slice(0, -6)); } - }) + }); const branchDataPromises = _.map(branchsLink, (branchLink) => get(githubAccessToken, branchLink)) let branchesDataResponse = await Promise.all(branchDataPromises); _.each(branchesDataResponse, (branchData) => branchesData = [...branchesData, ...branchData.data]); @@ -156,6 +155,7 @@ export default function routes(app, addon) { projectKeys = projectKeys && projectKeys.length && projectKeys.split(","); if (_.isEmpty(allProjectKeys)) { + console.log('is this empty !!!!', clientData.data.baseUrl) const data = await getAllProjects(jiraAccessToken, clientData.data.baseUrl); allProjectKeys = _.map(data, k => k.key); } @@ -243,11 +243,11 @@ export default function routes(app, addon) { }); app.post("/github/events", async (req, res, next) => { - // console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - // console.log(req.body, "Webhook url"); // The github throw much data here we will have to process it properly - // console.log("*********************************************"); + console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + console.log(req.body, "Webhook url"); // The github throw much data here we will have to process it properly + console.log("*********************************************"); let { repositories, action } = req.body; - const { id: installationId, account: installedFor } = req.body.installation; + const { id: installationId, account: installedFor, target_type, repository_selection } = req.body.installation; if (action === "created") { const jiraHost = await Installations.findOne({ @@ -263,7 +263,9 @@ export default function routes(app, addon) { organisation: installedFor.login, jira_client_key: jiraHost.client_key, github_account: installedFor, - repositories: repositories + repositories: repositories, + repository_selection, + account_type: target_type }, { where: { github_installation_id: installationId } } ); @@ -273,7 +275,9 @@ export default function routes(app, addon) { jira_client_key: jiraHost.client_key, github_installation_id: installationId, github_account: installedFor, - repositories: repositories + repositories: repositories, + repository_selection, + account_type: target_type }); } await Installations.update( @@ -288,21 +292,56 @@ export default function routes(app, addon) { const foundInstallation = await Subscriptions.findOne({ where: { github_installation_id: installationId } }); - console.log("+++++++++++++++++++++++++++++++++++++++++") - console.log(foundInstallation, "as found installation"); - console.log("-----------------------------------------") + let oldRepos = foundInstallation.repositories; + const removeIds = _.map(repositories_removed, (removeRepo) => { + return removeRepo.id; + }); + const repoIndex = _.findIndex(oldRepos, (oldRepo) => { + let found = false; + + return found; + }) + if (repoIndex > -1) { + oldRepos = oldRepos.slice(repoIndex); + await Subscriptions.update({ + repositories: oldRepos, + repository_selection, + account_type: target_type + }, + { where: { github_installation_id: installationId } } + ); + console.log("+++++++++++++++++++++++++++++++++++++++++"); + console.log(oldRepos, "inserting this in database"); + console.log("-----------------------------------------"); + } } if (action === "added") { const { repositories_added } = req.body; - console.log(repositories_added, "repo added new repo"); const foundInstallation = await Subscriptions.findOne({ where: { github_installation_id: installationId } }); - console.log("+++++++++++++++++++++++++++++++++++++++++") - console.log(foundInstallation, "as found installation in added "); - console.log("-----------------------------------------") + const oldRepos = foundInstallation.repositories; + const alreadExists = _.find(oldRepos, oldRepo => { + let found; + _.map(repositories_added, newRepo => { + found = oldRepo.id === newRepo.id; + return; + }); + return found; + }); + if (!alreadExists) { + const reposUpdated = [...oldRepos, ...repositories_added]; + await Subscriptions.update({ + repositories: reposUpdated, + repository_selection, + account_type: target_type + }, + { where: { github_installation_id: installationId } } + ); + } } + if (action === "deleted") { await Subscriptions.destroy({ where: { github_installation_id: installationId } From dd88cd07dad8899a73d8142634cb0ea26cf8add5 Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 15:04:57 +0500 Subject: [PATCH 06/16] spell fix --- routes/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/index.js b/routes/index.js index ab05889..2747f18 100644 --- a/routes/index.js +++ b/routes/index.js @@ -212,7 +212,7 @@ export default function routes(app, addon) { }, {where: {github_installation_id: installation_id} }) } const foundClient = await Installations.findOne({ - hwere: { github_installation_id: installation_id } + where: { github_installation_id: installation_id } }); res.redirect(`${foundClient.data.baseUrl}/plugins/servlet/ac/headlines-jira/headlines`); }); From 3e71d0a97622e7255389089091270f1ee561c1ab Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 15:27:13 +0500 Subject: [PATCH 07/16] A few code update --- routes/index.js | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/routes/index.js b/routes/index.js index 2747f18..e4266eb 100644 --- a/routes/index.js +++ b/routes/index.js @@ -293,27 +293,31 @@ export default function routes(app, addon) { where: { github_installation_id: installationId } }); let oldRepos = foundInstallation.repositories; - const removeIds = _.map(repositories_removed, (removeRepo) => { - return removeRepo.id; + const oldRepoIds = _.map(oldRepos, "id"); + + _.map(repositories_removed, r => { + const foundIndex = oldRepoIds.indexOf(r.id); + if (foundIndex > -1) { + console.log(foundIndex, 'foundIndex'); + console.log(oldRepos[foundIndex], 'oldRepos[foundIndex]'); + oldRepos.splice(foundIndex, 1); + console.log(oldRepos, 'oldRepos after splicing'); + } }); - const repoIndex = _.findIndex(oldRepos, (oldRepo) => { - let found = false; - - return found; - }) - if (repoIndex > -1) { - oldRepos = oldRepos.slice(repoIndex); - await Subscriptions.update({ - repositories: oldRepos, - repository_selection, - account_type: target_type - }, - { where: { github_installation_id: installationId } } - ); - console.log("+++++++++++++++++++++++++++++++++++++++++"); - console.log(oldRepos, "inserting this in database"); - console.log("-----------------------------------------"); - } + + console.log("+++++++++++++++++++++++++++++++++++++++++"); + console.log(oldRepos, "inserting this in database"); + console.log("-----------------------------------------"); + + await Subscriptions.update( + { + repositories: oldRepos, + repository_selection, + account_type: target_type + }, + { where: { github_installation_id: installationId } } + ); + } if (action === "added") { From 325b67d2a0125931b1ff2d228acafc8b112af87b Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 16:47:25 +0500 Subject: [PATCH 08/16] some styles --- public/css/modal.css | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/public/css/modal.css b/public/css/modal.css index 72b1bf2..0551b7c 100644 --- a/public/css/modal.css +++ b/public/css/modal.css @@ -10,4 +10,27 @@ #github-org-name , #github-repo-name { margin-left: 20px; +} + +.conformation-box { + margin: 20px 0; + display: flex; +} + +#confirm-org-logo { + width: 50px; + float: left; + padding: 0 10px 0 0px; +} + +.name-label { + text-align: left !important; +} + +form.aui .icon-required { + position: none; +} + +.field-group { + display: flex; } \ No newline at end of file From 7e835ba325f18e053a747b39549de0de65c78b9f Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 16:47:47 +0500 Subject: [PATCH 09/16] Added Preview Org functionality --- views/headlines.hbs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/views/headlines.hbs b/views/headlines.hbs index 128b82a..8171c66 100644 --- a/views/headlines.hbs +++ b/views/headlines.hbs @@ -64,6 +64,11 @@
+ +
+
+ +
From 7f8a7c94e67c83de0e10b7c49718d70882ad8cd9 Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 16:48:23 +0500 Subject: [PATCH 10/16] removed logs --- routes/index.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/routes/index.js b/routes/index.js index e4266eb..de2b6af 100644 --- a/routes/index.js +++ b/routes/index.js @@ -155,7 +155,6 @@ export default function routes(app, addon) { projectKeys = projectKeys && projectKeys.length && projectKeys.split(","); if (_.isEmpty(allProjectKeys)) { - console.log('is this empty !!!!', clientData.data.baseUrl) const data = await getAllProjects(jiraAccessToken, clientData.data.baseUrl); allProjectKeys = _.map(data, k => k.key); } @@ -243,9 +242,9 @@ export default function routes(app, addon) { }); app.post("/github/events", async (req, res, next) => { - console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - console.log(req.body, "Webhook url"); // The github throw much data here we will have to process it properly - console.log("*********************************************"); + // console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + // console.log(req.body, "Webhook url"); // The github throw much data here we will have to process it properly + // console.log("*********************************************"); let { repositories, action } = req.body; const { id: installationId, account: installedFor, target_type, repository_selection } = req.body.installation; @@ -288,7 +287,6 @@ export default function routes(app, addon) { if (action === "removed") { const { repositories_removed } = req.body; - console.log(repositories_removed, "repo removed"); const foundInstallation = await Subscriptions.findOne({ where: { github_installation_id: installationId } }); @@ -297,18 +295,8 @@ export default function routes(app, addon) { _.map(repositories_removed, r => { const foundIndex = oldRepoIds.indexOf(r.id); - if (foundIndex > -1) { - console.log(foundIndex, 'foundIndex'); - console.log(oldRepos[foundIndex], 'oldRepos[foundIndex]'); - oldRepos.splice(foundIndex, 1); - console.log(oldRepos, 'oldRepos after splicing'); - } + if (foundIndex > -1) oldRepos.splice(foundIndex, 1); }); - - console.log("+++++++++++++++++++++++++++++++++++++++++"); - console.log(oldRepos, "inserting this in database"); - console.log("-----------------------------------------"); - await Subscriptions.update( { repositories: oldRepos, From 4bb64cc1a5985442d59631a89d9589f4c6ec5a29 Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Wed, 22 Jan 2020 16:48:55 +0500 Subject: [PATCH 11/16] added preview Organization functionality --- public/js/headlines.js | 154 ++++++++++++++++++++++++----------------- 1 file changed, 90 insertions(+), 64 deletions(-) diff --git a/public/js/headlines.js b/public/js/headlines.js index fcc7d31..03e960e 100644 --- a/public/js/headlines.js +++ b/public/js/headlines.js @@ -1,110 +1,134 @@ -AJS.$(window).load(function () { +AJS.$(window).load(function() { let jiraAccessToken = AJS.$('meta[name="jiraAccessToken"]').attr("content"); - let clickedProject = ''; + let clickedProject = ""; let projectKeys = []; - let clickedRepo = ''; + let clickedRepo = ""; let projectRepos = []; - AJS.$("#github-data").on('submit', function(e){ + AJS.$("#look-org").on("click", function(e) { const orgName = AJS.$("#github-org-name").val(); AJS.$.ajax({ - type: 'POST', - url: 'github/setup', - data: {orgName}, - dataType: "json", - success: function (data) { - AJS.$("a[rel='modal:close']").trigger("click"); - const { link } = data; - window.open(link, '_blank'); + type: "GET", + url: `https://api.github.com/orgs/${orgName}`, + success: function(data) { + AJS.$("#confirm-org-logo").attr("src", data.avatar_url); + AJS.$("#confirm-org-description").html(data.description); + }, + error: function(error) { + console.log(error, "err data"); } }); - }) + }); - setInterval(function () { - let getSelectedProjectLinkUrl = '' - if (clickedProject === 'All' || projectRepos === 'All') { - getSelectedProjectLinkUrl = `headlines?jwt=${jiraAccessToken}` + AJS.$("#github-data").on("submit", function(e) { + const orgName = AJS.$("#github-org-name").val(); + if (!orgName.length); + else { + AJS.$.ajax({ + type: "POST", + url: "github/setup", + data: { orgName }, + dataType: "json", + success: function(data) { + AJS.$("a[rel='modal:close']").trigger("click"); + const { link } = data; + window.open(link, "_blank"); + } + }); + } + }); + + setInterval(function() { + let getSelectedProjectLinkUrl = ""; + if (clickedProject === "All" || projectRepos === "All") { + getSelectedProjectLinkUrl = `headlines?jwt=${jiraAccessToken}`; } else { getSelectedProjectLinkUrl = `headlines?projectKey=${projectKeys}&repoNames=${projectRepos}&jwt=${jiraAccessToken}`; } $.ajax({ - type: 'GET', + type: "GET", url: getSelectedProjectLinkUrl, - success: function (data) { - $('.issues-container').replaceWith(`
${$(".issues-container", data).html()}
`); - $('.issues-container .jira-loader').addClass('hide-loader') - $('.branches-container').replaceWith(`
${$(".branches-container", data).html()}
`); - $('.branches-container .jira-loader').addClass('hide-loader') + success: function(data) { + $(".issues-container").replaceWith( + `
${$(".issues-container", data).html()}
` + ); + $(".issues-container .jira-loader").addClass("hide-loader"); + $(".branches-container").replaceWith( + `
${$(".branches-container", data).html()}
` + ); + $(".branches-container .jira-loader").addClass("hide-loader"); } }); - }, 20000) - $('.project-link').on('click', function (e) { - $('.issues-container .jira-loader').removeClass('hide-loader') - clickedProject = $(this).attr('name'); + }, 20000); + $(".project-link").on("click", function(e) { + $(".issues-container .jira-loader").removeClass("hide-loader"); + clickedProject = $(this).attr("name"); let getSelectedProjectLinkUrl = null; - const allCheckedProjects = $('#jira-projects .project-link'); - if (clickedProject === 'All') { + const allCheckedProjects = $("#jira-projects .project-link"); + if (clickedProject === "All") { for (let index = 0; index < allCheckedProjects.length; index++) { - if ($(allCheckedProjects[index]).attr('name') !== 'All') { - $(allCheckedProjects[index]).prop('checked', false) + if ($(allCheckedProjects[index]).attr("name") !== "All") { + $(allCheckedProjects[index]).prop("checked", false); } } - getSelectedProjectLinkUrl = `headlines?jwt=${jiraAccessToken}` + getSelectedProjectLinkUrl = `headlines?jwt=${jiraAccessToken}`; } - if (e.target.checked && clickedProject !== 'All') { + if (e.target.checked && clickedProject !== "All") { for (let index = 0; index < allCheckedProjects.length; index++) { - if ($(allCheckedProjects[index]).attr('name') === 'All') { - $(allCheckedProjects[index]).prop('checked', false) + if ($(allCheckedProjects[index]).attr("name") === "All") { + $(allCheckedProjects[index]).prop("checked", false); } } projectKeys.push(clickedProject); getSelectedProjectLinkUrl = `headlines?projectKey=${projectKeys}&repoNames=${projectRepos}&jwt=${jiraAccessToken}`; } - if (!e.target.checked && clickedProject !== 'All') { + if (!e.target.checked && clickedProject !== "All") { for (let index = 0; index < allCheckedProjects.length; index++) { - if ($(allCheckedProjects[index]).attr('name') === 'All') { - $(allCheckedProjects[index]).prop('checked', false) + if ($(allCheckedProjects[index]).attr("name") === "All") { + $(allCheckedProjects[index]).prop("checked", false); } } const removeIndex = projectKeys.indexOf(clickedProject); projectKeys.splice(removeIndex, 1); } $.ajax({ - type: 'GET', + type: "GET", url: getSelectedProjectLinkUrl, - success: function (data) { - $('.issues-container').replaceWith(`
${$(".issues-container", data).html()}
`); - $('.issues-container .jira-loader').addClass('hide-loader') - $('.jira-dropdown').click(); + success: function(data) { + $(".issues-container").replaceWith( + `
${$(".issues-container", data).html()}
` + ); + $(".issues-container .jira-loader").addClass("hide-loader"); + $(".jira-dropdown").click(); } }); - }) - $('.repositories-link').on('click', function (e) { - $('.branches-container .github-loader').removeClass('hide-loader') - clickedRepo = $(this).attr('name'); - const allCheckedProjects = $('#github-repos .repositories-link'); + }); + $(".repositories-link").on("click", function(e) { + $(".branches-container .github-loader").removeClass("hide-loader"); + clickedRepo = $(this).attr("name"); + const allCheckedProjects = $("#github-repos .repositories-link"); let getSelectedProjectLinkUrl = null; - if (clickedRepo === 'All') { + if (clickedRepo === "All") { for (let index = 0; index < allCheckedProjects.length; index++) { - if ($(allCheckedProjects[index]).attr('name') !== 'All') { - $(allCheckedProjects[index]).prop('checked', false) + if ($(allCheckedProjects[index]).attr("name") !== "All") { + $(allCheckedProjects[index]).prop("checked", false); } } - getSelectedProjectLinkUrl = `headlines?jwt=${jiraAccessToken}` + getSelectedProjectLinkUrl = `headlines?jwt=${jiraAccessToken}`; } - if (e.target.checked && clickedRepo !== 'All') { + if (e.target.checked && clickedRepo !== "All") { for (let index = 0; index < allCheckedProjects.length; index++) { - if ($(allCheckedProjects[index]).attr('name') === 'All') { - $(allCheckedProjects[index]).prop('checked', false) + if ($(allCheckedProjects[index]).attr("name") === "All") { + $(allCheckedProjects[index]).prop("checked", false); } } projectRepos.push(clickedRepo); getSelectedProjectLinkUrl = `headlines?projectKey=${projectKeys}&repoNames=${projectRepos}&jwt=${jiraAccessToken}`; } - if (!e.target.checked && clickedRepo !== 'All') { + if (!e.target.checked && clickedRepo !== "All") { for (let index = 0; index < allCheckedProjects.length; index++) { - if ($(allCheckedProjects[index]).attr('name') === 'All') { - $(allCheckedProjects[index]).prop('checked', false) + if ($(allCheckedProjects[index]).attr("name") === "All") { + $(allCheckedProjects[index]).prop("checked", false); } } const removeIndex = projectRepos.indexOf(clickedRepo); @@ -112,13 +136,15 @@ AJS.$(window).load(function () { } $.ajax({ - type: 'GET', + type: "GET", url: getSelectedProjectLinkUrl, - success: function (data) { - $('.branches-container').replaceWith(`
${$(".branches-container", data).html()}
`); - $('.branches-container .jira-loader').addClass('hide-loader') - $('.git-dropdown').click(); + success: function(data) { + $(".branches-container").replaceWith( + `
${$(".branches-container", data).html()}
` + ); + $(".branches-container .jira-loader").addClass("hide-loader"); + $(".git-dropdown").click(); } }); - }) + }); }); From 64d1c43197e31a11abd584f8ce94614818f8c905 Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Thu, 23 Jan 2020 14:04:21 +0500 Subject: [PATCH 12/16] changed directory --- .sequelizerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.sequelizerc b/.sequelizerc index 07d6751..aab6eec 100644 --- a/.sequelizerc +++ b/.sequelizerc @@ -1,7 +1,7 @@ const path = require('path') module.exports = { - "config": path.resolve('./db/config.json'), + "config": path.resolve('./config.json'), "models-path": path.resolve('./lib/models'), "migrations-path": path.resolve('./db/migrations') } From 1a21edb2c9a82983caf38d5810c1e67b157b88e5 Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Thu, 23 Jan 2020 14:05:20 +0500 Subject: [PATCH 13/16] Data droping problem solving --- db/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/index.js b/db/index.js index bd7e457..6131f72 100644 --- a/db/index.js +++ b/db/index.js @@ -26,8 +26,9 @@ if (process.env.DATABASE_URL) { const Installations = InstallationsModel(sequelize, Sequelize); const Subscriptions = SubscriptionsModel(sequelize, Sequelize); -sequelize.sync({ force: true }).then(() => { - console.log(`Database & tables created!`); -}); +sequelize.sync({alter: {alter: true, drop: false } }) + .then(() => { + console.log(`Database & tables created!`); + }); export { Installations, Subscriptions }; From 70eb37f982394520ee80763ad5ee2a807e55b50c Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Thu, 23 Jan 2020 14:06:40 +0500 Subject: [PATCH 14/16] moved code to seperate file --- lib/jira/index.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/jira/index.js b/lib/jira/index.js index bc734e3..8af2b46 100644 --- a/lib/jira/index.js +++ b/lib/jira/index.js @@ -28,4 +28,51 @@ export const token = async (clientKey, userAccountId) => { } catch (error) { return error; } +}; + +export const connect = async (req, res, next) => { + const isHttps = req.secure || req.header("x-forwarded-proto") === "https"; + + return res.status(200).json({ + apiMigrations: { + gdpr: true + }, + name: "Headlines for Jira", + description: + "This plugin shows the recent updated tickets and branches of all projects a user is working on", + key: "headlines-jira", + baseUrl: `${isHttps ? "https" : "http"}://${req.get("host")}`, + lifecycle: { + installed: "/jira/events/install", + uninstalled: "/jira/events/uninstall", + enabled: "/jira/events/enable", + disabled: "/jira/events/disable" + }, + vendor: { + name: "Productbox", + url: "https://www.productbox.dev" + }, + authentication: { + type: "jwt" + }, + scopes: ["READ", "ACT_AS_USER"], + apiVersion: 1, + modules: { + generalPages: [ + { + key: "headlines", + location: "system.top.navigation.bar", + name: { + value: "Headlines" + }, + url: "/headlines", + conditions: [ + { + condition: "user_is_logged_in" + } + ] + } + ] + } + }); }; \ No newline at end of file From 41f8fed91a9d175f1d201e0e6435af241a606beb Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Thu, 23 Jan 2020 14:07:26 +0500 Subject: [PATCH 15/16] moved connect code to seperate file and some refactoring --- routes/index.js | 75 ++++++++++++------------------------------------- 1 file changed, 18 insertions(+), 57 deletions(-) diff --git a/routes/index.js b/routes/index.js index de2b6af..e48cfdc 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,7 +1,7 @@ import * as _ from "lodash"; import * as jwt from "atlassian-jwt"; import { Installations, Subscriptions } from "../db"; -import { token } from "../lib/jira"; +import { token, connect } from "../lib/jira"; import { authorizeApp, get } from "../lib/api/github"; import { getAllProjects, getAllProjectIssues } from "../lib/api/jira"; import { findAndUpdateElseInsert } from "../lib/models/installation"; @@ -20,52 +20,18 @@ export default function routes(app, addon) { res.redirect("/atlassian-connect.json"); }); - app.get("/atlassian-connect.json", (req, res, next) => { - const isHttps = req.secure || req.header("x-forwarded-proto") === "https"; - - return res.status(200).json({ - apiMigrations: { - gdpr: true - }, - name: "Headlines for Jira", - description: "This plugin shows the recent updated tickets and branches of all projects a user is working on", - key: "headlines-jira", - baseUrl: `${isHttps ? "https" : "http"}://${req.get("host")}`, - lifecycle: { - installed: "/jira/events/install", - uninstalled: "/jira/events/uninstall", - enabled: "/jira/events/enabled", - disabled: "/jira/events/disabled" - }, - vendor: { - name: "Productbox", - url: "https://www.productbox.dev" - }, - authentication: { - type: "jwt" - }, - scopes: ["READ", "ACT_AS_USER"], - apiVersion: 1, - modules: { - generalPages: [ - { - key: "headlines", - location: "system.top.navigation.bar", - name: { - value: "Headlines" - }, - url: "/headlines", - conditions: [ - { - condition: "user_is_logged_in" - } - ] - } - ] - } - }); + app.post("/jira/events/enable", async (req, res, next) => { + const updated = await Installations.update( + { enabled: true }, + { where: { client_key: req.body.clientKey } } + ); + console.log(updated[0]) + if(updated[0]) return res.sendStatus(200); + else return res.sendStatus(500); }); + app.use("/atlassian-connect.json", connect); + app.get("/headlines", async (req, res, next) => { const requestJwt = req.query && req.query.jwt && jwt.decode(req.query.jwt, "", true) || null; userAccountId = requestJwt && requestJwt.sub || null; @@ -248,14 +214,15 @@ export default function routes(app, addon) { let { repositories, action } = req.body; const { id: installationId, account: installedFor, target_type, repository_selection } = req.body.installation; + const foundSubscriptionWithId = await Subscriptions.findOne({ + where: { github_installation_id: installationId } + }); + if (action === "created") { const jiraHost = await Installations.findOne({ where: { organisation: installedFor.login } }); - - const foundSubscriptionWithId = await Subscriptions.findOne({ - where: { github_installation_id: installationId } - }); + if (foundSubscriptionWithId) { await Subscriptions.update( { @@ -287,10 +254,7 @@ export default function routes(app, addon) { if (action === "removed") { const { repositories_removed } = req.body; - const foundInstallation = await Subscriptions.findOne({ - where: { github_installation_id: installationId } - }); - let oldRepos = foundInstallation.repositories; + let oldRepos = foundSubscriptionWithId.repositories; const oldRepoIds = _.map(oldRepos, "id"); _.map(repositories_removed, r => { @@ -310,10 +274,7 @@ export default function routes(app, addon) { if (action === "added") { const { repositories_added } = req.body; - const foundInstallation = await Subscriptions.findOne({ - where: { github_installation_id: installationId } - }); - const oldRepos = foundInstallation.repositories; + const oldRepos = foundSubscriptionWithId.repositories; const alreadExists = _.find(oldRepos, oldRepo => { let found; _.map(repositories_added, newRepo => { From 751c2759e0c5bcef7c2cc3e1de9090a093043b5e Mon Sep 17 00:00:00 2001 From: Farhan-Haseeb Date: Mon, 27 Jan 2020 13:57:12 +0500 Subject: [PATCH 16/16] Solved bugs remove default packages --- package-lock.json | 142 +++++++++++++++++----------------------------- package.json | 1 - routes/index.js | 8 +-- 3 files changed, 55 insertions(+), 96 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8374cf7..0f63d57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -384,17 +384,12 @@ } }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" } } }, - "base64url": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz", - "integrity": "sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A==" - }, "basic-auth": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", @@ -816,11 +811,6 @@ "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=" }, - "crypto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz", - "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==" - }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", @@ -939,9 +929,9 @@ } }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" } } }, @@ -1292,12 +1282,12 @@ } }, "express-hbs": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/express-hbs/-/express-hbs-2.2.0.tgz", - "integrity": "sha512-oORcQXUVUBS7gd4+Yuf20BH3l09UNFuJoGDXaV9ERE4Q3GxE86mvbB1v81tQDgRhLUnVxU+7EMNWTMfHq31ttg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/express-hbs/-/express-hbs-2.3.0.tgz", + "integrity": "sha512-vhm9DXIPebBXnajFX5c33fMFe3Y+3Zd02BDn2uWiWVZ+A2VMErZYRLoVTx0fcldHM2wGLajjSO+dwubkklsOGA==", "requires": { "bluebird": "^3.5.3", - "handlebars": "4.4.5", + "handlebars": "4.5.3", "js-beautify": "1.8.8", "lodash": "4.17.15", "readdirp": "2.2.1" @@ -1440,9 +1430,9 @@ } }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" } } }, @@ -1717,9 +1707,9 @@ "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" }, "handlebars": { - "version": "4.4.5", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.5.tgz", - "integrity": "sha512-0Ce31oWVB7YidkaTq33ZxEbN+UDxMMgThvCe8ptgQViymL5DPis9uLdTA13MiRPhgvqyxIegugrP97iK3JeBHg==", + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz", + "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==", "requires": { "neo-async": "^2.6.0", "optimist": "^0.6.1", @@ -1733,9 +1723,9 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" }, "uglify-js": { - "version": "3.6.8", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.8.tgz", - "integrity": "sha512-XhHJ3S3ZyMwP8kY1Gkugqx3CJh2C3O0y8NPiSxtm1tyD/pktLAkFZsFGpuNfTZddKDQ/bbDBLAd2YyA1pbi8HQ==", + "version": "3.7.6", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.6.tgz", + "integrity": "sha512-yYqjArOYSxvqeeiYH2VGjZOqq6SVmhxzaPjJC1W2F9e+bqvFL9QXQ2osQuKUFjM2hGjKG2YclQnRKWQSt/nOTQ==", "optional": true, "requires": { "commander": "~2.20.3", @@ -2201,9 +2191,9 @@ }, "dependencies": { "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" } } }, @@ -2400,9 +2390,9 @@ }, "dependencies": { "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" } } }, @@ -2467,6 +2457,15 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "node-cron": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-2.0.3.tgz", + "integrity": "sha512-eJI+QitXlwcgiZwNNSRbqsjeZMp5shyajMR81RZCqeW0ZDEj4zU9tpd4nTh/1JsBiKbF8d08FCewiipDmVIYjg==", + "requires": { + "opencollective-postinstall": "^2.0.0", + "tz-offset": "0.0.1" + } + }, "node-json-minify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-json-minify/-/node-json-minify-1.0.0.tgz", @@ -2528,11 +2527,6 @@ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, - "oauth": { - "version": "0.9.15", - "resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz", - "integrity": "sha1-vR/vr2hslrdUda7VGWQS/2DPucE=" - }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", @@ -2608,6 +2602,11 @@ "mimic-fn": "^1.0.0" } }, + "opencollective-postinstall": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.2.tgz", + "integrity": "sha512-pVOEP16TrAO2/fjej1IdOyupJY8KDUM1CvsaScRbw6oddvpQoOfGk4ywha0HKKVAD6RkW4x6Q+tNBwhf3Bgpuw==" + }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", @@ -2682,40 +2681,6 @@ "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=" }, - "passport": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/passport/-/passport-0.4.1.tgz", - "integrity": "sha512-IxXgZZs8d7uFSt3eqNjM9NQ3g3uQCW5avD8mRNoXV99Yig50vjuaez6dQK2qC0kVWPRTujxY0dWgGfT09adjYg==", - "requires": { - "passport-strategy": "1.x.x", - "pause": "0.0.1" - } - }, - "passport-atlassian-oauth2": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/passport-atlassian-oauth2/-/passport-atlassian-oauth2-2.1.0.tgz", - "integrity": "sha512-uUjdoeeA0qqEedj14LzeAFGyK/eesPezQfdN1ui/7D8TYNCGVtuoYhKT64gT8KhOCz5nPYS12XWXRfoPTS6kpg==", - "requires": { - "passport-oauth2": "^1.4.0" - } - }, - "passport-oauth2": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/passport-oauth2/-/passport-oauth2-1.5.0.tgz", - "integrity": "sha512-kqBt6vR/5VlCK8iCx1/KpY42kQ+NEHZwsSyt4Y6STiNjU+wWICG1i8ucc1FapXDGO15C5O5VZz7+7vRzrDPXXQ==", - "requires": { - "base64url": "3.x.x", - "oauth": "0.9.x", - "passport-strategy": "1.x.x", - "uid2": "0.0.x", - "utils-merge": "1.x.x" - } - }, - "passport-strategy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", - "integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ=" - }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -2738,11 +2703,6 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, - "pause": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", - "integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10=" - }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -3399,9 +3359,9 @@ } }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==" + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" } } }, @@ -3419,11 +3379,11 @@ "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" }, "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", + "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", "requires": { - "atob": "^2.1.1", + "atob": "^2.1.2", "decode-uri-component": "^0.2.0", "resolve-url": "^0.2.1", "source-map-url": "^0.4.0", @@ -3754,6 +3714,11 @@ "mime-types": "~2.1.24" } }, + "tz-offset": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tz-offset/-/tz-offset-0.0.1.tgz", + "integrity": "sha512-kMBmblijHJXyOpKzgDhKx9INYU4u4E1RPMB0HqmKSgWG8vEcf3exEfLh4FFfzd3xdQOw9EuIy/cP0akY6rHopQ==" + }, "uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", @@ -3778,11 +3743,6 @@ "random-bytes": "~1.0.0" } }, - "uid2": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.3.tgz", - "integrity": "sha1-SDEm4Rd03y9xuLY53NeZw3YWK4I=" - }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", diff --git a/package.json b/package.json index f5e27dc..bb75500 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "body-parser": "^1.19.0", "compression": "^1.7.4", "cookie-parser": "^1.4.4", - "crypto": "^1.0.1", "errorhandler": "^1.5.1", "esm": "^3.2.22", "express": "^4.16.4", diff --git a/routes/index.js b/routes/index.js index e48cfdc..a67ce49 100644 --- a/routes/index.js +++ b/routes/index.js @@ -89,14 +89,14 @@ export default function routes(app, addon) { singleCommit.branchName = commitData.config.headers.branchName }) }) - const keyedOrgsData = _.keyBy(orgsData, 'html_url') + const keyedOrgsData = _.keyBy(orgsData, (e) => e.data.html_url); _.each(commitsData, commits => { gitHubData.push({ repo: { - name: keyedOrgsData[_.first(commits.html_url.split('/commit/'))] && keyedOrgsData[_.first(commits.html_url.split('/commit/'))].name, + name: keyedOrgsData[_.first(commits.html_url.split('/commit/'))] && keyedOrgsData[_.first(commits.html_url.split('/commit/'))].data.name, owner: { - name: keyedOrgsData[_.first(commits.html_url.split('/commit/'))] && keyedOrgsData[_.first(commits.html_url.split('/commit/'))].owner.login, - avatarUrl: keyedOrgsData[_.first(commits.html_url.split('/commit/'))] && keyedOrgsData[_.first(commits.html_url.split('/commit/'))].owner.avatar_url + name: keyedOrgsData[_.first(commits.html_url.split('/commit/'))] && keyedOrgsData[_.first(commits.html_url.split('/commit/'))].data.owner.login, + avatarUrl: keyedOrgsData[_.first(commits.html_url.split('/commit/'))] && keyedOrgsData[_.first(commits.html_url.split('/commit/'))].data.owner.avatar_url } }, branchName: commits.branchName,