Files
flipper/desktop/flipper-server-core/src/utils/environmentInfo.tsx
Lorenzo Blasa 94120d61aa RN-only build flag
Summary: Previously I had created a RN build, locally, with a few minor differences. That had to be reverted. Instead of reverting and re-applying changes, I'm introducing a flag that can be used in the interim to produce the RN-only builds.

Reviewed By: LukeDefeo

Differential Revision: D50555055

fbshipit-source-id: edface9a1587fb51e54eebe73724032baf985c83
2023-10-24 04:18:51 -07:00

65 lines
1.7 KiB
TypeScript

/**
* 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
*/
import process from 'process';
import os from 'os';
import fs from 'fs-extra';
import path from 'path';
import {EnvironmentInfo, ReleaseChannel} from 'flipper-common';
export async function getEnvironmentInfo(
packageJsonDir: string,
isProduction: boolean,
isHeadlessBuild: boolean,
): Promise<EnvironmentInfo> {
const packageJson = await fs.readJSON(
path.resolve(packageJsonDir, 'package.json'),
);
const releaseChannel: ReleaseChannel =
process.env.FLIPPER_RELEASE_CHANNEL === 'insiders'
? ReleaseChannel.INSIDERS
: process.env.FLIPPER_RELEASE_CHANNEL === 'stable'
? ReleaseChannel.STABLE
: packageJson.releaseChannel === 'insiders'
? ReleaseChannel.INSIDERS
: ReleaseChannel.STABLE;
// This is provided as part of the bundling process for headless.
const flipperReleaseRevision =
(global as any).__REVISION__ ?? packageJson.revision;
const appVersion =
process.env.FLIPPER_FORCE_VERSION ??
(isProduction ? packageJson.version : '0.0.0');
if (packageJson.reactNativeOnly) {
process.env.FLIPPER_REACT_NATIVE_ONLY = 'true';
}
return {
processId: process.pid,
isProduction,
isHeadlessBuild,
releaseChannel,
flipperReleaseRevision,
appVersion,
os: {
arch: process.arch,
platform: process.platform,
unixname: os.userInfo().username,
},
versions: {
electron: process.versions.electron,
node: process.versions.node,
platform: os.release(),
},
};
}