Coder Social home page Coder Social logo

Comments (9)

maxkomarychev avatar maxkomarychev commented on May 28, 2024 3

Hi,

I just published version 3.3.0 which addresses this issue. Please try it out. You can find updated documentation here

Thank you for choosing react-native-ultimate-config :)

from react-native-ultimate-config.

dvxme avatar dvxme commented on May 28, 2024 2

This is the patch. I purposefully avoided the hook approach because it would be harder to reconcile the newly generated .js with the already generated .d.ts file. This patch only creates a new template for a export default JS object, which overwrites the root index.js on the render-env script. It was quite simple and worked both for fast reloading via metro bundler for development, and for over-the-air updates via Codepush.

I am specifically patching the 3.1.2 version because it is the one installed in my application and we are currently unable to create another native release updating this library for the time being, but I would assume there are no major differences between the current code and the patched code, given how little is actually patched.

As a file:
react-native-ultimate-config+3.1.2.patch.zip

As text:

diff --git a/node_modules/react-native-ultimate-config/.DS_Store b/node_modules/react-native-ultimate-config/.DS_Store
new file mode 100644
index 0000000..0308b2d
Binary files /dev/null and b/node_modules/react-native-ultimate-config/.DS_Store differ
diff --git a/node_modules/react-native-ultimate-config/src/.DS_Store b/node_modules/react-native-ultimate-config/src/.DS_Store
new file mode 100644
index 0000000..47d8199
Binary files /dev/null and b/node_modules/react-native-ultimate-config/src/.DS_Store differ
diff --git a/node_modules/react-native-ultimate-config/src/render-env.js b/node_modules/react-native-ultimate-config/src/render-env.js
index f8b25f4..569779e 100644
--- a/node_modules/react-native-ultimate-config/src/render-env.js
+++ b/node_modules/react-native-ultimate-config/src/render-env.js
@@ -53,6 +53,7 @@ function render_template(template_name, data) {
 module.exports = function render_env(project_root, lib_root, env) {
   const map = {
     [path.join(lib_root, "index.d.ts")]: render_template("index.d.ts", env),
+    [path.join(lib_root, "index.js")]: render_template("index.js", env),
     [path.join(lib_root, "ios", `${code_file_name}.h`)]: render_template(
       "ConfigValues.h",
       env
diff --git a/node_modules/react-native-ultimate-config/src/templates/index.js.handlebars b/node_modules/react-native-ultimate-config/src/templates/index.js.handlebars
new file mode 100644
index 0000000..249cbd1
--- /dev/null
+++ b/node_modules/react-native-ultimate-config/src/templates/index.js.handlebars
@@ -0,0 +1,10 @@
+// DO NOT COMMIT OR EDIT THIS FILE
+export default {
+{{#each @root}}
+{{#if (isString (androidValue this))}}
+  {{@key}}: "{{{androidValue this}}}",
+{{else}}
+  {{@key}}: {{{androidValue this}}},
+{{/if}}
+{{/each}}
+}

from react-native-ultimate-config.

maxkomarychev avatar maxkomarychev commented on May 28, 2024 1

hi @dvxme ,

thank you for bringing up your case with over-the-air deploys.

I will consider your suggestion in how this can be implemented.
I will not be able to work on this project until at least mid January though, so meanwhile you can use hooks API in order to generate relevant javascript files in your codebase and use them as a wrapper to RNUC.

I will reopen this issue meanwhile.

Thanks!

from react-native-ultimate-config.

dvxme avatar dvxme commented on May 28, 2024 1

Sorry for the delayed response. I was working on the feature that will require this patch (using untracked hardcoded keys in the dev branch). As soon as I finish the patch itself, I can share it with you.

Thanks for answering!

from react-native-ultimate-config.

maxkomarychev avatar maxkomarychev commented on May 28, 2024

hi!

As you pointed out correctly I designed this lib in a way so that there is a single source of truth for all config variables and they are propagated in one direction.
While I understand convenience of fast reload I deliberately opted out of supporting this functionality in favor of full scale support on native side.

That said I am open to suggestions and consider pull requests adding this.

from react-native-ultimate-config.

maxkomarychev avatar maxkomarychev commented on May 28, 2024

@pke what's your usage of rnuc? do you use it via cli or through xchemes/flavors?

from react-native-ultimate-config.

pke avatar pke commented on May 28, 2024

I use to to configure Google Maps SDK API keys and have a "Playground" component in my app that was driven by Env vars. Now its just driven by a json file I have control over outside of rnuc.
So everything is fine now ;)

from react-native-ultimate-config.

dvxme avatar dvxme commented on May 28, 2024

I don't know if here's the better place to discuss this but I have the same problem because our app supports primarily CodePush for deploys, even though the truth propagation of settings throughout the native layers is really nice in the few times it was needed.

Our use case mainly uses RNUC for integration keys and most of them are JS-only. The few ones that are native benefit greatly from the native side integration, but the inability to change keys over-the-air slows down our deploy process considerably, to the point of hardcoding keys for a while until a few weeks/months worth of changes are ready for another app store release.

My main approach here to achieve JS-first source of truth would be patching the library (via patch-package) to add another template (a JS one), add another path to render_env and substitute index.js to point to this rendered env instead of NativeModules.

What do you think?

from react-native-ultimate-config.

maxkomarychev avatar maxkomarychev commented on May 28, 2024

@dvxme would it be possible for you to share a patch you have created with patch-library?

thanks.

from react-native-ultimate-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.