or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

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

0

# React Native Community CLI Types

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: @react-native-community/cli-types

7

- **Package Type**: npm

8

- **Language**: TypeScript

9

- **Installation**: `npm install @react-native-community/cli-types`

10

11

## Core Imports

12

13

```typescript

14

import {

15

Config,

16

Command,

17

ProjectConfig,

18

DependencyConfig,

19

AndroidProjectConfig,

20

IOSProjectConfig

21

} from "@react-native-community/cli-types";

22

```

23

24

For CommonJS:

25

26

```javascript

27

const {

28

Config,

29

Command,

30

ProjectConfig,

31

DependencyConfig,

32

AndroidProjectConfig,

33

IOSProjectConfig

34

} = require("@react-native-community/cli-types");

35

```

36

37

## Basic Usage

38

39

```typescript

40

import {

41

Config,

42

Command,

43

CommandFunction,

44

AndroidProjectConfig,

45

IOSProjectConfig

46

} from "@react-native-community/cli-types";

47

48

// Define a command function

49

const myCommand: CommandFunction = async (argv, ctx, args) => {

50

console.log(`Running command in project: ${ctx.project.android?.appName}`);

51

};

52

53

// Define a command

54

const command: Command = {

55

name: "my-command",

56

description: "Example CLI command",

57

func: myCommand,

58

options: [

59

{

60

name: "--verbose",

61

description: "Enable verbose logging",

62

default: false

63

}

64

]

65

};

66

67

// Work with configuration

68

function processConfig(config: Config) {

69

console.log(`React Native path: ${config.reactNativePath}`);

70

console.log(`Project root: ${config.root}`);

71

72

if (config.project.android) {

73

console.log(`Android app: ${config.project.android.appName}`);

74

}

75

76

if (config.project.ios) {

77

console.log(`iOS project: ${config.project.ios.xcodeProject?.name}`);

78

}

79

}

80

```

81

82

## Architecture

83

84

The type system is organized around several key areas:

85

86

- **Command System**: Type-safe command definitions with support for both standard and detached commands

87

- **Configuration Types**: Structured configuration for projects, dependencies, and platforms

88

- **Platform Types**: Specialized Android and iOS configuration with platform-specific features

89

- **Validation Integration**: Joi schema validation integration for configuration validation

90

- **Extension Points**: Generic platform configuration interfaces for custom platform support

91

92

## Capabilities

93

94

### Command System

95

96

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

97

98

```typescript { .api }

99

type CommandFunction<Args = Object> = (

100

argv: Array<string>,

101

ctx: Config,

102

args: Args

103

) => Promise<void> | void;

104

105

type Command<IsDetached extends boolean = false> = {

106

name: string;

107

description?: string;

108

detached?: IsDetached;

109

examples?: Array<{

110

desc: string;

111

cmd: string;

112

}>;

113

pkg?: {

114

name: string;

115

version: string;

116

};

117

func: IsDetached extends true

118

? DetachedCommandFunction<Object>

119

: CommandFunction<Object>;

120

options?: Array<CommandOption>;

121

};

122

```

123

124

[Command System](./command-system.md)

125

126

### Configuration Types

127

128

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

129

130

```typescript { .api }

131

interface Config {

132

root: string;

133

reactNativePath: string;

134

reactNativeVersion: string;

135

project: ProjectConfig;

136

dependencies: {

137

[key: string]: DependencyConfig;

138

};

139

platforms: {

140

android: AndroidPlatformConfig;

141

ios: IOSPlatformConfig;

142

[name: string]: PlatformConfig<any, any, any, any>;

143

};

144

assets: string[];

145

commands: Command[];

146

healthChecks: [];

147

}

148

149

type ProjectConfig = {

150

android?: Exclude<ReturnType<AndroidPlatformConfig['projectConfig']>, void>;

151

ios?: Exclude<ReturnType<IOSPlatformConfig['projectConfig']>, void>;

152

[key: string]: any;

153

};

154

```

155

156

[Configuration Types](./configuration-types.md)

157

158

### Android Platform Types

159

160

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

161

162

```typescript { .api }

163

interface AndroidProjectConfig {

164

sourceDir: string;

165

appName: string;

166

packageName: string;

167

applicationId: string;

168

mainActivity: string;

169

dependencyConfiguration?: string;

170

watchModeCommandParams?: string[];

171

assets: string[];

172

}

173

174

type AndroidDependencyConfig = {

175

sourceDir: string;

176

packageImportPath: string | null;

177

packageInstance: string | null;

178

dependencyConfiguration?: string;

179

buildTypes: string[];

180

libraryName?: string | null;

181

componentDescriptors?: string[] | null;

182

cmakeListsPath?: string | null;

183

cxxModuleCMakeListsModuleName?: string | null;

184

cxxModuleCMakeListsPath?: string | null;

185

cxxModuleHeaderName?: string | null;

186

isPureCxxDependency?: boolean;

187

};

188

```

189

190

[Android Platform Types](./android-platform.md)

191

192

### iOS Platform Types

193

194

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

195

196

```typescript { .api }

197

interface IOSProjectConfig {

198

sourceDir: string;

199

xcodeProject: IOSProjectInfo | null;

200

watchModeCommandParams?: string[];

201

automaticPodsInstallation?: boolean;

202

assets: string[];

203

}

204

205

interface IOSDependencyConfig {

206

podspecPath: string;

207

version: string;

208

scriptPhases: Array<IOSScriptPhase>;

209

configurations: string[];

210

}

211

212

type IOSScriptPhase = ({script: string} | {path: string}) & {

213

name: string;

214

shell_path?: string;

215

input_files?: string[];

216

output_files?: string[];

217

input_file_lists?: string[];

218

output_file_lists?: string[];

219

show_env_vars_in_log?: boolean;

220

execution_position?: 'before_compile' | 'after_compile' | 'any';

221

dependency_file?: string;

222

always_out_of_date?: string;

223

};

224

```

225

226

[iOS Platform Types](./ios-platform.md)

227

228

### Third-Party Type Definitions

229

230

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

231

232

```typescript { .api }

233

// Available through module augmentation after installing this package

234

declare module 'node-stream-zip' {

235

interface StreamZipOptions {

236

file: string;

237

storeEntries?: boolean;

238

skipEntryNameValidation?: boolean;

239

chunkSize?: number;

240

}

241

242

class ZipEntry {

243

name: string;

244

isDirectory: boolean;

245

isFile: boolean;

246

comment: string;

247

size: number;

248

}

249

250

class StreamZip {

251

constructor(config: StreamZipOptions);

252

on(event: 'ready', handler: () => void): void;

253

entries(): ZipEntry[];

254

extract(entry: string | null, outPath: string, callback: (err?: any) => void): void;

255

close(callback?: (err?: any) => void): void;

256

}

257

}

258

```

259

260

[Third-Party Type Definitions](./third-party-types.md)

261

262

## Core Types

263

264

```typescript { .api }

265

type Prompt = any;

266

267

type OptionValue = string | boolean | number;

268

269

type CommandOption<T = (ctx: Config) => OptionValue> = {

270

name: string;

271

description?: string;

272

parse?: (val: string) => any;

273

default?: OptionValue | T;

274

};

275

276

type DetachedCommandFunction<Args = Object> = (

277

argv: string[],

278

args: Args,

279

ctx: Config

280

) => Promise<void> | void;

281

282

type DetachedCommand = Command<true>;

283

284

interface PlatformConfig<

285

ProjectConfig,

286

ProjectParams,

287

DependencyConfig,

288

DependencyParams,

289

> {

290

npmPackageName?: string;

291

projectConfig: (

292

projectRoot: string,

293

projectParams: ProjectParams | void,

294

) => ProjectConfig | void;

295

dependencyConfig: (

296

dependency: string,

297

params: DependencyParams,

298

) => DependencyConfig | void;

299

}

300

301

interface DependencyConfig {

302

name: string;

303

root: string;

304

platforms: {

305

android?: AndroidDependencyConfig;

306

ios?: IOSDependencyConfig;

307

[key: string]: any;

308

};

309

}

310

311

type UserConfig = Omit<Config, 'root'> & {

312

reactNativePath: string | void;

313

project: {

314

android?: AndroidProjectParams;

315

ios?: IOSProjectParams;

316

[key: string]: any;

317

};

318

};

319

320

type UserDependencyConfig = {

321

dependency: Omit<DependencyConfig, 'name' | 'root'>;

322

commands: Command[];

323

platforms: Config['platforms'];

324

healthChecks: [];

325

};

326

327

type AndroidProjectParams = {

328

sourceDir?: string;

329

appName?: string;

330

manifestPath?: string;

331

packageName?: string;

332

dependencyConfiguration?: string;

333

watchModeCommandParams?: string[];

334

assets?: string[];

335

};

336

337

interface IOSProjectParams {

338

sourceDir?: string;

339

watchModeCommandParams?: string[];

340

automaticPodsInstallation?: boolean;

341

assets?: string[];

342

}

343

344

type IOSDependencyParams = Omit<

345

Partial<IOSDependencyConfig>,

346

'podspecPath' | 'version'

347

>;

348

349

type AndroidDependencyParams = {

350

sourceDir?: string;

351

manifestPath?: string;

352

packageName?: string;

353

dependencyConfiguration?: string;

354

packageImportPath?: string;

355

packageInstance?: string;

356

buildTypes?: string[];

357

libraryName?: string | null;

358

componentDescriptors?: string[] | null;

359

cmakeListsPath?: string | null;

360

cxxModuleCMakeListsModuleName?: string | null;

361

cxxModuleCMakeListsPath?: string | null;

362

cxxModuleHeaderName?: string | null;

363

};

364

```