Skip to content

Commit 5a18a76

Browse files
hurali97artus9033thymikee
authored
feat: use ruby script for post integrate (#233)
* chore: bootstrapped demo Expo app * chore: use expo config plugin in expo demo app * chore: reset Expo project * chore: use workspace specifier for monorepo deps * fix: do not toss up source sets in Gradle plugin * feat: base implementation for brownfield Expo config plugin * chore: update lock files * chore: update app.json in ExpoApp * chore: enable debug logging in app.json in ExpoApp * feat: use new logging system in the plugin * feat: templates engine for project modifications * feat: patch for Expo SDK pre v55, fix source file paths * feat: implemented Android brownfield plugin * chore: update ExpoApp scripts * fix: dedent gradle script insertion * fix: depend on Material in AndroidApp; fix typo in gradle scripting comments * fix: package name in ExpoApp * chore: use debug signing config for AndroidApp release variant - for testing purposes * chore: missing indent in gradleHelpers insertion * fix: add missing expo modifications to template build.gradle.kts * chore: use the Expo classes in template ReactNativeHostManager.kt * fix: iOS xcode project processing of target UUID * fix: make Android Expo config explicitly specify versions of RN Android deps to be properly resolved by Gradle when consumed * fix: running package:ios again * chore: udpate rock to 0.12.8 * chore: make nodemon watch template files in dev script for brownfield package * chore: reformat files, extract capitalized string helper, suppress unchecked cast compilation warnings * chore: deintegrate isExpo gradle plugin prop in favor of auto-detection * chore: typo in Android native demo app theme name * feat: config Maven publishing for part of the core expo modules * fix: correct artifact, group and version discovery for manually whitelisted publishable projects * feat: inject transitive dependencies into POM publication files * feat: instead of publishing, inject proper POM and Gradle Module JSON metadata with Expo transitive deps * feat: functional Expo demo in AndroidApp * chore: re-enable signing of gradle plugin * chore: use 0.0.1-snapshot by default in Expo plugin on Android * fix: filter out remaining expo transitive dependencies, add version mediation mechanisms * feat: seamless integration of Expo features into the brownfield CLI * refactor: restructure RNApp sources * feat: reuse RNApp sources in ExpoApp * feat: set up flavors for AndroidApp to consume expo or vanilla artifacts * ci: update CI to account for AndroidApp flavors * chore: remove obsolete comment * fix: monorepo-prone expo detection in CLI * feat: proper code sharing for RN demo apps * fix: make ReactNativeHostManager singatures match across flavors, properly initialize React Native * fix: restore .brownie.ts files in each project for codegen to work properly * feat: added an image view to the demo app * chore: strip obsolete comment * fix: proper module name in ios script * fix: brownie not to crash on Android * fix: handle brownie no stores in project in the CLI * feat: demo apps reorganized, pulled in clean template for expo app * feat: integrate brownie store with Expo demo app * docs: update docs * feat: temporarily deintegrate brownie from expo demo before android is implemented in brownie * chore: rename expo app project * chore: re-enable signing of the gradle plugin * chore: add changesets * refactor: format files * fix(ci): path to RN project in androidapp-road-test * refactor: format files to comply with detekt * chore: revert changes to brownie * fix: paths in packageIos in RN projects * ci: update workflow for Apple apps * feat: demo iOS app supporting interchanging brownfield artifacts * fix: patchExpoPre55.sh * fix: reorder build phases in iOS to first run patching after expo configure * wip: reorder build script phases PoC for Expo config plugin * chore: reorder code properly * chore: use SNAPSHOT for CI and local * chore: add plugin publish and patch scripts for local maven * chore: fix appleapp-road-test ci * chore: use macos runner for appleapp CI * fix(ci): update maven path for expo flavor * fix(ci): expo android * feat: ensure build phase correct order using post_integrate * feat: add ReactNativeHostManager to source files * fix: use the bundleURL in loadView * feat: present Expo RN UI in Apple App * chore: use latest version for brownfield-gradle-plugin * feat: add source files to PBXSourcesBuildPhase * feat: allow entry points other than main * feat: add configuration for vanilla and expo to AppleApp * fix: add info.plist to AppleApp * fix: bundle reference * fix(ci): add guard to only run pods for vanilla * docs: update ExpoApp usages * feat: remove coil dependency from plugin to the lib * refactor: remove TODO comments * feat: guard script reordering against expo version * feat: separate brownie usage by platform * chore: build android app with release variant * docs: add Expo Integration section * chore: bump versions * fix: remove color prop * Update docs/docs/docs/getting-started/expo.mdx Co-authored-by: Michał Pierzchała <thymikee@gmail.com> * Update docs/docs/docs/getting-started/expo.mdx Co-authored-by: Michał Pierzchała <thymikee@gmail.com> * docs: remove images * refactor: fix indentation * feat: use ruby script for post integrate * chore: remove changeset bump --------- Co-authored-by: artus9033 <artus9033@gmail.com> Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
1 parent 28b77bc commit 5a18a76

File tree

3 files changed

+53
-27
lines changed

3 files changed

+53
-27
lines changed

packages/react-native-brownfield/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"files": [
6262
"src",
6363
"lib",
64+
"scripts",
6465
"android",
6566
"ios",
6667
"cpp",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def react_native_brownfield_post_integrate(installer)
2+
projects = installer.aggregate_targets.map(&:user_project).compact.uniq
3+
projects.each do |project|
4+
modified = false
5+
6+
project.native_targets.each do |target|
7+
phases = target.build_phases
8+
expo_idx = phases.index { |p| p.respond_to?(:name) && p.name == '[Expo] Configure project' }
9+
patch_idx = phases.index { |p| p.respond_to?(:name) && p.name == 'Patch ExpoModulesProvider' }
10+
11+
next if expo_idx.nil? || patch_idx.nil?
12+
next if patch_idx > expo_idx
13+
14+
patch = phases.delete_at(patch_idx)
15+
expo_idx = phases.index { |p| p.respond_to?(:name) && p.name == '[Expo] Configure project' }
16+
phases.insert(expo_idx + 1, patch)
17+
modified = true
18+
end
19+
20+
project.save if modified
21+
end
22+
end

packages/react-native-brownfield/src/expo-config-plugin/ios/podfileHelpers.ts

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,47 @@ const BROWNFIELD_POD_HOOK_MARKER_START =
66
'# >>> react-native-brownfield expo phase ordering >>>';
77
const BROWNFIELD_POD_HOOK_MARKER_END =
88
'# <<< react-native-brownfield expo phase ordering <<<';
9+
const BROWNFIELD_POST_INTEGRATE_REQUIRE = `require File.join(File.dirname(\`node --print "require.resolve('@callstack/react-native-brownfield/package.json')"\`), "scripts/react_native_brownfield_post_integrate")`;
10+
const REACT_NATIVE_PODS_REQUIRE_REGEX =
11+
/^require File\.join\(File\.dirname\(`node --print "require\.resolve\('react-native\/package\.json'\)"`\), "scripts\/react_native_pods"\)\s*$/m;
912

10-
function ensureExpoPhaseOrderingHook(podfile: string): string {
11-
if (podfile.includes(BROWNFIELD_POD_HOOK_MARKER_START)) {
13+
function ensureBrownfieldPostIntegrateRequire(podfile: string): string {
14+
if (podfile.includes('scripts/react_native_brownfield_post_integrate')) {
1215
return podfile;
1316
}
1417

18+
const reactNativePodsRequireMatch = podfile.match(
19+
REACT_NATIVE_PODS_REQUIRE_REGEX
20+
);
21+
if (reactNativePodsRequireMatch) {
22+
const requireLine = reactNativePodsRequireMatch[0];
23+
return podfile.replace(
24+
requireLine,
25+
`${requireLine}\n${BROWNFIELD_POST_INTEGRATE_REQUIRE}\n`
26+
);
27+
}
28+
29+
return `${BROWNFIELD_POST_INTEGRATE_REQUIRE}\n\n${podfile}`;
30+
}
31+
32+
function ensureExpoPhaseOrderingHook(podfile: string): string {
33+
let modifiedPodfile = ensureBrownfieldPostIntegrateRequire(podfile);
34+
35+
if (modifiedPodfile.includes(BROWNFIELD_POD_HOOK_MARKER_START)) {
36+
return modifiedPodfile;
37+
}
38+
1539
const hook = `
1640
${BROWNFIELD_POD_HOOK_MARKER_START}
17-
def reorder_brownfield_expo_patch_phase!(installer)
18-
projects = installer.aggregate_targets.map(&:user_project).compact.uniq
19-
projects.each do |project|
20-
modified = false
21-
22-
project.native_targets.each do |target|
23-
phases = target.build_phases
24-
expo_idx = phases.index { |p| p.respond_to?(:name) && p.name == '[Expo] Configure project' }
25-
patch_idx = phases.index { |p| p.respond_to?(:name) && p.name == 'Patch ExpoModulesProvider' }
26-
27-
next if expo_idx.nil? || patch_idx.nil?
28-
next if patch_idx > expo_idx
29-
30-
patch = phases.delete_at(patch_idx)
31-
expo_idx = phases.index { |p| p.respond_to?(:name) && p.name == '[Expo] Configure project' }
32-
phases.insert(expo_idx + 1, patch)
33-
modified = true
34-
end
35-
36-
project.save if modified
37-
end
38-
end
39-
4041
post_integrate do |installer|
41-
reorder_brownfield_expo_patch_phase!(installer)
42+
react_native_brownfield_post_integrate(installer)
4243
end
4344
${BROWNFIELD_POD_HOOK_MARKER_END}
4445
`;
4546

46-
return `${podfile.trimEnd()}\n\n${hook}\n`;
47+
modifiedPodfile = `${modifiedPodfile.trimEnd()}\n\n${hook}\n`;
48+
49+
return modifiedPodfile;
4750
}
4851

4952
/**

0 commit comments

Comments
 (0)