refactor: simplify constant names

This commit is contained in:
Odonno 2019-01-26 17:51:18 +01:00
Родитель 10b5148354
Коммит 46ae1b1ad0
15 изменённых файлов: 64 добавлений и 63 удалений

Просмотреть файл

@ -12,12 +12,12 @@ module.exports = function (context, req) {
'Authorization': 'token ' + constants_1.ACCESS_TOKEN 'Authorization': 'token ' + constants_1.ACCESS_TOKEN
}; };
var pullRequestNumber = req.number; var pullRequestNumber = req.number;
github_1.getPullRequest(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, pullRequestNumber, function (pullRequest) { github_1.getPullRequest(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, pullRequestNumber, function (pullRequest) {
var creationMessage = pullRequest.body; var creationMessage = pullRequest.body;
var firstBlockOfCreationMessage = creationMessage.split(firstBlockTitle)[0]; var firstBlockOfCreationMessage = creationMessage.split(firstBlockTitle)[0];
if (firstBlockOfCreationMessage) { if (firstBlockOfCreationMessage) {
var linkedItemsNumbers = utils_1.distinct(functions_1.searchLinkedItemsNumbersInComment(firstBlockOfCreationMessage)); var linkedItemsNumbers = utils_1.distinct(functions_1.searchLinkedItemsNumbersInComment(firstBlockOfCreationMessage));
github_1.getIssueOrPullRequestLinks(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, linkedItemsNumbers, function (results) { github_1.getIssueOrPullRequestLinks(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, linkedItemsNumbers, function (results) {
var issuesNumber = results var issuesNumber = results
.filter(function (r) { return r.__typename === 'Issue'; }) .filter(function (r) { return r.__typename === 'Issue'; })
.map(function (r) { return r.__typename === 'Issue' ? r.number : null; }) .map(function (r) { return r.__typename === 'Issue' ? r.number : null; })
@ -28,19 +28,19 @@ module.exports = function (context, req) {
return; return;
} }
if (constants_1.ACTIVATE_MUTATION) { if (constants_1.ACTIVATE_MUTATION) {
github_1.getIssuesLabels(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, issuesNumber, function (issuesWithLabels) { github_1.getIssuesLabels(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, issuesNumber, function (issuesWithLabels) {
if (req.action === 'closed') { if (req.action === 'closed') {
var issuesWithLabelsWithExpectedLabel = issuesWithLabels.filter(function (iwl) { return iwl.labels.some(function (label) { return label === labelPRinProgress; }); }); var issuesWithLabelsWithExpectedLabel = issuesWithLabels.filter(function (iwl) { return iwl.labels.some(function (label) { return label === labelPRinProgress; }); });
issuesWithLabelsWithExpectedLabel.map(function (issueWithLabels) { issuesWithLabelsWithExpectedLabel.map(function (issueWithLabels) {
var labels = utils_1.distinct(issueWithLabels.labels.filter(function (label) { return label !== labelPRinProgress; })); var labels = utils_1.distinct(issueWithLabels.labels.filter(function (label) { return label !== labelPRinProgress; }));
github_1.setLabelsForIssue(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, issueWithLabels.number, labels); github_1.setLabelsForIssue(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, issueWithLabels.number, labels);
}); });
} }
if (req.action === 'opened' || req.action === 'reopened') { if (req.action === 'opened' || req.action === 'reopened') {
var issuesWithLabelsWithoutExpectedLabel = issuesWithLabels.filter(function (iwl) { return iwl.labels.every(function (label) { return label !== labelPRinProgress; }); }); var issuesWithLabelsWithoutExpectedLabel = issuesWithLabels.filter(function (iwl) { return iwl.labels.every(function (label) { return label !== labelPRinProgress; }); });
issuesWithLabelsWithoutExpectedLabel.map(function (issueWithLabels) { issuesWithLabelsWithoutExpectedLabel.map(function (issueWithLabels) {
var labels = utils_1.distinct(issueWithLabels.labels.concat([labelPRinProgress])); var labels = utils_1.distinct(issueWithLabels.labels.concat([labelPRinProgress]));
github_1.setLabelsForIssue(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, issueWithLabels.number, labels); github_1.setLabelsForIssue(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, issueWithLabels.number, labels);
}); });
} }
}); });

Просмотреть файл

@ -1,7 +1,7 @@
import { getPullRequest, getIssueOrPullRequestLinks, setLabelsForIssue, getIssuesLabels } from '../shared/github'; import { getPullRequest, getIssueOrPullRequestLinks, setLabelsForIssue, getIssuesLabels } from '../shared/github';
import { searchLinkedItemsNumbersInComment, completeFunction } from '../shared/functions'; import { searchLinkedItemsNumbersInComment, completeFunction } from '../shared/functions';
import { distinct } from '../shared/utils'; import { distinct } from '../shared/utils';
import { ACCESS_TOKEN, REPO_OWNER, REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants'; import { ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
const firstBlockTitle = '## PR Type'; const firstBlockTitle = '## PR Type';
const labelPRinProgress = 'PR in progress'; const labelPRinProgress = 'PR in progress';
@ -16,8 +16,8 @@ module.exports = (context, req) => {
getPullRequest( getPullRequest(
githubApiHeaders, githubApiHeaders,
REPO_OWNER, TARGET_REPO_OWNER,
REPO_NAME, TARGET_REPO_NAME,
pullRequestNumber, pullRequestNumber,
(pullRequest) => { (pullRequest) => {
// retrieve first block of creation block where user puts the linked issues // retrieve first block of creation block where user puts the linked issues
@ -27,7 +27,7 @@ module.exports = (context, req) => {
if (firstBlockOfCreationMessage) { if (firstBlockOfCreationMessage) {
const linkedItemsNumbers = distinct(searchLinkedItemsNumbersInComment(firstBlockOfCreationMessage)); const linkedItemsNumbers = distinct(searchLinkedItemsNumbersInComment(firstBlockOfCreationMessage));
getIssueOrPullRequestLinks(githubApiHeaders, REPO_OWNER, REPO_NAME, linkedItemsNumbers, (results) => { getIssueOrPullRequestLinks(githubApiHeaders, TARGET_REPO_OWNER, TARGET_REPO_NAME, linkedItemsNumbers, (results) => {
const issuesNumber = results const issuesNumber = results
.filter(r => r.__typename === 'Issue') .filter(r => r.__typename === 'Issue')
.map(r => r.__typename === 'Issue' ? r.number : null) .map(r => r.__typename === 'Issue' ? r.number : null)
@ -40,7 +40,7 @@ module.exports = (context, req) => {
} }
if (ACTIVATE_MUTATION) { if (ACTIVATE_MUTATION) {
getIssuesLabels(githubApiHeaders, REPO_OWNER, REPO_NAME, issuesNumber, (issuesWithLabels) => { getIssuesLabels(githubApiHeaders, TARGET_REPO_OWNER, TARGET_REPO_NAME, issuesNumber, (issuesWithLabels) => {
if (req.action === 'closed') { if (req.action === 'closed') {
// filter issues which DOES already contain the label // filter issues which DOES already contain the label
const issuesWithLabelsWithExpectedLabel = const issuesWithLabelsWithExpectedLabel =
@ -49,7 +49,7 @@ module.exports = (context, req) => {
// remove label 'PR in progress' // remove label 'PR in progress'
issuesWithLabelsWithExpectedLabel.map(issueWithLabels => { issuesWithLabelsWithExpectedLabel.map(issueWithLabels => {
const labels = distinct(issueWithLabels.labels.filter(label => label !== labelPRinProgress)); const labels = distinct(issueWithLabels.labels.filter(label => label !== labelPRinProgress));
setLabelsForIssue(githubApiHeaders, REPO_OWNER, REPO_NAME, issueWithLabels.number, labels); setLabelsForIssue(githubApiHeaders, TARGET_REPO_OWNER, TARGET_REPO_NAME, issueWithLabels.number, labels);
}); });
} }
if (req.action === 'opened' || req.action === 'reopened') { if (req.action === 'opened' || req.action === 'reopened') {
@ -60,7 +60,7 @@ module.exports = (context, req) => {
// add label 'PR in progress' // add label 'PR in progress'
issuesWithLabelsWithoutExpectedLabel.map(issueWithLabels => { issuesWithLabelsWithoutExpectedLabel.map(issueWithLabels => {
const labels = distinct(issueWithLabels.labels.concat([labelPRinProgress])); const labels = distinct(issueWithLabels.labels.concat([labelPRinProgress]));
setLabelsForIssue(githubApiHeaders, REPO_OWNER, REPO_NAME, issueWithLabels.number, labels); setLabelsForIssue(githubApiHeaders, TARGET_REPO_OWNER, TARGET_REPO_NAME, issueWithLabels.number, labels);
}); });
} }
}) })

Просмотреть файл

@ -9,11 +9,11 @@ module.exports = function (context) {
'User-Agent': 'github-bot-uwp-toolkit', 'User-Agent': 'github-bot-uwp-toolkit',
'Authorization': 'token ' + constants_1.ACCESS_TOKEN 'Authorization': 'token ' + constants_1.ACCESS_TOKEN
}; };
github_1.getAllMilestones(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, function (milestones) { github_1.getAllMilestones(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, function (milestones) {
var currentMilestone = milestones var currentMilestone = milestones
.filter(function (m) { return m.state === 'OPEN' && !!m.dueOn; }) .filter(function (m) { return m.state === 'OPEN' && !!m.dueOn; })
.sort(function (m1, m2) { return new Date(m1.dueOn).getTime() - new Date(m2.dueOn).getTime(); })[0]; .sort(function (m1, m2) { return new Date(m1.dueOn).getTime() - new Date(m2.dueOn).getTime(); })[0];
github_1.getAllGitHubIssuesRecursively(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, null, function (issues) { github_1.getAllGitHubIssuesRecursively(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, null, function (issues) {
var exclusiveLabels = [ var exclusiveLabels = [
'PR in progress', 'PR in progress',
'work in progress', 'work in progress',
@ -90,7 +90,7 @@ var makeDecisionsForIssuesInCurrentMilestone = function (githubApiHeaders, issue
}; };
var makeDecisionsForIssuesNotInMilestone = function (githubApiHeaders, issues) { var makeDecisionsForIssuesNotInMilestone = function (githubApiHeaders, issues) {
var decisions = issues.map(function (issue) { var decisions = issues.map(function (issue) {
var numberOfAlertsAlreadySent = detectNumberOfAlertsAlreadySent(constants_1.BOT_USERNAME, issue); var numberOfAlertsAlreadySent = detectNumberOfAlertsAlreadySent(constants_1.BOT_LOGIN, issue);
if (numberOfAlertsAlreadySent === 2) { if (numberOfAlertsAlreadySent === 2) {
return { return {
issue: issue, issue: issue,
@ -115,7 +115,7 @@ var makeDecisionsForIssuesNotInMilestone = function (githubApiHeaders, issues) {
}); });
decisions.filter(function (d) { return d.decision === 'close'; }).forEach(function (d) { decisions.filter(function (d) { return d.decision === 'close'; }).forEach(function (d) {
github_1.commentGitHubIssue(githubApiHeaders, d.issue.id, 'Issue is inactive. It was automatically closed.'); github_1.commentGitHubIssue(githubApiHeaders, d.issue.id, 'Issue is inactive. It was automatically closed.');
github_1.closeGitHubIssue(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, d.issue.number, d.issue.id); github_1.closeGitHubIssue(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, d.issue.number, d.issue.id);
}); });
} }
return decisions; return decisions;

Просмотреть файл

@ -2,7 +2,7 @@ import { addDays, distinct } from '../shared/utils';
import { completeFunction, containsExclusiveLabels } from '../shared/functions'; import { completeFunction, containsExclusiveLabels } from '../shared/functions';
import { IssueNode } from '../shared/models'; import { IssueNode } from '../shared/models';
import { getAllMilestones, getAllGitHubIssuesRecursively, commentGitHubIssue, closeGitHubIssue } from '../shared/github'; import { getAllMilestones, getAllGitHubIssuesRecursively, commentGitHubIssue, closeGitHubIssue } from '../shared/github';
import { ACCESS_TOKEN, REPO_OWNER, REPO_NAME, NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACTIVATE_MUTATION, BOT_USERNAME } from '../shared/constants'; import { ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACTIVATE_MUTATION, BOT_LOGIN } from '../shared/constants';
module.exports = (context) => { module.exports = (context) => {
const githubApiHeaders = { const githubApiHeaders = {
@ -12,8 +12,8 @@ module.exports = (context) => {
getAllMilestones( getAllMilestones(
githubApiHeaders, githubApiHeaders,
REPO_OWNER, TARGET_REPO_OWNER,
REPO_NAME, TARGET_REPO_NAME,
(milestones) => { (milestones) => {
const currentMilestone = milestones const currentMilestone = milestones
.filter(m => m.state === 'OPEN' && !!m.dueOn) .filter(m => m.state === 'OPEN' && !!m.dueOn)
@ -22,8 +22,8 @@ module.exports = (context) => {
getAllGitHubIssuesRecursively( getAllGitHubIssuesRecursively(
githubApiHeaders, githubApiHeaders,
REPO_OWNER, TARGET_REPO_OWNER,
REPO_NAME, TARGET_REPO_NAME,
null, null,
(issues) => { (issues) => {
const exclusiveLabels = [ const exclusiveLabels = [
@ -140,8 +140,9 @@ const makeDecisionsForIssuesNotInMilestone = (githubApiHeaders: any, issues: Iss
// take a decision about the issue (send a new alert or close it) // take a decision about the issue (send a new alert or close it)
const decisions = issues.map<IssueActivityDecision>(issue => { const decisions = issues.map<IssueActivityDecision>(issue => {
const numberOfAlertsAlreadySent = detectNumberOfAlertsAlreadySent( const numberOfAlertsAlreadySent = detectNumberOfAlertsAlreadySent(
BOT_USERNAME, BOT_LOGIN,
issue); issue
);
if (numberOfAlertsAlreadySent === 2) { if (numberOfAlertsAlreadySent === 2) {
return { return {
@ -182,8 +183,8 @@ const makeDecisionsForIssuesNotInMilestone = (githubApiHeaders: any, issues: Iss
closeGitHubIssue( closeGitHubIssue(
githubApiHeaders, githubApiHeaders,
REPO_OWNER, TARGET_REPO_OWNER,
REPO_NAME, TARGET_REPO_NAME,
d.issue.number, d.issue.number,
d.issue.id); d.issue.id);
}); });

Просмотреть файл

@ -9,11 +9,11 @@ module.exports = function (context) {
'User-Agent': 'github-bot-uwp-toolkit', 'User-Agent': 'github-bot-uwp-toolkit',
'Authorization': 'token ' + constants_1.ACCESS_TOKEN 'Authorization': 'token ' + constants_1.ACCESS_TOKEN
}; };
github_1.getAllMilestones(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, function (milestones) { github_1.getAllMilestones(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, function (milestones) {
var currentMilestone = milestones var currentMilestone = milestones
.filter(function (m) { return m.state === 'OPEN' && !!m.dueOn; }) .filter(function (m) { return m.state === 'OPEN' && !!m.dueOn; })
.sort(function (m1, m2) { return new Date(m1.dueOn).getTime() - new Date(m2.dueOn).getTime(); })[0]; .sort(function (m1, m2) { return new Date(m1.dueOn).getTime() - new Date(m2.dueOn).getTime(); })[0];
github_1.getAllOpenPullRequests(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, function (pullRequests) { github_1.getAllOpenPullRequests(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, function (pullRequests) {
var exclusiveLabels = [ var exclusiveLabels = [
'help wanted', 'help wanted',
'mute-bot' 'mute-bot'

Просмотреть файл

@ -2,7 +2,7 @@ import { getAllMilestones, getAllOpenPullRequests, commentGitHubPullRequest } fr
import { containsExclusiveLabels, completeFunction } from '../shared/functions'; import { containsExclusiveLabels, completeFunction } from '../shared/functions';
import { PullRequest } from '../shared/models'; import { PullRequest } from '../shared/models';
import { addDays } from '../shared/utils'; import { addDays } from '../shared/utils';
import { NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACCESS_TOKEN, REPO_OWNER, REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants'; import { NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
module.exports = (context) => { module.exports = (context) => {
const githubApiHeaders = { const githubApiHeaders = {
@ -12,8 +12,8 @@ module.exports = (context) => {
getAllMilestones( getAllMilestones(
githubApiHeaders, githubApiHeaders,
REPO_OWNER, TARGET_REPO_OWNER,
REPO_NAME, TARGET_REPO_NAME,
(milestones) => { (milestones) => {
const currentMilestone = milestones const currentMilestone = milestones
.filter(m => m.state === 'OPEN' && !!m.dueOn) .filter(m => m.state === 'OPEN' && !!m.dueOn)
@ -22,8 +22,8 @@ module.exports = (context) => {
getAllOpenPullRequests( getAllOpenPullRequests(
githubApiHeaders, githubApiHeaders,
REPO_OWNER, TARGET_REPO_OWNER,
REPO_NAME, TARGET_REPO_NAME,
(pullRequests) => { (pullRequests) => {
const exclusiveLabels = [ const exclusiveLabels = [
'help wanted', 'help wanted',

Просмотреть файл

@ -9,7 +9,7 @@ module.exports = function (context) {
'User-Agent': 'github-bot-uwp-toolkit', 'User-Agent': 'github-bot-uwp-toolkit',
'Authorization': 'token ' + constants_1.ACCESS_TOKEN 'Authorization': 'token ' + constants_1.ACCESS_TOKEN
}; };
github_1.getAllGitHubIssuesRecursively(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, null, function (issues) { github_1.getAllGitHubIssuesRecursively(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, null, function (issues) {
var exclusiveLabels = [ var exclusiveLabels = [
'PR in progress', 'PR in progress',
'work in progress', 'work in progress',

Просмотреть файл

@ -2,7 +2,7 @@ import { addDays, distinct } from '../shared/utils';
import { completeFunction } from '../shared/functions'; import { completeFunction } from '../shared/functions';
import { IssueNode } from '../shared/models'; import { IssueNode } from '../shared/models';
import { getAllGitHubIssuesRecursively, commentGitHubIssue } from '../shared/github'; import { getAllGitHubIssuesRecursively, commentGitHubIssue } from '../shared/github';
import { NUMBER_OF_DAYS_WITHOUT_RESPONSE, ACCESS_TOKEN, REPO_OWNER, REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants'; import { NUMBER_OF_DAYS_WITHOUT_RESPONSE, ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
module.exports = (context) => { module.exports = (context) => {
const githubApiHeaders = { const githubApiHeaders = {
@ -12,8 +12,8 @@ module.exports = (context) => {
getAllGitHubIssuesRecursively( getAllGitHubIssuesRecursively(
githubApiHeaders, githubApiHeaders,
REPO_OWNER, TARGET_REPO_OWNER,
REPO_NAME, TARGET_REPO_NAME,
null, null,
(issues) => { (issues) => {
const exclusiveLabels = [ const exclusiveLabels = [

Просмотреть файл

@ -9,7 +9,7 @@ module.exports = function (context) {
'User-Agent': 'github-bot-uwp-toolkit', 'User-Agent': 'github-bot-uwp-toolkit',
'Authorization': 'token ' + constants_1.ACCESS_TOKEN 'Authorization': 'token ' + constants_1.ACCESS_TOKEN
}; };
github_1.getAllGitHubIssuesRecursivelyFilterWithLabels(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, null, ["pending-uservoice-creation"], function (issues) { github_1.getAllGitHubIssuesRecursivelyFilterWithLabels(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, null, ["pending-uservoice-creation"], function (issues) {
context.log("Total of " + issues.length + " issues pending uservoice creation."); context.log("Total of " + issues.length + " issues pending uservoice creation.");
context.log(issues); context.log(issues);
var issuesWithoutActivity = issues.filter(function (issue) { var issuesWithoutActivity = issues.filter(function (issue) {

Просмотреть файл

@ -1,7 +1,7 @@
import { addDays } from '../shared/utils'; import { addDays } from '../shared/utils';
import { completeFunction } from '../shared/functions'; import { completeFunction } from '../shared/functions';
import { getAllGitHubIssuesRecursivelyFilterWithLabels, commentGitHubIssue } from '../shared/github'; import { getAllGitHubIssuesRecursivelyFilterWithLabels, commentGitHubIssue } from '../shared/github';
import { NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACCESS_TOKEN, REPO_OWNER, REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants'; import { NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
module.exports = (context) => { module.exports = (context) => {
const githubApiHeaders = { const githubApiHeaders = {
@ -11,8 +11,8 @@ module.exports = (context) => {
getAllGitHubIssuesRecursivelyFilterWithLabels( getAllGitHubIssuesRecursivelyFilterWithLabels(
githubApiHeaders, githubApiHeaders,
REPO_OWNER, TARGET_REPO_OWNER,
REPO_NAME, TARGET_REPO_NAME,
null, null,
["pending-uservoice-creation"], ["pending-uservoice-creation"],
(issues) => { (issues) => {

Просмотреть файл

@ -51,10 +51,10 @@ These environment variables should be set to launch the bot.
| Variable | Description | Default value | | Variable | Description | Default value |
|-|-|-| |-|-|-|
| GITHUB_BOT_UWP_TOOLKIT_USERNAME | Username of the GitHub account of the bot | uwptoolkitbot | | GITHUB_BOT_LOGIN | Login of the GitHub account of the bot | uwptoolkitbot |
| GITHUB_BOT_UWP_TOOLKIT_ACCESS_TOKEN | Personal Access Token used to retrieve data from the GitHub API | | | GITHUB_BOT_ACCESS_TOKEN | Personal Access Token used to retrieve data from the GitHub API | |
| GITHUB_BOT_UWP_TOOLKIT_REPO_OWNER | Target Repository owner | windows-toolkit | | GITHUB_BOT_TARGET_REPO_OWNER | Target Repository owner | windows-toolkit |
| GITHUB_BOT_UWP_TOOLKIT_REPO_NAME | Target Repository name | WindowsCommunityToolkit | | GITHUB_BOT_TARGET_REPO_NAME | Target Repository name | WindowsCommunityToolkit |
| GITHUB_BOT_UWP_TOOLKIT_ACTIVATE_MUTATION | Activate GitHub mutation calls | false | | GITHUB_BOT_ACTIVATE_MUTATION | Activate GitHub mutation calls | false |
| NUMBER_OF_DAYS_WITHOUT_ACTIVITY | Number of days without activity to check on `inactiveIssues` function | 7 | | NUMBER_OF_DAYS_WITHOUT_ACTIVITY | Number of days without activity to check on `inactiveIssues` function | 7 |
| NUMBER_OF_DAYS_WITHOUT_RESPONSE | Number of days without response to check on `noResponseFromCommunityOnIssues` function | 7 | | NUMBER_OF_DAYS_WITHOUT_RESPONSE | Number of days without response to check on `noResponseFromCommunityOnIssues` function | 7 |

Просмотреть файл

@ -1,10 +1,10 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.BOT_USERNAME = process.env.GITHUB_BOT_UWP_TOOLKIT_USERNAME || 'uwptoolkitbot'; exports.BOT_LOGIN = process.env.GITHUB_BOT_LOGIN || 'uwptoolkitbot';
exports.ACCESS_TOKEN = process.env.GITHUB_BOT_UWP_TOOLKIT_ACCESS_TOKEN; exports.ACCESS_TOKEN = process.env.GITHUB_BOT_ACCESS_TOKEN;
exports.REPO_OWNER = process.env.GITHUB_BOT_UWP_TOOLKIT_REPO_OWNER || 'windows-toolkit'; exports.TARGET_REPO_OWNER = process.env.GITHUB_BOT_TARGET_REPO_OWNER || 'windows-toolkit';
exports.REPO_NAME = process.env.GITHUB_BOT_UWP_TOOLKIT_REPO_NAME || 'WindowsCommunityToolkit'; exports.TARGET_REPO_NAME = process.env.GITHUB_BOT_TARGET_REPO_NAME || 'WindowsCommunityToolkit';
exports.ACTIVATE_MUTATION = process.env.GITHUB_BOT_UWP_TOOLKIT_ACTIVATE_MUTATION === 'true' ? true : false; exports.ACTIVATE_MUTATION = process.env.GITHUB_BOT_ACTIVATE_MUTATION === 'true' ? true : false;
exports.NUMBER_OF_DAYS_WITHOUT_ACTIVITY = process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY) : 7; exports.NUMBER_OF_DAYS_WITHOUT_ACTIVITY = process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY) : 7;
exports.NUMBER_OF_DAYS_WITHOUT_RESPONSE = process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE) : 7; exports.NUMBER_OF_DAYS_WITHOUT_RESPONSE = process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE) : 7;
//# sourceMappingURL=constants.js.map //# sourceMappingURL=constants.js.map

Просмотреть файл

@ -1,7 +1,7 @@
export const BOT_USERNAME = process.env.GITHUB_BOT_UWP_TOOLKIT_USERNAME || 'uwptoolkitbot'; export const BOT_LOGIN = process.env.GITHUB_BOT_LOGIN || 'uwptoolkitbot';
export const ACCESS_TOKEN = process.env.GITHUB_BOT_UWP_TOOLKIT_ACCESS_TOKEN; export const ACCESS_TOKEN = process.env.GITHUB_BOT_ACCESS_TOKEN;
export const REPO_OWNER = process.env.GITHUB_BOT_UWP_TOOLKIT_REPO_OWNER || 'windows-toolkit'; export const TARGET_REPO_OWNER = process.env.GITHUB_BOT_TARGET_REPO_OWNER || 'windows-toolkit';
export const REPO_NAME = process.env.GITHUB_BOT_UWP_TOOLKIT_REPO_NAME || 'WindowsCommunityToolkit'; export const TARGET_REPO_NAME = process.env.GITHUB_BOT_TARGET_REPO_NAME || 'WindowsCommunityToolkit';
export const ACTIVATE_MUTATION = process.env.GITHUB_BOT_UWP_TOOLKIT_ACTIVATE_MUTATION === 'true' ? true : false; export const ACTIVATE_MUTATION = process.env.GITHUB_BOT_ACTIVATE_MUTATION === 'true' ? true : false;
export const NUMBER_OF_DAYS_WITHOUT_ACTIVITY = process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY) : 7; export const NUMBER_OF_DAYS_WITHOUT_ACTIVITY = process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY) : 7;
export const NUMBER_OF_DAYS_WITHOUT_RESPONSE = process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE) : 7; export const NUMBER_OF_DAYS_WITHOUT_RESPONSE = process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE) : 7;

Просмотреть файл

@ -15,9 +15,9 @@ module.exports = function (context, req) {
'Authorization': 'token ' + constants_1.ACCESS_TOKEN 'Authorization': 'token ' + constants_1.ACCESS_TOKEN
}; };
var pullRequestNumber = req.number; var pullRequestNumber = req.number;
github_1.getPullRequest(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, pullRequestNumber, function (pullRequest) { github_1.getPullRequest(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, pullRequestNumber, function (pullRequest) {
var linkedItemsNumbers = getLinkedItemsNumbersInPullRequest(constants_1.BOT_USERNAME, pullRequest); var linkedItemsNumbers = getLinkedItemsNumbersInPullRequest(constants_1.BOT_LOGIN, pullRequest);
github_1.getIssueOrPullRequestLinks(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, linkedItemsNumbers, function (results) { github_1.getIssueOrPullRequestLinks(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, linkedItemsNumbers, function (results) {
var unclosedIssuesNumber = results var unclosedIssuesNumber = results
.filter(function (r) { return r.__typename === 'Issue' && r.closed === false; }) .filter(function (r) { return r.__typename === 'Issue' && r.closed === false; })
.map(function (r) { return r.__typename === 'Issue' ? r.number : null; }) .map(function (r) { return r.__typename === 'Issue' ? r.number : null; })

Просмотреть файл

@ -2,7 +2,7 @@ import { distinct } from '../shared/utils';
import { completeFunction, searchLinkedItemsNumbersInComment } from '../shared/functions'; import { completeFunction, searchLinkedItemsNumbersInComment } from '../shared/functions';
import { PullRequestNode } from '../shared/models'; import { PullRequestNode } from '../shared/models';
import { getPullRequest, getIssueOrPullRequestLinks, commentGitHubIssue } from '../shared/github'; import { getPullRequest, getIssueOrPullRequestLinks, commentGitHubIssue } from '../shared/github';
import { ACCESS_TOKEN, REPO_OWNER, REPO_NAME, BOT_USERNAME, ACTIVATE_MUTATION } from '../shared/constants'; import { ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, BOT_LOGIN, ACTIVATE_MUTATION } from '../shared/constants';
module.exports = (context, req) => { module.exports = (context, req) => {
if (req.action !== 'closed' || !req.pull_request.merged) { if (req.action !== 'closed' || !req.pull_request.merged) {
@ -20,17 +20,17 @@ module.exports = (context, req) => {
getPullRequest( getPullRequest(
githubApiHeaders, githubApiHeaders,
REPO_OWNER, TARGET_REPO_OWNER,
REPO_NAME, TARGET_REPO_NAME,
pullRequestNumber, pullRequestNumber,
(pullRequest) => { (pullRequest) => {
// get linked items (can be issue or PR) // get linked items (can be issue or PR)
const linkedItemsNumbers = getLinkedItemsNumbersInPullRequest( const linkedItemsNumbers = getLinkedItemsNumbersInPullRequest(
BOT_USERNAME, BOT_LOGIN,
pullRequest pullRequest
); );
getIssueOrPullRequestLinks(githubApiHeaders, REPO_OWNER, REPO_NAME, linkedItemsNumbers, (results) => { getIssueOrPullRequestLinks(githubApiHeaders, TARGET_REPO_OWNER, TARGET_REPO_NAME, linkedItemsNumbers, (results) => {
const unclosedIssuesNumber = results const unclosedIssuesNumber = results
.filter(r => r.__typename === 'Issue' && r.closed === false) .filter(r => r.__typename === 'Issue' && r.closed === false)
.map(r => r.__typename === 'Issue' ? r.number : null) .map(r => r.__typename === 'Issue' ? r.number : null)