feat: brownfield config file#339
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Introduces a unified configuration file system for the Brownfield CLI (react-native-brownfield.config.{js,json} or package.json#react-native-brownfield), validated via JSON schema, and migrates the legacy package.json#brownie block under a nested brownie key.
Changes:
- Adds
config.ts(load + validate + apply) wired intoactionRunner, plus a published JSON schema and type exports. - Updates Brownie codegen to support both legacy and new config sources with a migration warning and conflict error.
- Updates example apps and docs to use the new configuration format.
Reviewed changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/cli/src/config.ts | New module to load/validate/apply Brownfield config to commands |
| packages/cli/src/types.ts | New shared CLI/config type definitions |
| packages/cli/src/shared/utils/cli.ts | Wires addBrownfieldConfig into actionRunner |
| packages/cli/src/shared/utils/tests/cli.test.ts | Adds test for config integration in actionRunner |
| packages/cli/src/brownie/config.ts | Adds hasLegacyConfig and refactors package.json loading |
| packages/cli/src/brownie/commands/codegen.ts | Adds new-vs-legacy config handling and warning |
| packages/cli/src/brownie/tests/commands/codegen.test.ts | Adds test for conflicting configs error |
| packages/cli/src/brownie/index.ts | Exports BrownieConfig type |
| packages/cli/src/brownfield/commands/packageIos.ts | Switches to shared PackageIosOptions type |
| packages/cli/src/navigation/commands/codegen.ts | Formatting only |
| packages/cli/src/tests/config.test.ts | New tests for config loading, validation, and apply |
| packages/cli/schema.json | New JSON schema for the config |
| packages/cli/package.json | Adds ajv dependency and ./types export |
| packages/react-native-brownfield/src/index.ts | Re-exports BrownfieldConfig type |
| docs/docs/public/schema.json | Published copy of schema |
| docs/docs/public/package-json.schema.json | package.json schema extension |
| docs/docs/docs/api-reference/configuration.mdx | New configuration docs page |
| docs/docs/docs/api-reference/_meta.json | Adds new page to nav |
| docs/docs/docs/cli/brownfield.mdx | Adds config tip, removes --verbose row |
| docs/docs/docs/cli/brownie.mdx | Adds config tip |
| docs/docs/docs/getting-started/android.mdx | Adds config step, renumbers sections |
| docs/docs/docs/getting-started/ios.mdx | Adds config step, renumbers sections |
| docs/docs/docs/getting-started/quick-start.mdx | Adds link to config docs |
| apps/RNApp/react-native-brownfield.config.js | New sample JS config |
| apps/RNApp/package.json | Simplifies brownfield scripts |
| apps/ExpoApp54/react-native-brownfield.config.json | New sample JSON config |
| apps/ExpoApp54/package.json | Removes legacy brownie, simplifies scripts |
| apps/ExpoApp55/package.json | Migrates to new react-native-brownfield block |
| .vscode/settings.json | Registers schema for package.json autocomplete |
| yarn.lock | Adds ajv entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ```js | ||
| /** @type {import('@callstack/react-native-brownfield').BrownfieldConfig} */ | ||
| module.exports = { | ||
| moduleName: ':BrownfieldLib', |
There was a problem hiding this comment.
| moduleName: ':BrownfieldLib', | |
| moduleName: 'BrownfieldLib', |
| export type BrownfieldConfig = BrownfieldConfigMetadata & | ||
| BrownfieldCommonOptions & | ||
| BrownfieldAndroidConfig & | ||
| BrownfieldIosConfig & { brownie?: BrownieConfig }; |
There was a problem hiding this comment.
Let's adjust this to keep platform-specific options verbosely separated, so as not to confuse devs with what the options control:
BrownfieldConfigMetadata &
BrownfieldCommonOptions &
{android: BrownfieldAndroidConfig, ios: BrownfieldIosConfig}
& { brownie?: BrownieConfig };| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "title": "React Native Brownfield CLI config", | ||
| "description": "Configuration for react-native-brownfield.config.json and package.json#react-native-brownfield.", | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "$schema": { |
There was a problem hiding this comment.
I think we should aim for automating generation of this schema e.g. using https://www.npmjs.com/package/typescript-json-schema. The current setup would increase the maintenance effort for us, while if we could auto-generate this (say, from a script in package.json + that would run on build + that would be run in precommit by lefthook - that would make it fully automated. We already have all the types in place.
The only matter to be checked is the docstrings for keys in types imported from Rock (i.e. if they are descriptive enough). If not - we can always make an intermediate type that is constrained to include all keys (no less, no more) from the Rock-imported type(s) and provide our own docstring override there.
|
Hey! Solid work, I only left two comments. |
hurali97
left a comment
There was a problem hiding this comment.
Good work - Just take care of the below comments:
- Add changeset for the changed packages
- Inspect CI failures
Summary
Fixes #62
Test plan