Files
flipper/desktop/flipper-server-core/src/utils/environmentInfo.tsx
Andres Suarez 79023ee190 Update copyright headers from Facebook to Meta
Reviewed By: bhamodi

Differential Revision: D33331422

fbshipit-source-id: 016e8dcc0c0c7f1fc353a348b54fda0d5e2ddc01
2021-12-27 14:31:45 -08:00

59 lines
1.5 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,
): 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');
return {
processId: process.pid,
isProduction,
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(),
},
};
}