Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/setnpmreg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function createNpmrcFile {
[Parameter(Mandatory = $true)][string]$registry
)
Write-Host "Creating .npmrc file with registry=$registry" -ForegroundColor Blue
New-Item -Path . -Name ".npmrc" -ItemType "file" -Value "registry=$registry" -Force
New-Item -Path . -Name .npmrc -ItemType File -Value "registry=$registry`n" -Force
}

try {
Expand All @@ -19,6 +19,7 @@ try {
if ($response.StatusCode -eq 200) {
Write-Host "adsk npm registry is reachable" -ForegroundColor Green
createNpmrcFile -registry $adskNpmRegistry
Write-Output "//npm.autodesk.com/artifactory/api/npm/:_authToken=\`${NPM_TOKEN}" | Out-File -Append -FilePath .npmrc
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The authentication token is being written to the .npmrc file without validation that the NPM_TOKEN environment variable exists. This could result in a malformed .npmrc file with 'undefined' or empty token values. Consider adding a check to ensure NPM_TOKEN is set before writing the auth configuration.

Suggested change
Write-Output "//npm.autodesk.com/artifactory/api/npm/:_authToken=\`${NPM_TOKEN}" | Out-File -Append -FilePath .npmrc
if (-not $env:NPM_TOKEN) {
Write-Host "ERROR: NPM_TOKEN environment variable is not set. Cannot write authentication token to .npmrc." -ForegroundColor Red
exit 1
}
Write-Output "//npm.autodesk.com/artifactory/api/npm/:_authToken=${env:NPM_TOKEN}" | Out-File -Append -FilePath .npmrc

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious where is the NPM_TOKEN is set?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@avidit avidit Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can set NPM_TOKEN env variable in CI environment. In dev machines we would need to do npm login --registry https://npm.autodesk.com/artifactory/api/npm/autodesk-npm-virtual --auth-type web. I am still waiting for the next test window to verify this.

Copy link
Contributor

@zeusongit zeusongit Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A testing window has been scheduled for October 23 - 24 @avidit

}
else {
Write-Host "adsk npm registry is not reachable" -ForegroundColor Red
Expand Down
Loading