diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index f2b2d707..4a7ed7c7 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -42,6 +42,7 @@ steps: queue: "opensource-arm-mac-cocoa-12" env: EXPO_RELEASE_CHANNEL: ${BUILDKITE_BUILD_ID} + DEVELOPER_DIR: "/Applications/Xcode13.4.app" artifact_paths: build/output.ipa commands: - test/scripts/build-ios.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index d4dda301..46245b28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## v45.1.3 (2022-03-02) + +### Fixed + +- (bugsnag-expo-cli) Fix issue with automated installation when using app.config.js [#72](https://github.com/bugsnag/bugsnag-expo/pull/72) +- (expo) Add promise v8 as a peer dependency [#77](https://github.com/bugsnag/bugsnag-expo/pull/77) +- (plugin-expo-eas-sourcemaps) Restrict Bugsnag Android Gradle Plugin dependency to v7 [#101](https://github.com/bugsnag/bugsnag-expo/pull/101) + ## v45.1.2 (2022-08-21) ### Fixed diff --git a/packages/expo-cli/lib/configure-plugin.js b/packages/expo-cli/lib/configure-plugin.js index 3559b403..0573b3aa 100644 --- a/packages/expo-cli/lib/configure-plugin.js +++ b/packages/expo-cli/lib/configure-plugin.js @@ -34,26 +34,37 @@ function usingWorkspaces (projectRoot, usingYarnClassic) { } module.exports = async (projectRoot) => { + const appJsonPath = join(projectRoot, 'app.json') + let conf + + // read in existing app.json try { - const appJsonPath = join(projectRoot, 'app.json') - const conf = JSON.parse(await promisify(readFile)(appJsonPath, 'utf8')) - conf.expo.plugins = conf.expo.plugins || [] - if (conf.expo.plugins.includes(plugin)) { - return plugin + ' is already installed' - } - conf.expo.plugins.push(plugin) - await promisify(writeFile)(appJsonPath, JSON.stringify(conf, null, 2), 'utf8') + conf = JSON.parse(await promisify(readFile)(appJsonPath, 'utf8')) } catch (e) { // swallow and rethrow for errors that we can produce better messaging for if (e.code === 'ENOENT') { - throw new Error(`Couldn’t find app.json in "${projectRoot}". Is this the root of your Expo project?`) - } - if (e.name === 'SyntaxError') { + conf = { + expo: { + plugins: [] + } + } + } else if (e.name === 'SyntaxError') { throw new Error(`Couldn’t parse app.json because it wasn’t valid JSON: "${e.message}"`) + } else { + throw e } - throw e } + // update config + conf.expo = conf.expo || {} + conf.expo.plugins = conf.expo.plugins || [] + if (conf.expo.plugins.includes(plugin)) { + return plugin + ' is already installed' + } + conf.expo.plugins.push(plugin) + + await promisify(writeFile)(appJsonPath, JSON.stringify(conf, null, 2), 'utf8') + // do we need to add monorepo configuration? const withYarnClassic = await usingYarnClassic(projectRoot) const addMonorepoConfig = await usingWorkspaces(projectRoot, withYarnClassic) diff --git a/packages/expo-cli/lib/set-api-key.js b/packages/expo-cli/lib/set-api-key.js index 68749588..3c85d977 100644 --- a/packages/expo-cli/lib/set-api-key.js +++ b/packages/expo-cli/lib/set-api-key.js @@ -3,21 +3,34 @@ const { readFile, writeFile } = require('fs') const { promisify } = require('util') module.exports = async (apiKey, projectRoot) => { + const appJsonPath = join(projectRoot, 'app.json') + let conf + try { - const appJsonPath = join(projectRoot, 'app.json') - const conf = JSON.parse(await promisify(readFile)(appJsonPath, 'utf8')) - conf.expo.extra = conf.expo.extra || {} - conf.expo.extra.bugsnag = conf.expo.extra.bugsnag || {} - conf.expo.extra.bugsnag.apiKey = apiKey - await promisify(writeFile)(appJsonPath, JSON.stringify(conf, null, 2), 'utf8') + conf = JSON.parse(await promisify(readFile)(appJsonPath, 'utf8')) } catch (e) { // swallow and rethrow for errors that we can produce better messaging for if (e.code === 'ENOENT') { - throw new Error(`Couldn’t find app.json in "${projectRoot}". Is this the root of your Expo project?`) - } - if (e.name === 'SyntaxError') { + conf = { + expo: { + extra: { + bugsnag: { + } + } + } + } + // throw new Error(`Couldn’t find app.json in "${projectRoot}". Is this the root of your Expo project?`) + } else if (e.name === 'SyntaxError') { throw new Error(`Couldn’t parse app.json because it wasn’t valid JSON: "${e.message}"`) + } else { + throw e } - throw e } + + conf.expo = conf.expo || {} + conf.expo.extra = conf.expo.extra || {} + conf.expo.extra.bugsnag = conf.expo.extra.bugsnag || {} + conf.expo.extra.bugsnag.apiKey = apiKey + + await promisify(writeFile)(appJsonPath, JSON.stringify(conf, null, 2), 'utf8') } diff --git a/packages/expo-cli/lib/test/configure-plugin.test.js b/packages/expo-cli/lib/test/configure-plugin.test.js index fab1f841..f406ed0c 100644 --- a/packages/expo-cli/lib/test/configure-plugin.test.js +++ b/packages/expo-cli/lib/test/configure-plugin.test.js @@ -27,9 +27,14 @@ describe('expo-cli: upload sourcemaps configure-plugin', () => { }) }) - it('should provide a reasonable error when there is no app.json', async () => { + it('should create a basic file when there is no app.json', async () => { await withFixture('empty-00', async (projectRoot) => { - await expect(configurePlugin(projectRoot)).rejects.toThrow(/^Couldn’t find app\.json in/) + const msg = await configurePlugin(projectRoot) + expect(msg).toBe(undefined) + + const appJsonRaw = await readFile(`${projectRoot}/app.json`, 'utf8') + const appJson = JSON.parse(appJsonRaw) + expect(appJson.expo.plugins).toStrictEqual(['@bugsnag/plugin-expo-eas-sourcemaps']) }) }) diff --git a/packages/expo-cli/lib/test/fixtures/already-installed-01/package.json b/packages/expo-cli/lib/test/fixtures/already-installed-01/package.json index 65a0848d..c74db847 100644 --- a/packages/expo-cli/lib/test/fixtures/already-installed-01/package.json +++ b/packages/expo-cli/lib/test/fixtures/already-installed-01/package.json @@ -1,5 +1,5 @@ { - "name": "bugsnag-test-fixture-05", + "name": "already-installed-01", "private": "true", "version": "0.0.0", "dependencies": { diff --git a/packages/expo-cli/lib/test/set-api-key.test.js b/packages/expo-cli/lib/test/set-api-key.test.js index 61e4d50d..50ed7e68 100644 --- a/packages/expo-cli/lib/test/set-api-key.test.js +++ b/packages/expo-cli/lib/test/set-api-key.test.js @@ -14,7 +14,7 @@ describe('expo-cli: set-api-key', () => { }) }) - it('shouldn’t replaces an existing API key', async () => { + it('shouldn’t replace an existing API key', async () => { await withFixture('already-configured-00', async (projectRoot) => { const msg = await setApiKey('AABBCCDD', projectRoot) expect(msg).toBe(undefined) @@ -25,9 +25,14 @@ describe('expo-cli: set-api-key', () => { }) }) - it('should provide a reasonable error when there is no app.json', async () => { + it('should create a basic file with apiKey when there is no app.json', async () => { await withFixture('empty-00', async (projectRoot) => { - await expect(setApiKey('AABBCCDD', projectRoot)).rejects.toThrow(/^Couldn’t find app\.json in/) + const msg = await setApiKey('AABBCCDD', projectRoot) + expect(msg).toBe(undefined) + + const appJsonRaw = await readFile(`${projectRoot}/app.json`, 'utf8') + const appJson = JSON.parse(appJsonRaw) + expect(appJson.expo.extra.bugsnag.apiKey).toBe('AABBCCDD') }) }) diff --git a/packages/expo/package.json b/packages/expo/package.json index c8f5b3d4..fd800bcd 100644 --- a/packages/expo/package.json +++ b/packages/expo/package.json @@ -54,6 +54,7 @@ "peerDependencies": { "expo": ">=33.0.0", "expo-constants": "~13.1.1", + "promise": "^8", "react": "*" } } diff --git a/packages/plugin-expo-eas-sourcemaps/src/android.js b/packages/plugin-expo-eas-sourcemaps/src/android.js index 5f6279cf..ea87bf15 100644 --- a/packages/plugin-expo-eas-sourcemaps/src/android.js +++ b/packages/plugin-expo-eas-sourcemaps/src/android.js @@ -52,7 +52,7 @@ function injectDependencies (script) { mavenCentral() } dependencies { - classpath 'com.bugsnag:bugsnag-android-gradle-plugin:[7.3.0,)' + classpath 'com.bugsnag:bugsnag-android-gradle-plugin:7.+' } } diff --git a/test/features/fixtures/test-app/app.json b/test/features/fixtures/test-app/app.json index f50fd891..69a82894 100644 --- a/test/features/fixtures/test-app/app.json +++ b/test/features/fixtures/test-app/app.json @@ -26,6 +26,11 @@ }, "plugins": [ ["./config-plugins/withRemoveiOSNotificationEntitlement"] - ] + ], + "extra": { + "eas": { + "projectId": "EXPO_EAS_PROJECT_ID" + } + } } } diff --git a/test/scripts/build-common.sh b/test/scripts/build-common.sh index 5e9ed604..2d293baf 100755 --- a/test/scripts/build-common.sh +++ b/test/scripts/build-common.sh @@ -24,6 +24,9 @@ npm install bugsnag-expo-cli*.tgz # set bugsnag-js override versions if this build was triggered from the bugsnag-js repo ./set-bugsnag-js-overrides $BUGSNAG_JS_BRANCH $BUGSNAG_JS_COMMIT +# Set EAS Project ID +sed -i '' "s/EXPO_EAS_PROJECT_ID/$EXPO_EAS_PROJECT_ID/g" app.json + # install the remaining packages, this also re-installs the correct @bugsnag/expo version npm install *.tgz npm install