react-native-code-push icon indicating copy to clipboard operation
react-native-code-push copied to clipboard

Expo plugin to simplify installation with expo

Open deggertsen opened this issue 3 years ago • 47 comments

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 avatar Jan 10 '23 21:01 deggertsen

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 avatar Jan 11 '23 17:01 deggertsen

This will also resolve this issue https://github.com/microsoft/react-native-code-push/issues/2366

deggertsen avatar Jan 11 '23 18:01 deggertsen

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

deggertsen avatar Jan 11 '23 18:01 deggertsen

Any updates? It would help a lot

gustavo-bonfim avatar Feb 24 '23 11:02 gustavo-bonfim

Are there any updates ? :)

jakobsuckow avatar Apr 07 '23 14:04 jakobsuckow

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.

deggertsen avatar Apr 08 '23 19:04 deggertsen

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

WadhahEssam avatar Apr 19 '23 04:04 WadhahEssam

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 avatar Apr 19 '23 09:04 chhornponleu

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));

ouwargui avatar Apr 26 '23 00:04 ouwargui

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

Great suggestions! Thank you for the additions!

deggertsen avatar Jun 12 '23 14:06 deggertsen

Hi! @ouwargui would you be so kind to take a look at this issue I posted https://github.com/microsoft/appcenter-cli/issues/2417#event-10046451249

Basically after creating a project with npx create-expo-app@latest --template tabs@sdk-49 it seems that new files uses @/ for local imports, but that dislikes appcenter codepush release-react

For a work around I changed all local imports with @/ to good old ./

Thanks!

mgscreativa avatar Aug 09 '23 20:08 mgscreativa

Hi! I have written a repo to test the plugin and I can confirm that it works. Repo here https://github.com/mgscreativa/react-native-code-push-expo-plugin-managed-workflow

Please tell me if I can contribute any more to get this PR approved and merged.

Thanks!

mgscreativa avatar Aug 10 '23 16:08 mgscreativa

@retyui and @rvasseur31 can you review the code? Or tell me how can I review this too?

mgscreativa avatar Aug 10 '23 22:08 mgscreativa

@deggertsen let's say I want to build this project, or at least create the /plugin/build transpiled code, what should I do? Because I think that the package maintainers should know how to build (transpile) the plugin.

Thanks!

mgscreativa avatar Aug 10 '23 23:08 mgscreativa

@deggertsen let's say I want to build this project, or at least create the /plugin/build transpiled code, what should I do? Because I think that the package maintainers should know how to build (transpile) the plugin.

Thanks!

This is what I'm doing now. package.json

~
"scripts": {
    ~
    "postinstall": "npm run code-push:build",
    "code-push:build": "tsc --project node_modules/react-native-code-push/plugin/tsconfig.json",
    "prebuild": "expo prebuild",
    "update:android": "appcenter codepush release-react -a yourorg/yourproject -d yourenv",
    "update:ios": "appcenter codepush release-react -a yourorg/yourproject -d yourenv -p ./ios/YourProject/Info.plist",
    ~
},
"dependencies": {
    ~
    "react-native-code-push": "github:deggertsen/react-native-code-push",
    ~
},

You need to run npm run prebuild before running update:${os}. It works pretty well for me. Hopefully this PR would be merged soon.

pitzcarraldo avatar Aug 11 '23 08:08 pitzcarraldo

@pitzcarraldo thanks, but I mean to build this package and not the plugin, the plugin I have it working on https://github.com/mgscreativa/react-native-code-push-expo-plugin-managed-workflow

mgscreativa avatar Aug 11 '23 11:08 mgscreativa

@rvasseur31 expo/config-plugins is a re-export of @expo/config-plugins.

Since Expo SDK v47 https://blog.expo.dev/expo-sdk-47-a0f6f5c038af#fe48 they recommend to use expo/config-plugins (without @)

mgscreativa avatar Aug 11 '23 11:08 mgscreativa

@rvasseur31 expo/config-plugins is a re-export of @expo/config-plugins.

Since Expo SDK v47 https://blog.expo.dev/expo-sdk-47-a0f6f5c038af#fe48 they recommend to use expo/config-plugins (without @)

Thank you !

rvasseur31 avatar Aug 11 '23 12:08 rvasseur31

@rvasseur31 can you take a look at my other code reviews?

mgscreativa avatar Aug 11 '23 14:08 mgscreativa

I think you should also add latest build folder as suggested by @rvasseur31 so the plugin gets working OOB

mgscreativa avatar Aug 12 '23 10:08 mgscreativa

@deggertsen please take a look at my pr in the plugin repo, I think that there are more files with @expo/config-plugins imports. In the plugin repo I have removed them all except for one @expo/config-plugins import: import { ResourceXML } from '@expo/config-plugins/build/android/Resources' at src/android/stringDepencendy.ts

mgscreativa avatar Aug 12 '23 15:08 mgscreativa

@deggertsen please take a look at my pr in the plugin repo, I think that there are more files with @expo/config-plugins imports. In the plugin repo I have removed them all except for one @expo/config-plugins import: import { ResourceXML } from '@expo/config-plugins/build/android/Resources' at src/android/stringDepencendy.ts

I don't see any outstanding PRs in the plugin repo https://github.com/deggertsen/react-native-code-push-expo-plugin/pulls

deggertsen avatar Aug 12 '23 16:08 deggertsen

I mean, looking into all files for @expo/config-plugins import and removing the @ except for: import { ResourceXML } from '@expo/config-plugins/build/android/Resources at src/android/stringDependency.ts

mgscreativa avatar Aug 14 '23 12:08 mgscreativa

Anyway, all suggested changes where implemented In my last PR of the plugin repo, maybe you can just copy the flies into this PR and update it, and add the build folder so the plugin works OOB

mgscreativa avatar Aug 14 '23 12:08 mgscreativa

One thing I noticed is that appcenter codepush release-react command doesn't includes app.config file in the bundle.

Expo managed projects create this file to store app data and extra custom configuration parameters.

Is it possible to tell appcenter codepush release-react that needs to create that app.config file?

mgscreativa avatar Aug 15 '23 01:08 mgscreativa

@deggertsen and @mgscreativa , thank you so much for this contribution! I'm going to merge it once all checks are passed.

Anyway, all suggested changes where implemented In my last PR of the plugin repo, maybe you can just copy the flies into this PR and update it, and add the build folder so the plugin works OOB

@mgscreativa , I think it make sense to open a separate PR with the fixes you mention.

DmitriyKirakosyan avatar Sep 28 '23 09:09 DmitriyKirakosyan

@deggertsen CI is failing due to errors (mostly lint) in new files. Please take a look. To reproduce, run the commands locally:

npm run build:tests && npm run test:setup:ios
npm run build:tests && npm run test:setup:android

You can find more context regarding executing commands on CI in file .github/workflows/react-native-code-push-ci.yml.

DmitriyKirakosyan avatar Sep 28 '23 09:09 DmitriyKirakosyan

@deggertsen CI is failing due to errors (mostly lint) in new files. Please take a look. To reproduce, run the commands locally:

npm run build:tests && npm run test:setup:ios
npm run build:tests && npm run test:setup:android

You can find more context regarding executing commands on CI in file .github/workflows/react-native-code-push-ci.yml.

I'll try to take care of this tomorrow. Thanks for the feedback.

deggertsen avatar Sep 29 '23 01:09 deggertsen

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.

deggertsen avatar Sep 29 '23 14:09 deggertsen

@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?

baveku avatar Oct 16 '23 08:10 baveku