mirror of
https://github.com/react/react-native.git
synced 2026-09-29 16:58:04 +08:00
Update source repo URL for debugger-frontend, require branch arg (#41118)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41118 Updates the release process and guidance for `debugger-frontend`, now that the source [facebookexperimental/rn-chrome-devtools-frontend](https://github.com/facebookexperimental/rn-chrome-devtools-frontend) repo is published. The `sync-and-build` script now requires a `--branch` argument, allowing us to match release branches across repos for hotfixes (e.g. `0.73-stable`). Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D50496327 fbshipit-source-id: 671fd1581e23032eec0a419a6e50dac6c76feeb0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b256f8b791
commit
d4fe550478
@@ -25,8 +25,7 @@ const SignedSource = require('signedsource');
|
||||
const supportsColor = require('supports-color');
|
||||
|
||||
const DEVTOOLS_FRONTEND_REPO_URL =
|
||||
'https://github.com/motiz88/rn-chrome-devtools-frontend';
|
||||
const DEVTOOLS_FRONTEND_REPO_BRANCH = 'rn-0.73-chromium-5845';
|
||||
'https://github.com/facebookexperimental/rn-chrome-devtools-frontend';
|
||||
|
||||
const REPO_ROOT = path.resolve(__dirname, '../..');
|
||||
const PACKAGES_DIR /*: string */ = path.join(REPO_ROOT, 'packages');
|
||||
@@ -34,6 +33,7 @@ const PACKAGES_DIR /*: string */ = path.join(REPO_ROOT, 'packages');
|
||||
const config = {
|
||||
allowPositionals: true,
|
||||
options: {
|
||||
branch: {type: 'string'},
|
||||
'keep-scratch': {type: 'boolean'},
|
||||
nohooks: {type: 'boolean'},
|
||||
help: {type: 'boolean'},
|
||||
@@ -43,27 +43,24 @@ const config = {
|
||||
async function main() {
|
||||
const {
|
||||
positionals,
|
||||
values: {help, nohooks, 'keep-scratch': keepScratch},
|
||||
values: {help, branch, nohooks, 'keep-scratch': keepScratch},
|
||||
} = parseArgs(config);
|
||||
|
||||
if (help === true) {
|
||||
console.log(`
|
||||
Usage: node scripts/debugger-frontend/sync-and-build [OPTIONS] [checkout path]
|
||||
|
||||
Sync and build the debugger frontend into @react-native/debugger-frontend.
|
||||
|
||||
By default, checks out the currently pinned revision of the DevTools frontend.
|
||||
If an existing checkout path is provided, builds it instead.
|
||||
|
||||
Options:
|
||||
--nohooks Don't run gclient hooks in the devtools checkout (useful
|
||||
for existing checkouts).
|
||||
--keep-scratch Don't clean up temporary files.
|
||||
`);
|
||||
showHelp();
|
||||
process.exitCode = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const localCheckoutPath = positionals?.[0];
|
||||
|
||||
if (branch == null && !localCheckoutPath?.length) {
|
||||
console.error(chalk.red('Error: Missing option --branch'));
|
||||
showHelp();
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('\n' + chalk.bold.inverse('Syncing debugger-frontend') + '\n');
|
||||
|
||||
const scratchPath = await fs.mkdtemp(
|
||||
@@ -72,8 +69,8 @@ async function main() {
|
||||
process.stdout.write(chalk.dim(`Scratch path: ${scratchPath}\n\n`));
|
||||
|
||||
await checkRequiredTools();
|
||||
const localCheckoutPath = positionals.length ? positionals[0] : undefined;
|
||||
await buildDebuggerFrontend(scratchPath, localCheckoutPath, {
|
||||
branch: branch ?? '',
|
||||
gclientSyncOptions: {nohooks: nohooks === true},
|
||||
});
|
||||
await cleanup(scratchPath, keepScratch === true);
|
||||
@@ -83,6 +80,24 @@ async function main() {
|
||||
);
|
||||
}
|
||||
|
||||
function showHelp() {
|
||||
console.log(`
|
||||
Usage: node scripts/debugger-frontend/sync-and-build [OPTIONS] [checkout path]
|
||||
|
||||
Sync and build the debugger frontend into @react-native/debugger-frontend.
|
||||
|
||||
By default, checks out the currently pinned revision of the DevTools frontend.
|
||||
If an existing checkout path is provided, builds it instead.
|
||||
|
||||
Options:
|
||||
--branch The DevTools frontend branch to use. Ignored when
|
||||
providing a local checkout path.
|
||||
--nohooks Don't run gclient hooks in the devtools checkout (useful
|
||||
for existing checkouts).
|
||||
--keep-scratch Don't clean up temporary files.
|
||||
`);
|
||||
}
|
||||
|
||||
async function checkRequiredTools() {
|
||||
process.stdout.write('Checking that required tools are available' + '\n');
|
||||
await spawnSafe('git', ['--version'], {stdio: 'ignore'});
|
||||
@@ -104,9 +119,10 @@ async function checkRequiredTools() {
|
||||
async function buildDebuggerFrontend(
|
||||
scratchPath /*: string */,
|
||||
localCheckoutPath /*: ?string */,
|
||||
{
|
||||
gclientSyncOptions,
|
||||
} /*: $ReadOnly<{gclientSyncOptions: $ReadOnly<{nohooks: boolean}>}>*/,
|
||||
{branch, gclientSyncOptions} /*: $ReadOnly<{
|
||||
branch: string,
|
||||
gclientSyncOptions: $ReadOnly<{nohooks: boolean}>,
|
||||
}>*/,
|
||||
) {
|
||||
let checkoutPath;
|
||||
if (localCheckoutPath == null) {
|
||||
@@ -114,7 +130,7 @@ async function buildDebuggerFrontend(
|
||||
|
||||
await fs.mkdir(scratchPath, {recursive: true});
|
||||
|
||||
await checkoutDevToolsFrontend(scratchCheckoutPath);
|
||||
await checkoutDevToolsFrontend(scratchCheckoutPath, branch);
|
||||
checkoutPath = scratchCheckoutPath;
|
||||
} else {
|
||||
checkoutPath = localCheckoutPath;
|
||||
@@ -133,20 +149,24 @@ async function buildDebuggerFrontend(
|
||||
await generateBuildInfo({
|
||||
checkoutPath,
|
||||
packagePath,
|
||||
branch,
|
||||
isLocalCheckout: localCheckoutPath != null,
|
||||
gclientSyncOptions,
|
||||
gnArgsSummary,
|
||||
});
|
||||
}
|
||||
|
||||
async function checkoutDevToolsFrontend(checkoutPath /*: string */) {
|
||||
async function checkoutDevToolsFrontend(
|
||||
checkoutPath /*: string */,
|
||||
branch /*: string */,
|
||||
) {
|
||||
process.stdout.write('Checking out devtools-frontend\n');
|
||||
await fs.mkdir(checkoutPath, {recursive: true});
|
||||
await spawnSafe('git', [
|
||||
'clone',
|
||||
DEVTOOLS_FRONTEND_REPO_URL,
|
||||
'--branch',
|
||||
DEVTOOLS_FRONTEND_REPO_BRANCH,
|
||||
branch,
|
||||
'--single-branch',
|
||||
'--depth',
|
||||
'1',
|
||||
@@ -262,6 +282,7 @@ async function generateBuildInfo(
|
||||
info /*: $ReadOnly<{
|
||||
checkoutPath: string,
|
||||
isLocalCheckout: boolean,
|
||||
branch: string,
|
||||
packagePath: string,
|
||||
gclientSyncOptions: $ReadOnly<{nohooks: boolean}>,
|
||||
gnArgsSummary: string,
|
||||
@@ -298,7 +319,7 @@ async function generateBuildInfo(
|
||||
...(!info.isLocalCheckout
|
||||
? [
|
||||
'Remote URL: ' + DEVTOOLS_FRONTEND_REPO_URL,
|
||||
'Remote branch: ' + DEVTOOLS_FRONTEND_REPO_BRANCH,
|
||||
'Remote branch: ' + info.branch,
|
||||
]
|
||||
: ['Hostname: ' + hostname(), 'User: ' + userInfo().username]),
|
||||
'GN build args (overrides only): ',
|
||||
|
||||
Reference in New Issue
Block a user