Files
Pierre Moulon 6587beab88 Fixing typos (#55047)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55047

Changelog: [Internal]

Fixed typos found through comprehensive recursive scan of the react-native-github directory.

**Fixed typos:**
1. "accomodate" → "accommodate" in CHANGELOG-0.6x.md
2. "occured" → "occurred" in LaunchUtils.js
3. "compatability" → "compatibility" in 7 Renderer files
4. "recieved" → "received" in PointerEvent test files (6 instances)
5. "seperated" → "separated" in ImageExample.js

**Total: 16 typo instances fixed across 10 files**

All typos were found by scanning ~3000 text files (excluding dist/third-party/node_modules) using pattern matching for common misspellings.

Reviewed By: javache

Differential Revision: D89799362

fbshipit-source-id: 73e9123dc0bae3c1ce8e374f4752404ab7345347
2026-01-06 03:23:09 -08:00

121 lines
3.3 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
const {log, getNpmPackageInfo, run} = require('./utils');
async function _computePreviousVersionFrom(version) {
log(`Computing previous version from: ${version}`);
const regex = /^0\.(\d+)\.(\d+)(-rc\.(\d+))?$/;
const match = version.match(regex);
if (!match) {
throw new Error(`Invalid version format: ${version}`);
}
const minor = match[1];
const patch = match[2];
const rc = match[4];
if (rc) {
if (Number(rc) > 0) {
return `0.${minor}.${patch}-rc.${Number(rc) - 1}`;
}
//fetch latest version on NPM
const latestPkg = await getNpmPackageInfo('react-native', 'latest');
return latestPkg.version;
} else {
if (Number(patch) === 0) {
// No need to generate the changelog for 0.X.0 as we already generated it from RCs
log(
`Skipping changelog generation for ${version} as we already have it from the RCs`,
);
return null;
}
return `0.${minor}.${Number(patch) - 1}`;
}
}
function _generateChangelog(previousVersion, version, token) {
log(`Generating changelog for ${version} from ${previousVersion}`);
run('git checkout main');
run('git fetch');
run('git pull origin main');
const generateChangelogCommand = `npx @rnx-kit/rn-changelog-generator --base v${previousVersion} --compare v${version} --repo . --changelog ./CHANGELOG.md --token ${token}`;
run(generateChangelogCommand);
}
function _pushCommit(version) {
log(`Pushing commit to changelog/v${version}`);
run(`git checkout -b changelog/v${version}`);
run('git add CHANGELOG.md');
run(`git commit -m "[RN][Changelog] Add changelog for v${version}"`);
run(`git push origin changelog/v${version}`);
}
async function _createPR(version, token) {
log('Creating changelog pr');
const url = 'https://api.github.com/repos/facebook/react-native/pulls';
const body = `
## Summary
Add Changelog for ${version}
## Changelog:
[Internal] - Add Changelog for ${version}
## Test Plan:
N/A`;
const response = await fetch(url, {
method: 'POST',
headers: {
Accept: 'Accept: application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({
title: `[RN][Changelog] Add changelog for v${version}`,
head: `changelog/v${version}`,
base: 'main',
body: body,
}),
});
if (response.status !== 201) {
throw new Error(
`Failed to create PR: ${response.status} ${response.statusText}`,
);
}
const data = await response.json();
return data.html_url;
}
async function generateChangelog(version, token) {
if (version.startsWith('v')) {
version = version.substring(1);
}
const previousVersion = await _computePreviousVersionFrom(version);
if (previousVersion) {
log(`Previous version is ${previousVersion}`);
_generateChangelog(previousVersion, version, token);
_pushCommit(version);
const prURL = await _createPR(version, token);
log(`Created PR: ${prURL}`);
}
}
module.exports = {
generateChangelog,
// Exported only for testing purposes:
_computePreviousVersionFrom,
_generateChangelog,
_pushCommit,
_createPR,
};