Skip to content

Commit c966897

Browse files
robingenzclaude
andcommitted
feat!: the build step runs the CLI's binary create — the Xcode script is scripts/binary-create-xcode.sh, the Gradle task createHotCodePushBinary
The CLI renamed bundle embed to binary create, so an app's Xcode phase names the new script and the CLI from 4e278c3 on runs it. The baseline's preparation finds the phase by the script it runs, whichever name the demo gives it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent ead5759 commit c966897

8 files changed

Lines changed: 42 additions & 38 deletions

File tree

‎.github/workflows/baseline.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ jobs:
4141
working-directory: package
4242
run: npm ci && npm run build && npm pack --pack-destination "$RUNNER_TEMP"
4343
- name: Prepare the demo with the package
44-
run: node package/benchmarks/prepare-demo.mjs demo "$RUNNER_TEMP/with" with "$(ls "$RUNNER_TEMP"/hotcodepush-react-native-code-push-*.tgz)" --no-embed
44+
run: node package/benchmarks/prepare-demo.mjs demo "$RUNNER_TEMP/with" with "$(ls "$RUNNER_TEMP"/hotcodepush-react-native-code-push-*.tgz)" --no-binary-create
4545
- name: Measure the sizes and compare them with the baseline
4646
run: node package/benchmarks/measure-size.mjs "$RUNNER_TEMP/with" > "$RUNNER_TEMP/sizes.json" && node package/benchmarks/guard-size.mjs package/benchmarks/baseline.json "$RUNNER_TEMP/sizes.json" >> "$GITHUB_STEP_SUMMARY"

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
JAVA_VERSION: 21
1414

1515
# The native code compiles inside an app: the platform jobs install the package from this commit into the demo at
16-
# the commit the baseline names and build it. Debug builds, which bundle no JavaScript and so run no embed step.
16+
# the commit the baseline names and build it. Debug builds, which bundle no JavaScript, with the build step unwired.
1717
jobs:
1818
javascript:
1919
name: Lint, typecheck, test and build the JavaScript
@@ -56,7 +56,7 @@ jobs:
5656
working-directory: package
5757
run: npm ci && npm run build && npm pack --pack-destination "$RUNNER_TEMP"
5858
- name: Prepare the demo with the package
59-
run: node package/benchmarks/prepare-demo.mjs demo "$RUNNER_TEMP/with" with "$(ls "$RUNNER_TEMP"/hotcodepush-react-native-code-push-*.tgz)" --no-embed
59+
run: node package/benchmarks/prepare-demo.mjs demo "$RUNNER_TEMP/with" with "$(ls "$RUNNER_TEMP"/hotcodepush-react-native-code-push-*.tgz)" --no-binary-create
6060
- run: ./gradlew assembleDebug --console=plain
6161
working-directory: ${{ runner.temp }}/with/android
6262
ios:
@@ -87,7 +87,7 @@ jobs:
8787
working-directory: package
8888
run: npm ci && npm run build && npm pack --pack-destination "$RUNNER_TEMP"
8989
- name: Prepare the demo with the package
90-
run: node package/benchmarks/prepare-demo.mjs demo "$RUNNER_TEMP/with" with "$(ls "$RUNNER_TEMP"/hotcodepush-react-native-code-push-*.tgz)" --no-embed
90+
run: node package/benchmarks/prepare-demo.mjs demo "$RUNNER_TEMP/with" with "$(ls "$RUNNER_TEMP"/hotcodepush-react-native-code-push-*.tgz)" --no-binary-create
9191
- run: xcodebuild -workspace HotCodePushDemo.xcworkspace -scheme HotCodePushDemo -configuration Debug -destination 'generic/platform=iOS Simulator' CODE_SIGNING_ALLOWED=NO -quiet build
9292
working-directory: ${{ runner.temp }}/with/ios
9393
preview:

‎CLAUDE.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ When code and plan disagree, stop and surface it; never improvise.
1313
src/ NativeHotCodePush.ts (the Codegen spec), hot-code-push.ts (the API object), use-updates.ts (the hook), definitions.ts
1414
ios/ the Turbo Module (Objective-C++), the runtime and the bundle loader (Swift) over HotCodePushProtocol
1515
android/src/main/java/com/hotcodepush/reactnative the Turbo Module, the runtime, the bundle loader and the React host over com.hotcodepush:protocol-android
16-
android/hotcodepush.gradle the embed task the app's build.gradle applies
17-
scripts/embed-xcode.sh the embed step the app's Xcode phase runs
16+
android/hotcodepush.gradle the task that runs binary create, applied by the app's build.gradle
17+
scripts/binary-create-xcode.sh binary create as the app's Xcode phase runs it
1818
benchmarks/ the size and cold-start baseline, measured on the demo
1919
```
2020

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ On Android, `MainApplication.kt` imports the SDK's `getDefaultReactHost` in plac
3333
import com.hotcodepush.reactnative.HotCodePushReactHost.getDefaultReactHost
3434
```
3535

36-
The SDK reads `hotcodepush.json` from the app's resources, which the embed step writes on every native build that bundles the JavaScript. On iOS it is a Run Script phase after "Bundle React Native code and images":
36+
The SDK reads `hotcodepush.json` from the app's resources, which the build step, the CLI's `binary create`, writes on every native build that bundles the JavaScript. On iOS it is a Run Script phase after "Bundle React Native code and images":
3737

3838
```sh
3939
set -e
4040

4141
WITH_ENVIRONMENT="$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
42-
HOTCODEPUSH_EMBED="$REACT_NATIVE_PATH/../@hotcodepush/react-native-code-push/scripts/embed-xcode.sh"
42+
HOTCODEPUSH_BINARY_CREATE="$REACT_NATIVE_PATH/../@hotcodepush/react-native-code-push/scripts/binary-create-xcode.sh"
4343

44-
/bin/sh -c "$WITH_ENVIRONMENT $HOTCODEPUSH_EMBED"
44+
/bin/sh -c "$WITH_ENVIRONMENT $HOTCODEPUSH_BINARY_CREATE"
4545
```
4646

4747
On Android it is one line at the end of `android/app/build.gradle`:

‎android/hotcodepush.gradle‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// The embed step of the Android build. The app's build.gradle applies this file with the one line `hotcodepush init`
2-
// adds; for every variant React Native bundles, the task below runs the CLI's `bundle embed` after the bundling,
1+
// The build step of the Android build. The app's build.gradle applies this file with the one line `hotcodepush init`
2+
// adds; for every variant React Native bundles, the task below runs the CLI's `binary create` after the bundling,
33
// which writes hotcodepush.json into the variant's assets and registers the binary.
44

55
import javax.inject.Inject
@@ -10,7 +10,7 @@ repositories {
1010
maven { url 'https://jitpack.io' }
1111
}
1212

13-
abstract class HotCodePushEmbedTask extends DefaultTask {
13+
abstract class HotCodePushBinaryCreateTask extends DefaultTask {
1414
@Input
1515
abstract Property<String> getBinaryBuild()
1616

@@ -39,7 +39,7 @@ abstract class HotCodePushEmbedTask extends DefaultTask {
3939
abstract FileSystemOperations getFileSystemOperations()
4040

4141
@TaskAction
42-
void embed() {
42+
void createBinary() {
4343
// The embedded bundle as one tree, laid out as an uploaded bundle is: the JavaScript beside its drawable directories.
4444
fileSystemOperations.sync {
4545
it.from(jsBundleDir)
@@ -50,7 +50,7 @@ abstract class HotCodePushEmbedTask extends DefaultTask {
5050
execOperations.exec {
5151
it.workingDir = projectRoot.get().asFile
5252
it.commandLine(npx + [
53-
'hotcodepush', 'bundle', 'embed',
53+
'hotcodepush', 'binary', 'create',
5454
'--platform', 'android',
5555
'--path', stagingDirectory.get().asFile.path,
5656
'--binary-version', binaryVersion.get(),
@@ -64,13 +64,13 @@ abstract class HotCodePushEmbedTask extends DefaultTask {
6464
androidComponents.onVariants(androidComponents.selector().all()) { variant ->
6565
def variantName = variant.name.capitalize()
6666
def bundleTaskName = "createBundle${variantName}JsAndAssets"
67-
// A debuggable variant is served by Metro: React Native bundles nothing for it, and nothing is embedded.
67+
// A debuggable variant is served by Metro: React Native bundles nothing for it, and no binary is created.
6868
if (!tasks.names.contains(bundleTaskName)) {
6969
return
7070
}
7171
def bundleTask = tasks.named(bundleTaskName)
7272
def reactExtension = project.extensions.findByName('react')
73-
def embedTask = tasks.register("embedHotCodePush${variantName}", HotCodePushEmbedTask) {
73+
def binaryCreateTask = tasks.register("createHotCodePushBinary${variantName}", HotCodePushBinaryCreateTask) {
7474
it.group = 'hotcodepush'
7575
it.description = "Writes hotcodepush.json into the ${variant.name} assets and registers the binary."
7676
it.binaryBuild.set(variant.outputs[0].versionCode.map { String.valueOf(it) })
@@ -82,5 +82,5 @@ androidComponents.onVariants(androidComponents.selector().all()) { variant ->
8282
// The resource file carries the build's time as the floor and the registration is per build: the step never counts as up to date.
8383
it.outputs.upToDateWhen { false }
8484
}
85-
variant.sources.assets.addGeneratedSourceDirectory(embedTask) { it.outputDirectory }
85+
variant.sources.assets.addGeneratedSourceDirectory(binaryCreateTask) { it.outputDirectory }
8686
}

‎benchmarks/README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ What the package adds to an app, measured on the demo app and guarded from then
1313

1414
The first paint is the `[baseline] first paint` line both variants log on their first animation frame, read from the JavaScript console: logcat on Android, the unified log on iOS.
1515
Both numbers come from release builds, since a debug build asks Metro for its JavaScript and the SDK stays off in it.
16-
The "without" variant is the demo with the package and every line `init` wired removed — the embed step in Xcode and Gradle, the bundle the two apps ask the SDK for, the pinned pod — and the screen swapped for the same screen with nothing behind it.
16+
The "without" variant is the demo with the package and every line `init` wired removed — the build step in Xcode and Gradle, the bundle the two apps ask the SDK for, the pinned pod — and the screen swapped for the same screen with nothing behind it.
1717

18-
The sizes are measured with the embed step unwired in the "with" variant too, `--no-embed`: the step needs a login, the resource file it writes weighs a few kilobytes against a binary of tens of megabytes, and the guard in CI holds no credential.
19-
The cold starts are measured with the embed step in place, against a stack the CLI is logged in to, since an app without its resource file starts no SDK.
18+
The sizes are measured with the build step unwired in the "with" variant too, `--no-binary-create`: the step needs a login, the resource file it writes weighs a few kilobytes against a binary of tens of megabytes, and the guard in CI holds no credential.
19+
The cold starts are measured with the build step in place, against a stack the CLI is logged in to, since an app without its resource file starts no SDK.
2020

2121
## Where the bytes sit
2222

@@ -28,13 +28,13 @@ The simulator app grows by about 3.6 MB, nearly all of it in the `HotCodePushDem
2828

2929
```sh
3030
npm run build && npm pack --pack-destination /tmp
31-
node benchmarks/prepare-demo.mjs ../react-native-code-push-demo /tmp/baseline/with with /tmp/hotcodepush-react-native-code-push-0.0.0.tgz --no-embed
31+
node benchmarks/prepare-demo.mjs ../react-native-code-push-demo /tmp/baseline/with with /tmp/hotcodepush-react-native-code-push-0.0.0.tgz --no-binary-create
3232
node benchmarks/prepare-demo.mjs ../react-native-code-push-demo /tmp/baseline/without without
3333
node benchmarks/measure-size.mjs /tmp/baseline/with
3434
node benchmarks/measure-size.mjs /tmp/baseline/without
3535
```
3636

37-
For the cold starts, prepare the "with" variant again without `--no-embed`, with `HOTCODEPUSH_TOKEN` set and `hotcodepush.json` naming an app of that account, then:
37+
For the cold starts, prepare the "with" variant again without `--no-binary-create`, with `HOTCODEPUSH_TOKEN` set and `hotcodepush.json` naming an app of that account, then:
3838

3939
```sh
4040
node benchmarks/measure-cold-start.mjs /tmp/baseline/with --android emulator-5554 --ios <udid>

‎benchmarks/prepare-demo.mjs‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22
// Copies the demo app into a scratch directory as one of the two variants the baseline compares:
33
// `with` installs the package tarball, `without` removes the package and every line `init` wired
44
// and swaps the screen for the same screen with nothing behind it. Both log the first paint.
5-
// `--no-embed` unwires the embed step of the `with` variant, so its release build needs no login:
5+
// `--no-binary-create` unwires the build step of the `with` variant, so its release build needs no login:
66
// the resource file it would write weighs nothing against the binary, and the sizes are measured without it.
77
import { execFileSync } from 'node:child_process';
88
import { cpSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
99
import { join } from 'node:path';
1010

1111
const [source, target, variant, ...rest] = process.argv.slice(2);
1212
const tarball = rest.find(argument => !argument.startsWith('--'));
13-
const isEmbedUnwired = variant === 'without' || rest.includes('--no-embed');
13+
const isBinaryCreateUnwired =
14+
variant === 'without' || rest.includes('--no-binary-create');
1415
if (
1516
!source ||
1617
!target ||
1718
!['with', 'without'].includes(variant) ||
1819
(variant === 'with' && !tarball)
1920
) {
2021
console.error(
21-
'usage: prepare-demo.mjs <demo> <target> with <package.tgz> [--no-embed] | without',
22+
'usage: prepare-demo.mjs <demo> <target> with <package.tgz> [--no-binary-create] | without',
2223
);
2324
process.exit(2);
2425
}
@@ -40,11 +41,14 @@ cpSync(source, target, {
4041

4142
const firstPaintMarker =
4243
"requestAnimationFrame(() => console.log('[baseline] first paint'));";
43-
if (isEmbedUnwired) {
44+
if (isBinaryCreateUnwired) {
4445
editFile('android/app/build.gradle', text =>
4546
removeLines(text, 'hotcodepush.gradle'),
4647
);
47-
editFile('ios/HotCodePushDemo.xcodeproj/project.pbxproj', removeEmbedPhase);
48+
editFile(
49+
'ios/HotCodePushDemo.xcodeproj/project.pbxproj',
50+
removeBinaryCreatePhase,
51+
);
4852
}
4953
if (variant === 'with') {
5054
editFile('App.tsx', text =>
@@ -166,15 +170,15 @@ function removeLines(text, needle) {
166170
.join('\n');
167171
}
168172

169-
// The phase `init` added, out of the project again: its entry in the target's phases and its own object.
170-
function removeEmbedPhase(project) {
171-
return removeLines(
172-
project.replace(
173-
/\t\t[0-9A-F]{24} \/\* Embed HotCodePush \*\/ = \{[\s\S]*?\n\t\t\};\n/,
174-
'',
175-
),
176-
'/* Embed HotCodePush */,',
173+
// The phase `init` added, out of the project again: found by the package's script it runs, removed with the line of the target that names it.
174+
function removeBinaryCreatePhase(project) {
175+
const phase = project.match(
176+
/\t\t([0-9A-F]{24}) \/\* [^*]+ \*\/ = \{[^}]*react-native-code-push\/scripts\/[^}]*\};\n/,
177177
);
178+
if (phase === null) {
179+
throw new Error('The Xcode project runs no script of the package.');
180+
}
181+
return removeLines(project.replace(phase[0], ''), `${phase[1]} /*`);
178182
}
179183

180184
function run(command, args, cwd = target) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
2-
# The embed step of the Xcode build, run by the "Embed HotCodePush" phase `hotcodepush init` adds after
3-
# "Bundle React Native code and images": the CLI's `bundle embed` writes hotcodepush.json into the app
2+
# The build step of the Xcode build, run by the "Create HotCodePush binary" phase `hotcodepush init` adds after
3+
# "Bundle React Native code and images": the CLI's `binary create` writes hotcodepush.json into the app
44
# and registers the binary. The phase holds one line; what it runs lives here.
55
set -e
66

@@ -12,7 +12,7 @@ PATH="$(dirname "$NODE_BINARY"):$PATH"
1212
export PATH
1313

1414
cd "$PROJECT_ROOT"
15-
npx hotcodepush bundle embed \
15+
npx hotcodepush binary create \
1616
--platform ios \
1717
--path "$DEST" \
1818
--binary-version "$MARKETING_VERSION" \

0 commit comments

Comments
 (0)