Skip to content

Commit 27e632a

Browse files
committed
Updated npm packages 2024-10-08
1 parent e3fe02c commit 27e632a

File tree

4 files changed

+1151
-1481
lines changed

4 files changed

+1151
-1481
lines changed

eng/scripts/update-npm-dependencies.ps1

Lines changed: 5 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ param (
99

1010
$ErrorActionPreference = "Stop"
1111

12-
$env:npm_config_cache = "$PWD/src/submodules/Node-Externals/cache"
13-
1412
Write-Host "Ensuring the repository is clean"
1513
if (-not $WhatIf) {
1614
git clean -xdff
@@ -21,12 +19,6 @@ if (-not $WhatIf) {
2119
Remove-Item .\package-lock.json
2220
}
2321

24-
if (-not $SkipClearCache -and -not $WhatIf) {
25-
Write-Host "Clearing the npm cache"
26-
Remove-Item -Recurse -Force "$PWD/src/submodules/Node-Externals/cache"
27-
New-Item -ItemType Directory -Path "$PWD/src/submodules/Node-Externals/cache"
28-
}
29-
3022
try {
3123
Get-Command vsts-npm-auth -CommandType ExternalScript
3224
Write-Host "vsts-npm-auth is already installed"
@@ -50,74 +42,17 @@ if (-not $WhatIf) {
5042
npm install --prefer-online --include optional
5143
}
5244

53-
Write-Host "Adding optional dependencies to the cache"
54-
$rollupOptionalDependencies = (Get-Content .\package-lock.json | ConvertFrom-Json -AsHashtable).packages['node_modules/rollup'].optionalDependencies |
55-
Select-Object '@rollup/rollup-*';
56-
$commonOptionalDependencyVersion = $null;
57-
58-
foreach ($optionalDependency in ($rollupOptionalDependencies | Get-Member -MemberType NoteProperty)) {
59-
$optionalDependencyName = $optionalDependency.Name
60-
$optionalDependencyVersion = $rollupOptionalDependencies.$optionalDependencyName
61-
62-
if ($null -eq $commonOptionalDependencyVersion) {
63-
$commonOptionalDependencyVersion = $optionalDependencyVersion
64-
}
65-
66-
Write-Host "Adding $optionalDependencyName@$optionalDependencyVersion to the cache"
67-
if (-not $WhatIf) {
68-
npm cache add $optionalDependencyName@$optionalDependencyVersion
69-
}
70-
}
71-
72-
if ($null -ne $commonOptionalDependencyVersion) {
73-
Write-Host "Adding @rollup/wasm-node@$commonOptionalDependencyVersion to the cache"
74-
if (-not $WhatIf) {
75-
npm cache add "@rollup/wasm-node@$commonOptionalDependencyVersion"
76-
}
77-
}
78-
79-
Write-Host "Verifying the cache"
80-
if(-not $WhatIf) {
81-
npm cache verify
82-
}
83-
84-
# Navigate to the Node-Externals submodule
85-
# Checkout a branch named infrastructure/update-npm-package-cache-<date>
86-
# Stage the changes in the folder
87-
# Commit the changes with the message "Updated npm package cache <date>"
88-
# Use the GH CLI to create a PR for the branch in the origin remote
89-
90-
Push-Location src/submodules/Node-Externals
91-
$branchName = "infrastructure/update-npm-package-cache-$(Get-Date -Format 'yyyy-MM-dd')"
92-
if (-not $WhatIf) {
93-
git branch -D $branchName 2>$null
94-
git checkout -b $branchName
95-
git add .
96-
git commit -m "Updated npm package cache $(Get-Date -Format 'yyyy-MM-dd')"
97-
}
98-
99-
if ($WhatIf -or $SkipPullRequestCreation) {
100-
Write-Host "Skipping pull request creation for Node-Externals submodule"
101-
}
102-
else {
103-
Write-Host "Creating pull request for Node-Externals submodule"
104-
git branch --set-upstream-to=origin/main
105-
git push origin $branchName`:$branchName --force;
106-
gh repo set-default dotnet/Node-Externals
107-
gh pr create --base main --head "infrastructure/update-npm-package-cache-$(Get-Date -Format 'yyyy-MM-dd')" --title "[Infrastructure] Updated npm package cache $(Get-Date -Format 'yyyy-MM-dd')" --body "Do not merge this PR until the one in aspnetcore passes all checks."
108-
}
109-
11045
## Navigate to the root of the repository
111-
## Checkout a branch named infrastructure/update-npm-package-cache-<date>
46+
## Checkout a branch named infrastructure/update-npm-packages-<date>
11247
## Stage the changes in the folder
113-
## Commit the changes with the message "Updated npm package cache <date>"
48+
## Commit the changes with the message "Updated npm packages <date>"
11449
## Use the GH CLI to create a PR for the branch in the origin remote
115-
Pop-Location
11650
if(-not $WhatIf) {
51+
$branchName = "infrastructure/update-npm-packages-$(Get-Date -Format 'yyyy-MM-dd')"
11752
git branch -D $branchName 2>$null
11853
git checkout -b $branchName
11954
git add .
120-
git commit -m "Updated npm package cache $(Get-Date -Format 'yyyy-MM-dd')"
55+
git commit -m "Updated npm packages $(Get-Date -Format 'yyyy-MM-dd')"
12156
}
12257

12358
if ($WhatIf -or $SkipPullRequestCreation) {
@@ -128,5 +63,5 @@ else {
12863
git branch --set-upstream-to=origin/main
12964
git push origin $branchName`:$branchName --force;
13065
gh repo set-default dotnet/aspnetcore
131-
gh pr create --base main --head $branchName --title "[Infrastructure] Updated npm package cache $(Get-Date -Format 'yyyy-MM-dd')" --body ""
66+
gh pr create --base main --head $branchName --title "[Infrastructure] Updated npm packages $(Get-Date -Format 'yyyy-MM-dd')" --body ""
13267
}

0 commit comments

Comments
 (0)