Skip to content

Commit

Permalink
cli assemble support (facebook#44903)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#44903

Call our wrapper to assemble an Android build of helloworld.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D58287785
  • Loading branch information
blakef authored and facebook-github-bot committed Jun 13, 2024
1 parent 044e375 commit cadf80f
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions packages/helloworld/cli.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
launchApp,
launchSimulator,
} from './lib/ios';
import {app, apple} from '@react-native/core-cli-utils';
import {Option, program} from 'commander';
import {android, app, apple} from '@react-native/core-cli-utils';
import {Option, program, Command} from 'commander';
import {readFileSync} from 'fs';
import {Listr} from 'listr2';
import path from 'path';
Expand Down Expand Up @@ -110,6 +110,46 @@ const getBuildSettings = (mode: 'Debug' | 'Release'): BuildSettings => {

const build = program.command('build');

type AndroidBuildOptions = {
device: string,
arch: 'old' | 'new',
jsvm: 'hermes' | 'jsc',
prod: boolean,
P: string[],
};

build
.command('android')
.addOption(
new Option('--arch <arch>', "Choose React Native's architecture")
.choices(['new', 'old'])
.default('new'),
)
.addOption(
new Option('--jsvm <vm>', 'Choose VM used on device')
.choices(['jsc', 'hermes'])
.default('hermes'),
)
.option('--prod', 'Production build', () => true, false)
.addOption(
new Option('-P <value>', 'Additional Gradle project properties')
.argParser((value, previous: string[] = []) => previous.concat(value))
.default([]),
)
.action(
async ({prod, jsvm, arch, P}: AndroidBuildOptions, options: Command) => {
const mode = prod ? 'Release' : 'Debug';
const {assemble} = android({
cwd: cwd.android,
hermes: jsvm === 'hermes',
mode,
name: 'app',
newArchitecture: arch === 'new',
});
await run(assemble(...P.map(prop => `-P${prop}`), ...options.args));
},
);

build
.command('ios')
.description('Builds your app for iOS')
Expand Down

0 comments on commit cadf80f

Please sign in to comment.