Add starter package
Summary: Adds a new package with typescript set up, to be published to npm. Followed this as a guideline: https://itnext.io/step-by-step-building-and-publishing-an-npm-typescript-package-44fe7164964c Reviewed By: passy Differential Revision: D18244495 fbshipit-source-id: c684f0bb33e61699f605c637186c7a81136a920f
This commit is contained in:
committed by
Facebook Github Bot
parent
9670d6bde5
commit
2ae2352972
@@ -55,7 +55,7 @@ module.exports = {
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.tsx'],
|
||||
files: ['*.tsx', '*.ts'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
rules: {
|
||||
'prettier/prettier': [2, {...prettierConfig, parser: 'typescript'}],
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<PROJECT_ROOT>/src/plugins/sections/d3/d3.js$
|
||||
.*\.tsx
|
||||
.*/node_modules/.*
|
||||
<PROJECT_ROOT>/doctor/.*
|
||||
|
||||
[libs]
|
||||
flow-typed
|
||||
|
||||
1
doctor/.gitignore
vendored
Normal file
1
doctor/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/lib
|
||||
8
doctor/README.md
Normal file
8
doctor/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# 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`
|
||||
7
doctor/jestconfig.json
Normal file
7
doctor/jestconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"transform": {
|
||||
"^.+\\.(t|j)sx?$": "ts-jest"
|
||||
},
|
||||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
||||
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
|
||||
}
|
||||
38
doctor/package.json
Normal file
38
doctor/package.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "flipper-doctor",
|
||||
"version": "0.1.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.18.2",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
30
doctor/src/cli.ts
Normal file
30
doctor/src/cli.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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 {getEnvInfo} from './environmentInfo';
|
||||
import {getHealthchecks} from './index';
|
||||
|
||||
(async () => {
|
||||
const environmentInfo = await getEnvInfo();
|
||||
const healthchecks = getHealthchecks();
|
||||
const results = Object.entries(healthchecks).map(([key, category]) => [
|
||||
key,
|
||||
category
|
||||
? {
|
||||
label: category.label,
|
||||
results: category.healthchecks.map(({label, run}) => ({
|
||||
label,
|
||||
result: run(environmentInfo),
|
||||
})),
|
||||
}
|
||||
: {},
|
||||
]);
|
||||
|
||||
console.log(JSON.stringify(results, null, 2));
|
||||
})();
|
||||
37
doctor/src/environmentInfo.ts
Normal file
37
doctor/src/environmentInfo.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 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';
|
||||
};
|
||||
};
|
||||
|
||||
export async function getEnvInfo(): Promise<EnvironmentInfo> {
|
||||
return JSON.parse(
|
||||
await run(
|
||||
{
|
||||
SDKs: ['iOS SDK', 'Android SDK'],
|
||||
},
|
||||
{json: true, showNotFound: true},
|
||||
),
|
||||
);
|
||||
}
|
||||
10
doctor/src/globals.d.ts
vendored
Normal file
10
doctor/src/globals.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 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';
|
||||
63
doctor/src/index.ts
Normal file
63
doctor/src/index.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 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 {EnvironmentInfo} from './environmentInfo';
|
||||
|
||||
type HealthcheckCategory = {
|
||||
label: string;
|
||||
healthchecks: Healthcheck[];
|
||||
};
|
||||
|
||||
type Healthchecks = {
|
||||
android: HealthcheckCategory;
|
||||
ios?: HealthcheckCategory;
|
||||
};
|
||||
|
||||
type Healthcheck = {
|
||||
label: string;
|
||||
run: (
|
||||
env: EnvironmentInfo,
|
||||
) => {
|
||||
hasProblem: boolean;
|
||||
isRequired?: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
export function getHealthchecks(): Healthchecks {
|
||||
return {
|
||||
android: {
|
||||
label: 'Android',
|
||||
healthchecks: [
|
||||
{
|
||||
label: 'SDK Installed',
|
||||
run: (e: EnvironmentInfo) => ({
|
||||
hasProblem: e.SDKs['Android SDK'] != 'Not Found',
|
||||
isRequired: false,
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
...(process.platform === 'darwin'
|
||||
? {
|
||||
ios: {
|
||||
label: 'iOS',
|
||||
healthchecks: [
|
||||
{
|
||||
label: 'SDK Installed',
|
||||
run: (e: EnvironmentInfo) => ({
|
||||
hasProblem: e.SDKs['iOS SDK'].Platforms.length === 0,
|
||||
isRequired: false,
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
11
doctor/tsconfig.json
Normal file
11
doctor/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"outDir": "./lib",
|
||||
"strict": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/*"]
|
||||
}
|
||||
3
doctor/tslint.json
Normal file
3
doctor/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": ["tslint:recommended", "tslint-config-prettier"]
|
||||
}
|
||||
4015
doctor/yarn.lock
Normal file
4015
doctor/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user