@vercel/build-utils 5.4.3 → 5.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clone-env.js +11 -7
- package/dist/fs/run-user-scripts.js +19 -4
- package/dist/index.js +31 -12
- package/package.json +2 -2
package/dist/clone-env.js
CHANGED
@@ -15,14 +15,18 @@ function cloneEnv(...envs) {
|
|
15
15
|
if (env === undefined || env === null) {
|
16
16
|
return obj;
|
17
17
|
}
|
18
|
-
// the
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
// mixin the env first
|
19
|
+
obj = Object.assign(obj, env);
|
20
|
+
if (hasOwnProperty.call(env, 'Path')) {
|
21
|
+
// the system path is called `Path` on Windows and Node.js will
|
22
|
+
// automatically return the system path when accessing `PATH`,
|
23
|
+
// however we lose this proxied value when we destructure and
|
24
|
+
// thus we must explicitly copy it, but we must also remove the
|
25
|
+
// `Path` property since we can't have both a `PATH` and `Path`
|
26
|
+
obj.PATH = obj.Path;
|
27
|
+
delete obj.Path;
|
24
28
|
}
|
25
|
-
return
|
29
|
+
return obj;
|
26
30
|
}, {});
|
27
31
|
}
|
28
32
|
exports.cloneEnv = cloneEnv;
|
@@ -304,14 +304,17 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
304
304
|
env,
|
305
305
|
});
|
306
306
|
let commandArgs;
|
307
|
+
const isPotentiallyBrokenNpm = cliType === 'npm' &&
|
308
|
+
nodeVersion?.major === 16 &&
|
309
|
+
!args.includes('--legacy-peer-deps') &&
|
310
|
+
spawnOpts?.env?.ENABLE_EXPERIMENTAL_COREPACK !== '1';
|
307
311
|
if (cliType === 'npm') {
|
308
312
|
opts.prettyCommand = 'npm install';
|
309
313
|
commandArgs = args
|
310
314
|
.filter(a => a !== '--prefer-offline')
|
311
315
|
.concat(['install', '--no-audit', '--unsafe-perm']);
|
312
|
-
if (
|
313
|
-
spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === '1'
|
314
|
-
spawnOpts?.env?.ENABLE_EXPERIMENTAL_COREPACK !== '1') {
|
316
|
+
if (isPotentiallyBrokenNpm &&
|
317
|
+
spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === '1') {
|
315
318
|
// Starting in npm@8.6.0, if you ran `npm install --legacy-peer-deps`,
|
316
319
|
// and then later ran `npm install`, it would fail. So the only way
|
317
320
|
// to safely upgrade npm from npm@8.5.0 is to set this flag. The docs
|
@@ -336,7 +339,19 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
336
339
|
if (process.env.NPM_ONLY_PRODUCTION) {
|
337
340
|
commandArgs.push('--production');
|
338
341
|
}
|
339
|
-
|
342
|
+
try {
|
343
|
+
await spawnAsync(cliType, commandArgs, opts);
|
344
|
+
}
|
345
|
+
catch (_) {
|
346
|
+
const potentialErrorPath = path_1.default.join(process.env.HOME || '/', '.npm', 'eresolve-report.txt');
|
347
|
+
if (isPotentiallyBrokenNpm &&
|
348
|
+
!commandArgs.includes('--legacy-peer-deps') &&
|
349
|
+
fs_extra_1.default.existsSync(potentialErrorPath)) {
|
350
|
+
console.warn('Warning: Retrying "Install Command" with `--legacy-peer-deps` which may accept a potentially broken dependency and slow install time.');
|
351
|
+
commandArgs.push('--legacy-peer-deps');
|
352
|
+
await spawnAsync(cliType, commandArgs, opts);
|
353
|
+
}
|
354
|
+
}
|
340
355
|
debug_1.default(`Install complete [${Date.now() - installTime}ms]`);
|
341
356
|
return true;
|
342
357
|
}
|
package/dist/index.js
CHANGED
@@ -30131,14 +30131,18 @@ function cloneEnv(...envs) {
|
|
30131
30131
|
if (env === undefined || env === null) {
|
30132
30132
|
return obj;
|
30133
30133
|
}
|
30134
|
-
// the
|
30135
|
-
|
30136
|
-
|
30137
|
-
|
30138
|
-
|
30139
|
-
|
30140
|
-
|
30141
|
-
|
30134
|
+
// mixin the env first
|
30135
|
+
obj = Object.assign(obj, env);
|
30136
|
+
if (hasOwnProperty.call(env, 'Path')) {
|
30137
|
+
// the system path is called `Path` on Windows and Node.js will
|
30138
|
+
// automatically return the system path when accessing `PATH`,
|
30139
|
+
// however we lose this proxied value when we destructure and
|
30140
|
+
// thus we must explicitly copy it, but we must also remove the
|
30141
|
+
// `Path` property since we can't have both a `PATH` and `Path`
|
30142
|
+
obj.PATH = obj.Path;
|
30143
|
+
delete obj.Path;
|
30144
|
+
}
|
30145
|
+
return obj;
|
30142
30146
|
}, {});
|
30143
30147
|
}
|
30144
30148
|
exports.cloneEnv = cloneEnv;
|
@@ -31172,14 +31176,17 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
31172
31176
|
env,
|
31173
31177
|
});
|
31174
31178
|
let commandArgs;
|
31179
|
+
const isPotentiallyBrokenNpm = cliType === 'npm' &&
|
31180
|
+
nodeVersion?.major === 16 &&
|
31181
|
+
!args.includes('--legacy-peer-deps') &&
|
31182
|
+
spawnOpts?.env?.ENABLE_EXPERIMENTAL_COREPACK !== '1';
|
31175
31183
|
if (cliType === 'npm') {
|
31176
31184
|
opts.prettyCommand = 'npm install';
|
31177
31185
|
commandArgs = args
|
31178
31186
|
.filter(a => a !== '--prefer-offline')
|
31179
31187
|
.concat(['install', '--no-audit', '--unsafe-perm']);
|
31180
|
-
if (
|
31181
|
-
spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === '1'
|
31182
|
-
spawnOpts?.env?.ENABLE_EXPERIMENTAL_COREPACK !== '1') {
|
31188
|
+
if (isPotentiallyBrokenNpm &&
|
31189
|
+
spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === '1') {
|
31183
31190
|
// Starting in npm@8.6.0, if you ran `npm install --legacy-peer-deps`,
|
31184
31191
|
// and then later ran `npm install`, it would fail. So the only way
|
31185
31192
|
// to safely upgrade npm from npm@8.5.0 is to set this flag. The docs
|
@@ -31204,7 +31211,19 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
31204
31211
|
if (process.env.NPM_ONLY_PRODUCTION) {
|
31205
31212
|
commandArgs.push('--production');
|
31206
31213
|
}
|
31207
|
-
|
31214
|
+
try {
|
31215
|
+
await spawnAsync(cliType, commandArgs, opts);
|
31216
|
+
}
|
31217
|
+
catch (_) {
|
31218
|
+
const potentialErrorPath = path_1.default.join(process.env.HOME || '/', '.npm', 'eresolve-report.txt');
|
31219
|
+
if (isPotentiallyBrokenNpm &&
|
31220
|
+
!commandArgs.includes('--legacy-peer-deps') &&
|
31221
|
+
fs_extra_1.default.existsSync(potentialErrorPath)) {
|
31222
|
+
console.warn('Warning: Retrying "Install Command" with `--legacy-peer-deps` which may accept a potentially broken dependency and slow install time.');
|
31223
|
+
commandArgs.push('--legacy-peer-deps');
|
31224
|
+
await spawnAsync(cliType, commandArgs, opts);
|
31225
|
+
}
|
31226
|
+
}
|
31208
31227
|
debug_1.default(`Install complete [${Date.now() - installTime}ms]`);
|
31209
31228
|
return true;
|
31210
31229
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/build-utils",
|
3
|
-
"version": "5.4.
|
3
|
+
"version": "5.4.4",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"types": "./dist/index.d.js",
|
@@ -47,5 +47,5 @@
|
|
47
47
|
"typescript": "4.3.4",
|
48
48
|
"yazl": "2.5.1"
|
49
49
|
},
|
50
|
-
"gitHead": "
|
50
|
+
"gitHead": "27f4034bdce427953fea094b1c4dfbfb00342b54"
|
51
51
|
}
|