Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/
always-auth=true
60 changes: 60 additions & 0 deletions scripts/UpdateNpmDependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This script needs to be run on PowerShell 7+ (for ConvertFrom-Json) in the directory of the project

param (
[switch]$WhatIf
)

$ErrorActionPreference = "Stop"

if (-not (Test-Path .\package.json)) {
Write-Error "package.json not found in the current directory. Please run this script in the directory of the project."
exit 1
}

try {
Get-Command artifacts-npm-credprovider | Out-Null
Write-Host "artifacts-npm-credprovider is already installed"
}
catch {
Write-Host "Installing artifacts-npm-credprovider"
if (-not $WhatIf) {
npm install -g @microsoft/artifacts-npm-credprovider --registry https://pkgs.dev.azure.com/artifacts-public/23934c1b-a3b5-4b70-9dd3-d1bef4cc72a0/_packaging/AzureArtifacts/npm/registry/
}
}

Write-Host "Provisioning a token for the NPM registry. You might be prompted to authenticate."
if (-not $WhatIf) {
# This command provisions a token for the AzDO NPM registry to run npm install and ensure any missing package is mirrored.
artifacts-npm-credprovider -f -c .\.npmrc
}

Write-Host "Running npm install"
if (-not $WhatIf) {
npm install --prefer-online --include optional
}

# Add optional dependencies to the cache to ensure that they get mirrored
Write-Host "Adding optional dependencies to the cache"
$packages = (Get-Content .\package-lock.json | ConvertFrom-Json -AsHashtable).packages

$allOptionalDependencies = @()
foreach ($packagePath in $packages.Keys) {
$package = $packages[$packagePath]
if ($null -eq $package.optionalDependencies) {
continue
}

$optionalDependencies = $package.optionalDependencies
foreach ($optionalDependencyName in $optionalDependencies.Keys) {
$optionalDependencyVersion = $optionalDependencies[$optionalDependencyName]
$allOptionalDependencies += "$optionalDependencyName@$optionalDependencyVersion"
}
}

if ($allOptionalDependencies.Count -gt 0) {
Write-Host "Found $($allOptionalDependencies.Count) optional dependencies:"
$allOptionalDependencies | ForEach-Object { Write-Host " $_" }
if (-not $WhatIf) {
npm cache add @allOptionalDependencies
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Target Name="NpmInstall"
Inputs="$(_TypescriptRootPath)\package.json"
Outputs="$(_NpmInstallStampFile)">
<Exec Command="npm install" WorkingDirectory="$(_TypescriptRootPath)" />
<Exec Command="npm ci" WorkingDirectory="$(_TypescriptRootPath)" />
<Touch Files="$(_NpmInstallStampFile)" AlwaysCreate="true" />
</Target>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
override.json
package-lock.json
VSIXPackageVersion.json
LICENSE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Write-Host "Using version $PackageVersion"

# Write-Information "Building Report Publishing task"
Set-Location $PSScriptRoot/tasks/PublishAIEvaluationReport
npm install --omit=dev
npm ci --omit=dev
# Copy task files to dist folder
New-Item -ItemType Directory -Path ./dist -Force
copy-item -Path ./task.json -Destination ./dist/ -Force
Expand All @@ -39,7 +39,7 @@ remove-item -Path ./dist/node_modules/resolve/test -Recurse -Force -ErrorAction

# Write-Information "Building Extension Package"
Set-Location $PSScriptRoot
npm install
npm ci
npx tsc -b
npx vite build

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/
Loading
Loading