Skip to content

Commit b196a28

Browse files
fix Android pnpm
1 parent 1a14c8b commit b196a28

2 files changed

Lines changed: 29 additions & 6 deletions

File tree

packages/core/sentry.gradle

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,7 @@ project.afterEvaluate {
167167
project.logger.info("file not found '$propertiesFile' for '$variant'")
168168
}
169169

170-
def resolvedCliPackage = null
171-
try {
172-
resolvedCliPackage = new File(["node", "--print", "require.resolve('@sentry/cli/package.json')"].execute(null, rootDir).text.trim()).getParentFile();
173-
} catch (Throwable ignored) {}
174-
def cliPackage = resolvedCliPackage != null && resolvedCliPackage.exists() ? resolvedCliPackage.getAbsolutePath() : "$reactRoot/node_modules/@sentry/cli"
170+
def cliPackage = resolveSentryCliPackagePath(reactRoot)
175171
def cliExecutable = sentryProps.get("cli.executable", "$cliPackage/bin/sentry-cli")
176172

177173
// fix path separator for Windows
@@ -306,6 +302,32 @@ def resolveSentryReactNativeSDKPath(reactRoot) {
306302
return sentryPackage
307303
}
308304

305+
def resolveSentryCliPackagePath(reactRoot) {
306+
def resolvedCliPath = null
307+
try {
308+
def file = new File(["node", "--print", "require.resolve('@sentry/cli/package.json')"].execute(null, rootDir))
309+
resolvedCliPath = file.text.trim().getParentFile();
310+
} catch (Throwable ignored) { // Check if it's located in .pnpm
311+
try {
312+
def pnpmRefPath = reactRoot.toString() + "/node_modules/@sentry/react-native/node_modules/.bin/sentry-cli"
313+
def sentryCliFile = new File(pnpmRefPath)
314+
315+
if (sentryCliFile.exists()) {
316+
def cliFileText = sentryCliFile.text
317+
def matcher = cliFileText =~ /NODE_PATH="([^"]*?)@sentry\/cli\//
318+
319+
if (matcher.find()) {
320+
def match = matcher.group(1)
321+
resolvedCliPath = new File(match + "@sentry/cli")
322+
}
323+
}
324+
} catch (Throwable ignored2) {} // if the resolve fails we fallback to the default path
325+
}
326+
327+
def cliPackage = resolvedCliPath != null && resolvedCliPath.exists() ? resolvedCliPath.getAbsolutePath() : "$reactRoot/node_modules/@sentry/cli"
328+
return cliPackage
329+
}
330+
309331
/** Compose lookup map of build variants - to - outputs. */
310332
def extractReleasesInfo() {
311333
def releases = [:]

samples/react-native/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,6 @@
8585
"android": {
8686
"javaPackageName": "com.facebook.fbreact.specs"
8787
}
88-
}
88+
},
89+
"packageManager": "pnpm@10.12.4+sha512.5ea8b0deed94ed68691c9bad4c955492705c5eeb8a87ef86bc62c74a26b037b08ff9570f108b2e4dbd1dd1a9186fea925e527f141c648e85af45631074680184"
8990
}

0 commit comments

Comments
 (0)