CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-flow-typed

A CLI tool for managing high-quality Flow type definitions for third-party JavaScript libraries

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

Flow-typed

Flow-typed is a CLI tool for managing high-quality Flow type definitions for third-party JavaScript libraries. It provides a comprehensive repository system and automated tooling for discovering, installing, and managing type definitions, enabling developers to maintain strong type safety across their entire dependency graph.

Package Information

  • Package Name: flow-typed
  • Package Type: npm
  • Language: JavaScript/Flow
  • Installation: npm install -g flow-typed

Core Imports

import { 
  runCLI, 
  install, 
  search, 
  createDef, 
  createStub, 
  outdated, 
  runTests, 
  update, 
  updateCache, 
  validateDefs 
} from "flow-typed";

For CommonJS:

const { 
  runCLI, 
  install, 
  search, 
  createDef, 
  createStub, 
  outdated, 
  runTests, 
  update, 
  updateCache, 
  validateDefs 
} = require("flow-typed");

Basic Usage

import { runCLI, install } from "flow-typed";

// Run the CLI programmatically
runCLI();

// Install library definitions programmatically
const result = await install({
  explicitLibDefs: ['lodash', 'express'],
  flowVersion: 'v0.83.0',
  verbose: true,
  skip: false
});

Architecture

Flow-typed is built around several key components:

  • CLI Interface: Command-line interface with multiple commands for different operations
  • Command System: Modular command architecture where each command (install, search, etc.) is a separate module
  • Flow Version Management: Sophisticated system for handling Flow version compatibility and ranges
  • Library Definition Management: Repository system for caching and managing type definitions
  • NPM Integration: Deep integration with npm package management and dependency resolution
  • Git Operations: Repository cloning and management for the flow-typed definitions repository

Capabilities

CLI Commands

Primary command-line interface providing all flow-typed functionality through a yargs-based CLI system.

/**
 * Main CLI entry point function
 */
function runCLI(): void;

CLI Commands

Library Installation and Management

Core functionality for installing, updating, and managing Flow type definitions for third-party libraries.

/**
 * Install library definitions
 * @param args - Installation configuration options
 * @returns Promise resolving to exit code (0 for success)
 */
function install(args: InstallArgs): Promise<number>;

interface InstallArgs {
  flowVersion?: string;
  overwrite?: boolean;
  skip?: boolean;
  skipCache?: boolean;
  skipFlowRestart?: boolean;
  verbose?: boolean;
  libdefDir?: string;
  cacheDir?: string;
  packageDir?: string;
  ignoreDeps?: Array<string>;
  rootDir?: string;
  useCacheUntil?: number;
  explicitLibDefs?: Array<string>;
}

Installation and Management

Search and Discovery

Search functionality for finding available type definitions in the flow-typed repository.

/**
 * Search for available library definitions
 * @param args - Search configuration options
 * @returns Promise resolving to exit code (0 for success)
 */
function search(args: SearchArgs): Promise<number>;

interface SearchArgs {
  term: string;
  flowVersion?: string;
}

Search and Discovery

Definition Creation

Tools for creating new type definitions and stubs for libraries without existing definitions.

/**
 * Create template library definition
 * @param args - Creation configuration options
 * @returns Promise resolving to exit code (0 for success)
 */
function createDef(args: CreateDefArgs): Promise<number>;

/**
 * Create stub definition 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 CreateDefArgs {
  libName: string;
  ver: string;
}

interface CreateStubArgs {
  libName: string;
  libdefDir?: string;
  overwrite?: boolean;
  maxLines?: number;
}

Definition Creation

Flow Version Management

Comprehensive Flow version parsing, comparison, and compatibility checking system.

/**
 * Parse Flow version directory string
 * @param verStr - Version string to parse
 * @returns Parsed Flow version object
 */
function parseDirString(verStr: string): FlowVersion;

/**
 * Determine Flow version for a project
 * @param packageDir - Directory containing package.json
 * @param flowVersion - Optional explicit Flow version
 * @returns Promise resolving to Flow version
 */
function determineFlowSpecificVersion(
  packageDir: string,
  flowVersion?: string
): Promise<FlowVersion>;

type FlowVersion =
  | { kind: 'all' }
  | { kind: 'specific', ver: FlowSpecificVer }
  | { kind: 'ranged', upper: FlowSpecificVer | null, lower: FlowSpecificVer | null };

interface FlowSpecificVer {
  major: number;
  minor: number | 'x';
  patch: number | 'x';
  prerel: string | 'x' | null;
}

Flow Version Management

Library Definition Management

System for managing, filtering, and working with Flow type definitions from the repository.

/**
 * Get library definitions from directory
 * @param defsDir - Directory containing definitions
 * @returns Promise resolving to array of library definitions
 */
function getLibDefs(defsDir: string): Promise<Array<LibDef>>;

/**
 * Filter library definitions based on criteria
 * @param defs - Array of library definitions
 * @param filter - Filter criteria
 * @returns Filtered array of definitions
 */
function filterLibDefs(
  defs: Array<LibDef>,
  filter: FilterOptions
): Array<LibDef>;

interface LibDef {
  pkgName: string;
  pkgVersionStr: string;
  configPath: string | null;
  flowVersion: FlowVersion;
  flowVersionStr: string;
  path: string;
  testFilePaths: Array<string>;
}

interface FilterOptions {
  type: 'fuzzy' | 'exact';
  term: string;
  flowVersionStr?: string;
}

Library Definition Management

docs

cli-commands.md

creation.md

flow-versions.md

index.md

installation.md

libdefs.md

search.md

tile.json