Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update native dependency install to install msal-node-extensions #14343

Merged
3 commits merged into from
Mar 17, 2021
Merged
Changes from 1 commit
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
52 changes: 39 additions & 13 deletions eng/pipelines/templates/steps/use-node-test-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,48 @@ steps:

# Packages with native dependencies must be reinstalled after changing Node versions
- pwsh: |
$KeytarSymlinkPath = "common/temp/node_modules/.pnpm/node_modules/keytar"
$nativeDependencySymlinkPaths = "common/temp/node_modules/.pnpm/node_modules/keytar,common/temp/node_modules/.pnpm/node_modules/@azure/msal-node-extensions"
$currentLocation = Get-Location
$dependencySynlinks = $nativeDependencySymlinkPaths.Split(",")
praveenkuttappan marked this conversation as resolved.
Show resolved Hide resolved

# Map from the symlink path to the target path (npm has issues installing into symlink dirs)
# Example: common/temp/node_modules/.pnpm/keytar@5.6.0/node_modules/keytar
$KeytarTargetPath = (Get-Item $KeytarSymlinkPath).Target
foreach ($symlink in $dependencySynlinks)
{
Write-Host "Reinstalling native dependency $($symlink)"

# Need to run "npm install" at path containing "node_modules" folder
# Example: common/temp/node_modules/.pnpm/keytar@5.6.0
$KeytarInstallPath = Join-Path $KeytarTargetPath "../.."
# Map from the symlink path to the target path (npm has issues installing into symlink dirs)
# Example: common/temp/node_modules/.pnpm/keytar@5.6.0/node_modules/keytar
$targetPath = (Get-Item $symlink).Target

# <pkg>@<version> is the leaf node of the path
# Example: keytar@5.6.0
$KeytarPackageAtVersion = Split-Path -Leaf $KeytarInstallPath
# Need to run "npm install" at path containing "node_modules" folder
# Example: common/temp/node_modules/.pnpm/keytar@5.6.0
$packageInstallPath = Join-Path $targetPath "../.."

Set-Location $KeytarInstallPath
# <pkg>@<version> is the leaf node of the path
# Example: keytar@5.6.0
# Move one more level up if package has org name
# for e.g. node_modules\.pnpm\@azure\msal-node-extensions@1.0.0-alpha.6\node_modules\@azure\msal-node-extensions
if ((Split-Path -Leaf $packageInstallPath) -eq "node_modules") {
$packageInstallPath = Join-Path $packageInstallPath ".."
}

$packageAtVersion = Split-Path -Leaf $packageInstallPath

# Check if package has org name. for e.g @azure/msal-node-enxtensions
# This returns either @azure or .pnpm( if no org is present)
$packageParentName = Split-path -Leaf (Split-Path -Parent -Resolve $packageInstallPath)
if ($packageParentName.StartsWith("@"))
{
# Include org name in package name to install
$packageAtVersion = $packageParentName + "/" + $packageAtVersion
}

Set-Location $packageInstallPath

Write-Host "Installing $($packageAtVersion)"
# Install matching version of package
npm install --no-package-lock $packageAtVersion

Set-Location $currentLocation
}

# Install matching version of package
npm install --no-package-lock $KeytarPackageAtVersion
displayName: Reinstall native dependencies