Skip to content

Commit

Permalink
Merge pull request #542 from bugsnag/expo-on-prem-config
Browse files Browse the repository at this point in the history
feat(expo): Support "endpoint" option for builds/source maps
  • Loading branch information
bengourley authored May 23, 2019
2 parents b579ddb + 4ecc945 commit 7f1d656
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/expo/hooks/lib/report-build.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const reportBuild = require('bugsnag-build-reporter')

module.exports = async (apiKey, manifest, projectRoot) => {
module.exports = async (apiKey, manifest, projectRoot, endpoint) => {
const { revisionId, version } = manifest
await reportBuild({
apiKey,
appVersion: version,
metadata: { [`bundle@${new Date().toISOString()}`]: revisionId }
}, { path: projectRoot })
}, { path: projectRoot, endpoint })
}
14 changes: 9 additions & 5 deletions packages/expo/hooks/lib/upload-source-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ module.exports = async (
androidManifest,
androidBundle,
androidSourceMap,
projectRoot
projectRoot,
endpoint
) => {
const dir = await makeTmpDir()

Expand All @@ -30,26 +31,29 @@ module.exports = async (
await writeFileAsync(androidSourceMapPath, androidSourceMap, 'utf-8')
await writeFileAsync(androidBundlePath, androidBundle, 'utf-8')

const opts = { apiKey }
if (endpoint) opts.endpoint = endpoint

// android
console.log(`Uploading Android source map`)
await upload({
apiKey,
appVersion: androidManifest.version,
minifiedUrl: '*/cached-bundle-experience-*',
minifiedFile: androidBundlePath,
codeBundleId: androidManifest.revisionId,
sourceMap: androidSourceMapPath
sourceMap: androidSourceMapPath,
...opts
})

// ios
console.log(`Uploading iOS source map`)
await upload({
apiKey,
appVersion: iosManifest.version,
minifiedUrl: iosManifest.bundleUrl,
minifiedFile: iosBundlePath,
codeBundleId: iosManifest.revisionId,
sourceMap: iosSourceMapPath
sourceMap: iosSourceMapPath,
...opts
})
}

Expand Down
13 changes: 9 additions & 4 deletions packages/expo/hooks/post-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ module.exports = async ({
'@bugsnag/expo postPublish hook requires your Bugsnag API key'
)
}
if (!config || config.reportBuild !== false) {
await reportBuild(apiKey, iosManifest, projectRoot)

const buildReporterConfig = (config && config.buildReporter) ? config.buildReporter : {}
if (buildReporterConfig.disabled !== true) {
await reportBuild(apiKey, iosManifest, projectRoot, buildReporterConfig.endpoint)
}
if (!config || config.uploadSourcemaps !== false) {

const sourceMapConfig = (config && config.sourceMapUploader) ? config.sourceMapUploader : {}
if (sourceMapConfig.disabled !== true) {
await uploadSourcemaps(
apiKey,
iosManifest,
Expand All @@ -35,7 +39,8 @@ module.exports = async ({
androidManifest,
androidBundle,
androidSourceMap,
projectRoot
projectRoot,
sourceMapConfig.endpoint
)
}
} catch (e) {
Expand Down

0 comments on commit 7f1d656

Please sign in to comment.