Skip to content

Commit

Permalink
[cli] Update flow-bin to 0.200.0 (#4547)
Browse files Browse the repository at this point in the history
* update some stuff

* fix libdef file

* all errors fixed

* update to first 20x version

* update flow-typed stubs

* flow-typed lib is defaulted
  • Loading branch information
Brianzchen committed Oct 29, 2023
1 parent 97b7b42 commit 8a67a35
Show file tree
Hide file tree
Showing 23 changed files with 184 additions and 136 deletions.
2 changes: 0 additions & 2 deletions cli/.flowconfig
@@ -1,5 +1,4 @@
[libs]
flow-typed

[ignore]
.*/node_modules/json5/.*
Expand All @@ -12,7 +11,6 @@ flow-typed

[lints]
deprecated-type=error
deprecated-utility=error
unnecessary-optional-chain=error

[options]
Expand Down
4 changes: 2 additions & 2 deletions cli/flow-typed/npm/got_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: b89a9596242af179f2efdbc196a2aa27
// flow-typed version: <<STUB>>/got_v^11.8.5/flow_v0.183.0
// flow-typed signature: a6a6c5600d5d92aacf6db06779ec2eb4
// flow-typed version: <<STUB>>/got_v^11.8.5/flow_v0.200.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions cli/flow-typed/npm/simple-git_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: 1e3a30a0afdab72505a9d3994a6fbfb3
// flow-typed version: <<STUB>>/simple-git_v^3.10.0/flow_v0.183.0
// flow-typed signature: 4eb5f5fd4b8c0182cab633372f568ee2
// flow-typed version: <<STUB>>/simple-git_v^3.10.0/flow_v0.200.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions cli/flow-typed/npm/table_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: 17a914e29d17d9c9507612d1e7c4c95f
// flow-typed version: <<STUB>>/table_v^6.7.3/flow_v0.183.0
// flow-typed signature: c35f8f4f122daf562ebef1529439afd3
// flow-typed version: <<STUB>>/table_v^6.7.3/flow_v0.200.0

/**
* This is an autogenerated libdef stub for:
Expand Down
4 changes: 2 additions & 2 deletions cli/flow-typed/npm/which_vx.x.x.js
@@ -1,5 +1,5 @@
// flow-typed signature: 133afba1a53b393575404d6a71ff9be7
// flow-typed version: <<STUB>>/which_v^2.0.2/flow_v0.183.0
// flow-typed signature: 9b922bf2799941fbe91eb174d78e16b6
// flow-typed version: <<STUB>>/which_v^2.0.2/flow_v0.200.0

/**
* This is an autogenerated libdef stub for:
Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Expand Up @@ -64,7 +64,7 @@
"eslint-plugin-fb-flow": "^0.0.4",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-prettier": "^4.0.0",
"flow-bin": "^0.183.0",
"flow-bin": "0.200.0",
"flow-copy-source": "^2.0.9",
"jest": "^27.3.1"
},
Expand Down
16 changes: 10 additions & 6 deletions cli/src/commands/__tests__/install-test.js
Expand Up @@ -33,15 +33,15 @@ import {

const BASE_FIXTURE_ROOT = path.join(__dirname, '__install-fixtures__');

function _mock(mockFn) {
return ((mockFn: any): JestMockFn<any, any>);
function _mock(mockFn: any) {
return (mockFn: JestMockFn<any, any>);
}

async function touchFile(filePath) {
async function touchFile(filePath: string) {
await fs.close(await fs.open(filePath, 'w'));
}

async function writePkgJson(filePath, pkgJson) {
async function writePkgJson(filePath: string, pkgJson: {...}) {
await fs.writeJson(filePath, pkgJson);
}

Expand Down Expand Up @@ -224,7 +224,9 @@ describe('install (command)', () => {
(console: any).error = origConsoleError;
});

async function fakeProjectEnv(runTest) {
async function fakeProjectEnv(
runTest: (flowProjectDir: string) => Promise<void>,
) {
return await testProject(async ROOT_DIR => {
const FAKE_CACHE_DIR = path.join(ROOT_DIR, 'fakeCache');
const FAKE_CACHE_REPO_DIR = path.join(FAKE_CACHE_DIR, 'repo');
Expand Down Expand Up @@ -1859,7 +1861,9 @@ declare type jsx$HTMLElementProps = {||}`;
(console: any).warn = origConsoleWarn;
});

async function fakeProjectEnv(runTest) {
async function fakeProjectEnv(
runTest: (flowProjectDir: string) => Promise<void>,
) {
return await testProject(async ROOT_DIR => {
const FAKE_CACHE_DIR = path.join(ROOT_DIR, 'fakeCache');
const FAKE_CACHE_REPO_DIR = path.join(FAKE_CACHE_DIR, 'repo');
Expand Down
8 changes: 5 additions & 3 deletions cli/src/commands/__tests__/outdated-test.js
Expand Up @@ -25,11 +25,11 @@ import {run} from '../outdated';

const BASE_FIXTURE_ROOT = path.join(__dirname, '__outdated-fixtures__');

async function touchFile(filePath) {
async function touchFile(filePath: string) {
await fs.close(await fs.open(filePath, 'w'));
}

async function writePkgJson(filePath, pkgJson) {
async function writePkgJson(filePath: string, pkgJson: {...}) {
await fs.writeJson(filePath, pkgJson);
}

Expand All @@ -55,7 +55,9 @@ describe('outdated (command)', () => {
(console: any).error = origConsoleError;
});

async function fakeProjectEnv(runTest) {
async function fakeProjectEnv(
runTest: (flowProjectDir: string) => Promise<void>,
) {
return await testProject(async ROOT_DIR => {
const FAKE_CACHE_DIR = path.join(ROOT_DIR, 'fakeCache');
const FAKE_CACHE_REPO_DIR = path.join(FAKE_CACHE_DIR, 'repo');
Expand Down
6 changes: 5 additions & 1 deletion cli/src/commands/__tests__/search-test.js
Expand Up @@ -5,7 +5,11 @@ import {parseDirString as parseFlowDirString} from '../../lib/flowVersion.js';

describe('search command', () => {
describe('_formatDefTable()', () => {
function _generateFixturePkg(name, verStr, flowVerStr) {
function _generateFixturePkg(
name: string,
verStr: string,
flowVerStr: string,
) {
return {
pkgName: name,
pkgVersionStr: verStr,
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/install.js
Expand Up @@ -228,8 +228,8 @@ export async function run(args: Args): Promise<number> {
async function installEnvLibDefs(
env: Array<string>,
flowVersion: FlowVersion,
flowProjectRoot,
libdefDir,
flowProjectRoot: string,
libdefDir: string,
useCacheUntil: number,
overwrite: boolean,
): Promise<number> {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/outdated.js
Expand Up @@ -17,7 +17,7 @@ import {CACHE_REPO_EXPIRY, getCacheRepoDir} from '../lib/cacheRepoUtils';
import {getFtConfig} from '../lib/ftConfig';
import {findEnvDef, getEnvDefVersionHash, getEnvDefs} from '../lib/envDefs';

const pullSignature = v => v.split('\n').slice(0, 2);
const pullSignature = (v: string) => v.split('\n').slice(0, 2);

export const name = 'outdated';
export const description =
Expand Down
40 changes: 22 additions & 18 deletions cli/src/commands/runTests.js
Expand Up @@ -88,8 +88,8 @@ const basePathRegex = new RegExp(
);

async function getTestGroups(
repoDirPath,
envDirPath,
repoDirPath: string,
envDirPath: string,
onlyChanged: boolean = false,
): Promise<Array<TestGroup>> {
let libDefs = await getLibDefs(repoDirPath);
Expand Down Expand Up @@ -155,7 +155,7 @@ async function getTestGroups(
});
}

function printSkipMessage(flowVersion, githubUrl) {
function printSkipMessage(flowVersion: string, githubUrl: string) {
console.log(
'==========================================================================================',
);
Expand Down Expand Up @@ -348,7 +348,7 @@ const flowNameRegex = /^flow-v[0-9]+.[0-9]+.[0-9]+(\.exe)?$/;
* flow filename should be `flow-vx.x.x`
* @param {string} name
*/
function checkFlowFilename(name) {
function checkFlowFilename(name: string) {
return flowNameRegex.test(name);
}

Expand Down Expand Up @@ -420,7 +420,7 @@ export async function writeFlowConfig(
await fs.writeFile(destFlowConfigPath, flowConfigData);
}

function testTypeDefinition(flowVer, testDirPath) {
function testTypeDefinition(flowVer: string, testDirPath: string) {
return new Promise(res => {
const IS_WINDOWS = os.type() === 'Windows_NT';
const child = child_process.exec(
Expand All @@ -447,7 +447,11 @@ function testTypeDefinition(flowVer, testDirPath) {
});
}

async function runFlowTypeDefTests(flowVersionsToRun, groupId, testDirPath) {
async function runFlowTypeDefTests(
flowVersionsToRun: Array<string>,
groupId: string,
testDirPath: string,
) {
const errors = [];
while (flowVersionsToRun.length > 0) {
// Run tests in batches to avoid saturation
Expand Down Expand Up @@ -486,11 +490,11 @@ async function runFlowTypeDefTests(flowVersionsToRun, groupId, testDirPath) {
}

async function testLowestCapableFlowVersion(
lowerVersions,
testDirPath,
lowestFlowVersionRan,
lowerVersions: Array<string>,
testDirPath: string,
lowestFlowVersionRan: string,
) {
let lowerFlowVersionsToRun = lowerVersions;
let lowerFlowVersionsToRun: Array<string> = lowerVersions;
let lowestCapableFlowVersion = lowestFlowVersionRan;
while (lowerFlowVersionsToRun.length > 0) {
const lowerTestBatch = lowerFlowVersionsToRun
Expand Down Expand Up @@ -521,12 +525,12 @@ async function testLowestCapableFlowVersion(
}

async function findLowestCapableFlowVersion(
repoDirPath,
orderedFlowVersions,
lowestFlowVersionRan,
testDirPath,
libDefPath,
depPaths,
repoDirPath: string,
orderedFlowVersions: Array<string>,
lowestFlowVersionRan: string,
testDirPath: string,
libDefPath: string,
depPaths: Array<string>,
) {
let lowerFlowVersionsToRun = orderedFlowVersions.filter(flowVer => {
return semver.lt(flowVer, lowestFlowVersionRan);
Expand Down Expand Up @@ -602,7 +606,7 @@ function partitionListOfFlowVersionsPerConfigChange(
* Then shuffle to create a new Array<Array<>> that will test
* All dependencies across various supported versions.
*/
function getDepTestGroups(testGroup) {
function getDepTestGroups(testGroup: TestGroup) {
const flowDirVersion = extractFlowDirFromFlowDirPath(testGroup.id);
const depBasePath = getNpmLibDefDirFromNested(testGroup.libDefPath);

Expand Down Expand Up @@ -757,7 +761,7 @@ async function runTestGroup(

const flowErrors = [];

const executeTests = async (depPaths = []) => {
const executeTests = async (depPaths: Array<string> = []) => {
for (const sublistOfFlowVersions of groups) {
const lowestFlowVersionRanInThisGroup = sublistOfFlowVersions[0];
await writeFlowConfig(
Expand Down
4 changes: 2 additions & 2 deletions cli/src/lib/__tests__/cacheRepoUtils-test.js
Expand Up @@ -18,8 +18,8 @@ import {cloneInto, rebaseRepoMainline} from '../git';

import {fs} from '../node';

function _mock(mockFn) {
return ((mockFn: any): JestMockFn<*, *>);
function _mock(mockFn: any) {
return (mockFn: JestMockFn<any, any>);
}

describe('cacheRepoUtils', () => {
Expand Down
4 changes: 2 additions & 2 deletions cli/src/lib/__tests__/flowVersion-test.js
Expand Up @@ -564,11 +564,11 @@ describe('flowVersion', () => {
});

describe('determineFlowSpecificVersion', () => {
async function touchFile(filePath) {
async function touchFile(filePath: string) {
await fs.close(await fs.open(filePath, 'w'));
}

async function writePkgJson(filePath, pkgJson) {
async function writePkgJson(filePath: string, pkgJson: {...}) {
await fs.writeJson(filePath, pkgJson);
}

Expand Down
10 changes: 7 additions & 3 deletions cli/src/lib/__tests__/libDefs-test.js
Expand Up @@ -29,8 +29,8 @@ import {cloneInto, rebaseRepoMainline} from '../git.js';
* Jest's process of mocking in place fools Flow, so we use this as an explicit
* escape hatch when we need to side-step Flow.
*/
function _mock(mockFn) {
return (mockFn: any);
function _mock(mockFn: any) {
return (mockFn: JestMockFn<any, any>);
}

describe('libDefs', () => {
Expand Down Expand Up @@ -117,7 +117,11 @@ describe('libDefs', () => {
});

describe('filterLibDefs', () => {
function _generateMockLibdef(name, verStr, flowVerStr) {
function _generateMockLibdef(
name: string,
verStr: string,
flowVerStr: string,
) {
return {
pkgName: name,
pkgVersionStr: verStr,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/envDefs.js
Expand Up @@ -45,7 +45,7 @@ export const getEnvDefs = async (): Promise<Array<EnvLibDef>> => {
return [...settled].filter(Boolean).flat();
};

const getSingleEnvDef = async (defName, envDefPath) => {
const getSingleEnvDef = async (defName: string, envDefPath: string) => {
const itemPath = path.join(envDefPath, defName);
const itemStat = await fs.stat(itemPath);
if (itemStat.isDirectory()) {
Expand Down
6 changes: 5 additions & 1 deletion cli/src/lib/flowVersion.js
Expand Up @@ -307,7 +307,11 @@ function disjointVersions(a: FlowVersion, b: FlowVersion): boolean {
/**
* Given an array of versions, returns whether they are mutually disjoint.
*/
function _disjointVersionsAll(vers, len, i) {
function _disjointVersionsAll(
vers: Array<FlowVersion>,
len: number,
i: number,
) {
if (i + 1 >= len) return true;
for (let j = i + 1; j < len; j++) {
if (!disjointVersions(vers[i], vers[j])) {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/git.js
Expand Up @@ -38,7 +38,7 @@ async function getGitPath() {
}
}

function which(executable): Promise<string> {
function which(executable: string): Promise<string> {
return new Promise((res, rej) => {
whichCb(executable, (err, resolvedPath) => {
if (err) {
Expand Down

0 comments on commit 8a67a35

Please sign in to comment.