Skip to content

Commit 8fe6f3e

Browse files
authored
Allow custom npm registries at build time (microsoft#163629)
* use azure artifacts as new terrapin solution * debug * skip npm auth * bring back * also configure yarn * custom npm registry * oops * powershell * use none instead of empty string * uff
1 parent bece5db commit 8fe6f3e

16 files changed

+494
-320
lines changed

build/azure-pipelines/darwin/product-build-darwin-cli-sign.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,25 @@ steps:
1818

1919
- script: |
2020
set -e
21-
npm install https://aka.ms/enablesecurefeed --global && npm exec terrapinadotask -- standAlone
22-
timeoutInMinutes: 5
23-
retryCountOnTaskFailure: 3
24-
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['ENABLE_TERRAPIN'], 'true'))
25-
displayName: Switch to Terrapin packages
21+
npm config set registry "$NPM_REGISTRY" --location=project
22+
npm config set always-auth=true --location=project
23+
yarn config set registry "$NPM_REGISTRY"
24+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
25+
displayName: Setup NPM & Yarn
26+
27+
- task: npmAuthenticate@0
28+
inputs:
29+
workingFile: .npmrc
30+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
31+
displayName: Setup NPM Authentication
32+
33+
- script: node build/setup-npm-registry.js $NPM_REGISTRY
34+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
35+
displayName: Setup NPM Registry
2636

2737
- script: |
2838
set -e
29-
for i in {1..3}; do # try 3 times, for Terrapin
39+
for i in {1..3}; do # try 3 times
3040
yarn --cwd build --frozen-lockfile --check-files && break
3141
if [ $i -eq 3 ]; then
3242
echo "Yarn failed too many times" >&2

build/azure-pipelines/darwin/product-build-darwin-sign.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ steps:
3737
3838
- script: |
3939
mkdir -p .build
40-
node build/azure-pipelines/common/computeNodeModulesCacheKey.js x64 $ENABLE_TERRAPIN > .build/yarnlockhash
40+
node build/azure-pipelines/common/computeNodeModulesCacheKey.js x64 $NPM_REGISTRY > .build/yarnlockhash
4141
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
4242
displayName: Prepare yarn cache flags
4343
@@ -69,18 +69,28 @@ steps:
6969
7070
- script: |
7171
set -e
72-
npm install https://aka.ms/enablesecurefeed --global && npm exec terrapinadotask -- standAlone
73-
timeoutInMinutes: 5
74-
retryCountOnTaskFailure: 3
75-
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['ENABLE_TERRAPIN'], 'true'))
76-
displayName: Switch to Terrapin packages
72+
npm config set registry "$NPM_REGISTRY" --location=project
73+
npm config set always-auth=true --location=project
74+
yarn config set registry "$NPM_REGISTRY"
75+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
76+
displayName: Setup NPM & Yarn
77+
78+
- task: npmAuthenticate@0
79+
inputs:
80+
workingFile: .npmrc
81+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
82+
displayName: Setup NPM Authentication
83+
84+
- script: node build/setup-npm-registry.js $NPM_REGISTRY
85+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
86+
displayName: Setup NPM Registry
7787

7888
- script: |
7989
set -e
8090
export npm_config_arch=$(VSCODE_ARCH)
8191
export npm_config_node_gyp=$(which node-gyp)
8292
83-
for i in {1..3}; do # try 3 times, for Terrapin
93+
for i in {1..3}; do # try 3 times
8494
yarn --frozen-lockfile --check-files && break
8595
if [ $i -eq 3 ]; then
8696
echo "Yarn failed too many times" >&2

build/azure-pipelines/darwin/product-build-darwin-universal.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ steps:
3737
3838
- script: |
3939
mkdir -p .build
40-
node build/azure-pipelines/common/computeNodeModulesCacheKey.js x64 $ENABLE_TERRAPIN > .build/yarnlockhash
40+
node build/azure-pipelines/common/computeNodeModulesCacheKey.js x64 $NPM_REGISTRY > .build/yarnlockhash
4141
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
4242
displayName: Prepare yarn cache flags
4343
@@ -69,18 +69,28 @@ steps:
6969
7070
- script: |
7171
set -e
72-
npm install https://aka.ms/enablesecurefeed --global && npm exec terrapinadotask -- standAlone
73-
timeoutInMinutes: 5
74-
retryCountOnTaskFailure: 3
75-
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['ENABLE_TERRAPIN'], 'true'))
76-
displayName: Switch to Terrapin packages
72+
npm config set registry "$NPM_REGISTRY" --location=project
73+
npm config set always-auth=true --location=project
74+
yarn config set registry "$NPM_REGISTRY"
75+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
76+
displayName: Setup NPM & Yarn
77+
78+
- task: npmAuthenticate@0
79+
inputs:
80+
workingFile: .npmrc
81+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
82+
displayName: Setup NPM Authentication
83+
84+
- script: node build/setup-npm-registry.js $NPM_REGISTRY
85+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
86+
displayName: Setup NPM Registry
7787

7888
- script: |
7989
set -e
8090
export npm_config_arch=$(VSCODE_ARCH)
8191
export npm_config_node_gyp=$(which node-gyp)
8292
83-
for i in {1..3}; do # try 3 times, for Terrapin
93+
for i in {1..3}; do # try 3 times
8494
yarn --frozen-lockfile --check-files && break
8595
if [ $i -eq 3 ]; then
8696
echo "Yarn failed too many times" >&2

build/azure-pipelines/darwin/product-build-darwin.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ steps:
7373
7474
- script: |
7575
mkdir -p .build
76-
node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $ENABLE_TERRAPIN > .build/yarnlockhash
76+
node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $NPM_REGISTRY > .build/yarnlockhash
7777
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
7878
displayName: Prepare yarn cache flags
7979
@@ -98,18 +98,28 @@ steps:
9898
9999
- script: |
100100
set -e
101-
npm install https://aka.ms/enablesecurefeed --global && npm exec terrapinadotask -- standAlone
102-
timeoutInMinutes: 5
103-
retryCountOnTaskFailure: 3
104-
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['ENABLE_TERRAPIN'], 'true'))
105-
displayName: Switch to Terrapin packages
101+
npm config set registry "$NPM_REGISTRY" --location=project
102+
npm config set always-auth=true --location=project
103+
yarn config set registry "$NPM_REGISTRY"
104+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
105+
displayName: Setup NPM & Yarn
106+
107+
- task: npmAuthenticate@0
108+
inputs:
109+
workingFile: .npmrc
110+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
111+
displayName: Setup NPM Authentication
112+
113+
- script: node build/setup-npm-registry.js $NPM_REGISTRY
114+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
115+
displayName: Setup NPM Registry
106116

107117
- script: |
108118
set -e
109119
export npm_config_arch=$(VSCODE_ARCH)
110120
export npm_config_node_gyp=$(which node-gyp)
111121
112-
for i in {1..3}; do # try 3 times, for Terrapin
122+
for i in {1..3}; do # try 3 times
113123
yarn --frozen-lockfile --check-files && break
114124
if [ $i -eq 3 ]; then
115125
echo "Yarn failed too many times" >&2

build/azure-pipelines/linux/product-build-alpine.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ steps:
5757
5858
- script: |
5959
mkdir -p .build
60-
node build/azure-pipelines/common/computeNodeModulesCacheKey.js "alpine" $ENABLE_TERRAPIN > .build/yarnlockhash
60+
node build/azure-pipelines/common/computeNodeModulesCacheKey.js "alpine" $NPM_REGISTRY > .build/yarnlockhash
6161
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
6262
displayName: Prepare yarn cache flags
6363
@@ -82,15 +82,25 @@ steps:
8282
8383
- script: |
8484
set -e
85-
npm install https://aka.ms/enablesecurefeed --global && npm exec terrapinadotask -- standAlone
86-
timeoutInMinutes: 5
87-
retryCountOnTaskFailure: 3
88-
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['ENABLE_TERRAPIN'], 'true'))
89-
displayName: Switch to Terrapin packages
85+
npm config set registry "$NPM_REGISTRY" --location=project
86+
npm config set always-auth=true --location=project
87+
yarn config set registry "$NPM_REGISTRY"
88+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
89+
displayName: Setup NPM & Yarn
90+
91+
- task: npmAuthenticate@0
92+
inputs:
93+
workingFile: .npmrc
94+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
95+
displayName: Setup NPM Authentication
96+
97+
- script: node build/setup-npm-registry.js $NPM_REGISTRY
98+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
99+
displayName: Setup NPM Registry
90100

91101
- script: |
92102
set -e
93-
for i in {1..3}; do # try 3 times, for Terrapin
103+
for i in {1..3}; do # try 3 times
94104
yarn --frozen-lockfile --check-files --check-files && break
95105
if [ $i -eq 3 ]; then
96106
echo "Yarn failed too many times" >&2

build/azure-pipelines/linux/product-build-linux-client.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ steps:
9292
9393
- script: |
9494
mkdir -p .build
95-
node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $ENABLE_TERRAPIN > .build/yarnlockhash
95+
node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $NPM_REGISTRY > .build/yarnlockhash
9696
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
9797
displayName: Prepare yarn cache flags
9898
@@ -126,16 +126,26 @@ steps:
126126
127127
- script: |
128128
set -e
129-
npm install https://aka.ms/enablesecurefeed --global && npm exec terrapinadotask -- standAlone
130-
timeoutInMinutes: 5
131-
retryCountOnTaskFailure: 3
132-
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['ENABLE_TERRAPIN'], 'true'))
133-
displayName: Switch to Terrapin packages
129+
npm config set registry "$NPM_REGISTRY" --location=project
130+
npm config set always-auth=true --location=project
131+
yarn config set registry "$NPM_REGISTRY"
132+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
133+
displayName: Setup NPM & Yarn
134+
135+
- task: npmAuthenticate@0
136+
inputs:
137+
workingFile: .npmrc
138+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
139+
displayName: Setup NPM Authentication
140+
141+
- script: node build/setup-npm-registry.js $NPM_REGISTRY
142+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
143+
displayName: Setup NPM Registry
134144

135145
- script: |
136146
set -e
137147
node build/npm/setupBuildYarnrc
138-
for i in {1..3}; do # try 3 times, for Terrapin
148+
for i in {1..3}; do # try 3 times
139149
yarn --cwd build --frozen-lockfile --check-files && break
140150
if [ $i -eq 3 ]; then
141151
echo "Yarn failed too many times" >&2
@@ -181,7 +191,7 @@ steps:
181191
export VSCODE_REMOTE_CXX=$(which g++)
182192
fi
183193
184-
for i in {1..3}; do # try 3 times, for Terrapin
194+
for i in {1..3}; do # try 3 times
185195
yarn --frozen-lockfile --check-files && break
186196
if [ $i -eq 3 ]; then
187197
echo "Yarn failed too many times" >&2

build/azure-pipelines/linux/product-build-linux-server.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,21 @@ steps:
5656
5757
- script: |
5858
set -e
59-
npm install https://aka.ms/enablesecurefeed --global && npm exec terrapinadotask -- standAlone
60-
timeoutInMinutes: 5
61-
retryCountOnTaskFailure: 3
62-
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['ENABLE_TERRAPIN'], 'true'))
63-
displayName: Switch to Terrapin packages
59+
npm config set registry "$NPM_REGISTRY" --location=project
60+
npm config set always-auth=true --location=project
61+
yarn config set registry "$NPM_REGISTRY"
62+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
63+
displayName: Setup NPM & Yarn
64+
65+
- task: npmAuthenticate@0
66+
inputs:
67+
workingFile: .npmrc
68+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
69+
displayName: Setup NPM Authentication
70+
71+
- script: node build/setup-npm-registry.js $NPM_REGISTRY
72+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
73+
displayName: Setup NPM Registry
6474

6575
- script: |
6676
set -e

build/azure-pipelines/linux/scripts/install-remote-dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
echo "Installing remote dependencies"
55
(cd remote && rm -rf node_modules)
66

7-
for i in {1..3}; do # try 3 times, for Terrapin
7+
for i in {1..3}; do # try 3 times
88
yarn --cwd remote --frozen-lockfile --check-files && break
99
if [ $i -eq 3 ]; then
1010
echo "Yarn failed too many times" >&2

build/azure-pipelines/product-build-pr-cache.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ steps:
99

1010
- script: |
1111
mkdir -p .build
12-
node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $ENABLE_TERRAPIN > .build/yarnlockhash
12+
node build/azure-pipelines/common/computeNodeModulesCacheKey.js $VSCODE_ARCH $NPM_REGISTRY > .build/yarnlockhash
1313
node build/azure-pipelines/common/computeBuiltInDepsCacheKey.js > .build/builtindepshash
1414
displayName: Prepare yarn cache flags
1515
@@ -34,15 +34,25 @@ steps:
3434
3535
- script: |
3636
set -e
37-
npm install https://aka.ms/enablesecurefeed --global && npm exec terrapinadotask -- standAlone
38-
timeoutInMinutes: 5
39-
retryCountOnTaskFailure: 3
40-
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), eq(variables['ENABLE_TERRAPIN'], 'true'))
41-
displayName: Switch to Terrapin packages
37+
npm config set registry "$NPM_REGISTRY" --location=project
38+
npm config set always-auth=true --location=project
39+
yarn config set registry "$NPM_REGISTRY"
40+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
41+
displayName: Setup NPM & Yarn
42+
43+
- task: npmAuthenticate@0
44+
inputs:
45+
workingFile: .npmrc
46+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
47+
displayName: Setup NPM Authentication
48+
49+
- script: node build/setup-npm-registry.js $NPM_REGISTRY
50+
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
51+
displayName: Setup NPM Registry
4252

4353
- script: |
4454
set -e
45-
for i in {1..3}; do # try 3 times, for Terrapin
55+
for i in {1..3}; do # try 3 times
4656
yarn --frozen-lockfile --check-files && break
4757
if [ $i -eq 3 ]; then
4858
echo "Yarn failed too many times" >&2

build/azure-pipelines/product-build-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ variables:
1111
value: true
1212
- name: skipComponentGovernanceDetection
1313
value: true
14-
- name: ENABLE_TERRAPIN
15-
value: false
14+
- name: NPM_REGISTRY
15+
value: 'none'
1616
- name: VSCODE_CIBUILD
1717
value: ${{ in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI') }}
1818
- name: VSCODE_PUBLISH

0 commit comments

Comments
 (0)