mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Found this while I was trying to make my own react native info for CI. For android Podfile.lock is being read instead of gradle.properties ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [INTERNAL][FIXED] - Fixed React native info where Podfile.lock was being read for android For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: https://github.com/facebook/react-native/pull/48876 Reviewed By: blakef Differential Revision: D68553964 Pulled By: cortinico fbshipit-source-id: 7d6391195dab0c2230fe86fb465de6d3f94ccbef
96 lines
2.4 KiB
TypeScript
96 lines
2.4 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
|
|
* @oncall react_native
|
|
*/
|
|
|
|
import {getEnvironmentInfoAsJson} from './envinfo';
|
|
import {logger, version} from '@react-native-community/cli-tools';
|
|
import {Config} from '@react-native-community/cli-types';
|
|
import {readFileSync} from 'fs';
|
|
import path from 'path';
|
|
import {stringify} from 'yaml';
|
|
import {CliOptions} from './types';
|
|
|
|
type PlatformValues = {
|
|
hermesEnabled: boolean | string;
|
|
newArchEnabled: boolean | string;
|
|
};
|
|
|
|
interface Platforms {
|
|
Android: PlatformValues;
|
|
iOS: PlatformValues;
|
|
}
|
|
|
|
const notFound = 'Not found';
|
|
|
|
function fileContains(str: string, filePath: string[]): boolean | string {
|
|
try {
|
|
return readFileSync(path.join(...filePath), {encoding: 'utf8'}).includes(
|
|
str,
|
|
);
|
|
} catch {
|
|
return notFound;
|
|
}
|
|
}
|
|
|
|
export default async function getInfo(options: CliOptions, ctx: Config) {
|
|
try {
|
|
logger.info('Fetching system and libraries information...');
|
|
|
|
const platforms: Platforms = {
|
|
Android: {
|
|
hermesEnabled: notFound,
|
|
newArchEnabled: notFound,
|
|
},
|
|
iOS: {
|
|
hermesEnabled: notFound,
|
|
newArchEnabled: notFound,
|
|
},
|
|
};
|
|
|
|
if (process.platform !== 'win32' && ctx.project.ios?.sourceDir) {
|
|
platforms.iOS.hermesEnabled = fileContains('hermes-engine', [
|
|
ctx.project.ios.sourceDir,
|
|
'Podfile.lock',
|
|
]);
|
|
platforms.iOS.newArchEnabled = fileContains('-DRCT_NEW_ARCH_ENABLED=1', [
|
|
ctx.project.ios.sourceDir,
|
|
'Pods',
|
|
'Pods.xcodeproj',
|
|
'project.pbxproj',
|
|
]);
|
|
}
|
|
|
|
if (ctx.project.android?.sourceDir) {
|
|
platforms.Android.hermesEnabled = fileContains('hermesEnabled=true', [
|
|
ctx.project.Android.sourceDir,
|
|
'gradle.properties',
|
|
]);
|
|
platforms.Android.newArchEnabled = fileContains('newArchEnabled=true', [
|
|
ctx.project.Android.sourceDir,
|
|
'gradle.properties',
|
|
]);
|
|
}
|
|
|
|
const output = {
|
|
...(await getEnvironmentInfoAsJson()),
|
|
...platforms,
|
|
};
|
|
|
|
if (options.json) {
|
|
logger.log(JSON.stringify(output, null, 2));
|
|
} else {
|
|
logger.log(stringify(output));
|
|
}
|
|
} catch (err) {
|
|
logger.error(`Unable to print environment info.\n${err}`);
|
|
} finally {
|
|
await version.logIfUpdateAvailable(ctx.root);
|
|
}
|
|
}
|