Skip to content
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

[PLAT-6128] RN-CLI: Use a more exhaustive search for MainApplication.java #1365

Merged
merged 19 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9b9233f
feat(react-native-cli): Use a more exhaustive search for MainApplicat…
bengourley Apr 21, 2021
fa6c841
test(react-native-cli): Add ejected Expo fixture
bengourley Apr 22, 2021
ffc020e
test(react-native-cli): Enable ejected Expo end to end tests on CI
bengourley Apr 22, 2021
c3a630d
test(react-native-cli): Correct path in fixture logic
bengourley Apr 22, 2021
1087da0
test(react-native-cli): Add workarounds for failed stdout parsing
bengourley Apr 22, 2021
e1d64aa
test(react-native-cli): Disable OTA updates in Expo fixture
bengourley Apr 22, 2021
25ffde7
test(react-native-cli): Refactor to avoid global variable
bengourley Apr 22, 2021
c0bb007
test(react-native-cli): Rename files
bengourley Apr 22, 2021
40fd36e
test(react-native-cli): Add crashy package to fixture
bengourley Apr 22, 2021
01e09c4
test(react-native-cli): Set up iOS fixture app signing
bengourley Apr 22, 2021
41fc71a
test(react-native-cli): Add missing semi colon. Java!!!
bengourley Apr 22, 2021
04d0c5c
test(react-native-cli): Update crashy package path
bengourley Apr 22, 2021
f827015
test(react-native-cli): Disable incomplete steps
bengourley Apr 26, 2021
c5fdfa8
chore: Remove extraneous whitespace
bengourley Apr 27, 2021
edbda3d
test(react-native-cli): Remove uneccesary dropping of lines
bengourley Apr 27, 2021
4344510
Merge branch 'next' into bengourley/rn-cli-main-application-search
bengourley Apr 27, 2021
57365f3
chore: Update changelog
bengourley Apr 27, 2021
667565e
Merge branch 'bengourley/rn-cli-main-application-search' of github.co…
bengourley Apr 27, 2021
b15479b
test(react-native-cli): Don't npm install where unnecessary
bengourley Apr 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .buildkite/react-native-cli-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ steps:
env:
REACT_NATIVE_VERSION: "rn0_63"

- label: ':runner: RN 0.63 Expo (ejected) CLI tests'
depends_on: "cli-maze-image"
timeout_in_minutes: 20
plugins:
docker-compose#v3.7.0:
run: react-native-cli-tool-maze-runner
use-aliases: true
command: ["features/cli-tests"]
env:
REACT_NATIVE_VERSION: "rn0_63_expo_ejected"

#
# Built app test fixtures
#
Expand Down Expand Up @@ -135,6 +146,22 @@ steps:
artifact_paths:
- build/rn0_63.apk

- label: ':android: Init and build RN 0.63 Expo (ejected) apk'
key: 'rn-0-63-expo-ejected-apk'
depends_on:
- 'android-builder-image'
timeout_in_minutes: 15
env:
DEBUG: true
REACT_NATIVE_VERSION: rn0_63_expo_ejected
plugins:
- docker-compose#v3.7.0:
run: react-native-cli-android-builder
command: ["features/build-app-tests/build-android-app.feature"]
artifact_paths:
- build/rn0_63_expo_ejected.apk
skip: To be fixed and enabled via PLAT-6449

- label: ':ios: Init and build RN 0.60 ipa'
key: 'rn-0-60-ipa'
timeout_in_minutes: 30
Expand Down Expand Up @@ -179,6 +206,18 @@ steps:
commands:
- test/react-native-cli/scripts/init-and-build-test.sh rn0_63

- label: ':ios: Init and build RN 0.63 Expo (ejected) ipa'
key: 'rn-0-63-expo-ejected-ipa'
timeout_in_minutes: 30
agents:
queue: 'opensource-mac-rn'
env:
DEBUG: true
artifact_paths: build/rn0_63_expo_ejected.ipa
commands:
- test/react-native-cli/scripts/init-and-build-test.sh rn0_63_expo_ejected
skip: To be fixed and enabled via PLAT-6449

#
# Init, build and notify end-to-end tests
#
Expand Down Expand Up @@ -258,6 +297,26 @@ steps:
concurrency: 9
concurrency_group: 'browserstack-app'

- label: ':runner: RN 0.63 Expo (ejected) Android end-to-end tests'
depends_on: "rn-0-63-expo-ejected-apk"
timeout_in_minutes: 10
plugins:
artifacts#v1.2.0:
download: "build/rn0_63_expo_ejected.apk"
docker-compose#v3.7.0:
pull: react-native-cli-maze-runner
run: react-native-cli-maze-runner
use-aliases: true
command:
- --app=build/rn0_63_expo_ejected.apk
- --farm=bs
- --device=ANDROID_11_0
- --a11y-locator
- features/run-app-tests
concurrency: 9
concurrency_group: 'browserstack-app'
skip: To be fixed and enabled via PLAT-6449

- label: ':runner: RN 0.60 iOS end-to-end tests'
depends_on: "rn-0-60-ipa"
timeout_in_minutes: 10
Expand Down Expand Up @@ -333,3 +392,23 @@ steps:
- features/run-app-tests
concurrency: 9
concurrency_group: 'browserstack-app'

- label: ':runner: RN 0.63 Expo (ejected) iOS end-to-end tests'
depends_on: "rn-0-63-expo-ejected-ipa"
timeout_in_minutes: 10
plugins:
artifacts#v1.2.0:
download: "build/rn0_63_expo_ejected.ipa"
docker-compose#v3.7.0:
pull: react-native-cli-maze-runner
run: react-native-cli-maze-runner
use-aliases: true
command:
- --app=build/rn0_63_expo_ejected.ipa
- --farm=bs
- --device=IOS_14
- --a11y-locator
- features/run-app-tests
concurrency: 9
concurrency_group: 'browserstack-app'
skip: To be fixed and enabled via PLAT-6449
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## TBD

### Added

- (react-native-cli): Add support for ejected Expo apps [#1365](https://github.com/bugsnag/bugsnag-js/pull/1365)

## v7.9.5 (2021-04-26)

### Changed
Expand Down
77 changes: 77 additions & 0 deletions packages/react-native-cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/react-native-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.0",
"consola": "^2.15.0",
"glob": "^7.1.6",
"plist": "^3.0.1",
"prompts": "^2.4.0",
"xcode": "^3.0.1"
Expand Down
23 changes: 14 additions & 9 deletions packages/react-native-cli/src/lib/Insert.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Logger } from '../Logger'
import path from 'path'
import { promises as fs } from 'fs'
import { promisify } from 'util'
import glob from 'glob'

const asyncGlob = promisify(glob)

const BUGSNAG_JS_IMPORT_INIT =
`import Bugsnag from "@bugsnag/react-native";
Expand Down Expand Up @@ -76,20 +80,21 @@ export async function insertIos (projectRoot: string, logger: Logger): Promise<v

export async function insertAndroid (projectRoot: string, logger: Logger): Promise<void> {
logger.info('Adding Bugsnag to the Android layer')
const comDir = path.join(projectRoot, 'android', 'app', 'src', 'main', 'java', 'com')
let appPackagePath

let mainApplicationPath
try {
appPackagePath = (await fs.readdir(comDir))[0]
if (!appPackagePath) {
logger.warn(FAIL_MSG('MainApplication.java'))
return
}
const comDir = path.join(projectRoot, 'android', 'app', 'src', 'main', 'java', 'com')
const relativeMainApplicationPath = (await asyncGlob('**/*/MainApplication.java', {
cwd: comDir
}))[0]
if (!relativeMainApplicationPath) return logger.warn(FAIL_MSG('MainApplication.java'))
mainApplicationPath = path.join(comDir, relativeMainApplicationPath)
} catch (e) {
logger.error(FAIL_MSG('MainApplication.java'))
logger.warn(FAIL_MSG('MainApplication.java'))
return
}

try {
const mainApplicationPath = path.join(comDir, appPackagePath, 'MainApplication.java')
const mainApplication = await fs.readFile(mainApplicationPath, 'utf8')

if (mainApplication.includes(BUGSNAG_JAVA_IMPORT) || mainApplication.includes(BUGSNAG_JAVA_INIT)) {
Expand Down
Loading