Skip to content

Commit 3779b2e

Browse files
committed
Vendor acquisition-sdk instead of depending on the code-push npm package
Adds src/acquisition-sdk/ (vendored TypeScript from the archived microsoft/code-push repo, trimmed types.ts to only what's used, tests ported for future reference but not wired into any runner), a tsconfig.build.json + build:ts script compiling it to lib/ at prepack/setup time, and points CodePush.js at the compiled output instead of the code-push package. Drops the code-push dependency entirely, which was only ever used for this one submodule and pulled in the superagent/proxy-agent/vm2 CLI dependency chain that never actually shipped in the bundled app JS.
1 parent d4f2020 commit 3779b2e

23 files changed

Lines changed: 1340 additions & 438 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ build/Release
7777
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
7878
node_modules
7979

80+
# Compiled output of src/ (built via `npm run build:ts`, generated fresh at publish time)
81+
lib/
82+
8083
# Xcode
8184
#
8285
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

.npmignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ Recipes/
3434
bin/
3535
test/
3636

37+
# Don't publish TypeScript source - only the compiled lib/ output (built via `npm run build:ts`
38+
# as part of `prepack`) ships
39+
# Anchored to repo root (leading slash) - an unanchored `src/` also matches android/app/src/,
40+
# which stripped the native Android module's Java sources from every published tarball.
41+
/src/
42+
3743
# Remove after this framework is published on NPM
3844
code-push-plugin-testing-framework/
3945

@@ -101,3 +107,9 @@ packages/
101107

102108
.watchmanconfig
103109

110+
# Dev tooling, not relevant to consumers
111+
.claude/
112+
.config/
113+
CLAUDE.md
114+
mise.toml
115+

CLAUDE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ React Native CodePush is a native module that enables over-the-air updates for R
1616
### Build
1717
- `npm run build` - Build TypeScript tests to bin/ directory
1818
- `npm run tsc` - TypeScript compilation
19+
- `npm run build:ts` - Compiles `src/` (currently just the vendored `acquisition-sdk`) to `lib/`, which is what ships to consumers instead of raw `.ts`. Wired into `setup` (so local dev/tests have `lib/` available) and `prepack` (so `npm publish`/`npm pack` always ship a freshly built `lib/`).
20+
- This split (a separate `tsconfig.build.json` and `tsconfig.json` for `test/` -> `bin/`) is temporary. Once `CodePush.js` and the rest of this repo's runtime JS are migrated to TypeScript, these should be unified into a single build, and adopting `react-native-builder-bob` (or some other common tool) is worth considering at that point instead of hand-rolled `tsc` + npm script wiring.
1921

2022
### Platform Testing
2123
- Tests run on actual emulators/simulators with real React Native apps
@@ -28,7 +30,7 @@ React Native CodePush is a native module that enables over-the-air updates for R
2830
- **JavaScript Bridge** (`CodePush.js`): Main API layer exposing update methods
2931
- **Native Modules**: Platform-specific implementations handling file operations, bundle management
3032
- **Update Manager**: Handles download, installation, and rollback logic
31-
- **Acquisition SDK**: Manages server communication and update metadata
33+
- **Acquisition SDK** (`src/acquisition-sdk/`): Manages server communication and update metadata
3234

3335
### Platform Structure
3436
- **iOS**: `ios/` - Objective-C implementation with CocoaPods integration
@@ -46,6 +48,7 @@ React Native CodePush is a native module that enables over-the-air updates for R
4648
- **Custom Test Runner**: TypeScript-based test framework in `test/`
4749
- **Real App Testing**: Creates actual React Native apps for integration testing
4850
- **Scenario Testing**: Update, rollback, and error scenarios
51+
- **No unit test infra yet**: this repo only has the mocha-based integration suite above. `src/acquisition-sdk/__tests__/` contains tests ported from upstream `microsoft/code-push`, kept for future reference - they are deliberately not wired into `npm test` or any runner. Don't assume they're dead/forgotten code, and don't wire them in without setting up real unit test infra first.
4952
- **Templates**: `test/template/` holds native files (Podfile, AppDelegate, Android app files) and JS scenarios copied over top of a freshly generated RN/Expo app during test setup, overwriting its defaults — edit files here, not the generated project, for changes to persist
5053
- **`test:ios` vs `test:setup:ios` vs `test:fast:ios`**: `test:ios` is just `test:setup:ios` followed by `test:fast:ios` — the two are meant to be split apart for local iteration.
5154
- `test:setup:ios` (mocha `--ios --setup`) boots the simulator and provisions the test app once: copies templates, runs `pod install`, patches Info.plist/AppDelegate. It never builds or runs any test scenario.
@@ -61,3 +64,4 @@ React Native CodePush is a native module that enables over-the-air updates for R
6164
- **Android Gradle Plugin**: Automatically generates bundle hashes and processes assets
6265
- **iOS CocoaPods**: Manages native dependencies and build configuration
6366
- **Bundle Processing**: Automated zip creation and hash calculation for OTA updates
67+
- **`.npmignore` is a blocklist, not an allowlist**: `package.json` has no `files` field, so any new top-level file/dir ships to npm by default unless explicitly excluded. When adding new repo tooling/config, check whether it needs a `.npmignore` entry. Verify with `npm pack --dry-run`.

CodePush.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk";
1+
import { AcquisitionManager as Sdk } from "./lib/acquisition-sdk/acquisition-sdk";
22
import { Alert } from "./AlertAdapter";
33
import requestFetchAdapter from "./request-fetch-adapter";
44
import { AppState, Platform } from "react-native";
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
export declare namespace Http {
2+
const enum Verb {
3+
GET = 0,
4+
HEAD = 1,
5+
POST = 2,
6+
PUT = 3,
7+
DELETE = 4,
8+
TRACE = 5,
9+
OPTIONS = 6,
10+
CONNECT = 7,
11+
PATCH = 8
12+
}
13+
interface Response {
14+
statusCode: number;
15+
body?: string;
16+
}
17+
interface Requester {
18+
request(verb: Verb, url: string, callback: Callback<Response>): void;
19+
request(verb: Verb, url: string, requestBody: string, callback: Callback<Response>): void;
20+
}
21+
}
22+
export interface Package {
23+
deploymentKey: string;
24+
description: string;
25+
label: string;
26+
appVersion: string;
27+
isMandatory: boolean;
28+
packageHash: string;
29+
packageSize: number;
30+
}
31+
export interface RemotePackage extends Package {
32+
downloadUrl: string;
33+
}
34+
export interface NativeUpdateNotification {
35+
updateAppVersion: boolean;
36+
appVersion: string;
37+
}
38+
export interface LocalPackage extends Package {
39+
localPath: string;
40+
}
41+
export interface Callback<T> {
42+
(error: Error, parameter: T): void;
43+
}
44+
export interface Configuration {
45+
appVersion: string;
46+
clientUniqueId: string;
47+
deploymentKey: string;
48+
serverUrl: string;
49+
ignoreAppVersion?: boolean;
50+
}
51+
export declare class AcquisitionStatus {
52+
static DeploymentSucceeded: string;
53+
static DeploymentFailed: string;
54+
}
55+
export declare class AcquisitionManager {
56+
private readonly BASE_URL_PART;
57+
private _appVersion;
58+
private _clientUniqueId;
59+
private _deploymentKey;
60+
private _httpRequester;
61+
private _ignoreAppVersion;
62+
private _serverUrl;
63+
private _publicPrefixUrl;
64+
private _statusCode;
65+
private static _apiCallsDisabled;
66+
constructor(httpRequester: Http.Requester, configuration: Configuration);
67+
private isRecoverable;
68+
private handleRequestFailure;
69+
queryUpdateWithCurrentPackage(currentPackage: Package, callback?: Callback<RemotePackage | NativeUpdateNotification>): void;
70+
reportStatusDeploy(deployedPackage?: Package, status?: string, previousLabelOrAppVersion?: string, previousDeploymentKey?: string, callback?: Callback<void>): void;
71+
reportStatusDownload(downloadedPackage: Package, callback?: Callback<void>): void;
72+
}

lib/acquisition-sdk/acquisition-sdk.js

Lines changed: 213 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)