Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Allow providing a postExport hook #2227

Merged
merged 9 commits into from
Jun 8, 2020

Conversation

vernondegoede
Copy link
Contributor

@vernondegoede vernondegoede commented Jun 4, 2020

We would like to upload our sourcemaps to Sentry after creating an export. Since we don't publish our assets to Expo (we just create a local CDN, export our assets and then generate a build using Turtle), we cannot rely on the existing postPublish hook.

As @fson mentioned in #298 (comment), it would be nice to have a postExport hook.

Testing

I tested this locally by running:

/Users/vernondegoede/Sites/expo-cli/packages/expo-cli/bin/expo.js export --dump-sourcemap --public-url=https://localhost:3000

Outcome (left some stuff out intentionally):

[...]
Saving blah.png
Saving foo.png
Files successfully saved.
Processing asset bundle patterns:
- /Users/vernondegoede/Sites/mollie-mobile/**/*
Building sourcemaps
Configuring sourcemaps
Preparing additional debugging files
Running postExport hook: sentry-expo/upload-sourcemaps
Export was successful. Your exported files can be found in dist
Created release WZxxxxxxx.

> Analyzing 4 sources
> Rewriting sources
> Adding source map references
> Bundled 4 files for upload
> Uploaded release files to Sentry
> File processing complete

Source Map Upload Report
  Minified Scripts
    ~/main.android.bundle (sourcemap at main.android.map)
    ~/main.ios.bundle (sourcemap at main.ios.map)
  Source Maps
    ~/main.android.map
    ~/main.ios.map
[...]

@byCedric byCedric requested a review from fson June 4, 2020 11:02
Copy link
Contributor

@fson fson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, this looks excellent!

packages/xdl/src/Project.ts Outdated Show resolved Hide resolved
packages/xdl/src/Project.ts Outdated Show resolved Hide resolved
vernondegoede and others added 3 commits June 5, 2020 16:50
Co-authored-by: Ville Immonen <ville.immonen@iki.fi>
Co-authored-by: Ville Immonen <ville.immonen@iki.fi>
@vernondegoede
Copy link
Contributor Author

Thanks for the review @fson! Pushed the requested changes 🙌

Copy link
Contributor

@fson fson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@cruzach would you like to check this out before merging? It should work with sentry-expo for self-hosted projects.

@cruzach
Copy link
Contributor

cruzach commented Jun 5, 2020

thanks @vernondegoede this is awesome to have! one question- should we warn if the postExport hook is being run without the --dump-sourcemap option specified?

@fson
Copy link
Contributor

fson commented Jun 5, 2020

That’s a good point @cruzach. I think rather than warning, we should always pass the source maps to postExport hooks (also postPublish hooks always get them), but only write them to disk if --dump-sourcemap is given. The maps are generated here, could check if any number >0 of hooks is set up:

({ iosSourceMap, androidSourceMap } = await _buildSourceMapsAsync(projectRoot));

@vernondegoede
Copy link
Contributor Author

Good point! The latest changes should take care of that @fson and @cruzach.

@cruzach cruzach self-requested a review June 8, 2020 13:43
Copy link
Contributor

@fson fson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @vernondegoede! :shipit:

@fson fson merged commit a181410 into expo:master Jun 8, 2020
@vernondegoede vernondegoede deleted the vernon/post-export-hook branch June 8, 2020 15:27
@vernondegoede
Copy link
Contributor Author

@fson @cruzach I'm currently testing the postExport hook using expo-cli@3.21.6. The hook gets called, but validation of app.json seems to fail initially (it's just warnings, though).

Logs:

Generating export of project files
Error: Problem validating fields in app.json. See https://docs.expo.io/workflow/configuration/
 • Field: hooks - should NOT have additional property 'postExport'.
Unable to find an existing Expo CLI instance for this directory; starting a new one...
Exporting your app...
Error: Problem validating fields in app.json. See https://docs.expo.io/workflow/configuration/
 • Field: hooks - should NOT have additional property 'postExport'.
Starting Metro Bundler on port 19001.
Building iOS bundle
Finished building JavaScript bundle in 38750ms.
Building Android bundle
Finished building JavaScript bundle in 32622ms.
Finished saving JS Bundles.
Analyzing assets
Finished building JavaScript bundle in 2060ms.
Finished building JavaScript bundle in 2011ms.
Saving assets

[...]

Files successfully saved.
Processing asset bundle patterns:
- /Users/vernondegoede/Sites/mollie-mobile/**/*
Building sourcemaps
Finished building JavaScript bundle in 243ms.
Finished building JavaScript bundle in 219ms.
Configuring sourcemaps
Preparing additional debugging files
Running postExport hook: sentry-expo/upload-sourcemaps
Terminating server processes.
› Closing Expo server
› Stopping Metro bundler
Created release xzOAKVgQNA.

Export was successful. Your exported files can be found in dist
> Analyzing 4 sources
> Rewriting sources
> Adding source map references
> Bundled 4 files for upload
> Uploaded release files to Sentry
> File processing complete

Source Map Upload Report
  Minified Scripts
    ~/main.android.bundle (sourcemap at main.android.map)
    ~/main.ios.bundle (sourcemap at main.ios.map)
  Source Maps
    ~/main.android.map
    ~/main.ios.map

Anything that should be updated?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants