Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/react-native-code-push-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7.4'
ruby-version: '2.7.6'
bundler-cache: true
- name: Package Installation
run: npm install
Expand All @@ -58,7 +58,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7.4'
ruby-version: '2.7.6'
bundler-cache: true
- name: Install dependencies
run: npm install
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ Follow these steps to test your modifications to the plugin manually:

First, make sure you have installed the dependencies for the plugin by following the steps above.

Then, make sure you have installed `react-native-cli`.
Then, make sure you have installed `react-native`.

```
npm install -g react-native-cli
npm install -g react-native
```

To run Android tests, make sure you have `sdk\tools`, `sdk\emulator` and `sdk\platform-tools` in your PATH.
Expand Down Expand Up @@ -131,4 +131,4 @@ To run the core unit tests on Android and pull the plugin from NPM:
NPM=true CORE=true npm run test:android
```

...and so on!
...and so on!
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ We try our best to maintain backwards compatibility of our plugin with previous
| v0.59 | v5.6+ *(RN refactored js bundle loader code)* |
| v0.60-v0.61 | v6.0+ *(RN migrated to Autolinking)* |
| v0.62-v0.64 | v6.2+ *(RN removed LiveReload)* |
| v0.65-v0.69 | v7.2+ *(RN updated iPhone-target-version)* |
| v0.65-v0.70 | v7.0+ *(RN updated iPhone-target-version)* |
| v0.71 | v7.2+ *(RN moved to react-native-gradle-plugin)* |

*NOTE: `react-native-code-push` versions lower than **[v5.7.0](https://github.com/microsoft/react-native-code-push/releases/tag/v5.7.0)** will stop working in the near future. You can find more information in our [documentation](https://github.com/microsoft/code-push/blob/master/migration-notice.md).*

Expand Down
44 changes: 25 additions & 19 deletions android/codepush.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.nio.file.Paths;

def config = project.hasProperty("react") ? project.react : [];
def bundleAssetName = config.bundleAssetName ?: "index.android.bundle"
def config = project.extensions.findByName("react") ?: []
def bundleAssetName = config.bundleAssetName.get() ?: "index.android.bundle"

// because elvis operator
def elvisFile(thing) {
Expand All @@ -23,11 +23,18 @@ android.buildTypes.each { buildType ->
buildType.resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
}

gradle.projectsEvaluated {
gradle.projectsEvaluated {
def debuggableVariants = config.debuggableVariants.get() ?: ['debug']

android.applicationVariants.all { variant ->
// No code push for debuggable variants
if (debuggableVariants.contains(variant.name)) {
return;
}

def nodeModulesPath;
if (config.root) {
nodeModulesPath = Paths.get(config.root, "/node_modules");
nodeModulesPath = Paths.get(config.root.asFile.get().absolutePath, "/node_modules");
} else if (project.hasProperty('nodeModulesPath')) {
nodeModulesPath = project.nodeModulesPath
} else {
Expand All @@ -42,40 +49,38 @@ gradle.projectsEvaluated {
def jsBundleFile;

// Additional node commandline arguments
def nodeExecutableAndArgs = config.nodeExecutableAndArgs ?: ["node"]
def extraPackagerArgs = config.extraPackagerArgs ?: []
def nodeExecutableAndArgs = config.nodeExecutableAndArgs.get() ?: ["node"]
def extraPackagerArgs = config.extraPackagerArgs.get() ?: []

// Make this task run right after the bundle task
def generateBundledResourcesHash;

if (variant.hasProperty("bundleJsAndAssets")) {
def reactBundleTask = variant.bundleJsAndAssets
jsBundleDir = reactBundleTask.generatedAssetsFolders[0].absolutePath
resourcesDir = reactBundleTask.generatedResFolders[0].absolutePath
def reactBundleTask = tasks.findByName("createBundle${targetName}JsAndAssets")
if (reactBundleTask) {
jsBundleDir = reactBundleTask.property('jsBundleDir').asFile.get()
resourcesDir = reactBundleTask.property('resourcesDir').asFile.get()
jsBundleFile = file("$jsBundleDir/$bundleAssetName")

generateBundledResourcesHash = tasks.create(
name: "generateBundledResourcesHash${targetName}",
type: Exec) {
commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, jsBundleFile, jsBundleDir)

enabled config."bundleIn${targetName}" ||
config."bundleIn${variant.buildType.name.capitalize()}" ?:
targetName.toLowerCase().contains("release")
enabled !debuggableVariants.contains(variant.name) ?: targetName.toLowerCase().contains("release")
Comment thread
thewulf7 marked this conversation as resolved.
}

runBefore("merge${targetName}Resources", generateBundledResourcesHash)
runBefore("merge${targetName}Assets", generateBundledResourcesHash)
runBefore("merge${targetName}Assets", generateBundledResourcesHash)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is a build error due to duplicate assets

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change above only removes whitespace and I believe it is only setting dependencies

I've quickly run that test locally and it's fine on my system.

I'll dig deeper later tonight

MikhailSuendukov is there any way to whitelist me so my pushes can run the GitHub tests without needing approval?

@Protino Gurupad Mamadapur (Protino) Mar 7, 2023 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

John Ferlito (@johnf) Just a thought, would it be possible to run GitHub tests on your personal repo to check what's wrong?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gurupad Mamadapur (@Protino) Thanks for reminding me of the obvious!! 😄 trying that now

@sesm Sergey Smyshlyaev (sesm) Mar 7, 2023 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've experienced duplicate assets error when using the version from John Ferlito (@johnf) branch in my current project. Running ./gradlew clean and rebuilding always fixed it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sergey Smyshlyaev (@sesm) were you switching between old and new versions? The old react native grade code and the new plugin seem to use different directories for flavours. debugUat vs debug/uat
So a clean is likely required in that instance

@sesm Sergey Smyshlyaev (sesm) Mar 9, 2023 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

John Ferlito (@johnf) I've been switching between old and new versions, but I've done ./gradlew clean since then, so all artefacts should be cleaned. I'm having an issue right now, that after I create a build with release configuration (./gradlew assemblePlaygroundRelease in my case), I have to clean the project before I can create the same build one more time, otherwise I get a duplicate assets error.

@nhatnguyenbp nhatnguyenbp Mar 14, 2023 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can resolve the issue duplicate assets by remove android/app/build/ASSETS/createBundleDebugJsAndAssets/CodePushHash

The issue happen when start building project second time.

} else {
def jsBundleDirConfigName = "jsBundleDir${targetName}"
jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ?:
jsBundleDir = elvisFile(config."$jsBundleDirConfigName").get() ?:
file("$buildDir/intermediates/assets/${targetPath}")

def resourcesDirConfigName = "resourcesDir${targetName}"
resourcesDir = elvisFile(config."${resourcesDirConfigName}") ?:
resourcesDir = elvisFile(config."${resourcesDirConfigName}").get() ?:
file("$buildDir/intermediates/res/merged/${targetPath}")

// In case version of 'Android Plugin for Gradle'' is lower than 1.3.0
// In case version of 'Android Plugin for Gradle'' is lower than 1.3.0
// '$buildDir' has slightly different structure - 'merged' folder
// does not exists so '${targetPath}' folder contains directly in 'res' folder.
if (!resourcesDir.exists() && file("$buildDir/intermediates/res/${targetPath}").exists()) {
Expand Down Expand Up @@ -107,7 +112,8 @@ gradle.projectsEvaluated {
generateBundledResourcesHash.dependsOn("recordFilesBeforeBundleCommand${targetName}")
}

generateBundledResourcesHash.dependsOn("bundle${targetName}JsAndAssets")
generateBundledResourcesHash.dependsOn("createBundle${targetName}JsAndAssets")

runBefore("processArmeabi-v7a${targetName}Resources", generateBundledResourcesHash)
runBefore("processX86${targetName}Resources", generateBundledResourcesHash)
runBefore("processUniversal${targetName}Resources", generateBundledResourcesHash)
Expand Down
2 changes: 1 addition & 1 deletion code-push-plugin-testing-framework/script/testConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// IMPORTS //
var os = require("os");
var path = require("path");
var TestUtil_1 = require("./TestUtil");
var TestUtil_1 = require("./testUtil");
//////////////////////////////////////////////////////////////////////////////////////////
// Configuration variables.
// What plugin to use, what project directories to use, etc.
Expand Down
3 changes: 1 addition & 2 deletions docs/setup-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ In order to integrate CodePush into your Android project, please perform the fol
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
```

2. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition underneath `react.gradle`:
2. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition to the end of the file:

```gradle
...
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
...
```
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-code-push",
"version": "7.1.0",
"version": "7.2.0",
"description": "React Native plugin for the CodePush service",
"main": "CodePush.js",
"typings": "typings/react-native-code-push.d.ts",
Expand Down
1 change: 0 additions & 1 deletion test/template/index.android.js

This file was deleted.

1 change: 0 additions & 1 deletion test/template/index.ios.js

This file was deleted.

34 changes: 0 additions & 34 deletions test/template/ios/TestCodePush/AppDelegate.m

This file was deleted.

41 changes: 41 additions & 0 deletions test/template/ios/TestCodePush/AppDelegate.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#import "AppDelegate.h"

#import <CodePush/CodePush.h>

#import <React/RCTBundleURLProvider.h>
#import <React/RCTBridge.h>
#import <React/RCTRootView.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"CODE_PUSH_TEST_APP_NAME"
initialProperties:nil];

self.moduleName = @"TestCodePush";
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};

return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [CodePush bundleURL];
}

/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
///
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
- (BOOL)concurrentRootEnabled
{
return true;
}

@end
24 changes: 11 additions & 13 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ class RNAndroid extends Platform.Android implements RNPlatform {
//// Set up gradle to build CodePush with the app
// Add CodePush to android/app/build.gradle
const buildGradle = path.join(innerprojectDirectory, "android", "app", "build.gradle");

TestUtil.replaceString(buildGradle,
"apply from: \"../../node_modules/react-native/react.gradle\"",
"apply from: \"../../node_modules/react-native/react.gradle\"\napply from: \"" + gradleContent + "\"");
"apply from: file\\(\"../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle\"\\); applyNativeModulesAppBuildGradle\\(project\\)",
"apply from: file(\"../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle\"); applyNativeModulesAppBuildGradle(project)\napply from: \"" + gradleContent + "\"");

// Add CodePush to android/settings.gradle
const settingsGradle = path.join(innerprojectDirectory, "android", "settings.gradle");
Expand Down Expand Up @@ -122,13 +123,10 @@ class RNAndroid extends Platform.Android implements RNPlatform {
* Build function of the test application, the command depends on the OS
*/
buildFunction(androidDirectory: string): Q.Promise<void> {
if (process.platform === "darwin") {
return TestUtil.getProcessOutput(`./gradlew assembleRelease --daemon`, { noLogStdOut: true, cwd: androidDirectory })
.then(() => { return null; });
} else {
return TestUtil.getProcessOutput(`gradlew assembleRelease --daemon`, { noLogStdOut: true, cwd: androidDirectory })
const gradlewCommand = process.platform === "darwin" || process.platform === "linux" ? "./gradlew" : "gradlew";
return TestUtil.getProcessOutput(`${gradlewCommand} clean`, { noLogStdOut: true, cwd: androidDirectory })
.then(() => TestUtil.getProcessOutput(`${gradlewCommand} assembleRelease --daemon`, { noLogStdOut: true, cwd: androidDirectory }))
.then(() => { return null; });
}
}

/**
Expand Down Expand Up @@ -178,7 +176,7 @@ class RNIOS extends Platform.IOS implements RNPlatform {
installPlatform(projectDirectory: string): Q.Promise<void> {
const iOSProject: string = path.join(projectDirectory, TestConfig.TestAppName, "ios");
const infoPlistPath: string = path.join(iOSProject, TestConfig.TestAppName, "Info.plist");
const appDelegatePath: string = path.join(iOSProject, TestConfig.TestAppName, "AppDelegate.m");
const appDelegatePath: string = path.join(iOSProject, TestConfig.TestAppName, "AppDelegate.mm");


// Install the Podfile
Expand All @@ -195,9 +193,9 @@ class RNIOS extends Platform.IOS implements RNPlatform {
// Add the correct bundle identifier
.then(TestUtil.replaceString.bind(undefined, path.join(iOSProject, TestConfig.TestAppName + ".xcodeproj", "project.pbxproj"),
"PRODUCT_BUNDLE_IDENTIFIER = [^;]*", "PRODUCT_BUNDLE_IDENTIFIER = \"" + TestConfig.TestNamespace + "\""))
// Copy the AppDelegate.m to the project
// Copy the AppDelegate.mm to the project
.then(TestUtil.copyFile.bind(undefined,
path.join(TestConfig.templatePath, "ios", TestConfig.TestAppName, "AppDelegate.m"),
path.join(TestConfig.templatePath, "ios", TestConfig.TestAppName, "AppDelegate.mm"),
appDelegatePath, true))
.then<void>(TestUtil.replaceString.bind(undefined, appDelegatePath, TestUtil.CODE_PUSH_TEST_APP_NAME_PLACEHOLDER, TestConfig.TestAppName));
}
Expand Down Expand Up @@ -307,7 +305,7 @@ class RNProjectManager extends ProjectManager {
}
mkdirp.sync(projectDirectory);

return TestUtil.getProcessOutput("npx react-native init " + appName + " --version 0.67.1", { cwd: projectDirectory, timeout: 30 * 60 * 1000 })
return TestUtil.getProcessOutput("npx react-native init " + appName + " --version 0.71.3", { cwd: projectDirectory, timeout: 30 * 60 * 1000 })
.then((e) => { console.log(`"npx react-native init ${appName}" success. cwd=${projectDirectory}`); return e; })
.then(this.copyTemplate.bind(this, templatePath, projectDirectory))
.then<void>(TestUtil.getProcessOutput.bind(undefined, TestConfig.thisPluginInstallString, { cwd: path.join(projectDirectory, TestConfig.TestAppName) }))
Expand Down Expand Up @@ -377,7 +375,7 @@ class RNProjectManager extends ProjectManager {
deferred.resolve(undefined);
});
return deferred.promise
.then(TestUtil.getProcessOutput.bind(undefined, "npx react-native bundle --platform " + targetPlatform.getName() + " --entry-file index." + targetPlatform.getName() + ".js --bundle-output " + bundlePath + " --assets-dest " + bundleFolder + " --dev false",
.then(TestUtil.getProcessOutput.bind(undefined, "npx react-native bundle --entry-file index.js --platform " + targetPlatform.getName() + " --bundle-output " + bundlePath + " --assets-dest " + bundleFolder + " --dev false",
{ cwd: path.join(projectDirectory, TestConfig.TestAppName) }))
.then<string>(TestUtil.archiveFolder.bind(undefined, bundleFolder, "", path.join(projectDirectory, TestConfig.TestAppName, "update.zip"), isDiff));
}
Expand Down