A CLI tool for managing high-quality Flow type definitions for third-party JavaScript libraries
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Core functionality for installing, updating, and managing Flow type definitions for third-party libraries. This system provides automated discovery and installation of type definitions from the flow-typed repository.
Install Flow type definitions for your project's dependencies.
/**
* Install library definitions into the ./flow-typed directory
* Automatically detects project dependencies and installs compatible definitions
* @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>;
}Usage Examples:
import { install } from "flow-typed";
// Install all dependencies
const result = await install({
verbose: true,
flowVersion: "v0.83.0"
});
// Install specific libraries
const result = await install({
explicitLibDefs: ["lodash", "express", "react"],
overwrite: true,
libdefDir: "custom-flow-typed"
});
// Install with dependency exclusions
const result = await install({
ignoreDeps: ["dev-only-package", "testing-lib"],
skip: false // Generate stubs for missing definitions
});Manage the local cache of library definitions from the flow-typed repository.
/**
* Get the cache repository directory path
* @returns Path to the cache repository directory
*/
function getCacheRepoDir(): string;
/**
* Set a custom cache directory (internal function)
* @param dir - Custom cache directory path
*/
function _setCustomCacheDir(dir: string): void;
/** Cache repository expiry time constant */
const CACHE_REPO_EXPIRY: number;Functions for working with npm-specific library definitions and package resolution.
/**
* Get cached npm library definitions
* @param cacheExpiry - Cache expiry time in milliseconds
* @param skipCache - Skip cache update if true
* @returns Promise resolving to array of npm library definitions
*/
function getCacheNpmLibDefs(
cacheExpiry: number,
skipCache: boolean = false
): Promise<Array<NpmLibDef>>;
/**
* Check if package version matches library definition version
* @param pkgVersion - Package version to check
* @param libDefVersion - Library definition version
* @returns Boolean indicating if versions match
*/
function pkgVersionMatch(pkgVersion: string, libDefVersion: string): boolean;
/**
* Find npm library definition for a package
* @param pkgName - Package name to find definition for
* @param pkgVersion - Package version
* @param flowVersion - Flow version for compatibility
* @param libDefs - Array of available library definitions
* @returns Library definition or null if not found
*/
function findNpmLibDef(
pkgName: string,
pkgVersion: string,
flowVersion: FlowVersion,
libDefs: Array<NpmLibDef>
): NpmLibDef | null;
/**
* Get installed npm library definitions
* @param flowVersion - Flow version for compatibility
* @param libdefDir - Directory containing library definitions
* @returns Promise resolving to array of installed definitions
*/
function getInstalledNpmLibDefs(
flowVersion: FlowVersion,
libdefDir: string
): Promise<Array<NpmLibDef>>;
/**
* Get npm library definitions for a directory
* @param defsDir - Directory containing definitions
* @param libdefDir - Library definition directory
* @returns Promise resolving to array of npm library definitions
*/
function getNpmLibDefs(
defsDir: string,
libdefDir: string
): Promise<Array<NpmLibDef>>;
/**
* Get version hash for npm library definition
* @param libDef - Library definition to get hash for
* @returns Promise resolving to version hash string
*/
function getNpmLibDefVersionHash(libDef: NpmLibDef): Promise<string>;
/**
* Get scoped package name for library definition
* @param libDef - Library definition
* @returns Scoped package name string
*/
function getScopedPackageName(libDef: NpmLibDef): string;
interface NpmLibDef extends LibDef {
npmPackageName: string;
npmVersionRange: string;
}Functions for working with package.json files and dependency resolution.
/**
* Find package dependency version string
* @param pkgJsonPath - Path to package.json
* @param pkgName - Package name to find
* @returns Promise resolving to version string or null
*/
function findPackageJsonDepVersionStr(
pkgJsonPath: string,
pkgName: string
): Promise<string | null>;
/**
* Find package.json file path starting from a directory
* @param pathStr - Starting directory path
* @returns Promise resolving to package.json path
*/
function findPackageJsonPath(pathStr: string): Promise<string>;
/**
* Find workspace packages in a monorepo
* @param rootPath - Root path to search from
* @returns Promise resolving to array of workspace package paths
*/
function findWorkspacesPackages(rootPath: string): Promise<Array<string>>;
/**
* Get package.json dependencies
* @param pkgJson - Parsed package.json object
* @param includeDevDeps - Include development dependencies
* @returns Object with dependency name to version mappings
*/
function getPackageJsonDependencies(
pkgJson: PkgJson,
includeDevDeps?: boolean
): { [string]: string };
/**
* Merge multiple package.json dependency objects
* @param deps - Array of dependency objects to merge
* @returns Merged dependency object
*/
function mergePackageJsonDependencies(
deps: Array<{ [string]: string }>
): { [string]: string };
/**
* Get package.json data from file path
* @param pathStr - Path to package.json file
* @returns Promise resolving to parsed package.json object
*/
function getPackageJsonData(pathStr: string): Promise<PkgJson>;
/**
* Load PnP resolver for Yarn PnP projects
* @param rootPath - Root path of the project
* @returns Promise resolving to PnP resolver or null
*/
function loadPnpResolver(rootPath: string): Promise<any | null>;
interface PkgJson {
name?: string;
version?: string;
dependencies?: { [string]: string };
devDependencies?: { [string]: string };
peerDependencies?: { [string]: string };
workspaces?: Array<string> | { packages: Array<string> };
}Security features for verifying the integrity of library definitions.
/**
* Sign code stream with cryptographic signature
* @param codeStream - Stream containing code to sign
* @returns Promise resolving to signed code stream
*/
function signCodeStream(codeStream: any): Promise<any>;
/**
* Verify signed code for authenticity
* @param signedCode - Signed code to verify
* @returns Promise resolving to verification result
*/
function verifySignedCode(signedCode: string): Promise<boolean>;
/**
* Parse signed code version information
* @param versionStr - Version string from signed code
* @returns Parsed version information
*/
function parseSignedCodeVersion(versionStr: string): any;The installation process follows this workflow:
skipCache is true)skip is true)skipFlowRestart is true)