Move flipper-doctor library out of sonar folder
Summary: Temporary move flipper-doctor library out of sonar folder to fix the build Reviewed By: jknoxville Differential Revision: D18626493 fbshipit-source-id: 352587b0db914a0f40069f6af6cd5569b03fb508
This commit is contained in:
committed by
Facebook Github Bot
parent
ddb135ac39
commit
735a586c37
1
doctor/.gitignore
vendored
1
doctor/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
/lib
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
.gitignore
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# Flipper Doctor
|
|
||||||
|
|
||||||
This package exists for running checks to diagnose and potentially fix issues affecting the operation of Flipper.
|
|
||||||
It's designed to be primarily used programmatically but may also expose a CLI interface.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
`cd doctor`
|
|
||||||
`yarn run run`
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.(t|j)sx?$": "ts-jest"
|
|
||||||
},
|
|
||||||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
|
||||||
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "flipper-doctor",
|
|
||||||
"version": "0.2.0",
|
|
||||||
"description": "Utility for checking for issues with a flipper installation",
|
|
||||||
"main": "lib/index.js",
|
|
||||||
"types": "lib/index.d.ts",
|
|
||||||
"license": "MIT",
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/jest": "^24.0.21",
|
|
||||||
"eslint": "^6.6.0",
|
|
||||||
"jest": "^24.9.0",
|
|
||||||
"prettier": "^1.19.1",
|
|
||||||
"ts-jest": "^24.1.0",
|
|
||||||
"tslint-config-prettier": "^1.18.0",
|
|
||||||
"typescript": "^3.7.2"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "tsc",
|
|
||||||
"prepare": "npm run build",
|
|
||||||
"prepublishOnly": "npm test && npm run lint",
|
|
||||||
"preversion": "npm run lint",
|
|
||||||
"test": "jest --config jestconfig.json",
|
|
||||||
"lint": "eslint -c ../.eslintrc.js src/**/* --ext .js,.ts && tsc --noemit",
|
|
||||||
"fix": "eslint -c ../.eslintrc.js src/**/* --fix --ext .js,.ts",
|
|
||||||
"run": "npm run build && node lib/cli.js"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib/**/*"
|
|
||||||
],
|
|
||||||
"keywords": [
|
|
||||||
"Flipper",
|
|
||||||
"Doctor"
|
|
||||||
],
|
|
||||||
"author": "Facebook, Inc",
|
|
||||||
"dependencies": {
|
|
||||||
"envinfo": "^7.4.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Facebook, Inc. and its 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 {getHealthchecks} from './index';
|
|
||||||
import {getEnvInfo} from './environmentInfo';
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const environmentInfo = await getEnvInfo();
|
|
||||||
console.log(JSON.stringify(environmentInfo));
|
|
||||||
const healthchecks = getHealthchecks();
|
|
||||||
const results = await Promise.all(
|
|
||||||
Object.entries(healthchecks).map(async ([key, category]) => [
|
|
||||||
key,
|
|
||||||
category
|
|
||||||
? {
|
|
||||||
label: category.label,
|
|
||||||
results: await Promise.all(
|
|
||||||
category.healthchecks.map(async ({label, run}) => ({
|
|
||||||
label,
|
|
||||||
result: await run(environmentInfo),
|
|
||||||
})),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
: {},
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(JSON.stringify(results, null, 2));
|
|
||||||
})();
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Facebook, Inc. and its 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 {run} from 'envinfo';
|
|
||||||
|
|
||||||
export type EnvironmentInfo = {
|
|
||||||
SDKs: {
|
|
||||||
'iOS SDK': {
|
|
||||||
Platforms: string[];
|
|
||||||
};
|
|
||||||
'Android SDK':
|
|
||||||
| {
|
|
||||||
'API Levels': string[] | 'Not Found';
|
|
||||||
'Build Tools': string[] | 'Not Found';
|
|
||||||
'System Images': string[] | 'Not Found';
|
|
||||||
'Android NDK': string | 'Not Found';
|
|
||||||
}
|
|
||||||
| 'Not Found';
|
|
||||||
};
|
|
||||||
IDEs: {
|
|
||||||
Xcode: {
|
|
||||||
version: string;
|
|
||||||
path: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function getEnvInfo(): Promise<EnvironmentInfo> {
|
|
||||||
return JSON.parse(
|
|
||||||
await run(
|
|
||||||
{
|
|
||||||
SDKs: ['iOS SDK', 'Android SDK'],
|
|
||||||
IDEs: ['Xcode'],
|
|
||||||
},
|
|
||||||
{json: true, showNotFound: true},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
10
doctor/src/globals.d.ts
vendored
10
doctor/src/globals.d.ts
vendored
@@ -1,10 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare module 'envinfo';
|
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Facebook, Inc. and its 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 {exec} from 'child_process';
|
|
||||||
import {promisify} from 'util';
|
|
||||||
import {EnvironmentInfo, getEnvInfo} from './environmentInfo';
|
|
||||||
export {getEnvInfo} from './environmentInfo';
|
|
||||||
|
|
||||||
type HealthcheckCategory = {
|
|
||||||
label: string;
|
|
||||||
isRequired: boolean;
|
|
||||||
healthchecks: Healthcheck[];
|
|
||||||
};
|
|
||||||
|
|
||||||
type Healthchecks = {
|
|
||||||
common: HealthcheckCategory;
|
|
||||||
android: HealthcheckCategory;
|
|
||||||
ios?: HealthcheckCategory;
|
|
||||||
};
|
|
||||||
|
|
||||||
type Healthcheck = {
|
|
||||||
label: string;
|
|
||||||
isRequired?: boolean;
|
|
||||||
run: (
|
|
||||||
env: EnvironmentInfo,
|
|
||||||
) => Promise<{
|
|
||||||
hasProblem: boolean;
|
|
||||||
helpUrl?: string;
|
|
||||||
}>;
|
|
||||||
};
|
|
||||||
|
|
||||||
type CategoryResult = [
|
|
||||||
string,
|
|
||||||
{
|
|
||||||
label: string;
|
|
||||||
results: Array<{
|
|
||||||
label: string;
|
|
||||||
isRequired: boolean;
|
|
||||||
result: {hasProblem: boolean};
|
|
||||||
}>;
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export function getHealthchecks(): Healthchecks {
|
|
||||||
return {
|
|
||||||
common: {
|
|
||||||
label: 'Common',
|
|
||||||
isRequired: true,
|
|
||||||
healthchecks: [
|
|
||||||
{
|
|
||||||
label: 'OpenSSL Installed',
|
|
||||||
run: async (_: EnvironmentInfo) => {
|
|
||||||
const isAvailable = await commandSucceeds('openssl version');
|
|
||||||
return {
|
|
||||||
hasProblem: !isAvailable,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
android: {
|
|
||||||
label: 'Android',
|
|
||||||
isRequired: false,
|
|
||||||
healthchecks: [
|
|
||||||
{
|
|
||||||
label: 'SDK Installed',
|
|
||||||
isRequired: true,
|
|
||||||
run: async (e: EnvironmentInfo) => ({
|
|
||||||
hasProblem: e.SDKs['Android SDK'] === 'Not Found',
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'ANDROID_HOME set',
|
|
||||||
run: async (e: EnvironmentInfo) => ({
|
|
||||||
hasProblem: !!process.env.ANDROID_HOME,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
...(process.platform === 'darwin'
|
|
||||||
? {
|
|
||||||
ios: {
|
|
||||||
label: 'iOS',
|
|
||||||
isRequired: false,
|
|
||||||
healthchecks: [
|
|
||||||
{
|
|
||||||
label: 'SDK Installed',
|
|
||||||
isRequired: true,
|
|
||||||
run: async (e: EnvironmentInfo) => ({
|
|
||||||
hasProblem: e.SDKs['iOS SDK'].Platforms.length === 0,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'XCode Installed',
|
|
||||||
isRequired: true,
|
|
||||||
run: async (e: EnvironmentInfo) => ({
|
|
||||||
hasProblem: e.IDEs == null || e.IDEs.Xcode == null,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'xcode-select set',
|
|
||||||
isRequired: true,
|
|
||||||
run: async (_: EnvironmentInfo) => ({
|
|
||||||
hasProblem: !(await commandSucceeds('xcode-select -p')),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Instruments exists',
|
|
||||||
isRequired: true,
|
|
||||||
run: async (_: EnvironmentInfo) => {
|
|
||||||
const hasInstruments = await commandSucceeds(
|
|
||||||
'which instruments',
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
hasProblem: !hasInstruments,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function runHealthchecks(): Promise<Array<CategoryResult>> {
|
|
||||||
const environmentInfo = await getEnvInfo();
|
|
||||||
const healthchecks: Healthchecks = getHealthchecks();
|
|
||||||
const results: Array<CategoryResult> = (
|
|
||||||
await Promise.all(
|
|
||||||
Object.entries(healthchecks).map(async ([key, category]) => {
|
|
||||||
if (!category) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const categoryResult: CategoryResult = [
|
|
||||||
key,
|
|
||||||
{
|
|
||||||
label: category.label,
|
|
||||||
results: await Promise.all(
|
|
||||||
category.healthchecks.map(async ({label, run, isRequired}) => ({
|
|
||||||
label,
|
|
||||||
isRequired: isRequired ?? true,
|
|
||||||
result: await run(environmentInfo).catch(e => {
|
|
||||||
console.error(e);
|
|
||||||
// TODO Improve result type to be: OK | Problem(message, fix...)
|
|
||||||
return {
|
|
||||||
hasProblem: true,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
})),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
return categoryResult;
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
).filter(notNull);
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function commandSucceeds(command: string): Promise<boolean> {
|
|
||||||
return await promisify(exec)(command)
|
|
||||||
.then(() => true)
|
|
||||||
.catch(() => false);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function notNull<T>(x: T | null | undefined): x is T {
|
|
||||||
return x !== null && x !== undefined;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "es5",
|
|
||||||
"module": "commonjs",
|
|
||||||
"declaration": true,
|
|
||||||
"outDir": "./lib",
|
|
||||||
"strict": true
|
|
||||||
},
|
|
||||||
"include": ["src"],
|
|
||||||
"exclude": ["node_modules", "**/__tests__/*"]
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["tslint:recommended", "tslint-config-prettier"]
|
|
||||||
}
|
|
||||||
4015
doctor/yarn.lock
4015
doctor/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user