or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

android-platform.mdcommand-system.mdconfiguration-types.mdindex.mdios-platform.mdthird-party-types.md
tile.json

tessl/npm-react-native-community--cli-types

TypeScript type definitions for React Native Community CLI configuration and command structures

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@react-native-community/cli-types@20.0.x

To install, run

npx @tessl/cli install tessl/npm-react-native-community--cli-types@20.0.0

index.mddocs/

React Native Community CLI Types

React Native Community CLI Types provides comprehensive TypeScript type definitions for the React Native Community CLI ecosystem. It defines core types for CLI commands, configuration structures, platform-specific settings for Android and iOS, dependency management, and project configuration patterns, enabling type-safe development across all React Native CLI packages.

Package Information

  • Package Name: @react-native-community/cli-types
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @react-native-community/cli-types

Core Imports

import {
  Config,
  Command,
  ProjectConfig,
  DependencyConfig,
  AndroidProjectConfig,
  IOSProjectConfig
} from "@react-native-community/cli-types";

For CommonJS:

const {
  Config,
  Command,
  ProjectConfig,
  DependencyConfig,
  AndroidProjectConfig,
  IOSProjectConfig
} = require("@react-native-community/cli-types");

Basic Usage

import {
  Config,
  Command,
  CommandFunction,
  AndroidProjectConfig,
  IOSProjectConfig
} from "@react-native-community/cli-types";

// Define a command function
const myCommand: CommandFunction = async (argv, ctx, args) => {
  console.log(`Running command in project: ${ctx.project.android?.appName}`);
};

// Define a command
const command: Command = {
  name: "my-command",
  description: "Example CLI command",
  func: myCommand,
  options: [
    {
      name: "--verbose",
      description: "Enable verbose logging",
      default: false
    }
  ]
};

// Work with configuration
function processConfig(config: Config) {
  console.log(`React Native path: ${config.reactNativePath}`);
  console.log(`Project root: ${config.root}`);
  
  if (config.project.android) {
    console.log(`Android app: ${config.project.android.appName}`);
  }
  
  if (config.project.ios) {
    console.log(`iOS project: ${config.project.ios.xcodeProject?.name}`);
  }
}

Architecture

The type system is organized around several key areas:

  • Command System: Type-safe command definitions with support for both standard and detached commands
  • Configuration Types: Structured configuration for projects, dependencies, and platforms
  • Platform Types: Specialized Android and iOS configuration with platform-specific features
  • Validation Integration: Joi schema validation integration for configuration validation
  • Extension Points: Generic platform configuration interfaces for custom platform support

Capabilities

Command System

Complete type definitions for CLI command development with support for standard commands, detached commands, and command options.

type CommandFunction<Args = Object> = (
  argv: Array<string>,
  ctx: Config,
  args: Args
) => Promise<void> | void;

type Command<IsDetached extends boolean = false> = {
  name: string;
  description?: string;
  detached?: IsDetached;
  examples?: Array<{
    desc: string;
    cmd: string;
  }>;
  pkg?: {
    name: string;
    version: string;
  };
  func: IsDetached extends true
    ? DetachedCommandFunction<Object>
    : CommandFunction<Object>;
  options?: Array<CommandOption>;
};

Command System

Configuration Types

Core configuration types that define the structure of React Native CLI configurations, including project settings, dependency management, and platform configurations.

interface Config {
  root: string;
  reactNativePath: string;
  reactNativeVersion: string;
  project: ProjectConfig;
  dependencies: {
    [key: string]: DependencyConfig;
  };
  platforms: {
    android: AndroidPlatformConfig;
    ios: IOSPlatformConfig;
    [name: string]: PlatformConfig<any, any, any, any>;
  };
  assets: string[];
  commands: Command[];
  healthChecks: [];
}

type ProjectConfig = {
  android?: Exclude<ReturnType<AndroidPlatformConfig['projectConfig']>, void>;
  ios?: Exclude<ReturnType<IOSPlatformConfig['projectConfig']>, void>;
  [key: string]: any;
};

Configuration Types

Android Platform Types

Comprehensive Android platform configuration types covering project structure, dependency management, C++ modules, and build configuration.

interface AndroidProjectConfig {
  sourceDir: string;
  appName: string;
  packageName: string;
  applicationId: string;
  mainActivity: string;
  dependencyConfiguration?: string;
  watchModeCommandParams?: string[];
  assets: string[];
}

type AndroidDependencyConfig = {
  sourceDir: string;
  packageImportPath: string | null;
  packageInstance: string | null;
  dependencyConfiguration?: string;
  buildTypes: string[];
  libraryName?: string | null;
  componentDescriptors?: string[] | null;
  cmakeListsPath?: string | null;
  cxxModuleCMakeListsModuleName?: string | null;
  cxxModuleCMakeListsPath?: string | null;
  cxxModuleHeaderName?: string | null;
  isPureCxxDependency?: boolean;
};

Android Platform Types

iOS Platform Types

Complete iOS platform configuration types with CocoaPods integration, Xcode project handling, and script phase management.

interface IOSProjectConfig {
  sourceDir: string;
  xcodeProject: IOSProjectInfo | null;
  watchModeCommandParams?: string[];
  automaticPodsInstallation?: boolean;
  assets: string[];
}

interface IOSDependencyConfig {
  podspecPath: string;
  version: string;
  scriptPhases: Array<IOSScriptPhase>;
  configurations: string[];
}

type IOSScriptPhase = ({script: string} | {path: string}) & {
  name: string;
  shell_path?: string;
  input_files?: string[];
  output_files?: string[];
  input_file_lists?: string[];
  output_file_lists?: string[];
  show_env_vars_in_log?: boolean;
  execution_position?: 'before_compile' | 'after_compile' | 'any';
  dependency_file?: string;
  always_out_of_date?: string;
};

iOS Platform Types

Third-Party Type Definitions

Type definitions for third-party modules used within the React Native CLI ecosystem, provided as module augmentation for enhanced TypeScript support.

// Available through module augmentation after installing this package
declare module 'node-stream-zip' {
  interface StreamZipOptions {
    file: string;
    storeEntries?: boolean;
    skipEntryNameValidation?: boolean;
    chunkSize?: number;
  }
  
  class ZipEntry {
    name: string;
    isDirectory: boolean;
    isFile: boolean;
    comment: string;
    size: number;
  }
  
  class StreamZip {
    constructor(config: StreamZipOptions);
    on(event: 'ready', handler: () => void): void;
    entries(): ZipEntry[];
    extract(entry: string | null, outPath: string, callback: (err?: any) => void): void;
    close(callback?: (err?: any) => void): void;
  }
}

Third-Party Type Definitions

Core Types

type Prompt = any;

type OptionValue = string | boolean | number;

type CommandOption<T = (ctx: Config) => OptionValue> = {
  name: string;
  description?: string;
  parse?: (val: string) => any;
  default?: OptionValue | T;
};

type DetachedCommandFunction<Args = Object> = (
  argv: string[],
  args: Args,
  ctx: Config
) => Promise<void> | void;

type DetachedCommand = Command<true>;

interface PlatformConfig<
  ProjectConfig,
  ProjectParams,
  DependencyConfig,
  DependencyParams,
> {
  npmPackageName?: string;
  projectConfig: (
    projectRoot: string,
    projectParams: ProjectParams | void,
  ) => ProjectConfig | void;
  dependencyConfig: (
    dependency: string,
    params: DependencyParams,
  ) => DependencyConfig | void;
}

interface DependencyConfig {
  name: string;
  root: string;
  platforms: {
    android?: AndroidDependencyConfig;
    ios?: IOSDependencyConfig;
    [key: string]: any;
  };
}

type UserConfig = Omit<Config, 'root'> & {
  reactNativePath: string | void;
  project: {
    android?: AndroidProjectParams;
    ios?: IOSProjectParams;
    [key: string]: any;
  };
};

type UserDependencyConfig = {
  dependency: Omit<DependencyConfig, 'name' | 'root'>;
  commands: Command[];
  platforms: Config['platforms'];
  healthChecks: [];
};

type AndroidProjectParams = {
  sourceDir?: string;
  appName?: string;
  manifestPath?: string;
  packageName?: string;
  dependencyConfiguration?: string;
  watchModeCommandParams?: string[];
  assets?: string[];
};

interface IOSProjectParams {
  sourceDir?: string;
  watchModeCommandParams?: string[];
  automaticPodsInstallation?: boolean;
  assets?: string[];
}

type IOSDependencyParams = Omit<
  Partial<IOSDependencyConfig>,
  'podspecPath' | 'version'
>;

type AndroidDependencyParams = {
  sourceDir?: string;
  manifestPath?: string;
  packageName?: string;
  dependencyConfiguration?: string;
  packageImportPath?: string;
  packageInstance?: string;
  buildTypes?: string[];
  libraryName?: string | null;
  componentDescriptors?: string[] | null;
  cmakeListsPath?: string | null;
  cxxModuleCMakeListsModuleName?: string | null;
  cxxModuleCMakeListsPath?: string | null;
  cxxModuleHeaderName?: string | null;
};