Typescriptify the main process code (14/N)

Summary: Converted scripts/yarn-install.js to typescript

Reviewed By: passy

Differential Revision: D20098071

fbshipit-source-id: be56a95a11089cd857efb00e62866213a88b739c
This commit is contained in:
Anton Nikolaev
2020-02-27 05:28:02 -08:00
committed by Facebook Github Bot
parent 2bd61bca87
commit ab0078a13f
3 changed files with 23 additions and 10 deletions

11
.vscode/launch.json vendored
View File

@@ -27,7 +27,16 @@
"type": "node",
"request": "launch",
"name": "Launch Current Script",
"program": "${file}",
"args": ["${file}"],
"env": {
"TS_NODE_FILES": "true",
},
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart",
"runtimeArgs": [
"--require",
"ts-node/register"
],
"cwd": "${workspaceFolder}"
}
],

View File

@@ -211,7 +211,7 @@
},
"scripts": {
"preinstall": "yarn config set ignore-engines",
"postinstall": "node scripts/yarn-install.js && patch-package",
"postinstall": "cross-env TS_NODE_FILES=true node --require ts-node/register scripts/yarn-install.ts && patch-package",
"rm-dist": "rimraf dist",
"rm-modules": "rimraf node_modules static/node_modules",
"rm-temp": "rimraf $TMPDIR/jest* $TMPDIR/react-native-packager*",
@@ -222,7 +222,7 @@
"start:no-embedded-plugins": "cross-env NODE_ENV=development cross-env FLIPPER_NO_EMBEDDED_PLUGINS=true TS_NODE_FILES=true node --require ts-node/register scripts/start-dev-server.ts",
"build": "yarn rm-dist && cross-env NODE_ENV=production TS_NODE_FILES=true node --require ts-node/register scripts/build-release.ts $@",
"build-headless": "yarn rm-dist && mkdir dist && cross-env NODE_ENV=production TS_NODE_FILES=true node --require ts-node/register scripts/build-headless.ts $@",
"fix": "eslint . --fix --ext .js,.tsx",
"fix": "eslint . --fix --ext .js,.ts,.tsx",
"test": "jest --testPathPattern=\"node\\.(js|tsx)$\" --no-cache",
"test:debug": "node --inspect node_modules/.bin/jest --runInBand",
"test-electron": "jest --testPathPattern=\"electron\\.(js|tsx)$\" --testEnvironment=@jest-runner/electron/environment --runner=@jest-runner/electron --no-cache",

View File

@@ -7,10 +7,12 @@
* @format
*/
const path = require('path');
const util = require('util');
const glob = util.promisify(require('glob'));
const exec = util.promisify(require('child_process').exec);
import path from 'path';
import util from 'util';
import globImport from 'glob';
import {exec as execImport} from 'child_process';
const glob = util.promisify(globImport);
const exec = util.promisify(execImport);
const PACKAGES = [
'headless-tests',
'static',
@@ -30,9 +32,11 @@ Promise.all(
),
)
.then(async packages => {
packages = packages.reduce((acc, cv) => acc.concat(cv), []);
console.log(`Installing dependencies for ${packages.length} plugins`);
for (const pkg of packages) {
const flattenPackages = packages.reduce((acc, cv) => acc.concat(cv), []);
console.log(
`Installing dependencies for ${flattenPackages.length} plugins`,
);
for (const pkg of flattenPackages) {
const {stderr} = await exec(
// This script is itself executed by yarn (as postinstall script),
// therefore another yarn instance is running, while we are trying to