Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expo plugin to simplify installation with expo #2415

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

deggertsen
Copy link

The old configuration required modification if the android app directory wasn't at the root of the project. With this change, the script should work no matter where the android directory exists in the repo.

The old configuration required modification if the android app directory wasn't at the root of the project. With this change, the script should work no matter where the android directory exists in the repo.
@deggertsen deggertsen requested a review from a team as a code owner January 10, 2023 21:42
@deggertsen deggertsen changed the title Make android configuration paths dynamic Expo plugin to simplify installation with expo Jan 11, 2023
@deggertsen
Copy link
Author

I have updated the PR to include an Expo plugin to make it easier for Expo builds to include react-native-code-push without as much configuration. I have updated the android and ios docs to reflect this new method of configuration.

@deggertsen
Copy link
Author

This will also resolve this issue #2366

@deggertsen
Copy link
Author

@microsoft-github-policy-service agree company="latitudegames"

@deggertsen deggertsen requested a review from retyui February 2, 2023 16:43
@GustavoBonfimS
Copy link

Any updates? It would help a lot

@jakobsuckow
Copy link

Are there any updates ? :)

@deggertsen
Copy link
Author

It's just waiting for review. It would probably be good if anyone else could test what I've done to confirm that it works.

@WadhahEssam
Copy link

WadhahEssam commented Apr 19, 2023

I tested this, and works great, only thing that is missing from the setup is the javascript side.

here is an example of what worked with me (straight forward)
Screenshot 2023-04-19 at 7 44 01 AM

@chhornponleu
Copy link

Seems not working when project is using Expo Router

  • no App exported from index.js. Is it done automatically or I need extra work around?
  • appcenter codepush release-react -a .... not working (tried ios). It could not find

@ouwargui
Copy link

Seems not working when project is using Expo Router

  • no App exported from index.js. Is it done automatically or I need extra work around?

  • appcenter codepush release-react -a .... not working (tried ios). It could not find

@chhornponleu to fix the expo router problem, in your index.js/ts, try to do it like this:

import { registerRootComponent } from "expo";
import { ExpoRoot } from "expo-router";
import codePush from "react-native-code-push";

// Must be exported or Fast Refresh won't update the context
export function App() {
  const ctx = require.context("./app");
  return <ExpoRoot context={ctx} />;
}

registerRootComponent(codePush(App));

Copy link

@rvasseur31 rvasseur31 left a comment

Choose a reason for hiding this comment

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

Thank you for your PR !
I suggest you make a few changes to react native 71.

plugin/src/android/buildscriptDependency.ts Outdated Show resolved Hide resolved
plugin/src/android/mainApplicationDependency.ts Outdated Show resolved Hide resolved
plugin/src/android/settingsDependency.ts Outdated Show resolved Hide resolved
deggertsen and others added 3 commits June 12, 2023 10:04
Co-authored-by: rvasseur31 <46020438+rvasseur31@users.noreply.github.com>
Co-authored-by: rvasseur31 <46020438+rvasseur31@users.noreply.github.com>
Co-authored-by: rvasseur31 <46020438+rvasseur31@users.noreply.github.com>
@deggertsen
Copy link
Author

Thank you for your PR ! I suggest you make a few changes to react native 71.

Great suggestions! Thank you for the additions!

@deggertsen
Copy link
Author

It looks like we might need to integrate this with the tests in order to resolve the checks. I don't think I'm going to have time to dive into that for a while, so if anyone else is able to help with that I would welcome the help.

@baveku
Copy link

baveku commented Oct 16, 2023

@deggertsen I try use your solution, but I have some error in app.plugin.js

CommandError: Cannot find module './plugin/build'
Require stack:
- /node_modules/react-native-code-push/app.plugin.js
- /node_modules/@expo/config-plugins/build/utils/plugin-resolver.js
- /node_modules/@expo/config-plugins/build/plugins/withStaticPlugin.js
- /node_modules/@expo/config-plugins/build/plugins/withPlugins.js
- /node_modules/@expo/config-plugins/build/index.js
- /node_modules/@expo/cli/build/src/prebuild/clearNativeFolder.js
- /node_modules/@expo/cli/build/src/prebuild/prebuildAsync.js
- /node_modules/@expo/cli/build/src/prebuild/index.js
- /node_modules/@expo/cli/build/bin/cli
- /node_modules/expo/bin/cli

What should I do?

@mgscreativa
Copy link

@deggertsen I try use your solution, but I have some error in app.plugin.js

CommandError: Cannot find module './plugin/build'
Require stack:
- /node_modules/react-native-code-push/app.plugin.js
- /node_modules/@expo/config-plugins/build/utils/plugin-resolver.js
- /node_modules/@expo/config-plugins/build/plugins/withStaticPlugin.js
- /node_modules/@expo/config-plugins/build/plugins/withPlugins.js
- /node_modules/@expo/config-plugins/build/index.js
- /node_modules/@expo/cli/build/src/prebuild/clearNativeFolder.js
- /node_modules/@expo/cli/build/src/prebuild/prebuildAsync.js
- /node_modules/@expo/cli/build/src/prebuild/index.js
- /node_modules/@expo/cli/build/bin/cli
- /node_modules/expo/bin/cli

What should I do?

Take a look at my implementation https://github.com/mgscreativa/react-native-code-push-expo-plugin-managed-workflow

@mgscreativa
Copy link

It looks like we might need to integrate this with the tests in order to resolve the checks. I don't think I'm going to have time to dive into that for a while, so if anyone else is able to help with that I would welcome the help.

Hi @deggertsen if you give some guidance on where should I get my hands into, I can help

@baveku
Copy link

baveku commented Oct 17, 2023

@deggertsen I try use your solution, but I have some error in app.plugin.js

CommandError: Cannot find module './plugin/build'
Require stack:
- /node_modules/react-native-code-push/app.plugin.js
- /node_modules/@expo/config-plugins/build/utils/plugin-resolver.js
- /node_modules/@expo/config-plugins/build/plugins/withStaticPlugin.js
- /node_modules/@expo/config-plugins/build/plugins/withPlugins.js
- /node_modules/@expo/config-plugins/build/index.js
- /node_modules/@expo/cli/build/src/prebuild/clearNativeFolder.js
- /node_modules/@expo/cli/build/src/prebuild/prebuildAsync.js
- /node_modules/@expo/cli/build/src/prebuild/index.js
- /node_modules/@expo/cli/build/bin/cli
- /node_modules/expo/bin/cli

What should I do?

Take a look at my implementation https://github.com/mgscreativa/react-native-code-push-expo-plugin-managed-workflow

I tried, and it works. I saw you build ts to js and Expo-plugins can apply our plugin to android + ios template.
Codepush will work on Expo project with this solution.
I hope we can merge into main soon.

@deggertsen
Copy link
Author

It looks like we might need to integrate this with the tests in order to resolve the checks. I don't think I'm going to have time to dive into that for a while, so if anyone else is able to help with that I would welcome the help.

Hi @deggertsen if you give some guidance on where should I get my hands into, I can help

Honestly, I'm not sure. It looks like all that's needed are written tests for the plugin, but I haven't written tests using the method I'm seeing here so I would have to learn it in order to implement it same as you. If I already knew how, I would have already done it. Thanks for your willingness to help. Maybe the Microsoft team can give some additional guidance, but perhaps they are in the same boat 😆 .

@WilliamWelsh
Copy link

WilliamWelsh commented Oct 30, 2023

My updates always fail to install and immediately rollback. I used to have expo-updates in this app, and removed the package, the updates stuff from app.json, and removed Supporting/Expo.plist.

Note: I had an error CommandError: Cannot find module './plugin/build' and had to cd into node modules and tsc to build the plugin

app.json (Not using Android)

 "plugins": [
      [
        "react-native-code-push",
        {
          "ios": {
            "CodePushDeploymentKey": "my key is set correctly here"
          },
          "android": {
            "CodePushDeploymentKey": "",
            "CodePushPublicKey": ""
          }
        }
      ]
    ],
    "updates": {
      "enabled": false,
      "fallbackToCacheTimeout": 0
    }

package.json

"react-native-code-push": "github:deggertsen/react-native-code-push"

index.js

import App from "./App";
import { Platform, AppRegistry } from "react-native";
import { name as appName } from "./app.json";
import codePush from "react-native-code-push";

const codePushOptions = {
  checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
  mandatoryInstallMode: codePush.InstallMode.IMMEDIATE,
  installMode: codePush.InstallMode.IMMEDIATE,
  updateDialog: {
    appendReleaseDescription: true,
    title: "A new update is available!",
    mandatoryContinueButtonLabel: "Download & Restart",
    descriptionPrefix: "",
    mandatoryUpdateMessage: ""
  }
};

if (Platform.OS !== "windows") {
  const { registerRootComponent } = require("expo");
  registerRootComponent(codePush(codePushOptions)(App));
} else {
  AppRegistry.registerComponent(appName, () => App);
}

@imwexpex
Copy link

Same as above for me.
iOS - works fine, while Android always fails to install and immediately rollback.

@mgscreativa
Copy link

mgscreativa commented Oct 31, 2023

@WilliamWelsh
Copy link

Have you tried my implementation? https://github.com/mgscreativa/react-native-code-push-expo-plugin-managed-workflow

I have and I have the exact same result (my app is ejected by the way). I tried the setup from this PR, the plugin pre-built on his repo, and the plugin on your repo.

@rvasseur31
Copy link

@WilliamWelsh, I think you should remove these lines :

    "updates": {
      "enabled": false,
      "fallbackToCacheTimeout": 0
    }

It may cause a conflict in your native files

@imwexpex
Copy link

imwexpex commented Nov 1, 2023

The issue on Android happens only when the app is downloaded from the Play Store.

If I run npx expo run:android --variant release - installing of OTA update is successful

At the same time app downloaded from the Play Store errored with the:
Update is invalid - A JS bundle file named "null" could not be found within the downloaded contents.

@zgordon02
Copy link

I am running into the same issue as @WilliamWelsh. I opened an issue here: #2615

Does anyone have a resolution?

@WilliamWelsh
Copy link

Does anyone have a resolution?

Haven't been able to figure it out yet, going to try this next: https://github.com/GSTJ/react-native-code-push-plugin

@WilliamWelsh, I think you should remove these lines :
It may cause a conflict in your native files

Removed and the issue persists

@zgordon02
Copy link

@imwexpex any update on your situation? I am about to make the call to use Expo EAS Updates instead of codepush because of this Android issue.

I already use expo updates but I do self-hosted updates with the old cli. My team preferred codePush so we wanted to try it.

@deggertsen
Copy link
Author

Worth looking into this if you haven't already. expo/config-plugins#204

@mvolonnino
Copy link

mvolonnino commented Dec 22, 2023

The issue on Android happens only when the app is downloaded from the Play Store.

If I run npx expo run:android --variant release - installing of OTA update is successful

At the same time app downloaded from the Play Store errored with the: Update is invalid - A JS bundle file named "null" could not be found within the downloaded contents.

I am running into the same thing on Android as well.

When it comes to iOS, I can successfully install and restart the app which then applies the codepush bundle and I can see the changes on a standalone build through eas build command.

Immediately after the next force restart (user closes app) the codepush bundle is no longer used and the original bundle that was included with eas build is used instead.

Another thing to note, there is no rollbacks on the actual update - when i look at the appcenter, it shows 1 download, 1 install, and 0 rollbacks, and when i inspect the LocalPackage from codePush.getUpdateMetadata(), it shows what seems to be correct information about the codepush bundle:

It looks something like this albeit with a few of the values swapped out:

{
        isPending: false,
        packageSize: 2337248,
        appVersion: '2.2.9',
        packageHash: 'fakehash',
        downloadUrl: 'fakeurl',
        failedInstall: false,
        isFirstRun: false,
      }

We can see tho, isPending is false which makes sense since it has already been downloaded and installed from the original download and restart, with failedInstall: false as well - but the original bundle from the eas build is used, not the actual codepush bundle

@deggertsen
Copy link
Author

Given the announcement of the retirement of App Center on March 31, 2025 including CodePush I'm interested in seeing what the "special version of CodePush" is and if we might have an open source repo that we can use to build better support for Expo. If anyone gets any information before I do, please share!

We have prepared a special version of CodePush to integrate into your app and run independently from App Center. If you’d like to get access to the codebase of this CodePush standalone version, please reach out to our support team at support@appcenter.ms for more information.

@nicolascavallin
Copy link

Given the announcement of the retirement of App Center on March 31, 2025 including CodePush I'm interested in seeing what the "special version of CodePush" is and if we might have an open source repo that we can use to build better support for Expo. If anyone gets any information before I do, please share!

We have prepared a special version of CodePush to integrate into your app and run independently from App Center. If you’d like to get access to the codebase of this CodePush standalone version, please reach out to our support team at support@appcenter.ms for more information.

I talk with them by email. They just told me that will be an "standalone" version (without use AppCenter). Also the API will be the same. But no more data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.