Skip to content

Commit 58a49f1

Browse files
[Infrastructure] Updated npm packages 2024-10-08 (#58301) (#58469)
* Updates the script since we no longer user the package cache. * Renames the dotnet-runtime package to @microsoft/dotnet-runtime to avoid npm audit issues (someone squat over the package name). * Updates the npm dependencies. Co-authored-by: Javier Calvarro Nelson <jacalvar@microsoft.com>
1 parent 0aaece9 commit 58a49f1

File tree

12 files changed

+1161
-1463
lines changed

12 files changed

+1161
-1463
lines changed

eng/scripts/update-npm-dependencies.ps1

Lines changed: 6 additions & 43 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,6 +42,7 @@ if (-not $WhatIf) {
5042
npm install --prefer-online --include optional
5143
}
5244

45+
# Add optional dependencies to the cache to ensure that they get mirrored
5346
Write-Host "Adding optional dependencies to the cache"
5447
$rollupOptionalDependencies = (Get-Content .\package-lock.json | ConvertFrom-Json -AsHashtable).packages['node_modules/rollup'].optionalDependencies |
5548
Select-Object '@rollup/rollup-*';
@@ -76,48 +69,18 @@ if ($null -ne $commonOptionalDependencyVersion) {
7669
}
7770
}
7871

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-
}
10972

11073
## Navigate to the root of the repository
111-
## Checkout a branch named infrastructure/update-npm-package-cache-<date>
74+
## Checkout a branch named infrastructure/update-npm-packages-<date>
11275
## Stage the changes in the folder
113-
## Commit the changes with the message "Updated npm package cache <date>"
76+
## Commit the changes with the message "Updated npm packages <date>"
11477
## Use the GH CLI to create a PR for the branch in the origin remote
115-
Pop-Location
11678
if(-not $WhatIf) {
79+
$branchName = "infrastructure/update-npm-packages-$(Get-Date -Format 'yyyy-MM-dd')"
11780
git branch -D $branchName 2>$null
11881
git checkout -b $branchName
11982
git add .
120-
git commit -m "Updated npm package cache $(Get-Date -Format 'yyyy-MM-dd')"
83+
git commit -m "Updated npm packages $(Get-Date -Format 'yyyy-MM-dd')"
12184
}
12285

12386
if ($WhatIf -or $SkipPullRequestCreation) {
@@ -128,5 +91,5 @@ else {
12891
git branch --set-upstream-to=origin/main
12992
git push origin $branchName`:$branchName --force;
13093
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 ""
94+
gh pr create --base main --head $branchName --title "[Infrastructure] Updated npm packages $(Get-Date -Format 'yyyy-MM-dd')" --body ""
13295
}

0 commit comments

Comments
 (0)