Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] [TS Migration] Migrate 'nativeVersionUpdater.js', 'GithubUtils.js', 'markPullRequestsAsDeployed.js' and 'bumpVersion.js' .github files to TypeScript #38280

Merged
merged 38 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
532777a
start migrating nativeVersionUpdater
JKobrynski Mar 11, 2024
ec0d553
migrate bumpVersion.js to TypeScript
JKobrynski Mar 11, 2024
7068222
start migrating markPullRequestsAsDeployed to TypeScript
JKobrynski Mar 11, 2024
2260d2a
start migrating GithubUtils to TypeScript
JKobrynski Mar 11, 2024
75d44f2
continue migrating GithubUtils to TypeScript
JKobrynski Mar 12, 2024
dd49bc3
fix naming convention errors is markPullRequestsAsDeployed.ts
JKobrynski Mar 14, 2024
db3cfd9
fix type casting in createOrUpdateStagingDeployTest.ts
JKobrynski Mar 14, 2024
da9fb4c
fix all type errors in GithubUtils and GithubUtilsTest
JKobrynski Mar 14, 2024
6ae1faf
Merge branch 'main' into migrateGroup22ToTypeScript
JKobrynski Mar 14, 2024
51baa62
fix GithubUtils related type errors in other files
JKobrynski Mar 14, 2024
928e663
remove unnecessary comment
JKobrynski Mar 14, 2024
e70c7e1
build actions
JKobrynski Mar 15, 2024
7e5465f
clean up GithubUtils
JKobrynski Mar 15, 2024
0e5cf33
Merge branch 'main' into migrateGroup22ToTypeScript
JKobrynski Mar 15, 2024
f47670b
parse npmVersion to Number
JKobrynski Mar 15, 2024
677044e
remove unnecessary code
JKobrynski Mar 15, 2024
a94cc9f
fix octokit mock typing
JKobrynski Mar 18, 2024
efe7c0c
Merge branch 'main' into migrateGroup22ToTypeScript
JKobrynski Mar 18, 2024
8ea974a
fix return value errors in isStagingDeployLockedTest.ts
JKobrynski Mar 18, 2024
5c2ecc2
rebuild gh actions
JKobrynski Mar 18, 2024
ddd969b
change require to import in verifySignedCommits.js
JKobrynski Mar 18, 2024
b63ad6e
rebuild gh actions
JKobrynski Mar 18, 2024
5a91678
fix tests and import related type errors
JKobrynski Mar 18, 2024
bf0560d
clean up the code
JKobrynski Mar 18, 2024
1d7db41
apply suggested changes
JKobrynski Mar 18, 2024
bcaf8e6
apply suggested changes
JKobrynski Mar 19, 2024
a526bd8
add @github import alias
JKobrynski Mar 19, 2024
2510b05
apply suggested changes
JKobrynski Mar 19, 2024
86eceb3
fix lint errors
JKobrynski Mar 19, 2024
39e5310
Merge branch 'main' into migrateGroup22ToTypeScript
JKobrynski Mar 22, 2024
87ee28a
apply suggested changes;
JKobrynski Mar 22, 2024
f7a3f59
Merge branch 'main' into migrateGroup22ToTypeScript
JKobrynski Mar 25, 2024
5bf2473
apply suggested changes
JKobrynski Mar 25, 2024
c08893c
Merge branch 'main' into migrateGroup22ToTypeScript
JKobrynski Mar 25, 2024
d3b028e
Merge branch 'main' into migrateGroup22ToTypeScript
JKobrynski Mar 26, 2024
46b507f
fix mock imports in test files
JKobrynski Mar 26, 2024
77a54cc
Merge branch 'main' into migrateGroup22ToTypeScript
JKobrynski Mar 26, 2024
8b9611b
Merge branch 'main' into migrateGroup22ToTypeScript
JKobrynski Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading