-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #808 from bugsnag/expo-cli-version-compat
fix(expo-cli): Ensure appropriate code is inserted based on Bugsnag version
- Loading branch information
Showing
15 changed files
with
213 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { promisify } = require('util') | ||
const { readFile } = require('fs') | ||
const { join } = require('path') | ||
|
||
module.exports = async (dir) => { | ||
try { | ||
const pkg = JSON.parse(await promisify(readFile)(join(dir, 'package.json'), 'utf8')) | ||
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies, ...pkg.peerDependencies } | ||
return allDeps['@bugsnag/expo'] | ||
} catch (e) { | ||
throw new Error('Could not load package.json. Is this the project root?') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* global describe, it, expect */ | ||
|
||
const prepareFixture = require('./lib/prepare-fixture') | ||
const detectInstalled = require('../detect-installed') | ||
|
||
describe('expo-cli: detect-installed', () => { | ||
it('should work on a fresh project', async () => { | ||
const projectRoot = await prepareFixture('blank-00') | ||
const version = await detectInstalled(projectRoot) | ||
expect(version).toBe(undefined) | ||
}) | ||
|
||
it('should work on project with Bugsnag installed', async () => { | ||
const projectRoot = await prepareFixture('already-configured-00') | ||
const version = await detectInstalled(projectRoot) | ||
expect(version).toBe('^7.0.0') | ||
|
||
const projectRoot2 = await prepareFixture('already-configured-01') | ||
const version2 = await detectInstalled(projectRoot2) | ||
expect(version2).toBe('7.0.0') | ||
}) | ||
}) |
8 changes: 8 additions & 0 deletions
8
packages/expo-cli/lib/test/fixtures/already-configured-00/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "bugsnag-test-fixture-00", | ||
"private": "true", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"@bugsnag/expo": "^7.0.0" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/expo-cli/lib/test/fixtures/already-configured-01/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "bugsnag-test-fixture-01", | ||
"private": "true", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"@bugsnag/expo": "7.0.0" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/expo-cli/lib/test/fixtures/already-configured-02/App.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const Bugsnag = require('@bugsnag/expo') | ||
const React = require('react') | ||
const { StyleSheet, Text, View } = require('react-native') | ||
|
||
Bugsnag.start() | ||
|
||
export default class App extends React.Component { | ||
render () { | ||
return ( | ||
<View style={styles.container}> | ||
<Text>Hello Expo!</Text> | ||
</View> | ||
) | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
backgroundColor: '#fff', | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
} | ||
}) |
39 changes: 39 additions & 0 deletions
39
packages/expo-cli/lib/test/fixtures/already-configured-02/app.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"expo": { | ||
"name": "Bugsnag test fixture", | ||
"slug": "bugsnag-test-fixture", | ||
"privacy": "unlisted", | ||
"sdkVersion": "32.0.0", | ||
"platforms": [ | ||
"ios", | ||
"android" | ||
], | ||
"version": "1.0.0", | ||
"orientation": "portrait", | ||
"icon": "./assets/icon.png", | ||
"splash": { | ||
"image": "./assets/splash.png", | ||
"resizeMode": "contain", | ||
"backgroundColor": "#ffffff" | ||
}, | ||
"updates": { | ||
"fallbackToCacheTimeout": 0 | ||
}, | ||
"assetBundlePatterns": [ | ||
"**/*" | ||
], | ||
"extra": { | ||
"bugsnag": { | ||
"apiKey": "XoXoXoXoXoXo" | ||
} | ||
}, | ||
"hooks": { | ||
"postPublish": [ | ||
{ | ||
"file": "@bugsnag/expo/hooks/post-publish.js", | ||
"config": {} | ||
} | ||
] | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/expo-cli/lib/test/fixtures/already-configured-02/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "bugsnag-test-fixture-02", | ||
"private": "true", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"@bugsnag/expo": "6.5.1" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/expo-cli/lib/test/fixtures/already-installed-00/App.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const React = require('react') | ||
const { StyleSheet, Text, View } = require('react-native') | ||
|
||
export default class App extends React.Component { | ||
render () { | ||
return ( | ||
<View style={styles.container}> | ||
<Text>Hello Expo!</Text> | ||
</View> | ||
) | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
backgroundColor: '#fff', | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
} | ||
}) |
39 changes: 39 additions & 0 deletions
39
packages/expo-cli/lib/test/fixtures/already-installed-00/app.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"expo": { | ||
"name": "Bugsnag test fixture", | ||
"slug": "bugsnag-test-fixture", | ||
"privacy": "unlisted", | ||
"sdkVersion": "32.0.0", | ||
"platforms": [ | ||
"ios", | ||
"android" | ||
], | ||
"version": "1.0.0", | ||
"orientation": "portrait", | ||
"icon": "./assets/icon.png", | ||
"splash": { | ||
"image": "./assets/splash.png", | ||
"resizeMode": "contain", | ||
"backgroundColor": "#ffffff" | ||
}, | ||
"updates": { | ||
"fallbackToCacheTimeout": 0 | ||
}, | ||
"assetBundlePatterns": [ | ||
"**/*" | ||
], | ||
"extra": { | ||
"bugsnag": { | ||
"apiKey": "XoXoXoXoXoXo" | ||
} | ||
}, | ||
"hooks": { | ||
"postPublish": [ | ||
{ | ||
"file": "@bugsnag/expo/hooks/post-publish.js", | ||
"config": {} | ||
} | ||
] | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/expo-cli/lib/test/fixtures/already-installed-00/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "bugsnag-test-fixture-03", | ||
"private": "true", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"@bugsnag/expo": "^6.5.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "bugsnag-test-fixture", | ||
"name": "bugsnag-test-fixture-04", | ||
"private": "true", | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters