numandev1 / react-native-keys

🔐 Protected .ENVs variables in React Native 🚀✨
MIT License
314 stars 28 forks source link

Expo Support should add #47

Closed numandev1 closed 1 year ago

chanphiromsok commented 1 year ago

Hello could you share me what to want to do ? may I can help you write expo plugins with expo prebuild

numandev1 commented 1 year ago

@chanphiromsok I just wanna know about the expo user point of view into app.config.json + some edge cases, it would be good to have a little call on it, after that i will make it soon

chanphiromsok commented 1 year ago

@chanphiromsok I just wanna know about the expo user point of view into app.config.json + some edge cases, it would be good to have a little call on it, after that i will make it soon

in app.config.{js,ts,json} it can use build base on ENV (dev or prod) but the different is expo not encrypt when using in NativeModule like google maps key.

numandev1 commented 1 year ago

@chanphiromsok should the user declare android product flavors with mapping of key files and ios scheme with mapping of key files like this?

{
  "name": "my app",
  "plugins": [
    [
      "react-native-keys",
      {
        "android": {
          "keyFiles": {
            "development": "keys.development.json",
            "production": "keys.development.json",
            "staging": "keys.development.json"
          },
          "productFlavors": {
            "development": {
              "applicationIdSuffix": ".dev1"
            },
            "staging": {
              "applicationIdSuffix": ".staging"
            },
            "production": {
              "applicationIdSuffix": ""
            }
          }
        },
        "ios": {
          "keyFiles": {
            "development": "keys.development.json",
            "production": "keys.development.json",
            "staging": "keys.development.json"
          },
          "schemes":{
            "dev": "development", //value is the keyFile name
            "staging": "staging",
            "prod": "production"
          }
        }
      }
    ]
  ]
}
chanphiromsok commented 1 year ago

I like to use one for one rather than map key/value

numandev1 commented 1 year ago

@chanphiromsok What if users have multiple environments, I also wanna use a clean solution from app.config.json, we should allow user to allow user to have multiple environments if he wants, can you suggest me any clean solution from app.config.json

chanphiromsok commented 1 year ago

@chanphiromsok What if users have multiple environments, I also wanna use a clean solution from app.config.json, we should allow user to allow user to have multiple environments if he wants, can you suggest me any clean solution from app.config.json

if user want multiple environments your https://github.com/numandev1/react-native-keys/issues/47#issuecomment-1719201015 solution is good to go and I can't say my ideas is right I want you to know more about expo users perspective on your library

numandev1 commented 1 year ago

@chanphiromsok thanks for helping me out❤ did you ever manage ios scheme or productFlavors into the expo? how do you manage two environments in the expo?

I wanna make the simpler solution above mine solution is also looking complex to me

chanphiromsok commented 1 year ago

@chanphiromsok thanks for helping me out❤ did you ever manage ios scheme or productFlavors into the expo? how do you manage two environments in the expo?

I wanna make the simpler solution above mine solution is also looking complex to me

I edit in the Xcode but it not better approach 😅

numandev1 commented 1 year ago

@chanphiromsok hahaha if you edit into Xcode then build on the expo server using eas will not work, i don't know how expo user manage multiple environments into expo

chanphiromsok commented 1 year ago

@chanphiromsok hahaha if you edit into Xcode then build on the expo server using eas will not work, i don't know how expo user manage multiple environments into expo

I use prebuilt our team is experiment expo now it use on prod 😅

numandev1 commented 1 year ago

https://docs.expo.dev/build-reference/variants/ https://docs.expo.dev/build-reference/variables/ https://docs.expo.dev/guides/environment-variables/ they are managing different build environment like this, i have to make a solution where expo user can easily migrate to this pacage

chanphiromsok commented 1 year ago

this is I my plugins I write inject for code push for expo prebuild

numandev1 commented 1 year ago

@chanphiromsok thanks for your input, I have added expo support, you can find docs here: https://github.com/numandev1/react-native-keys#managed-expo

app.config.json

{
  "name": "my app",
  "plugins": [
    [
      "react-native-keys",
      {
        "android": {
          "defaultKeyFile": "keys.staging.json" //default: keys.development.json
        },
        "ios": {
          "defaultKeyFile": "keys.staging.json" //default: keys.development.json
        }
      }
    ]
  ]
}

defining defaultKeyFile is for fallback after that, you can test other key files like this

KEYSFILE=keys.staging.json npx expo run:android

I have released the feature in 0.7.0, can you check and let me know?

chanphiromsok commented 1 year ago

Error expo plugin when installation

image
CommandError: Cannot find module './plugin/build'
Require stack:
- /Users/user/Desktop/example-keys/node_modules/react-native-keys/app.plugin.js

maybe you forget transpile from ts to js I did not found build dir in node_modules

image
numandev1 commented 1 year ago

@chanphiromsok can you check 0.7.1, sorry 🙏 i forget files line into package.json

numandev1 commented 1 year ago

@chanphiromsok did you check?

chanphiromsok commented 1 year ago

@chanphiromsok did you check?

Hi sorry for late response ,new fixed still error CommandError: Cannot find module 'walk-sync'

numandev1 commented 1 year ago

@chanphiromsok sorry, I added walk-sync into devDependencies which was wrong, it should add dependencies. can you check 0.7.3 now? 🙏 🙏

chanphiromsok commented 1 year ago

@chanphiromsok sorry, I added walk-sync into devDependencies which was wrong, it should add dependencies. can you check 0.7.3 now? 🙏 🙏

It work now but I wish you using plain node instead of external lib 😅