Skip to content

Commit 6eae08c

Browse files
committed
feat: unified CLI
1 parent c53583a commit 6eae08c

37 files changed

Lines changed: 425 additions & 380 deletions

docs/docs/docs/getting-started/cli.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ To build the artifact for Android without publishing, run `npx brownie package:a
3232

3333
Available arguments:
3434

35-
| Argument | Description |
36-
| ------------- | ------------------------------------------------------------------------------------------------------------------------- |
37-
| --variant | Specify your app's build variant, which is constructed from build type and product flavor, e.g. 'debug' or 'freeRelease'. |
38-
| --module-name | AAR module name |
39-
| --verbose | Enable verbose logging |
35+
| Argument | Description |
36+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
37+
| --variant | Specify your app's build variant, which is constructed from build type and product flavor, e.g. 'debug' or 'freeRelease'. (default: "debug") |
38+
| --module-name | AAR module name |
39+
| --verbose | Enable verbose logging |
4040

4141
## Publish locally for Android
4242

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint": "turbo run lint",
1212
"typecheck": "turbo run typecheck",
1313
"build": "turbo run build",
14-
"build:watch": "yarn workspaces foreach -Ap run build:watch",
14+
"build:watch": "yarn workspaces foreach -Api run build:watch",
1515
"release": "release-it --config packages/react-native-brownfield/.release-it.json",
1616
"brownfield:plugin:publish:local": "bash ./gradle-plugins/publish-to-maven-local.sh",
1717
"build:brownfield": "turbo run build:brownfield",

packages/brownie/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
"scripts": {
3131
"lint": "eslint \"**/*.{js,ts,tsx}\"",
3232
"typecheck": "tsc --noEmit",
33-
"build": "bob build && tsc -p scripts/tsconfig.json",
33+
"build": "bob build",
34+
"build:watch": "nodemon --watch src --ext js,ts,json --exec \"bob build\"",
3435
"test": "jest"
3536
},
36-
"bin": "./lib/scripts/cli.js",
3737
"keywords": [
3838
"brownie",
3939
"react-native-brownfield",
@@ -75,7 +75,9 @@
7575
"@types/jest": "^29.5.14",
7676
"@types/node": "^22.0.0",
7777
"@types/react": "^19.1.1",
78+
"eslint": "^8.57.1",
7879
"jest": "^29.7.0",
80+
"nodemon": "^3.1.11",
7981
"react": "19.1.1",
8082
"react-native": "0.82.1",
8183
"react-native-builder-bob": "^0.40.14",

packages/brownie/scripts/cli.ts

Lines changed: 0 additions & 74 deletions
This file was deleted.

packages/brownie/scripts/commands/codegen.ts

Lines changed: 0 additions & 146 deletions
This file was deleted.

packages/brownie/scripts/tsconfig.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/cli/package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,28 @@
4949
"@react-native-community/cli-config": "*",
5050
"@react-native-community/cli-config-android": "*"
5151
},
52-
"devDependencies": {
52+
"dependencies": {
5353
"@react-native-community/cli-config": "^20.0.0",
5454
"@react-native-community/cli-config-android": "^20.0.0",
55-
"@react-native-community/cli-types": "^20.0.0",
56-
"@react-native/babel-preset": "0.82.1",
57-
"@react-native/eslint-config": "0.82.1",
5855
"@rock-js/cli": "link:../../../rock/packages/cli",
5956
"@rock-js/platform-android": "link:../../../rock/packages/platform-android",
6057
"@rock-js/platform-apple-helpers": "link:../../../rock/packages/platform-apple-helpers",
6158
"@rock-js/platform-ios": "link:../../../rock/packages/platform-ios",
6259
"@rock-js/plugin-brownfield-android": "link:../../../rock/packages/plugin-brownfield-android",
6360
"@rock-js/plugin-brownfield-ios": "link:../../../rock/packages/plugin-brownfield-ios",
6461
"@rock-js/tools": "link:../../../rock/packages/tools",
62+
"commander": "^14.0.2",
63+
"lodash.clonedeep": "^4.5.0",
64+
"ts-morph": "^25.0.0"
65+
},
66+
"devDependencies": {
67+
"@react-native-community/cli-types": "^20.0.0",
68+
"@react-native/babel-preset": "0.82.1",
69+
"@react-native/eslint-config": "0.82.1",
6570
"@types/jest": "^30.0.0",
6671
"@types/lodash.clonedeep": "^4.5.9",
6772
"@types/node": "^25.0.3",
68-
"commander": "^14.0.2",
6973
"eslint": "^8.57.1",
70-
"lodash.clonedeep": "^4.5.0",
7174
"nodemon": "^3.1.11",
7275
"typescript": "5.8.3"
7376
},
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './packageAndroid.js';
2+
export * from './packageIos.js';
3+
export * from './publishAndroid.js';
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { packageAarAction } from '@rock-js/plugin-brownfield-android';
2+
import {
3+
packageAarOptions,
4+
type PackageAarFlags,
5+
} from '@rock-js/platform-android';
6+
7+
import { Command } from 'commander';
8+
9+
import { getProjectInfo } from '../utils/index.js';
10+
import {
11+
actionRunner,
12+
curryOptions,
13+
ExampleUsage,
14+
} from '../../shared/index.js';
15+
16+
export const packageAndroidCommand = curryOptions(
17+
new Command('package:android').description('Build Android AAR'),
18+
packageAarOptions.map((option) =>
19+
option.name.startsWith('--variant')
20+
? { ...option, default: 'debug' }
21+
: option
22+
)
23+
).action(
24+
actionRunner(async (options: PackageAarFlags) => {
25+
const { projectRoot, platformConfig } = getProjectInfo('android');
26+
27+
await packageAarAction({
28+
projectRoot,
29+
pluginConfig: platformConfig,
30+
moduleName: options.moduleName,
31+
variant: options.variant,
32+
});
33+
})
34+
);
35+
36+
export const packageAndroidExample = new ExampleUsage(
37+
'package:android --module-name :BrownfieldLib --variant release',
38+
"Build Android AAR for 'BrownfieldLib' module in release variant"
39+
);

0 commit comments

Comments
 (0)