Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add newArchEnabled and hermesEnabled to info command #1897

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/cli-doctor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"semver": "^6.3.0",
"strip-ansi": "^5.2.0",
"sudo-prompt": "^9.0.0",
"wcwidth": "^1.0.1"
"wcwidth": "^1.0.1",
"yaml": "^2.2.1"
},
"files": [
"build",
Expand Down
79 changes: 77 additions & 2 deletions packages/cli-doctor/src/commands/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,87 @@
import getEnvironmentInfo from '../tools/envinfo';
import {logger, version} from '@react-native-community/cli-tools';
import {Config} from '@react-native-community/cli-types';
import {readFile} from 'fs-extra';
import path from 'path';
import {stringify} from 'yaml';

type PlatformValues = {
hermesEnabled: boolean | string;
newArchEnabled: boolean | string;
};

interface Platforms {
Android: PlatformValues;
iOS: PlatformValues;
}

const info = async function getInfo(_argv: Array<string>, ctx: Config) {
try {
logger.info('Fetching system and libraries information...');
const output = await getEnvironmentInfo(false);
logger.log(output);

const notFound = 'Not found';

const platforms: Platforms = {
Android: {
hermesEnabled: notFound,
newArchEnabled: notFound,
},
iOS: {
hermesEnabled: notFound,
newArchEnabled: notFound,
},
};

if (process.platform !== 'win32' && ctx.project.ios?.sourceDir) {
try {
const podfile = await readFile(
path.join(ctx.project.ios.sourceDir, '/Podfile.lock'),
'utf8',
);

platforms.iOS.hermesEnabled = podfile.includes('hermes-engine');
} catch (e) {
platforms.iOS.hermesEnabled = notFound;
}

try {
const project = await readFile(
path.join(
ctx.project.ios.sourceDir,
'/Pods/Pods.xcodeproj/project.pbxproj',
),
);

platforms.iOS.newArchEnabled = project.includes(
'-DRCT_NEW_ARCH_ENABLED=1',
);
} catch {
platforms.iOS.newArchEnabled = notFound;
}
}

if (ctx.project.android?.sourceDir) {
try {
const gradleProperties = await readFile(
path.join(ctx.project.android.sourceDir, '/gradle.properties'),
'utf8',
);

platforms.Android.hermesEnabled = gradleProperties.includes(
'hermesEnabled=true',
);
platforms.Android.newArchEnabled = gradleProperties.includes(
'newArchEnabled=true',
);
} catch {
platforms.Android.hermesEnabled = notFound;
platforms.Android.newArchEnabled = notFound;
}
}

const output = await getEnvironmentInfo();

logger.log(stringify({...output, ...platforms}));
} catch (err) {
logger.error(`Unable to print environment info.\n${err}`);
} finally {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13307,6 +13307,11 @@ yaml@^2.1.3:
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.1.3.tgz#9b3a4c8aff9821b696275c79a8bee8399d945207"
integrity sha512-AacA8nRULjKMX2DvWvOAdBZMOfQlypSFkjcOcu9FalllIDJ1kvlREzcdIZmidQUqqeMv7jorHjq2HlLv/+c2lg==

yaml@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.2.1.tgz#3014bf0482dcd15147aa8e56109ce8632cd60ce4"
integrity sha512-e0WHiYql7+9wr4cWMx3TVQrNwejKaEe7/rHNmQmqRjazfOP5W8PB6Jpebb5o6fIapbz9o9+2ipcaTM2ZwDI6lw==

[email protected]:
version "20.2.4"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54"
Expand Down