1
- # For local testing, you can pass branchName and/or buildVersion.
2
- # If both parameters are specified, only buildVersion will be used.
1
+ # For local testing, you can pass buildVersion.
3
2
# Example usage:
4
- # ./test-example.ps1 -branchName 23.1.3+
5
3
# ./test-example.ps1 -buildVersion 23.1.13
6
4
param (
7
- [string ]$branchName = [Environment ]::GetEnvironmentVariable(" BRANCH_NAME" , [EnvironmentVariableTarget ]::Machine),
8
- [string ]$buildVersion = [Environment ]::GetEnvironmentVariable(" BUILD_VERSION" , [EnvironmentVariableTarget ]::Machine)
5
+ [string ]$buildVersion = $Env: CodeCentralBuildVersion
9
6
)
10
7
11
- # Repository's branch name, e.g. 24.1.3+
12
- $global :BRANCH_NAME = $branchName
13
- # Masstest-specific parameter. Specifies the minor version (example: '21.1.5') !or daily build (example: '21.2.2005')
8
+ # Masstest-specific parameter. Specifies the minor version (example: '21.1.5')
14
9
$global :BUILD_VERSION = $buildVersion
15
10
16
11
$global :ERROR_CODE = 0
17
12
$global :FAILED_PROJECTS = @ ()
18
13
19
- $global :ALL_VERSIONS = @ (
20
- " 14.1" , " 14.2" ,
21
- " 15.1" , " 15.2" ,
22
- " 16.1" , " 16.2" ,
23
- " 17.1" , " 17.2" ,
24
- " 18.1" , " 18.2" ,
25
- " 19.1" , " 19.2" ,
26
- " 20.1" , " 20.2" ,
27
- " 21.1" , " 21.2" ,
28
- " 22.1" , " 22.2" ,
29
- " 23.1" , " 23.2" ,
30
- " 24.1" , " 24.2" ,
31
- " 25.1" , " 25.2"
32
- )
33
-
34
14
function Install-Packages {
35
15
param (
36
16
[string ]$folderName ,
37
17
[string []]$packages ,
38
18
[string ]$buildVersion
39
19
)
20
+
40
21
Write-Output " `n Installing packages in folder: $folderName "
41
-
42
- $packageList = $packages | ForEach-Object { " $_ @$buildVersion " }
43
- Write-Output " `n Packages to install: $ ( $packageList -join " , " ) "
44
- # TODO: Uninstall DevExtreme packages to avoid potential peer-dependency issues
45
- npm install @ ($packageList ) -- save -- save-exact -- no- fund
46
- if (-not $? ) {
47
- Write-Error " `n ERROR: Failed to install DevExtreme packages in $folderName "
48
- throw " Installation failed in $folderName "
22
+
23
+ # Loop through each package and install it individually
24
+ foreach ($package in $packages ) {
25
+ $packageWithVersion = " $package @$buildVersion "
26
+ Write-Output " Installing $packageWithVersion ..."
27
+
28
+ npm install -- save -- save-exact -- no- fund -- loglevel= error -- force $packageWithVersion
29
+ if (-not $? ) {
30
+ Write-Error " `n ERROR: Failed to install $packageWithVersion in $folderName "
31
+ throw " Installation failed for $packageWithVersion in $folderName "
32
+ }
49
33
}
34
+
35
+ Write-Output " `n All packages installed successfully in $folderName "
50
36
}
51
37
52
38
function Build-Project {
@@ -98,6 +84,9 @@ function Process-JavaScriptProjects {
98
84
Push-Location $folderName
99
85
100
86
try {
87
+ Write-Output " `n Removing node_modules & package-lock.json: $pwd "
88
+ Remove-Item - Recurse - Force node_modules - ErrorAction SilentlyContinue
89
+ Remove-Item - Force package- lock.json - ErrorAction SilentlyContinue
101
90
Install-Packages - folderName $folderName - packages $packages - buildVersion $buildVersion
102
91
Write-Output " `n Installing remaining packages in $folderName "
103
92
npm install -- save -- save-exact -- no- fund -- loglevel= error
@@ -155,71 +144,17 @@ function Process-DotNetProjects {
155
144
Write-Output " `n Completed .NET project processing."
156
145
}
157
146
158
- function Set-BuildVersion {
159
- Write-Output " `n --== Starting Set-BuildVersion process. ==--"
160
-
161
- $BUILD_VERSION = $global :BUILD_VERSION
162
- if ($BUILD_VERSION ) {
163
- Write-Output " BUILD_VERSION is already set: $BUILD_VERSION "
164
- return
165
- }
166
-
167
- $BUILD_VERSIONS_LIST = " BUILD_VERSIONS_LIST"
168
-
169
- $inputMajorMinor = $global :BRANCH_NAME -replace " \.\d+\+$" , " "
170
- Write-Output " Extracted major.minor version from branch name: $inputMajorMinor "
171
-
172
- $filteredList = $global :ALL_VERSIONS | Where-Object {
173
- ($_ -replace " \." -as [double ]) -ge ($inputMajorMinor -replace " \." -as [double ])
174
- }
175
- Write-Output " Filtered versions list: $filteredList "
176
-
177
- $currentValue = [Environment ]::GetEnvironmentVariable($BUILD_VERSIONS_LIST , [EnvironmentVariableTarget ]::Machine)
178
- $currentList = if ($currentValue ) {
179
- $currentValue -split " ;"
180
- } else {
181
- $filteredList
182
- }
183
- Write-Output " Current versions list: $currentList "
184
-
185
- if ($currentList.Count -gt 1 ) {
186
- $inputMajorMinor = $currentList [0 ]
187
- $updatedList = $currentList [1 .. ($currentList.Count - 1 )]
188
- } else {
189
- Write-Output " The list in the environment variable has only one item."
190
- $inputMajorMinor = $currentList [0 ]
191
- $updatedList = @ ()
192
- }
193
-
194
- $global :BUILD_VERSION = $inputMajorMinor
195
- Write-Output " BUILD_VERSION set to: $global :BUILD_VERSION "
196
-
197
- $newValue = $updatedList -join " ;"
198
- [Environment ]::SetEnvironmentVariable($BUILD_VERSIONS_LIST , $newValue , [EnvironmentVariableTarget ]::Machine)
199
-
200
- Write-Output " Environment variable '$BUILD_VERSIONS_LIST ' updated."
201
- Write-Output " New list: $updatedList "
202
- }
203
-
204
147
function Write-BuildInfo {
205
- $BRANCH_NAME = if ($global :BRANCH_NAME -ne $null -and $global :BRANCH_NAME -ne " " ) {
206
- $global :BRANCH_NAME
207
- } else {
208
- " (empty)"
209
- }
210
-
211
148
$BUILD_VERSION = if ($global :BUILD_VERSION -ne $null -and $global :BUILD_VERSION -ne " " ) {
212
149
$global :BUILD_VERSION
213
150
} else {
214
151
" (empty)"
215
152
}
216
153
217
- Write-Output " `n Branch Name: $BRANCH_NAME "
218
154
Write-Output " Build Version: $BUILD_VERSION "
219
155
}
220
156
221
157
Write-BuildInfo
222
- Set-BuildVersion
223
158
Process - JavaScriptProjects - buildVersion $global :BUILD_VERSION
224
159
Process - DotNetProjects
225
160
@@ -228,4 +163,4 @@ if ($global:ERROR_CODE -ne 0 -and $global:FAILED_PROJECTS.Count -gt 0) {
228
163
Write-Output " `FAILED PROJECTS: $ ( ($global :FAILED_PROJECTS -join " , " )) "
229
164
}
230
165
231
- [ System.Environment ]:: Exit ( $global :ERROR_CODE )
166
+ exit $global :ERROR_CODE
0 commit comments