diff --git a/index.ts b/index.ts index 20c9fba4d..545d871d3 100644 --- a/index.ts +++ b/index.ts @@ -4,7 +4,14 @@ import dotenv from 'dotenv'; import { Octokit } from 'octokit'; -import * as projects from './projects.json'; +import _projects from './projects.json'; + +interface Projects{ + urls: string[]; + category?: { projectUrl: string} +} + +const projects = _projects as Projects; // init env variables dotenv.config(); @@ -84,7 +91,7 @@ async function main() { // prepare for issue updating const isDevpoolUnavailableLabel = devpoolIssue.labels?.some((label) => label.name === LABELS.UNAVAILABLE); const devpoolIssueLabelsStringified = devpoolIssue.labels.map(label => label.name).sort().toString(); - const projectIssueLabelsStringified = getDevpoolIssueLabels(projectIssue).sort().toString(); + const projectIssueLabelsStringified = getDevpoolIssueLabels(projectIssue, projectUrl).sort().toString(); // Update devpool issue if any of the following has been updated: // - issue title // - issue state (open/closed) @@ -105,7 +112,7 @@ async function main() { title: projectIssue.title, body: projectIssue.html_url, state: projectIssue.state, - labels: getDevpoolIssueLabels(projectIssue), + labels: getDevpoolIssueLabels(projectIssue, projectUrl), }); console.log(`Updated: ${devpoolIssue.html_url} (${projectIssue.html_url})`); } else { @@ -123,7 +130,7 @@ async function main() { repo: DEVPOOL_REPO_NAME, title: projectIssue.title, body: projectIssue.html_url, - labels: getDevpoolIssueLabels(projectIssue), + labels: getDevpoolIssueLabels(projectIssue, projectUrl), }); console.log(`Created: ${createdIssue.data.html_url} (${projectIssue.html_url})`); } @@ -223,7 +230,8 @@ async function getAllIssues(ownerName: string, repoName: string) { * @param issue issue object */ function getDevpoolIssueLabels( - issue: Issue + issue: Issue, + projectUrl: string ) { // get owner and repo name from issue's URL because the repo name could be updated const [ownerName, repoName] = getRepoCredentials(issue.html_url); @@ -246,6 +254,9 @@ function getDevpoolIssueLabels( if (!devpoolIssueLabels.includes(projectIssueLabel.name)) devpoolIssueLabels.push(projectIssueLabel.name); } + // if project category for the project is defined, add its category label + if (projects.category && projectUrl in projects.category) devpoolIssueLabels.push(projects.category.projectUrl); + return devpoolIssueLabels; } diff --git a/projects.json b/projects.json index 46021ae11..55314a31e 100644 --- a/projects.json +++ b/projects.json @@ -13,5 +13,9 @@ "https://github.com/ubiquity/telegram-ubiquibot", "https://github.com/ubiquity/ubiquibot-logging", "https://github.com/gitcoindev/ubiquibot" - ] + ], + "category": { + "https://github.com/gitcoindev/ubiquibot": "award winning bot fork", + "https://github.com/ubiquity/ubiquity-dollar": "ubidollar" + } }