From 97663e591115feff3a28e5427b369899048fc742 Mon Sep 17 00:00:00 2001 From: lucas Date: Tue, 22 Oct 2024 17:49:32 +0100 Subject: [PATCH 1/3] improve cordova setup --- lib/Steps/Integrations/Cordova.ts | 77 +++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 20 deletions(-) diff --git a/lib/Steps/Integrations/Cordova.ts b/lib/Steps/Integrations/Cordova.ts index 0ee82621..cba36e5c 100755 --- a/lib/Steps/Integrations/Cordova.ts +++ b/lib/Steps/Integrations/Cordova.ts @@ -190,31 +190,68 @@ export class Cordova extends BaseIntegration { shellPath: '/bin/sh', shellScript: // eslint-disable-next-line prefer-template + '#!/bin/bash\\n' + + '# print commands before executing them and stop on first error\\n' + + 'set -x -e\\n' + 'echo "warning: uploading debug symbols - set SENTRY_SKIP_DSYM_UPLOAD=true to skip this"\\n' + - 'if [ -n "$SENTRY_SKIP_DSYM_UPLOAD" ]; then\\n' + - ' echo "warning: skipping debug symbol upload"\\n' + - ' exit 0\\n' + - 'fi\\n' + - 'export SENTRY_PROPERTIES=' + - cwd + - '\\n' + - 'function getProperty {\\n' + - ' PROP_KEY=$1\\n' + - ' PROP_VALUE=`cat $SENTRY_PROPERTIES | grep "$PROP_KEY" | cut -d\'=\' -f2`\\n' + - ' if [ -z "$PROP_VALUE" ]; then\\n' + - ' echo "plugins/sentry-cordova/node_modules/@sentry/cli/bin/sentry-cli"\\n' + - ' else\\n' + - ' echo $PROP_VALUE\\n' + + '[ -z "$SENTRY_FORCE_FOREGROUND"] && SENTRY_FORCE_FOREGROUND=true\\n' + + '[[ "$SENTRY_FORCE_FOREGROUND" == true ]] && SENTRY_FORCE_FOREGROUND_FLAG="--force-foreground"\\n' + + 'get_node_command() {\\n' + + ' if [ -x "$(command -v ${NODE_BINARY})" ]; then\\n' + + ' echo "${NODE_BINARY}"\\n' + + ' return 0\\n' + + ' fi\\n' + + ' if [ -x "$(which node)" ]; then\\n' + + ' echo "node"\\n' + + ' return 0\\n' + + ' fi\\n' + + ' NVM_NODE_VERSIONS_DIR="$HOME/.nvm/versions/node"\\n' + + ' if [ -d "$NVM_NODE_VERSIONS_DIR" ] && [ "$(ls -A $NVM_NODE_VERSIONS_DIR)" ]; then\\n' + + ' HIGHEST_VERSION=$(ls -v "$NVM_NODE_VERSIONS_DIR" | tail -n 1)\\n' + + ' NODE_BINARY="$NVM_NODE_VERSIONS_DIR/$HIGHEST_VERSION/bin/node"\\n' + + ' if [ -x "$NODE_BINARY" ]; then\\n' + + ' echo "$NODE_BINARY"\\n' + + ' return 0\\n' + ' fi\\n' + + ' fi\\n' + + ' echo ""\\n' + + ' return 0\\n' + '}\\n' + - 'if [ ! -f $SENTRY_PROPERTIES ]; then\\n' + - ' echo "warning: SENTRY: sentry.properties file not found! Skipping symbol upload."\\n' + + 'LOCAL_NODE_BINARY=$(get_node_command)\\n' + + 'if [ -z "$LOCAL_NODE_BINARY" ]; then\\n' + + ' echo "warning: SENTRY: Node.js binary not found! Skipping symbol upload."\\n' + ' exit 0\\n' + + 'else\\n' + + ' echo "Using Node.js from ${LOCAL_NODE_BINARY}"\\n' + + 'fi\\n' + + 'if [ -z "$SENTRY_PROPERTIES" ]; then\\n' + + ' if [ -f "./sentry.properties" ]; then\\n' + + ' export SENTRY_PROPERTIES=sentry.properties\\n' + + ' elif [ -f "../../sentry.properties" ]; then\\n' + + ' export SENTRY_PROPERTIES=../../sentry.properties\\n' + + ' else\\n' + + ' echo "warning: SENTRY: sentry.properties file not found! Skipping symbol upload."\\n' + + ' exit 0\\n' + + ' fi\\n' + 'fi\\n' + - 'echo "# Reading property from $SENTRY_PROPERTIES"\\n' + - 'SENTRY_CLI=$(getProperty "cli.executable")\\n' + - 'SENTRY_COMMAND="../../$SENTRY_CLI upload-dsym"\\n' + - '$SENTRY_COMMAND', + 'echo "sentry properties found at : $(readlink -f ${SENTRY_PROPERTIES})"\\n' + + '[ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_PACKAGE_PATH=$("$LOCAL_NODE_BINARY" --print "require(\'path\').dirname(require.resolve(\'@sentry/cli/package.json\'))")\\n' + + '[ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_EXECUTABLE="${SENTRY_CLI_PACKAGE_PATH}/bin/sentry-cli"\\n' + + 'SENTRY_COMMAND="${SENTRY_CLI_EXECUTABLE} upload-dsym $SENTRY_FORCE_FOREGROUND_FLAG"\\n' + + 'if [ "$SENTRY_SKIP_DSYM_UPLOAD" != true ]; then\\n' + + ' set +x +e\\n' + + ' SENTRY_XCODE_COMMAND_OUTPUT=$(/bin/sh -c "$LOCAL_NODE_BINARY $SENTRY_COMMAND" 2>&1)\\n' + + ' if [ $? -eq 0 ]; then\\n' + + ' echo "$SENTRY_XCODE_COMMAND_OUTPUT"\\n' + + ' echo "$SENTRY_XCODE_COMMAND_OUTPUT" | awk \'{print "output: sentry-cli - " $0}\'\\n' + + ' else\\n' + + ' echo "error: sentry-cli - To disable debug symbols upload, set SENTRY_SKIP_DSYM_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true"\\n' + + ' echo "error: sentry-cli - $SENTRY_XCODE_COMMAND_OUTPUT"\\n' + + ' fi\\n' + + ' set -x -e\\n' + + 'else\\n' + + ' echo "SENTRY_SKIP_DSYM_UPLOAD=true, skipping debug symbols upload"\\n' + + 'fi' }, ); } From 93dd7eb4a465ead9c1bdd1312adeaf28940701f2 Mon Sep 17 00:00:00 2001 From: lucas Date: Tue, 22 Oct 2024 18:10:06 +0100 Subject: [PATCH 2/3] changelog and fix --- CHANGELOG.md | 5 +++++ lib/Steps/Integrations/Cordova.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a784814..fc903c78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +- fix(cordova): Don't fail to build if node isn't found. ([#694](https://github.com/getsentry/sentry-wizard/pull/694)) +- ref(cordova): Improved logs with Cordova integration and Sentry-CLI now runs in foregroung. ([#694](https://github.com/getsentry/sentry-wizard/pull/694)) + ## 3.34.2 - fix(nextjs): Don't ask for package manager twice (#690) diff --git a/lib/Steps/Integrations/Cordova.ts b/lib/Steps/Integrations/Cordova.ts index cba36e5c..75f5ec3a 100755 --- a/lib/Steps/Integrations/Cordova.ts +++ b/lib/Steps/Integrations/Cordova.ts @@ -251,7 +251,7 @@ export class Cordova extends BaseIntegration { ' set -x -e\\n' + 'else\\n' + ' echo "SENTRY_SKIP_DSYM_UPLOAD=true, skipping debug symbols upload"\\n' + - 'fi' + 'fi', }, ); } From 51a9cc28b1353259436c94a073363cadbcd7b020 Mon Sep 17 00:00:00 2001 From: lucas Date: Tue, 22 Oct 2024 18:14:45 +0100 Subject: [PATCH 3/3] remove unused field --- lib/Steps/Integrations/Cordova.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Steps/Integrations/Cordova.ts b/lib/Steps/Integrations/Cordova.ts index 75f5ec3a..42fe1e57 100755 --- a/lib/Steps/Integrations/Cordova.ts +++ b/lib/Steps/Integrations/Cordova.ts @@ -180,7 +180,7 @@ export class Cordova extends BaseIntegration { return; } } - const cwd = path.join(process.cwd(), 'sentry.properties'); + path.join(process.cwd(), 'sentry.properties'); proj.addBuildPhase( [], 'PBXShellScriptBuildPhase',