@@ -6,8 +6,8 @@ const { argv } = require('process');
6
6
const xcode = require ( 'xcode' ) ;
7
7
const parseArgs = require ( 'minimist' ) ;
8
8
const semver = require ( 'semver' ) ;
9
- const { logger } = require ( '@sentry/core' ) ;
10
- logger . enable ( ) ;
9
+ const { debug } = require ( '@sentry/core' ) ;
10
+ debug . enable ( ) ;
11
11
12
12
const args = parseArgs ( argv . slice ( 2 ) ) ;
13
13
if ( ! args . project ) {
@@ -17,7 +17,7 @@ if (!args['rn-version']) {
17
17
throw new Error ( 'Missing --rn-version' ) ;
18
18
}
19
19
20
- logger . info ( 'Patching Xcode project' , args . project , 'for RN version' , args [ 'rn-version' ] ) ;
20
+ debug . log ( 'Patching Xcode project' , args . project , 'for RN version' , args [ 'rn-version' ] ) ;
21
21
22
22
const newBundleScriptRNVersion = '0.69.0-rc.0' ;
23
23
@@ -29,15 +29,15 @@ const symbolsScript = `
29
29
` ;
30
30
const symbolsPatchRegex = / s e n t r y - c l i \s + ( u p l o a d - d s y m | d e b u g - f i l e s u p l o a d ) / ;
31
31
if ( semver . satisfies ( args [ 'rn-version' ] , `< ${ newBundleScriptRNVersion } ` , { includePrerelease : true } ) ) {
32
- logger . info ( 'Applying old bundle script patch' ) ;
32
+ debug . log ( 'Applying old bundle script patch' ) ;
33
33
bundleScript = `
34
34
export NODE_BINARY=node
35
35
../node_modules/@sentry/react-native/scripts/sentry-xcode.sh ../node_modules/react-native/scripts/react-native-xcode.sh
36
36
` ;
37
37
bundleScriptRegex = / ( p a c k a g e r | s c r i p t s ) \/ r e a c t - n a t i v e - x c o d e \. s h \b / ;
38
38
bundlePatchRegex = / s e n t r y - c l i \s + r e a c t - n a t i v e [ \s - ] x c o d e / ;
39
39
} else if ( semver . satisfies ( args [ 'rn-version' ] , `>= ${ newBundleScriptRNVersion } ` , { includePrerelease : true } ) ) {
40
- logger . info ( 'Applying new bundle script patch' ) ;
40
+ debug . log ( 'Applying new bundle script patch' ) ;
41
41
bundleScript = `
42
42
WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
43
43
REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"
@@ -62,38 +62,32 @@ for (const key in buildPhasesRaw) {
62
62
}
63
63
}
64
64
65
- buildPhases . forEach ( ( phase ) => {
65
+ buildPhases . forEach ( phase => {
66
66
const isBundleReactNative = phase . shellScript . match ( bundleScriptRegex ) ;
67
67
const isPatched = phase . shellScript . match ( bundlePatchRegex ) ;
68
68
if ( ! isBundleReactNative ) {
69
69
return ;
70
70
}
71
71
if ( isPatched ) {
72
- logger . warn ( 'Xcode project Bundle RN Build phase already patched' ) ;
72
+ debug . warn ( 'Xcode project Bundle RN Build phase already patched' ) ;
73
73
return ;
74
74
}
75
75
phase . shellScript = JSON . stringify ( bundleScript ) ;
76
- logger . info ( 'Patched Xcode project Bundle RN Build phase' ) ;
76
+ debug . log ( 'Patched Xcode project Bundle RN Build phase' ) ;
77
77
} ) ;
78
78
79
- const isSymbolsPhase = ( phase ) => phase . shellScript . match ( symbolsPatchRegex ) ;
79
+ const isSymbolsPhase = phase => phase . shellScript . match ( symbolsPatchRegex ) ;
80
80
const areSymbolsPatched = buildPhases . some ( isSymbolsPhase ) ;
81
81
82
82
if ( ! areSymbolsPatched ) {
83
- project . addBuildPhase (
84
- [ ] ,
85
- 'PBXShellScriptBuildPhase' ,
86
- 'Upload Debug Symbols to Sentry' ,
87
- null ,
88
- {
89
- shellPath : '/bin/sh' ,
90
- shellScript : symbolsScript ,
91
- } ,
92
- ) ;
93
- logger . info ( 'Added Xcode project Upload Debug Symbols Build phase' ) ;
83
+ project . addBuildPhase ( [ ] , 'PBXShellScriptBuildPhase' , 'Upload Debug Symbols to Sentry' , null , {
84
+ shellPath : '/bin/sh' ,
85
+ shellScript : symbolsScript ,
86
+ } ) ;
87
+ debug . log ( 'Added Xcode project Upload Debug Symbols Build phase' ) ;
94
88
} else {
95
- logger . warn ( 'Xcode project Upload Debug Symbols Build phase already patched' ) ;
89
+ debug . warn ( 'Xcode project Upload Debug Symbols Build phase already patched' ) ;
96
90
}
97
91
98
92
fs . writeFileSync ( args . project , project . writeSync ( ) ) ;
99
- logger . info ( 'Patched Xcode project successfully!' ) ;
93
+ debug . log ( 'Patched Xcode project successfully!' ) ;
0 commit comments