or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

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

configuration-types.mddocs/

0

# Configuration Types

1

2

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

3

4

## Capabilities

5

6

### Main Configuration

7

8

The central configuration interface that contains all React Native CLI settings and project metadata.

9

10

```typescript { .api }

11

/**

12

* Complete CLI configuration object containing all project and platform settings

13

*/

14

interface Config {

15

/** Root directory of the React Native project */

16

root: string;

17

/** Path to React Native installation */

18

reactNativePath: string;

19

/** Version of React Native being used */

20

reactNativeVersion: string;

21

/** Multi-platform project configuration */

22

project: ProjectConfig;

23

/** Dictionary of dependency configurations keyed by dependency name */

24

dependencies: {

25

[key: string]: DependencyConfig;

26

};

27

/** Platform-specific configurations with extensible platform support */

28

platforms: {

29

android: AndroidPlatformConfig;

30

ios: IOSPlatformConfig;

31

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

32

};

33

/** Array of asset directories to be processed */

34

assets: string[];

35

/** Available CLI commands */

36

commands: Command[];

37

/** Health check configurations (deprecated, will be removed) */

38

healthChecks: [];

39

}

40

```

41

42

**Usage Examples:**

43

44

```typescript

45

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

46

47

// Working with configuration

48

function analyzeProject(config: Config) {

49

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

50

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

51

52

// Check available platforms

53

if (config.project.android) {

54

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

55

}

56

57

if (config.project.ios) {

58

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

59

}

60

61

// List dependencies

62

Object.keys(config.dependencies).forEach(dep => {

63

console.log(`Dependency: ${dep} at ${config.dependencies[dep].root}`);

64

});

65

66

// Count assets

67

console.log(`Asset directories: ${config.assets.length}`);

68

69

// Available commands

70

console.log(`Available commands: ${config.commands.map(cmd => cmd.name).join(', ')}`);

71

}

72

```

73

74

### Project Configuration

75

76

Multi-platform project configuration supporting Android, iOS, and custom platforms.

77

78

```typescript { .api }

79

/**

80

* Multi-platform project configuration

81

*/

82

type ProjectConfig = {

83

/** Android project configuration (optional) */

84

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

85

/** iOS project configuration (optional) */

86

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

87

/** Custom platform configurations */

88

[key: string]: any;

89

};

90

```

91

92

**Usage Examples:**

93

94

```typescript

95

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

96

97

// Check what platforms are configured

98

function getPlatforms(project: ProjectConfig): string[] {

99

const platforms: string[] = [];

100

101

if (project.android) platforms.push('android');

102

if (project.ios) platforms.push('ios');

103

104

// Check for custom platforms

105

Object.keys(project).forEach(key => {

106

if (key !== 'android' && key !== 'ios' && project[key]) {

107

platforms.push(key);

108

}

109

});

110

111

return platforms;

112

}

113

114

// Validate project has required platforms

115

function validateProject(project: ProjectConfig, requiredPlatforms: string[]): boolean {

116

return requiredPlatforms.every(platform => {

117

if (platform === 'android') return !!project.android;

118

if (platform === 'ios') return !!project.ios;

119

return !!project[platform];

120

});

121

}

122

```

123

124

### Dependency Configuration

125

126

Configuration for individual dependencies with multi-platform support.

127

128

```typescript { .api }

129

/**

130

* Multi-platform dependency configuration

131

*/

132

interface DependencyConfig {

133

/** Dependency name */

134

name: string;

135

/** Root directory of the dependency */

136

root: string;

137

/** Platform-specific dependency configurations */

138

platforms: {

139

/** Android dependency configuration (optional) */

140

android?: Exclude<

141

ReturnType<AndroidPlatformConfig['dependencyConfig']>,

142

void

143

>;

144

/** iOS dependency configuration (optional) */

145

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

146

/** Custom platform dependency configurations */

147

[key: string]: any;

148

};

149

}

150

```

151

152

**Usage Examples:**

153

154

```typescript

155

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

156

157

// Analyze dependency platform support

158

function analyzeDependency(dep: DependencyConfig) {

159

console.log(`Dependency: ${dep.name}`);

160

console.log(`Location: ${dep.root}`);

161

162

const supportedPlatforms: string[] = [];

163

164

if (dep.platforms.android) {

165

supportedPlatforms.push('android');

166

console.log(`Android library: ${dep.platforms.android.libraryName || 'default'}`);

167

}

168

169

if (dep.platforms.ios) {

170

supportedPlatforms.push('ios');

171

console.log(`iOS podspec: ${dep.platforms.ios.podspecPath}`);

172

}

173

174

// Check custom platforms

175

Object.keys(dep.platforms).forEach(platform => {

176

if (platform !== 'android' && platform !== 'ios' && dep.platforms[platform]) {

177

supportedPlatforms.push(platform);

178

}

179

});

180

181

console.log(`Supported platforms: ${supportedPlatforms.join(', ')}`);

182

}

183

184

// Filter dependencies by platform

185

function getDependenciesForPlatform(

186

dependencies: {[key: string]: DependencyConfig},

187

platform: string

188

): DependencyConfig[] {

189

return Object.values(dependencies).filter(dep =>

190

dep.platforms[platform] !== undefined

191

);

192

}

193

```

194

195

### User Configuration Types

196

197

Configuration types for user-provided settings with optional values and parameter objects.

198

199

```typescript { .api }

200

/**

201

* User-provided configuration with optional root and parameter-based project settings

202

*/

203

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

204

/** React Native path (optional for user config) */

205

reactNativePath: string | void;

206

/** Project configuration using parameter objects */

207

project: {

208

android?: AndroidProjectParams;

209

ios?: IOSProjectParams;

210

[key: string]: any;

211

};

212

};

213

214

/**

215

* User-provided dependency configuration for packages that extend CLI functionality

216

*/

217

type UserDependencyConfig = {

218

/** Dependency configuration without name and root (provided by package context) */

219

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

220

/** Commands provided by this dependency */

221

commands: Command[];

222

/** Platform configurations provided by this dependency */

223

platforms: Config['platforms'];

224

/** Health checks provided by this dependency (deprecated) */

225

healthChecks: [];

226

};

227

```

228

229

**Usage Examples:**

230

231

```typescript

232

import { UserConfig, UserDependencyConfig, AndroidProjectParams, IOSProjectParams } from "@react-native-community/cli-types";

233

234

// Create user configuration

235

const userConfig: UserConfig = {

236

reactNativePath: './node_modules/react-native',

237

reactNativeVersion: '0.72.0',

238

project: {

239

android: {

240

sourceDir: 'android/app/src/main/java',

241

appName: 'MyApp',

242

packageName: 'com.mycompany.myapp'

243

} as AndroidProjectParams,

244

ios: {

245

sourceDir: 'ios',

246

automaticPodsInstallation: true

247

} as IOSProjectParams

248

},

249

dependencies: {},

250

platforms: {} as any,

251

assets: ['./assets'],

252

commands: [],

253

healthChecks: []

254

};

255

256

// Create dependency configuration for a plugin

257

const pluginConfig: UserDependencyConfig = {

258

dependency: {

259

platforms: {

260

android: {

261

sourceDir: 'android',

262

packageImportPath: 'com.myplugin.MyPlugin',

263

packageInstance: 'new MyPlugin()',

264

buildTypes: ['debug', 'release'],

265

dependencyConfiguration: 'implementation'

266

},

267

ios: {

268

podspecPath: './ios/MyPlugin.podspec',

269

version: '1.0.0',

270

scriptPhases: [],

271

configurations: ['Debug', 'Release']

272

}

273

}

274

},

275

commands: [

276

{

277

name: 'my-plugin-command',

278

description: 'Run my plugin command',

279

func: async (argv, ctx, args) => {

280

console.log('Running plugin command');

281

}

282

}

283

],

284

platforms: {} as any,

285

healthChecks: []

286

};

287

```

288

289

### Platform Configuration Interface

290

291

Generic platform configuration interface that enables extensible platform support.

292

293

```typescript { .api }

294

/**

295

* Generic platform configuration interface enabling extensible platform support

296

* @template ProjectConfig - Platform-specific project configuration type

297

* @template ProjectParams - Platform-specific project parameters type

298

* @template DependencyConfig - Platform-specific dependency configuration type

299

* @template DependencyParams - Platform-specific dependency parameters type

300

*/

301

interface PlatformConfig<

302

ProjectConfig,

303

ProjectParams,

304

DependencyConfig,

305

DependencyParams,

306

> {

307

/** NPM package name that provides this platform support (optional) */

308

npmPackageName?: string;

309

/** Function to generate project configuration from parameters */

310

projectConfig: (

311

projectRoot: string,

312

projectParams: ProjectParams | void,

313

) => ProjectConfig | void;

314

/** Function to generate dependency configuration from parameters */

315

dependencyConfig: (

316

dependency: string,

317

params: DependencyParams,

318

) => DependencyConfig | void;

319

}

320

```

321

322

**Usage Examples:**

323

324

```typescript

325

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

326

327

// Custom platform configuration

328

interface CustomProjectConfig {

329

buildDir: string;

330

mainFile: string;

331

}

332

333

interface CustomProjectParams {

334

buildDir?: string;

335

mainFile?: string;

336

}

337

338

interface CustomDependencyConfig {

339

libPath: string;

340

version: string;

341

}

342

343

interface CustomDependencyParams {

344

libPath?: string;

345

}

346

347

const customPlatform: PlatformConfig<

348

CustomProjectConfig,

349

CustomProjectParams,

350

CustomDependencyConfig,

351

CustomDependencyParams

352

> = {

353

npmPackageName: '@mycompany/react-native-custom-platform',

354

355

projectConfig: (projectRoot: string, params: CustomProjectParams | void) => {

356

return {

357

buildDir: params?.buildDir || `${projectRoot}/build`,

358

mainFile: params?.mainFile || `${projectRoot}/src/main.custom`

359

};

360

},

361

362

dependencyConfig: (dependency: string, params: CustomDependencyParams) => {

363

return {

364

libPath: params.libPath || `./libs/${dependency}`,

365

version: '1.0.0'

366

};

367

}

368

};

369

370

// Register custom platform

371

function addCustomPlatform(config: Config): Config {

372

return {

373

...config,

374

platforms: {

375

...config.platforms,

376

custom: customPlatform as any

377

}

378

};

379

}

380

```

381

382

### Platform-Specific Configuration Types

383

384

Type aliases for the built-in Android and iOS platform configurations.

385

386

```typescript { .api }

387

/**

388

* Android platform configuration type

389

*/

390

type AndroidPlatformConfig = PlatformConfig<

391

AndroidProjectConfig,

392

AndroidProjectParams,

393

AndroidDependencyConfig,

394

AndroidDependencyParams

395

>;

396

397

/**

398

* iOS platform configuration type

399

*/

400

type IOSPlatformConfig = PlatformConfig<

401

IOSProjectConfig,

402

IOSProjectParams,

403

IOSDependencyConfig,

404

IOSDependencyParams

405

>;

406

```

407

408

**Usage Examples:**

409

410

```typescript

411

import { AndroidPlatformConfig, IOSPlatformConfig, Config } from "@react-native-community/cli-types";

412

413

// Access platform configurations from main config

414

function getPlatformConfigs(config: Config) {

415

const androidPlatform: AndroidPlatformConfig = config.platforms.android;

416

const iosPlatform: IOSPlatformConfig = config.platforms.ios;

417

418

// Use platform configurations to generate project configs

419

const androidProject = androidPlatform.projectConfig('/path/to/project', {

420

sourceDir: 'android/app/src/main/java',

421

appName: 'MyApp'

422

});

423

424

const iosProject = iosPlatform.projectConfig('/path/to/project', {

425

sourceDir: 'ios',

426

automaticPodsInstallation: true

427

});

428

429

console.log('Android project:', androidProject);

430

console.log('iOS project:', iosProject);

431

}

432

```