From d0ace0243f38a946d223d0aaf2fef7a1918fa00c Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Wed, 16 Jul 2025 08:20:40 -0700 Subject: [PATCH 1/3] Exclude unimportant files from Electron build Summary: TSIA Changelog: [Internal] Reviewed By: huntie Differential Revision: D78351935 --- scripts/debugger-shell/build-binary.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/debugger-shell/build-binary.js b/scripts/debugger-shell/build-binary.js index ed98c9269d63..46ba775ed21d 100644 --- a/scripts/debugger-shell/build-binary.js +++ b/scripts/debugger-shell/build-binary.js @@ -44,6 +44,21 @@ async function main() { if (!pkg.main.startsWith('./dist/')) { throw new Error('Package not built yet. Run scripts/build/build.js first.'); } + + const IGNORE_PREFIXES = [ + 'src', + 'dist/node', + 'metainternal/build-mac', + '__tests__', + 'README.md', + ].map( + dirRelativeToPackageRoot => + path.join(PACKAGE_ROOT, dirRelativeToPackageRoot) + path.sep, + ); + const IGNORE_FILES = ['BUCK'].map(fileRelativeToPackageRoot => + path.join(PACKAGE_ROOT, fileRelativeToPackageRoot), + ); + await packager({ dir: PACKAGE_ROOT, icon: path.join(PACKAGE_ROOT, 'src/electron/resources/icon'), @@ -64,6 +79,10 @@ async function main() { OriginalFilename: `${APP_NAME}.exe`, }, overwrite: true, + ignore: [ + ...IGNORE_PREFIXES.map(prefix => new RegExp('^' + escapeRegex(prefix))), + ...IGNORE_FILES.map(file => new RegExp('^' + escapeRegex(file) + '$')), + ], }); } @@ -73,3 +92,7 @@ if (require.main === module) { process.exitCode = 1; }); } + +function escapeRegex(str /*: string */) /*: string */ { + return str.replace(/[-[\]\\/{}()*+?.^$|]/g, '\\$&'); +} From 18e60d7061f43071cd7e3e5a6ccb0ec861b66d07 Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Wed, 16 Jul 2025 08:20:40 -0700 Subject: [PATCH 2/3] Implement --version flag Summary: Changelog: [Internal] Adds a basic `--version` command line flag to the RNDT shell. This will be used in code paths (including tests) that need to verify that the shell is executable, but do not need to actually display a window or hand over control to the main shell instance. Reviewed By: huntie Differential Revision: D78351936 --- .../debugger-shell/src/electron/index.flow.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/debugger-shell/src/electron/index.flow.js b/packages/debugger-shell/src/electron/index.flow.js index 4dc67035f813..a07b0fc2afa1 100644 --- a/packages/debugger-shell/src/electron/index.flow.js +++ b/packages/debugger-shell/src/electron/index.flow.js @@ -10,6 +10,22 @@ // $FlowFixMe[unclear-type] We have no Flow types for the Electron API. const {app} = require('electron') as any; +const util = require('util'); + +// Handle global command line arguments which don't require a window +// or the single instance lock to be held. +const { + values: {version = false}, +} = util.parseArgs({ + options: {version: {type: 'boolean'}}, + args: process.argv.slice(app.isPackaged ? 1 : 2), + strict: false, +}); +if (version) { + console.log(`${app.getName()} v${app.getVersion()}`); + // Not app.quit() - we want to exit immediately without initialising the graphical subsystem. + app.exit(0); +} const gotTheLock = app.requestSingleInstanceLock({ argv: process.argv.slice(2), From 67672e7b37b3c321f6529446e0070510413556ff Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Wed, 16 Jul 2025 08:20:40 -0700 Subject: [PATCH 3/3] Fix argv handling for packaged mode Summary: Changelog: [Internal] TSIA, missed this in D77591742 Reviewed By: huntie Differential Revision: D78413090 --- packages/debugger-shell/src/electron/index.flow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/debugger-shell/src/electron/index.flow.js b/packages/debugger-shell/src/electron/index.flow.js index a07b0fc2afa1..12c6cad55377 100644 --- a/packages/debugger-shell/src/electron/index.flow.js +++ b/packages/debugger-shell/src/electron/index.flow.js @@ -28,7 +28,7 @@ if (version) { } const gotTheLock = app.requestSingleInstanceLock({ - argv: process.argv.slice(2), + argv: process.argv.slice(app.isPackaged ? 1 : 2), }); if (!gotTheLock) {