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
[ENG-8790][eas-cli] Fix updates synchronization of native files to include strings.xml #1865
Conversation
After figuring out why this code is necessary (i.e. why config plugins aren't being run), my next questions will be: I think I'm missing a ton of context about why this sync even needs to happen in the first place. |
Size Change: -959 B (0%) Total Size: 41.5 MB
|
Codecov Report
@@ Coverage Diff @@
## main #1865 +/- ##
==========================================
- Coverage 52.73% 52.72% -0.01%
==========================================
Files 474 474
Lines 17110 17114 +4
Branches 3423 3423
==========================================
Hits 9021 9021
- Misses 8072 8076 +4
Partials 17 17
|
It's intended to sync values with native code in a bare project.
I think answer for all of this is because this is used in bare projects, so we can't expect that prebuild will or even could be run.
And, specifically to that point. Maybe we can here, but not in general. Code in eas-cli needs to handle most (ideally all) native projects that EAS supports, so it's a higher standard than is expected in prebuild. e.g. prebuild assumes that there will be no variant/flavors and when we interact with any with projects we need to be aware of that. For example instead of writing to main strings.xml you could write to runtime version to resource specific to a variant that is going to be built. (just an example I don't think it's need here) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this problem a bit more, how about colocating all the workflow agnostic 'modding code' in @expo/config-plugins
? The problem is, we have 4 places which we 'mod' the Updates code:
expo prebuild
, managed workflow. Code in@expo/config-plugins
, called innpx expo prebuild
and Turtle Builderseas updates:configure
, bare workflow. Calls out to a subroutine in@expo/config-plugins
eas build
, bare workflow. Calls out to a subroutine in@expo/config-plugins
- Turtle Builders, workflow agnostic. Code in build-tools
When doug added bug fixes to @expo/config-plugins
, all the other call sites for the bare/agnostic workflows fell out of sync. They either broke completely by running a subset of the methods, or were flawed because they never picked up the bug fixes. What if we export a method called modUpdatesBareOrAgnosticWorkflow
in @expo/config-plugins
that mods a bare/agnostic workflow, and have it be called by eas-cli
and build-tools
? That way, if we make any bug changes in the future, all our fixes can be made in @expo/config-plugins
and we won't have to reimplement the same thing in 4 different places.
@wkozyra95 mentioned there is a higher standard in eas-cli
and build-tools
, where we cannot make assumptions about the variant/flavour of a project. However, if someone were to install expo-updates
, we are requiring them to have the correct keys in AndroidManifest.xml and strings.xml. We can assert all our preconditions in the @expo/config-plugins
for the bare and agnostic workflows if they are different from managed. So something like this:
export const withUpdates = [...]
// run by build-tools and eas-cli
export function modUpdatesBareOrAgnosticWorkflow () {
// assert preconditions for string.xml, if any
// run the same subroutines as withUpdates
}
The problem is that at different places we are doing slightly different things. if we had some method to sync configuration only for updates then we could use it in eas-cli and prebuild, but in turtle code does not sync values with app.json. It syncs one value passed as an argument. We could write this method (e.g. setUpdatedConfiguration) in a way that takes everything as an argument and only updates stuff based on the passed object, but in that case, it wouldn't be full solution, just a helper method, so there still would be a risk that someone adds code to plugin and not this helper method. At this point, we are getting back to a problem what is a public API of config-plugins?
That was just an example, there other alternatives could be The other approaches that we might consider:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wkozyra95 makes sense. At the very least, let's add a comment in config-plugins
for anyone who tries to make changes in the future. That way, we can do our best to avoid this type of situation from happening again and it's not a lot of extra work.
Still need to test this before landing. I'm assuming the repro is something like: create bare project using old CLIs, prebuild using old CLI, build using the CLI in this PR? |
yes, but you also need to specify some runtimeVersion (or policy) so when you run build there is anything to sync. Plus expo-updates need to be installed, otherwise version is not synced |
/changelog-entry bug-fix Fix updates synchronization of native files to include strings.xml for bare projects |
✅ Thank you for adding the changelog entry! |
Since eas-cli 3.13.3, which include this PR, the XML prolog of my And then it fails because I'm using Here is the diff after trying to build: diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -1,4 +0,3 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resources>
<string name="app_name">MyApp</string>
<string name="expo_runtime_version">10</string>
|
Why
expo/expo@166385e added this to the config plugin.
This code in eas-cli is supposed to emulate the config plugin, but for bare projects.
How
Make the config plugin emulation also do the new synchronization of strings.xml.
Test Plan
<meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version"
<meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version"
<string name="expo_runtime_version">1.0</string>
to strings.xml