Skip to content

Commit 2c1d884

Browse files
azure-sdkhallipr
andauthored
Use emitter-package-lock.json and @Local feed view (Azure#38325)
Co-authored-by: Patrick Hallisey <pahallis@microsoft.com>
1 parent 15eaba8 commit 2c1d884

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

eng/common/scripts/TypeSpec-Project-Generate.ps1

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,36 @@ function NpmInstallForProject([string]$workingDirectory) {
4646
Write-Host("Copying package.json from $replacementPackageJson")
4747
Copy-Item -Path $replacementPackageJson -Destination "package.json" -Force
4848

49+
#default to root/eng/emitter-package-lock.json but you can override by writing
50+
#Get-${Language}-EmitterPackageLockPath in your Language-Settings.ps1
51+
$emitterPackageLock = Join-Path $PSScriptRoot "../../emitter-package-lock.json"
52+
if (Test-Path "Function:$GetEmitterPackageLockPathFn") {
53+
$emitterPackageLock = &$GetEmitterPackageLockPathFn
54+
}
55+
56+
$usingLockFile = Test-Path $emitterPackageLock
57+
58+
if ($usingLockFile) {
59+
Write-Host("Copying package-lock.json from $emitterPackageLock")
60+
Copy-Item -Path $emitterPackageLock -Destination "package-lock.json" -Force
61+
}
62+
4963
$useAlphaNpmRegistry = (Get-Content $replacementPackageJson -Raw).Contains("-alpha.")
5064

5165
if($useAlphaNpmRegistry) {
5266
Write-Host "Package.json contains '-alpha.' in the version, Creating .npmrc using public/azure-sdk-for-js-test-autorest feed."
53-
"registry=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest/npm/registry/ `n`nalways-auth=true" | Out-File '.npmrc'
67+
"registry=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest@local/npm/registry/ `n`nalways-auth=true" | Out-File '.npmrc'
68+
}
69+
70+
if ($usingLockFile) {
71+
Write-Host "> npm ci"
72+
npm ci
73+
}
74+
else {
75+
Write-Host "> npm install"
76+
npm install
5477
}
5578

56-
npm install --no-lock-file
5779
if ($LASTEXITCODE) { exit $LASTEXITCODE }
5880
}
5981
finally {

eng/common/scripts/common.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ $GetRepositoryLinkFn = "Get-${Language}-RepositoryLink"
6161
$GetEmitterAdditionalOptionsFn = "Get-${Language}-EmitterAdditionalOptions"
6262
$GetEmitterNameFn = "Get-${Language}-EmitterName"
6363
$GetEmitterPackageJsonPathFn = "Get-${Language}-EmitterPackageJsonPath"
64+
$GetEmitterPackageLockPathFn = "Get-${Language}-EmitterPackageLockPath"
6465

6566
# Expected to be set in eng/scripts/docs/Docs-Onboarding.ps1
6667
$SetDocsPackageOnboarding = "Set-${Language}-DocsPackageOnboarding"

0 commit comments

Comments
 (0)