Flow-typed provides a comprehensive command-line interface with multiple commands for managing Flow type definitions. All commands are built using yargs and follow consistent patterns for argument handling and output.
The primary entry point for the command-line interface that sets up all available commands.
/**
* Main CLI entry point function that initializes yargs with all available commands
* Automatically handles command routing, error handling, and process exit codes
*/
function runCLI(): void;Usage Example:
import { runCLI } from "flow-typed";
// Start the CLI - this will parse process.argv and execute the appropriate command
runCLI();Install Flow type definitions for dependencies in your project.
/**
* Install library definitions into the ./flow-typed directory
* @param args - Installation configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function install(args: InstallArgs): Promise<number>;
interface InstallArgs {
/** Flow version that fetched libdefs must be compatible with */
flowVersion?: string;
/** Overwrite existing library definitions */
overwrite?: boolean;
/** Do not generate stubs for missing libdefs */
skip?: boolean;
/** Do not update cache prior to installing libdefs */
skipCache?: boolean;
/** Do not restart flow after installing libdefs */
skipFlowRestart?: boolean;
/** Print additional verbose info while installing libdefs */
verbose?: boolean;
/** Use a custom directory to install libdefs */
libdefDir?: string;
/** Custom cache directory */
cacheDir?: string;
/** Directory containing package.json */
packageDir?: string;
/** Array of dependency names to ignore during installation */
ignoreDeps?: Array<string>;
/** Root directory for the project */
rootDir?: string;
/** Use cache until specified time in milliseconds */
useCacheUntil?: number;
/** Explicitly specify packages to install */
explicitLibDefs?: Array<string>;
}Create template library definitions for new packages.
/**
* Create template library definitions in flow-typed repository
* @param args - Creation configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function createDef(args: CreateDefArgs): Promise<number>;
interface CreateDefArgs {
/** Name of the library to create definition for */
libName: string;
/** Version range to add (e.g., "1.x.x") */
ver: string;
}Create stub definitions for libraries without existing type definitions.
/**
* Create stub definitions for missing libraries
* @param args - Stub creation configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function createStub(args: CreateStubArgs): Promise<number>;
interface CreateStubArgs {
/** Array of package names to create stubs for */
packages: Array<string>;
/** Directory to install stub definitions */
libdefDir?: string;
/** Overwrite existing stub definitions */
overwrite?: boolean;
/** Generate libdef from TypeScript definitions */
typescript?: boolean;
/** Directory of .flowconfig relative to node_modules */
rootDir?: string;
/** Maximum depth for template generation */
maxDepth?: number;
}Search for available library definitions by name.
/**
* Perform a simple search (by name) of available libdefs
* @param args - Search configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function search(args: SearchArgs): Promise<number>;
interface SearchArgs {
/** Search term to look for in library names */
term: string;
/** Flow version that fetched libdefs must be compatible with */
flowVersion?: string;
}Check for outdated library definitions in your project.
/**
* Check for outdated library definitions
* @param args - Outdated check configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function outdated(args: OutdatedArgs): Promise<number>;
interface OutdatedArgs {
/** Flow version for compatibility checking */
flowVersion?: string;
/** Directory containing library definitions */
libdefDir?: string;
/** Directory containing package.json */
packageDir?: string;
/** Use cache until specified time in milliseconds */
useCacheUntil?: number;
/** Directory of .flowconfig relative to node_modules */
rootDir?: string;
}Run tests for library definitions to validate their correctness.
/**
* Run tests for library definitions
* @param args - Test execution configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function runTests(args: RunTestsArgs): Promise<number>;
interface RunTestsArgs {
/** Path to specific definition or test file */
path?: string;
/** Run only changed definition tests */
onlyChanged?: boolean;
/** Only run against the latest X versions of Flow */
numberOfFlowVersions?: number;
/** Test patterns to match */
testPatterns: Array<string>;
}Update existing library definitions to newer versions.
/**
* Update existing library definitions
* @param args - Update configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function update(args: UpdateArgs): Promise<number>;
interface UpdateArgs {
/** Flow version for compatibility */
flowVersion?: string;
/** Directory containing library definitions */
libdefDir?: string;
/** Specific packages to update */
packages?: Array<string>;
}Update the local cache of available library definitions.
/**
* Update the local cache of library definitions
* @param args - Cache update configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function updateCache(args: UpdateCacheArgs): Promise<number>;
interface UpdateCacheArgs {
/** Print verbose output during cache update */
verbose?: boolean;
/** Custom cache directory */
cacheDir?: string;
}Validate library definitions for correctness and consistency.
/**
* Validate library definitions for correctness
* @param args - Validation configuration options
* @returns Promise resolving to exit code (0 for success)
*/
function validateDefs(args: ValidateDefsArgs): Promise<number>;
interface ValidateDefsArgs {
/** Directory path containing definitions to validate */
definitionsDirPath: string;
}All commands follow these patterns:
Promise<number> where 0 indicates successsetup function for yargs configuration