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