@bravemobile/react-native-code-push 12.0.1 → 12.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,32 @@
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+ - `CodePush.js` and `package-mixins.js` expose the JavaScript API, with supporting utilities in `logging.js` and `AlertAdapter.js`.
5
+ - Native bridges live in `android/` and `ios/`; keep platform-specific assets scoped there.
6
+ - The Expo sample and reference implementations sit in `Examples/`, while CLI logic and packaging helpers live in `cli/` and `code-push-plugin-testing-framework/`.
7
+ - Automated tests are authored in TypeScript under `test/` and emitted into `bin/test` after build; documentation and release notes remain in `docs/` and `Recipes/`.
8
+
9
+ ## Build, Test, and Development Commands
10
+ - `npm install` installs dependencies (Node >=18 is required).
11
+ - `npm run build:tests` transpiles the TypeScript test harness into `bin/test`.
12
+ - `npm run test` runs the full Mocha suite across Android and iOS adapters; use `npm run test:android` or `npm run test:ios` when iterating on a single platform.
13
+ - `npm run test:fast` skips environment setup for quicker feedback once devices are ready.
14
+ - `npm run eslint` checks JavaScript/TypeScript style; `npm run tslint` targets the legacy TypeScript specs; `npm run jest` covers the semver logic in `versioning/`.
15
+ - `npm run clean` clears generated artifacts before rebuilding.
16
+
17
+ ## Coding Style & Naming Conventions
18
+ - Use 2-space indentation and double quotes in TypeScript tests (see `tslint.json`); match surrounding style elsewhere and let ESLint guide fixes.
19
+ - Components and HOCs use PascalCase (`CodePush`), utilities camelCase, and CLI binaries kebab-case.
20
+ - Keep platform guards explicit (`Platform.OS`) and annotate non-obvious flows with concise comments.
21
+
22
+ ## Testing Guidelines
23
+ - Place new specs alongside `test/test.ts`; share fixtures via `test/template/` or the helper utilities in `code-push-plugin-testing-framework/`.
24
+ - Always run `npm run build:tests` before executing tests locally or in CI.
25
+ - Document which device targets were used when running `npm run test`, and prefer `:android`/`:ios` variants during platform-specific debugging.
26
+ - Extend `versioning/` tests when changing release or rollback logic and verify with `npm run jest`.
27
+
28
+ ## Commit & Pull Request Guidelines
29
+ - Follow conventional commits (`type(scope): summary`), mirroring history such as `chore(Example): update the example app to v12`.
30
+ - Reference related issues in the body, summarize behavioral changes, and attach screenshots/logs for Example app updates.
31
+ - Ensure lint, Mocha, and Jest suites pass before requesting review; include the commands executed in the PR description.
32
+ - Rebase instead of merging from main when tidying feature branches to keep history linear.
@@ -1,10 +1,9 @@
1
1
  const { createRunOncePlugin } = require('expo/config-plugins');
2
- const { withAndroidBuildScriptDependency, withAndroidMainApplicationDependency } = require('./withCodePushAndroid');
2
+ const { withAndroidMainApplicationDependency } = require('./withCodePushAndroid');
3
3
  const { withIosBridgingHeader, withIosAppDelegateDependency } = require('./withCodePushIos');
4
4
  const pkg = require('../../package.json');
5
5
 
6
6
  const withCodePush = (config) => {
7
- config = withAndroidBuildScriptDependency(config);
8
7
  config = withAndroidMainApplicationDependency(config);
9
8
  config = withIosBridgingHeader(config);
10
9
  config = withIosAppDelegateDependency(config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bravemobile/react-native-code-push",
3
- "version": "12.0.1",
3
+ "version": "12.0.2",
4
4
  "description": "React Native plugin for the CodePush service",
5
5
  "main": "CodePush.js",
6
6
  "typings": "typings/react-native-code-push.d.ts",
@@ -1,9 +0,0 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
-
3
- <uses-permission android:name="android.permission.INTERNET" />
4
-
5
- <application>
6
- <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
7
- </application>
8
-
9
- </manifest>
@@ -1,85 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { initAndroid, modifyMainApplicationKt } = require('../initAndroid');
4
-
5
- const tempDir = path.join(__dirname, 'temp');
6
-
7
- // https://github.com/react-native-community/template/blob/0.80.2/template/android/app/src/main/java/com/helloworld/MainApplication.kt
8
- const ktTemplate = `
9
- package com.helloworld
10
-
11
- import android.app.Application
12
- import com.facebook.react.PackageList
13
- import com.facebook.react.ReactApplication
14
- import com.facebook.react.ReactHost
15
- import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
16
- import com.facebook.react.ReactNativeHost
17
- import com.facebook.react.ReactPackage
18
- import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
19
- import com.facebook.react.defaults.DefaultReactNativeHost
20
-
21
- class MainApplication : Application(), ReactApplication {
22
-
23
- override val reactNativeHost: ReactNativeHost =
24
- object : DefaultReactNativeHost(this) {
25
- override fun getPackages(): List<ReactPackage> =
26
- PackageList(this).packages.apply {
27
- // Packages that cannot be autolinked yet can be added manually here, for example:
28
- // add(MyReactNativePackage())
29
- }
30
-
31
- override fun getJSMainModuleName(): String = "index"
32
-
33
- override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
34
-
35
- override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
36
- override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
37
- }
38
-
39
- override val reactHost: ReactHost
40
- get() = getDefaultReactHost(applicationContext, reactNativeHost)
41
-
42
- override fun onCreate() {
43
- super.onCreate()
44
- loadReactNative(this)
45
- }
46
- }
47
- `;
48
-
49
- describe('Android init command', () => {
50
- it('should correctly modify Kotlin MainApplication content', () => {
51
- const modifiedContent = modifyMainApplicationKt(ktTemplate);
52
- expect(modifiedContent).toContain('import com.microsoft.codepush.react.CodePush');
53
- expect(modifiedContent).toContain('override fun getJSBundleFile(): String = CodePush.getJSBundleFile()');
54
- });
55
-
56
- it('should log a message and exit if MainApplication.java is found', async () => {
57
- const originalCwd = process.cwd();
58
-
59
- fs.mkdirSync(tempDir, { recursive: true });
60
- process.chdir(tempDir);
61
-
62
- // Arrange
63
- const javaAppDir = path.join(tempDir, 'android', 'app', 'src', 'main', 'java', 'com', 'helloworld');
64
- fs.mkdirSync(javaAppDir, { recursive: true });
65
- const javaFilePath = path.join(javaAppDir, 'MainApplication.java');
66
- const originalContent = '// Java file content';
67
- fs.writeFileSync(javaFilePath, originalContent);
68
-
69
- const consoleSpy = jest.spyOn(console, 'log').mockImplementation(() => {
70
- });
71
-
72
- // Act
73
- await initAndroid();
74
-
75
- // Assert
76
- expect(consoleSpy).toHaveBeenCalledWith('MainApplication.java is not supported. Please migrate to MainApplication.kt.');
77
- const finalContent = fs.readFileSync(javaFilePath, 'utf-8');
78
- expect(finalContent).toBe(originalContent); // Ensure file is not modified
79
-
80
- consoleSpy.mockRestore();
81
-
82
- process.chdir(originalCwd);
83
- fs.rmSync(tempDir, { recursive: true, force: true });
84
- });
85
- });
@@ -1,98 +0,0 @@
1
- const { modifyObjectiveCAppDelegate, modifySwiftAppDelegate } = require('../initIos');
2
-
3
- // https://github.com/react-native-community/template/blob/0.80.2/template/ios/HelloWorld/AppDelegate.swift
4
- const swiftTemplate = `
5
- import UIKit
6
- import React
7
- import React_RCTAppDelegate
8
- import ReactAppDependencyProvider
9
-
10
- @main
11
- class AppDelegate: UIResponder, UIApplicationDelegate {
12
- var window: UIWindow?
13
- var reactNativeDelegate: ReactNativeDelegate?
14
- var reactNativeFactory: RCTReactNativeFactory?
15
-
16
- func application(
17
- _ application: UIApplication,
18
- didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
19
- ) -> Bool {
20
- let delegate = ReactNativeDelegate()
21
- let factory = RCTReactNativeFactory(delegate: delegate)
22
- delegate.dependencyProvider = RCTAppDependencyProvider()
23
- reactNativeDelegate = delegate
24
- reactNativeFactory = factory
25
- window = UIWindow(frame: UIScreen.main.bounds)
26
- factory.startReactNative(
27
- withModuleName: "HelloWorld",
28
- in: window,
29
- launchOptions: launchOptions
30
- )
31
- return true
32
- }
33
- }
34
-
35
- class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
36
- override func sourceURL(for bridge: RCTBridge) -> URL? {
37
- self.bundleURL()
38
- }
39
-
40
- override func bundleURL() -> URL? {
41
- #if DEBUG
42
- RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
43
- #else
44
- Bundle.main.url(forResource: "main", withExtension: "jsbundle")
45
- #endif
46
- }
47
- }
48
- `;
49
-
50
- // https://github.com/react-native-community/template/blob/0.76.9/template/ios/HelloWorld/AppDelegate.mm
51
- const objcTemplate = `
52
- #import "AppDelegate.h"
53
-
54
- #import <React/RCTBundleURLProvider.h>
55
-
56
- @implementation AppDelegate
57
-
58
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
59
- {
60
- self.moduleName = @"HelloWorld";
61
- // You can add your custom initial props in the dictionary below.
62
- // They will be passed down to the ViewController used by React Native.
63
- self.initialProps = @{};
64
-
65
- return [super application:application didFinishLaunchingWithOptions:launchOptions];
66
- }
67
-
68
- - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
69
- {
70
- return [self bundleURL];
71
- }
72
-
73
- - (NSURL *)bundleURL
74
- {
75
- #if DEBUG
76
- return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
77
- #else
78
- return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
79
- #endif
80
- }
81
-
82
- @end
83
- `;
84
-
85
- describe('iOS init command - pure functions', () => {
86
- it('should correctly modify Swift AppDelegate content', () => {
87
- const modifiedContent = modifySwiftAppDelegate(swiftTemplate);
88
- expect(modifiedContent).toContain('CodePush.bundleURL()');
89
- expect(modifiedContent).not.toContain('Bundle.main.url(forResource: "main", withExtension: "jsbundle")');
90
- });
91
-
92
- it('should correctly modify Objective-C AppDelegate content', () => {
93
- const modifiedContent = modifyObjectiveCAppDelegate(objcTemplate);
94
- expect(modifiedContent).toContain('#import <CodePush/CodePush.h>');
95
- expect(modifiedContent).toContain('[CodePush bundleURL]');
96
- expect(modifiedContent).not.toContain('[[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];');
97
- });
98
- });