@@ -44,21 +44,17 @@ Write-Host "UpgradeSmokeTest -RnwVersion $RnwVersion"
44
44
45
45
[string ]$LocalRnwVersion = $null
46
46
47
- Write-Host " Determining local react-native-windows version from yarn.lock..."
48
- if (Test-Path " yarn.lock" ) {
49
- [bool ]$lineFound = $False
50
- foreach ($line in Get-Content " yarn.lock" ) {
51
- if ($lineFound ) {
52
- $LocalRnwVersion = $line.Substring ($line.IndexOf (" "" " )).Trim(" "" " )
47
+ Write-Host " Determining local react-native-windows version from yarn why"
48
+
49
+ $yarnWhy = & yarn why react- native- windows
50
+ foreach ($line in $yarnWhy ) {
51
+ if ($line.StartsWith (" => Found" )) {
52
+ $LocalRnwVersion = $line.Substring ($line.IndexOf (" @" )+1 ).Trim(" "" " )
53
+ break ;
54
+ } elseif ($line.Contains (" react-native-windows@npm:" )) {
55
+ $LocalRnwVersion = $line.Substring ($line.IndexOf (" :" )+1 ).Split(' ' )[0 ]
53
56
break ;
54
57
}
55
- if ($line.StartsWith (" react-native-windows" )) {
56
- $lineFound = $True ;
57
- }
58
- }
59
- } else {
60
- Write-Host " Exiting, yarn.lock not found."
61
- exit 1
62
58
}
63
59
64
60
if ($LocalRnwVersion -eq $null ) {
@@ -93,33 +89,38 @@ if ($Force) {
93
89
Write-Host " Starting upgrade..."
94
90
}
95
91
96
- [string ]$ReactVersion = npm info react- native- windows@$RnwVersion devDependencies.react
97
- Write-Host " RNW $RnwVersion depends on react@$ReactVersion "
92
+ [string ]$ReactVersion = npm info react- native- windows@$TargetRnwVersion devDependencies.react
93
+ Write-Host " RNW $TargetRnwVersion depends on react@$ReactVersion "
98
94
99
- [string ]$ReactNativeVersion = npm info react- native- windows@$RnwVersion devDependencies.react- native
100
- Write-Host " RNW $RnwVersion depends on react-native@$ReactNativeVersion "
95
+ [string ]$ReactNativeVersion = npm info react- native- windows@$TargetRnwVersion devDependencies.react- native
96
+ Write-Host " RNW $TargetRnwVersion depends on react-native@$ReactNativeVersion "
97
+
98
+ $yarnUpgradeCmd = " upgrade"
99
+ if (Test-Path " .yarn" ) {
100
+ $yarnUpgradeCmd = " up"
101
+ }
101
102
102
103
Write-Host " Upgrading to react@$ReactVersion ..."
103
- yarn.cmd upgrade react@$ReactVersion
104
+ yarn $yarnUpgradeCmd react@$ReactVersion
104
105
105
106
if ($LastExitCode -ne 0 ) {
106
107
Write-Error " Failed to upgrade to react @$ReactVersion "
107
108
exit $LastExitCode
108
109
}
109
110
110
111
Write-Host " Upgrading to react-native@$ReactNativeVersion ..."
111
- yarn.cmd upgrade react- native@$ReactNativeVersion
112
+ yarn $yarnUpgradeCmd react- native@$ReactNativeVersion
112
113
113
114
if ($LastExitCode -ne 0 ) {
114
115
Write-Error " Failed to upgrade to react-native@$ReactNativeVersion "
115
116
exit $LastExitCode
116
117
}
117
118
118
- Write-Host " Upgrading to react-native-windows@$RnwVersion ..."
119
- yarn.cmd upgrade react- native- windows@$RnwVersion
119
+ Write-Host " Upgrading to react-native-windows@$TargetRnwVersion ..."
120
+ yarn $yarnUpgradeCmd react- native- windows@$TargetRnwVersion
120
121
121
122
if ($LastExitCode -ne 0 ) {
122
- Write-Error " Failed to upgrade to react-native-windows@$RnwVersion "
123
+ Write-Error " Failed to upgrade to react-native-windows@$TargetRnwVersion "
123
124
exit $LastExitCode
124
125
}
125
126
0 commit comments