-
Notifications
You must be signed in to change notification settings - Fork 40
feat: brownfield config file #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7e7602c
2e49823
de2fc04
a54bf4a
64fb67d
04a9b05
f8596ee
dd4001b
4d998f3
998c13d
e55b36f
81d21bf
fada2ba
696caf9
217a3f0
c0c7096
794dcc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "json.schemas": [ | ||
| { | ||
| "fileMatch": ["**/package.json"], | ||
| "url": "https://oss.callstack.com/react-native-brownfield/package-json.schema.json" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "$schema": "https://oss.callstack.com/react-native-brownfield/schema.json", | ||
| "moduleName": "brownfieldlib", | ||
| "scheme": "BrownfieldLib", | ||
| "verbose": true, | ||
| "brownie": { | ||
| "kotlin": "./android/brownfieldlib/src/main/java/com/callstack/rnbrownfield/demo/expoapp54/Generated/", | ||
| "kotlinPackageName": "com.callstack.rnbrownfield.demo.expoapp54" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /** | ||
| * @type {import('@callstack/react-native-brownfield').BrownfieldConfig} | ||
| */ | ||
| module.exports = { | ||
| moduleName: ':BrownfieldLib', | ||
| scheme: 'BrownfieldLib', | ||
| verbose: true, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,6 @@ dist-ssr | |
| *.sln | ||
| *.sw? | ||
| doc_build | ||
|
|
||
| # Copied schema file | ||
| docs/public/schema.json | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,194 @@ | ||||||
| # Configuration files | ||||||
|
|
||||||
| The Brownfield CLI can load configuration from a file instead of repeating the same flags on every command. | ||||||
| That configuration covers both `@callstack/react-native-brownfield` and `@callstack/brownie` options. | ||||||
|
|
||||||
| Configuration keys use camelCase names that match CLI flags. | ||||||
| For example, `--module-name` becomes `moduleName`, `--build-folder` becomes `buildFolder`, and `--use-prebuilt-rn-core` becomes `usePrebuiltRnCore`. | ||||||
|
|
||||||
| ## Choose one configuration source | ||||||
|
|
||||||
| The CLI supports exactly one configuration source per project: | ||||||
|
|
||||||
| - `react-native-brownfield.config.js` | ||||||
| - `react-native-brownfield.config.json` | ||||||
| - `package.json` under the `react-native-brownfield` key | ||||||
|
|
||||||
| Do not keep more than one of these at the same time. | ||||||
| If the CLI finds multiple sources, it throws an error instead of guessing which one should win. | ||||||
|
|
||||||
| When both a config value and a CLI flag are set for the same option, the CLI flag wins. | ||||||
| The CLI also validates the file against the published schema and logs warnings for unknown or invalid keys. | ||||||
|
|
||||||
| ## JavaScript config file | ||||||
|
|
||||||
| If you prefer a JavaScript file, create `react-native-brownfield.config.js` and export a plain object with `module.exports`: | ||||||
|
|
||||||
| ```js | ||||||
| /** @type {import('@callstack/react-native-brownfield').BrownfieldConfig} */ | ||||||
| module.exports = { | ||||||
| moduleName: ':BrownfieldLib', | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| scheme: 'BrownfieldLib', | ||||||
| verbose: true, | ||||||
| brownie: { | ||||||
| kotlin: | ||||||
| './android/BrownfieldLib/src/main/java/com/example/brownfield/Generated/', | ||||||
| kotlinPackageName: 'com.example.brownfield', | ||||||
| }, | ||||||
| }; | ||||||
| ``` | ||||||
|
|
||||||
| ## JSON config file | ||||||
|
|
||||||
| If you want schema autocomplete and validation directly in the config file, use `react-native-brownfield.config.json`: | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "$schema": "https://oss.callstack.com/react-native-brownfield/schema.json", | ||||||
| "moduleName": "brownfieldlib", | ||||||
| "scheme": "BrownfieldLib", | ||||||
| "configuration": "Release", | ||||||
| "verbose": true, | ||||||
| "usePrebuiltRnCore": true, | ||||||
| "brownie": { | ||||||
| "kotlin": "./android/brownfieldlib/src/main/java/com/example/brownfield/Generated/", | ||||||
| "kotlinPackageName": "com.example.brownfield" | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ## package.json config | ||||||
|
|
||||||
| If you prefer to keep everything in `package.json`, place the configuration under `react-native-brownfield`: | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "name": "my-app", | ||||||
| "brownfield": { | ||||||
| "moduleName": ":BrownfieldLib", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| "scheme": "BrownfieldLib", | ||||||
| "verbose": true, | ||||||
| "brownie": { | ||||||
| "kotlin": "./android/BrownfieldLib/src/main/java/com/example/brownfield/Generated/", | ||||||
| "kotlinPackageName": "com.example.brownfield" | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ## Configuration reference | ||||||
|
|
||||||
| All file-based options mirror CLI flags, but they use camelCase property names. | ||||||
|
|
||||||
| ### Shared keys | ||||||
|
|
||||||
| | Key | Type | Description | | ||||||
| | --------- | --------- | --------------------------------------------------------------------- | | ||||||
| | `$schema` | `string` | JSON Schema URL used by editors for validation and autocomplete. | | ||||||
| | `verbose` | `boolean` | Enables verbose CLI logging. | | ||||||
| | `brownie` | `object` | Nested Brownie configuration used by `brownfield codegen`. See below. | | ||||||
|
|
||||||
| ### Android keys | ||||||
|
|
||||||
| | Key | Type | Description | | ||||||
| | ------------ | -------- | -------------------------------------------------------------------- | | ||||||
| | `moduleName` | `string` | Android module name used for packaging and publishing AAR artifacts. | | ||||||
| | `variant` | `string` | Android build variant, for example `debug` or `freeRelease`. | | ||||||
|
|
||||||
| ### iOS keys | ||||||
|
|
||||||
| | Key | Type | Description | | ||||||
| | -------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------- | | ||||||
| | `scheme` | `string` | Xcode scheme used for packaging. | | ||||||
| | `configuration` | `string` | Xcode build configuration, for example `Debug` or `Release`. | | ||||||
| | `target` | `string` | Explicit Xcode target name. | | ||||||
| | `destination` | `string[]` | One or more Xcode destinations, such as `simulator`, `device`, or full destination strings. | | ||||||
| | `buildFolder` | `string` | Custom build output directory. By default, Brownfield uses the `.brownfield/build` path inside the iOS project. | | ||||||
| | `archive` | `boolean` | Creates an archive build suitable for IPA export and distribution. | | ||||||
| | `extraParams` | `string[]` | Extra arguments passed to `xcodebuild`. | | ||||||
| | `exportExtraParams` | `string[]` | Extra arguments passed to the archive export step. | | ||||||
| | `exportOptionsPlist` | `string` | Export options plist filename used during archive export. | | ||||||
| | `installPods` | `boolean` | Controls automatic CocoaPods installation. Set `false` to match `--no-install-pods`. | | ||||||
| | `newArch` | `boolean` | Controls React Native new architecture support. Set `false` to match `--no-new-arch`. | | ||||||
| | `local` | `boolean` | Forces a local `xcodebuild` flow. | | ||||||
| | `usePrebuiltRnCore` | `boolean` | Controls whether iOS packaging uses React Native Apple prebuilts. Omit it to keep Brownfield's version-aware defaults. | | ||||||
|
|
||||||
| ## Brownie configuration | ||||||
|
|
||||||
| The Brownie configuration lives inside the main Brownfield config under the `brownie` key. | ||||||
| This is the preferred format for Brownie code generation. | ||||||
|
|
||||||
| Currently supported Brownie keys are: | ||||||
|
|
||||||
| | Key | Type | Description | | ||||||
| | ------------------- | -------- | ----------------------------------------------------------------------- | | ||||||
| | `kotlin` | `string` | Directory where generated Kotlin Brownie store files should be written. | | ||||||
| | `kotlinPackageName` | `string` | Kotlin package name used in generated Brownie store files. | | ||||||
|
|
||||||
| Example inside `react-native-brownfield.config.json`: | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "$schema": "https://oss.callstack.com/react-native-brownfield/schema.json", | ||||||
| "brownie": { | ||||||
| "kotlin": "./android/BrownfieldLib/src/main/java/com/rnapp/brownfieldlib/Generated/", | ||||||
| "kotlinPackageName": "com.rnapp.brownfieldlib" | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| Only the Kotlin output is configurable. | ||||||
| Swift Brownie files are always generated to `node_modules/@callstack/brownie/ios/Generated/`. | ||||||
|
|
||||||
| ## Migrating from legacy Brownie configuration | ||||||
|
|
||||||
| Legacy Brownie configuration used a top-level `brownie` block in `package.json`: | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "brownie": { | ||||||
| "kotlin": "./android/BrownfieldLib/src/main/java/com/rnapp/brownfieldlib/Generated/", | ||||||
| "kotlinPackageName": "com.rnapp.brownfieldlib" | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| The new format moves the same values under the main Brownfield config: | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "brownfield": { | ||||||
| "moduleName": ":BrownfieldLib", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| "scheme": "BrownfieldLib", | ||||||
| "brownie": { | ||||||
| "kotlin": "./android/BrownfieldLib/src/main/java/com/rnapp/brownfieldlib/Generated/", | ||||||
| "kotlinPackageName": "com.rnapp.brownfieldlib" | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| You can also migrate to a standalone config file: | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "$schema": "https://oss.callstack.com/react-native-brownfield/schema.json", | ||||||
| "moduleName": ":BrownfieldLib", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| "scheme": "BrownfieldLib", | ||||||
| "brownie": { | ||||||
| "kotlin": "./android/BrownfieldLib/src/main/java/com/rnapp/brownfieldlib/Generated/", | ||||||
| "kotlinPackageName": "com.rnapp.brownfieldlib" | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| Migration steps: | ||||||
|
|
||||||
| 1. Pick one main Brownfield config source. | ||||||
| 2. Move the legacy `package.json#brownie` values into the nested `brownie` object in that source. | ||||||
| 3. Remove the old top-level `brownie` block from `package.json`. | ||||||
| 4. Run `brownfield codegen` again. | ||||||
|
|
||||||
| Do not keep the legacy and new Brownie configuration at the same time. | ||||||
| If both are present, `brownfield codegen` throws an error. | ||||||
| If only the legacy format is present, the command still works for now, but it prints a migration warning. | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure that we need
:in the name. At least this is how it was invoked via the command line.