Skip to content

Commit 04af1cc

Browse files
committed
Use one constant for version string
1 parent d18ddb1 commit 04af1cc

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

packages/core/plugin/src/withSentryAndroidGradlePlugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export interface SentryAndroidGradlePluginOptions {
1313
includeSourceContext?: boolean;
1414
}
1515

16+
export const sentryAndroidGradlePluginVersion = '4.14.1';
17+
1618
/**
1719
* Adds the Sentry Android Gradle Plugin to the project.
1820
* https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#enable-sentry-agp
@@ -29,8 +31,6 @@ export function withSentryAndroidGradlePlugin(
2931
includeSourceContext = false,
3032
}: SentryAndroidGradlePluginOptions = {},
3133
): any {
32-
const version = '4.14.1';
33-
3434
// Modify android/build.gradle
3535
const withSentryProjectBuildGradle = (config: any): any => {
3636
return withProjectBuildGradle(config, (projectBuildGradle: any) => {
@@ -45,7 +45,7 @@ export function withSentryAndroidGradlePlugin(
4545
return config;
4646
}
4747

48-
const dependency = `classpath("io.sentry:sentry-android-gradle-plugin:${version}")`;
48+
const dependency = `classpath("io.sentry:sentry-android-gradle-plugin:${sentryAndroidGradlePluginVersion}")`;
4949

5050
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5151
if (projectBuildGradle.modResults.contents.includes(dependency)) {

packages/core/test/expo-plugin/withSentryAndroidGradlePlugin.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { withAppBuildGradle, withProjectBuildGradle } from '@expo/config-plugins
22

33
import { warnOnce } from '../../plugin/src/utils';
44
import type { SentryAndroidGradlePluginOptions } from '../../plugin/src/withSentryAndroidGradlePlugin';
5-
import { withSentryAndroidGradlePlugin } from '../../plugin/src/withSentryAndroidGradlePlugin';
5+
import {
6+
sentryAndroidGradlePluginVersion,
7+
withSentryAndroidGradlePlugin,
8+
} from '../../plugin/src/withSentryAndroidGradlePlugin';
69

710
jest.mock('@expo/config-plugins', () => ({
811
withProjectBuildGradle: jest.fn(),
@@ -43,7 +46,6 @@ describe('withSentryAndroidGradlePlugin', () => {
4346
});
4447

4548
it('adds the Sentry plugin to build.gradle when enableAndroidGradlePlugin is enabled', () => {
46-
const version = '4.14.1';
4749
const options: SentryAndroidGradlePluginOptions = { enableAndroidGradlePlugin: true };
4850

4951
(withProjectBuildGradle as jest.Mock).mockImplementation((config, callback) => {
@@ -65,13 +67,12 @@ describe('withSentryAndroidGradlePlugin', () => {
6567
});
6668

6769
expect(modifiedGradle.modResults.contents).toContain(
68-
`classpath("io.sentry:sentry-android-gradle-plugin:${version}")`,
70+
`classpath("io.sentry:sentry-android-gradle-plugin:${sentryAndroidGradlePluginVersion}")`,
6971
);
7072
});
7173

7274
it('warnOnce if the Sentry plugin is already included in build.gradle', () => {
73-
const version = '4.14.1';
74-
const includedBuildGradle = `dependencies { classpath("io.sentry:sentry-android-gradle-plugin:${version}")}`;
75+
const includedBuildGradle = `dependencies { classpath("io.sentry:sentry-android-gradle-plugin:${sentryAndroidGradlePluginVersion}")}`;
7576
const options: SentryAndroidGradlePluginOptions = { enableAndroidGradlePlugin: true };
7677

7778
(withProjectBuildGradle as jest.Mock).mockImplementation((config, callback) => {

0 commit comments

Comments
 (0)