diff --git a/.vscode/launch.json b/.vscode/launch.json index fbf906bbb..61294f2e6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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}" } ], diff --git a/package.json b/package.json index e2db0855e..80dfad330 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/yarn-install.js b/scripts/yarn-install.ts similarity index 79% rename from scripts/yarn-install.js rename to scripts/yarn-install.ts index acf80a05a..a5967c0d0 100644 --- a/scripts/yarn-install.js +++ b/scripts/yarn-install.ts @@ -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