microsoft / appcenter-cli

Command-line Interface (CLI) for Visual Studio App Center
https://appcenter.ms/
MIT License
581 stars 234 forks source link

[breakingchange] --sourcemap-output arguments broken #2462

Closed kopax-polyconseil closed 10 months ago

kopax-polyconseil commented 11 months ago

Description

We use to have our react native code push android/ios configured with sentry without issue since july 17th.

It seems that the command appcenter codepush release-react stopped to generate sourcemaps properly.

--sourcemap-output was used before but without any params, as a true/false flip, in order to generated source map.

image

Source : https://learn.microsoft.com/en-us/appcenter/distribution/codepush/cli

Problem : the parameter seems now to expect a parameter and does not work as expected, if I pass a value, such as --sourcemap-output ./build/CodePush/index.android.bundle.map, it will fail with the following error (with DEBUG="appcenter-cli:*") :

$ DEBUG="appcenter-cli:*" yarn appcenter codepush release-react --token $ANDROID_APPCENTER_API_TOKEN --deployment-name Production --app pass-Culture/passculture-prod-android --target-binary-version "1.256.0" --description "(PC-24621) fix(useSearchVenueOffers): fix sentry error (#5353)" --disable-duplicate-release-error --sourcemap-output --output-dir ./build --sourcemap-output ./build/CodePush/index.android.bundle.map

Running "react-native bundle" command:

node node_modules/.bin/react-native bundle --assets-dest build/CodePush --bundle-output build/CodePush/index.android.bundle --dev false --entry-file index.js --platform android --sourcemap-output ,./build/CodePush/index.android.bundle.map
warn Package react-native-appsflyer contains invalid configuration: "dependency.platforms.ios.podspecPath" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
warn Package react-native-flipper contains invalid configuration: "dependency.platforms.ios.project" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
Mapping the following sym linked packages:
{}
Welcome to Metro v0.72.4
              Fast - Scalable - Integrated
info Writing bundle output to:, build/CodePush/index.android.bundle
info Writing sourcemap output to:, ,./build/CodePush/index.android.bundle.map
error ENOENT: no such file or directory, open ',./build/CodePush/index.android.bundle.map'.
Error: ENOENT: no such file or directory, open ',./build/CodePush/index.android.bundle.map'
info Run CLI with --verbose flag for more details.
  appcenter-cli:commands:codepush:release-react Failed to release a CodePush update - Error: "react-native bundle" command failed (exitCode=1, signal=null).
  appcenter-cli:commands:codepush:release-react     at ChildProcess.<anonymous> (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/appcenter-cli/dist/commands/codepush/lib/react-native-utils.js:269:24)
  appcenter-cli:commands:codepush:release-react     at ChildProcess.emit (node:events:513:28)
  appcenter-cli:commands:codepush:release-react     at maybeClose (node:internal/child_process:1091:16)
  appcenter-cli:commands:codepush:release-react     at ChildProcess._handle.onexit (node:internal/child_process:302:5) +0ms
Error: Failed to release a CodePush update.
error Command failed with exit code 3.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command

I have found by reading appcenter-cli source code that it can work using --sourcemap-output-dir instead, to generate the source map

Repro Steps

This used to generate source map using --sourcemap-output without value:

git clone git@github.com:pass-culture/pass-culture-app-native.git
cd pass-culture-app-native
git checkout hotfix-production-v1.256.0-1
yarn appcenter codepush release-react --token $ANDROID_APPCENTER_API_TOKEN --deployment-name Production --app pass-Culture/passculture-prod-android --target-binary-version "1.256.0" --description "(PC-24621) fix(useSearchVenueOffers): fix sentry error (#5353)" --disable-duplicate-release-error --sourcemap-output --output-dir ./build
npx sentry-cli react-native appcenter pass-Culture/passculture-prod-android android ./build/CodePush   --deployment Production  --dist 10256000-android   --release-name  1.256.0-android+codepush:v76

Adding --sourcemap-output ./build/CodePush fail

Expected behavior

We expect --sourcemap-output to not break

Details

  1. Is there a particular beacon/command that you are having trouble with?
    • e.g. appcenter codepush release-react
  2. Which version of the App Center CLI are you using?
    • 2.14.0
  3. Which OS version did you experience the issue on?
    • Linux debian 5.8.0-0.bpo.2-amd64
  4. What command line/shell are you using?
    • bash 5.1.4
  5. What version of Node.js and NPM/Yarn are you using?
    • v18.7.0 / yarn 1.22.15
DmitriyKirakosyan commented 10 months ago

Hi @kopax-polyconseil, apologies for the delayed response.

You're right about --sourcemap-output now requiring a path to the source map. It will generate a source map provided the path is accurate. In your input, there seems to be a typo with a comma: ',./build/CodePush/index.android.bundle.map'. Please ensure all directories in the path are present.

As you've discerned, another option is to use the --sourcemap-output-dir argument.

Previously, appcenter-cli would produce a source map even without the --sourcemap-output parameter if --output-dir was defined. This was an unintended behavior, fixed in https://github.com/microsoft/appcenter-cli/pull/2099/.

Since you've found a solution, I'm closing this issue. Feel free to reach out with further queries.

DmitriyKirakosyan commented 10 months ago

@kopax-polyconseil , sorry for the confusion with , character. It was not your typo actually, but it is how appcenter-cli works. You specified the argument --sourcemap-output twice, so it thought it is an array :)

kopax-polyconseil commented 10 months ago

No I didn't, and it used to work, the only way arround we found was to use --sourcemap-output-dir. It use to work well with --sourcemap-output, this is a regression and the issue was due to the wrapping done here. I had no time to dig further, but I suggest you consider to reopen this :)

DmitriyKirakosyan commented 10 months ago

@kopax-polyconseil The reason it worked for you is that the --sourcemap-output option was effectively bypassed due to the lack of a specified value. Despite this, the sourcemap was still generated because of the presence of the --output-dir option. This, however, is not the intended behavior of these commands. To correctly generate the sourcemap, you should either use the --sourcemap-output-dir option or provide a specific path for the --sourcemap-output.