Skip to content

Commit

Permalink
fix merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Mar 27, 2024
2 parents a5c0a63 + b0db06d commit f778dd1
Show file tree
Hide file tree
Showing 174 changed files with 50,403 additions and 82,752 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ module.exports = {
// This path is provide alias for files like `ONYXKEYS` and `CONST`.
'@src': './src',
'@desktop': './desktop',
'@github': './.github',
},
},
],
Expand Down
44 changes: 22 additions & 22 deletions .github/actions/javascript/authorChecklist/authorChecklist.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable @typescript-eslint/naming-convention */
import * as core from '@actions/core';
import * as github from '@actions/github';
import escapeRegExp from 'lodash/escapeRegExp';
import CONST from '../../../libs/CONST';
import GithubUtils from '../../../libs/GithubUtils';
import CONST from '@github/libs/CONST';
import GithubUtils from '@github/libs/GithubUtils';
import newComponentCategory from './categories/newComponentCategory';

const pathToAuthorChecklist = `https://raw.githubusercontent.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}/main/.github/PULL_REQUEST_TEMPLATE.md`;
Expand All @@ -20,24 +21,24 @@ const CHECKLIST_CATEGORIES = {
*/
async function getChecklistCategoriesForPullRequest(): Promise<Set<string>> {
const checks = new Set<string>();
const changedFiles = await GithubUtils.paginate(GithubUtils.octokit.pulls.listFiles, {
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
// eslint-disable-next-line @typescript-eslint/naming-convention
pull_number: prNumber,
// eslint-disable-next-line @typescript-eslint/naming-convention
per_page: 100,
});
const possibleCategories = await Promise.all(
Object.values(CHECKLIST_CATEGORIES).map(async (category) => ({
items: category.items,
doesCategoryApply: await category.detect(changedFiles),
})),
);
for (const category of possibleCategories) {
if (category.doesCategoryApply) {
for (const item of category.items) {
checks.add(item);
if (prNumber !== undefined) {
const changedFiles = await GithubUtils.paginate(GithubUtils.octokit.pulls.listFiles, {
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
pull_number: prNumber,
per_page: 100,
});
const possibleCategories = await Promise.all(
Object.values(CHECKLIST_CATEGORIES).map(async (category) => ({
items: category.items,
doesCategoryApply: await category.detect(changedFiles),
})),
);
for (const category of possibleCategories) {
if (category.doesCategoryApply) {
for (const item of category.items) {
checks.add(item);
}
}
}
}
Expand Down Expand Up @@ -126,12 +127,11 @@ async function generateDynamicChecksAndCheckForCompletion() {
const newBody = contentBeforeChecklist + checklistStartsWith + checklist + checklistEndsWith + contentAfterChecklist;

// Update the PR body
if (didChecklistChange) {
if (didChecklistChange && prNumber !== undefined) {
console.log('Checklist changed, updating PR...');
await GithubUtils.octokit.pulls.update({
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
// eslint-disable-next-line @typescript-eslint/naming-convention
pull_number: prNumber,
body: newBody,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import github from '@actions/github';
import {parse} from '@babel/parser';
import traverse from '@babel/traverse';
import CONST from '../../../../libs/CONST';
import GithubUtils from '../../../../libs/GithubUtils';
import promiseSome from '../../../../libs/promiseSome';
import CONST from '@github/libs/CONST';
import GithubUtils from '@github/libs/GithubUtils';
import promiseSome from '@github/libs/promiseSome';
import type Category from './Category';

type SuperClassType = {superClass: {name?: string; object: {name: string}; property: {name: string}} | null; name: string};
Expand Down Expand Up @@ -81,7 +81,7 @@ async function detectReactComponentInFile(filename: string): Promise<boolean | u
};
try {
const {data} = await GithubUtils.octokit.repos.getContent(params);
const content = 'content' in data ? nodeBase64ToUtf8(data.content || '') : data;
const content = nodeBase64ToUtf8('content' in data ? data?.content ?? '' : '');
return detectReactComponent(content, filename);
} catch (error) {
console.error('An unknown error occurred with the GitHub API: ', error, params);
Expand Down
Loading

0 comments on commit f778dd1

Please sign in to comment.