react-native-code-push icon indicating copy to clipboard operation
react-native-code-push copied to clipboard

release-react has no option to store bundle file?

Open igorclark opened this issue 10 years ago • 4 comments

Hi there, we're trying to use an error reporting service which needs to have RN bundle and sourcemap files uploaded in order to show the full JS trace. code-push release-react gives us the --sourcemapOutput option so we can pass the sourcemap path we want through to react-native bundle, but it doesn't seem to have a matching --bundleOutput option.

Maybe it wouldn't work because of the way it bundles files inside the Code Push blobs, but is there any way this could get added? Or is there another way to do this? What I'm thinking right now is that I'd need to run the code-push release-react command to push the code, then run the react-native bundle command to generate the new bundle and sourcemap files, then upload them. But I'm not 100% sure that the generated files would be identical, and it'd also be great to be able to remove the second bundle command.

Is that even possible?

Thanks!

igorclark avatar Oct 12 '16 16:10 igorclark

Could you please let us know which error reporting service you are using? Is the requirement that you want to find out where is the bundle output generated? Is it not at this location - ./CodePush/main.jsbundle We have two commands for codepush: release & release-react. With release command you can customize the paths for bundle if that is what you want. https://microsoft.github.io/code-push/docs/cli.html#link-4 thank you.

cc: @panarasi

piyushjo avatar Oct 18 '16 22:10 piyushjo

Hi @piyushjo, thanks for getting back to me. We've been trying to use Bugsnag, but we've tried Sentry and Crashlytics too. It's the same issue for any of them with React Native, as they all need you to upload matching bundle and sourcemap files in order to get usable stack traces into JS code, rather than into the underlying Obj-C or Java RN classes.

Using release-react, the bundle is not at ./CodePush, it's in some opaque temporary filesystem location (e.g. /var/folders/tx/ckdp0nf12ps6c9txsg6_5hq40000gn/T/CodePush in the push I just did). The problem is that this location is transient, and even if it weren't, it's not accessible programmatically from the code-push CLI, so getting a hold of it in any kind of deploy-syncing script would mean some pretty brittle (e.g.) sed or awking.

Using release seems to provide just these options:

$ code-push release --help
Usage: code-push release <appName> <updateContentsPath> <targetBinaryVersion> [options]

Options:
  --deploymentName, -d       Deployment to release the update to  [string] [default: "Staging"]
  --description, --des       Description of the changes made to the app in this release  [string] [default: null]
  --disabled, -x             Specifies whether this release should be immediately downloadable  [boolean] [default: false]
  --mandatory, -m            Specifies whether this release should be considered mandatory  [boolean] [default: false]
  --noDuplicateReleaseError  When this flag is set, releasing a package that is identical to the latest release will produce a warning instead of an error  [boolean] [default: false]
  --rollout, -r              Percentage of users this release should be available to  [string] [default: "100%"]

Examples:
  release MyApp app.js "*"                                     Releases the "app.js" file to the "MyApp" app's "Staging" deployment, targeting any binary version using the "*" wildcard range syntax.
  release MyApp ./platforms/ios/www 1.0.3 -d Production        Releases the "./platforms/ios/www" folder and all its contents to the "MyApp" app's "Production" deployment, targeting only the 1.0.3 binary version
  release MyApp ./platforms/ios/www 1.0.3 -d Production -r 20  Releases the "./platforms/ios/www" folder and all its contents to the "MyApp" app's "Production" deployment, targeting the 1.0.3 binary version and rolling out to about 20% of the users

and according to the link you posted the updateContents parameter seems to refer to already-existing packaged content (I guess created by react-native bundle), rather than where the content should be packaged. Using this I guess we could do it the other way round, bundle everything to where we want using react-native and then do the release using code-push release rather than release-react and pointing to the bundle. But that takes away a lot of the convenience and niceness of using release-react.

So the requirement is to be able to specify in a code-push release-react parameter where the bundle and sourcemap files should be stored, and for them to remain present on the filesystem after the code-push upload has finished in this case. Hope that makes sense.

igorclark avatar Oct 19 '16 09:10 igorclark

Hi @igorclark, this is the line in our source that deletes the generated bundle after it is released: https://github.com/Microsoft/code-push/blob/master/cli/script/command-executor.ts#L1184.

We don't currently have the resources to address this issue, but as a temporary workaround, maybe you could find that line in your global node modules and comment it out? Alternatively, if you wanted to submit a PR to customize the release-react command, we would love to look at it!

For some context, here is what the release-react command does: https://github.com/Microsoft/code-push/blob/master/cli/script/command-executor.ts#L1264

And here is where command line flags are parsed: https://github.com/Microsoft/code-push/blob/master/cli/script/command-parser.ts#L414

Please let us know what you end up going with :)

richardhuaaa avatar Oct 19 '16 18:10 richardhuaaa

Hey thanks @silhouettes, that's cool, from those source refs it looks fairly straightforward to make it output the bundle to a specific location as well as the sourcemap. Not sure when I'll have time to look further into that either but it seems eminently doable. Thanks!

igorclark avatar Oct 20 '16 12:10 igorclark