Skip to content
Closed
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
12 changes: 10 additions & 2 deletions packages/cli-doctor/src/commands/doctor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import chalk from 'chalk';
import {logger, getLoader} from '@react-native-community/cli-tools';
import {
logger,
getLoader,
findProjectRoot,
} from '@react-native-community/cli-tools';
import {getHealthchecks, HEALTHCHECK_TYPES} from '../tools/healthchecks';
import printFixOptions, {KEYS} from '../tools/printFixOptions';
import runAutomaticFix, {AUTOMATIC_FIX_LEVELS} from '../tools/runAutomaticFix';
Expand Down Expand Up @@ -116,6 +120,8 @@ const doctorCommand = (async (_, options) => {

const environmentInfo = await getEnvironmentInfo();

const projectRoot = findProjectRoot();

const iterateOverHealthChecks = async ({
label,
healthchecks,
Expand All @@ -133,7 +139,7 @@ const doctorCommand = (async (_, options) => {
version,
versions,
versionRange,
} = await healthcheck.getDiagnostics(environmentInfo);
} = await healthcheck.getDiagnostics(environmentInfo, projectRoot);

// Assume that it's required unless specified otherwise
const isRequired = healthcheck.isRequired !== false;
Expand Down Expand Up @@ -213,6 +219,7 @@ const doctorCommand = (async (_, options) => {
stats,
loader,
environmentInfo,
projectRoot,
});
}

Expand Down Expand Up @@ -248,6 +255,7 @@ const doctorCommand = (async (_, options) => {
stats,
loader,
environmentInfo,
projectRoot,
});

process.exit(0);
Expand Down
7 changes: 2 additions & 5 deletions packages/cli-doctor/src/tools/healthchecks/xcodeEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {HealthCheckInterface} from '../../types';
import fs from 'fs';
import path from 'path';
import {promisify} from 'util';
import {findProjectRoot} from '@react-native-community/cli-tools';
import {findPodfilePaths} from '@react-native-community/cli-platform-ios';

const xcodeEnvFile = '.xcode.env';
Expand All @@ -26,8 +25,7 @@ function pathDoesNotHaveXcodeEnvFile(pathString: string): boolean {
export default {
label: '.xcode.env',
description: 'File to customize Xcode environment',
getDiagnostics: async () => {
const projectRoot = findProjectRoot();
getDiagnostics: async (_, projectRoot) => {
const allPathsHasXcodeEnvFile = findPodfilePaths(projectRoot)
.map((pathString) => {
const basePath = removeLastPathComponent(pathString);
Expand All @@ -38,9 +36,8 @@ export default {
needsToBeFixed: !allPathsHasXcodeEnvFile,
};
},
runAutomaticFix: async () => {
runAutomaticFix: async ({projectRoot}) => {
const templateXcodeEnv = '_xcode.env';
const projectRoot = findProjectRoot();

const templateIosPath = path.dirname(
require.resolve('react-native/template/ios'),
Expand Down
3 changes: 3 additions & 0 deletions packages/cli-doctor/src/tools/runAutomaticFix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ interface RunAutomaticFixArgs {
};
loader: Loader;
environmentInfo: EnvironmentInfo;
projectRoot: string;
}

export default async function ({
healthchecks,
automaticFixLevel,
stats,
environmentInfo,
projectRoot,
}: RunAutomaticFixArgs) {
// Remove the fix options from screen
if (process.stdout.isTTY) {
Expand Down Expand Up @@ -90,6 +92,7 @@ export default async function ({
loader: spinner,
logManualInstallation,
environmentInfo,
projectRoot,
});
} catch (error) {
// TODO: log the error in a meaningful way
Expand Down
2 changes: 2 additions & 0 deletions packages/cli-doctor/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export type RunAutomaticFix = (args: {
message?: string;
}) => void;
environmentInfo: EnvironmentInfo;
projectRoot: string;
}) => Promise<void> | void;

export type HealthCheckInterface = {
Expand All @@ -84,6 +85,7 @@ export type HealthCheckInterface = {
description?: string;
getDiagnostics: (
environmentInfo: EnvironmentInfo,
projectRoot: string,
) => Promise<{
version?: string;
versions?: [string];
Expand Down