mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
bf51035e04
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52357 Changelog: [Internal] Adds a hyper-minimal build script using `electron/packager` that produces custom binaries for the experimental React Native DevTools standalone shell. The main user-facing benefit of this is replacing the Electron name and icon with our own branding. NOTE: `electron/packager` is designed to include the application code in the resulting binary. This is arguably overkill for us - the current launch model of `electron src/electron/index.js` is actually wholly sufficient for what we need - but I decided to go with the grain of the available tooling for simplicity. Icon design courtesy of huntie. 🙏 Reviewed By: huntie Differential Revision: D77591742 fbshipit-source-id: a968465df4f54fba54c874b6300788e151600ed7
76 lines
2.0 KiB
JavaScript
76 lines
2.0 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.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
// NOTE: Meta-internal setup must happen before any other imports.
|
|
let isMetaInternal = true;
|
|
try {
|
|
require.resolve('./metainternal/build-binary-setup');
|
|
} catch {
|
|
isMetaInternal = false;
|
|
}
|
|
if (isMetaInternal) {
|
|
// $FlowIgnore[cannot-resolve-module] - not resolvable in OSS
|
|
require('./metainternal/build-binary-setup');
|
|
}
|
|
|
|
const {packager} = require('@electron/packager');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const APP_NAME = 'React Native DevTools';
|
|
const COMPANY_NAME = 'Meta Platforms Technologies LLC';
|
|
const COPYRIGHT = `© ${new Date().getFullYear()} ${COMPANY_NAME}`;
|
|
const APP_BUNDLE_IDENTIFIER = 'dev.reactnative.devtools';
|
|
|
|
const PACKAGE_ROOT = path.join(
|
|
__dirname,
|
|
'..',
|
|
'..',
|
|
'packages',
|
|
'debugger-shell',
|
|
);
|
|
|
|
async function main() {
|
|
const pkg = JSON.parse(
|
|
fs.readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8'),
|
|
);
|
|
if (!pkg.main.startsWith('./dist/')) {
|
|
throw new Error('Package not built yet. Run scripts/build/build.js first.');
|
|
}
|
|
await packager({
|
|
dir: PACKAGE_ROOT,
|
|
icon: path.join(PACKAGE_ROOT, 'src/electron/resources/icon'),
|
|
platform: ['win32', 'darwin', 'linux'],
|
|
arch: ['x64', 'arm64'],
|
|
name: APP_NAME,
|
|
appVersion: pkg.version,
|
|
appCopyright: COPYRIGHT,
|
|
appCategoryType: 'public.app-category.developer-tools',
|
|
asar: true,
|
|
appBundleId: APP_BUNDLE_IDENTIFIER,
|
|
out: path.join(PACKAGE_ROOT, 'build'),
|
|
win32metadata: {
|
|
CompanyName: COMPANY_NAME,
|
|
ProductName: APP_NAME,
|
|
InternalName: APP_NAME,
|
|
FileDescription: `${APP_NAME}.exe`,
|
|
OriginalFilename: `${APP_NAME}.exe`,
|
|
},
|
|
overwrite: true,
|
|
});
|
|
}
|
|
|
|
if (require.main === module) {
|
|
main().catch(err => {
|
|
console.error(err);
|
|
process.exitCode = 1;
|
|
});
|
|
}
|