@vercel/build-utils 5.4.1 → 5.4.3
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.d.ts +10 -0
- package/dist/clone-env.js +28 -0
- package/dist/fs/run-user-scripts.js +15 -6
- package/dist/index.d.ts +2 -1
- package/dist/index.js +54 -7
- package/dist/types.d.ts +2 -0
- package/package.json +2 -2
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { Env } from './types';
|
2
|
+
/**
|
3
|
+
* Clones zero or more objects into a single new object while ensuring that the
|
4
|
+
* `PATH` environment variable is defined when the `PATH` or `Path` environment
|
5
|
+
* variables are defined.
|
6
|
+
*
|
7
|
+
* @param {Object} [...envs] Objects and/or `process.env` to clone and merge
|
8
|
+
* @returns {Object} The new object
|
9
|
+
*/
|
10
|
+
export declare function cloneEnv(...envs: (Env | undefined)[]): Env;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.cloneEnv = void 0;
|
4
|
+
const { hasOwnProperty } = Object.prototype;
|
5
|
+
/**
|
6
|
+
* Clones zero or more objects into a single new object while ensuring that the
|
7
|
+
* `PATH` environment variable is defined when the `PATH` or `Path` environment
|
8
|
+
* variables are defined.
|
9
|
+
*
|
10
|
+
* @param {Object} [...envs] Objects and/or `process.env` to clone and merge
|
11
|
+
* @returns {Object} The new object
|
12
|
+
*/
|
13
|
+
function cloneEnv(...envs) {
|
14
|
+
return envs.reduce((obj, env) => {
|
15
|
+
if (env === undefined || env === null) {
|
16
|
+
return obj;
|
17
|
+
}
|
18
|
+
// the system path is called `Path` on Windows and Node.js will
|
19
|
+
// automatically return the system path when accessing `PATH`,
|
20
|
+
// however we lose this proxied value when we destructure and
|
21
|
+
// thus we must explicitly copy it
|
22
|
+
if (hasOwnProperty.call(env, 'PATH') || hasOwnProperty.call(env, 'Path')) {
|
23
|
+
obj.PATH = env.PATH;
|
24
|
+
}
|
25
|
+
return Object.assign(obj, env);
|
26
|
+
}, {});
|
27
|
+
}
|
28
|
+
exports.cloneEnv = cloneEnv;
|
@@ -15,6 +15,7 @@ const debug_1 = __importDefault(require("../debug"));
|
|
15
15
|
const errors_1 = require("../errors");
|
16
16
|
const node_version_1 = require("./node-version");
|
17
17
|
const read_config_file_1 = require("./read-config-file");
|
18
|
+
const clone_env_1 = require("../clone-env");
|
18
19
|
// Only allow one `runNpmInstall()` invocation to run concurrently
|
19
20
|
const runNpmInstallSema = new async_sema_1.default(1);
|
20
21
|
function spawnAsync(command, args, opts = {}) {
|
@@ -123,7 +124,7 @@ async function runShellScript(fsPath, args = [], spawnOpts) {
|
|
123
124
|
exports.runShellScript = runShellScript;
|
124
125
|
function getSpawnOptions(meta, nodeVersion) {
|
125
126
|
const opts = {
|
126
|
-
env:
|
127
|
+
env: clone_env_1.cloneEnv(process.env),
|
127
128
|
};
|
128
129
|
if (!meta.isDev) {
|
129
130
|
let found = false;
|
@@ -294,7 +295,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
294
295
|
console.log('Installing dependencies...');
|
295
296
|
debug_1.default(`Installing to ${destPath}`);
|
296
297
|
const opts = { cwd: destPath, ...spawnOpts };
|
297
|
-
const env =
|
298
|
+
const env = clone_env_1.cloneEnv(opts.env || process.env);
|
298
299
|
delete env.NODE_ENV;
|
299
300
|
opts.env = getEnvForPackageManager({
|
300
301
|
cliType,
|
@@ -308,6 +309,17 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
308
309
|
commandArgs = args
|
309
310
|
.filter(a => a !== '--prefer-offline')
|
310
311
|
.concat(['install', '--no-audit', '--unsafe-perm']);
|
312
|
+
if (nodeVersion?.major === 16 &&
|
313
|
+
spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === '1' &&
|
314
|
+
spawnOpts?.env?.ENABLE_EXPERIMENTAL_COREPACK !== '1') {
|
315
|
+
// Starting in npm@8.6.0, if you ran `npm install --legacy-peer-deps`,
|
316
|
+
// and then later ran `npm install`, it would fail. So the only way
|
317
|
+
// to safely upgrade npm from npm@8.5.0 is to set this flag. The docs
|
318
|
+
// say this flag is not recommended so its is behind a feature flag
|
319
|
+
// so we can remove it in node@18, which can introduce breaking changes.
|
320
|
+
// See https://docs.npmjs.com/cli/v8/using-npm/config#legacy-peer-deps
|
321
|
+
commandArgs.push('--legacy-peer-deps');
|
322
|
+
}
|
311
323
|
}
|
312
324
|
else if (cliType === 'pnpm') {
|
313
325
|
// PNPM's install command is similar to NPM's but without the audit nonsense
|
@@ -401,10 +413,7 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
|
401
413
|
cliType,
|
402
414
|
lockfileVersion,
|
403
415
|
nodeVersion: undefined,
|
404
|
-
env:
|
405
|
-
...process.env,
|
406
|
-
...spawnOpts?.env,
|
407
|
-
},
|
416
|
+
env: clone_env_1.cloneEnv(process.env, spawnOpts?.env),
|
408
417
|
}),
|
409
418
|
};
|
410
419
|
if (cliType === 'npm') {
|
package/dist/index.d.ts
CHANGED
@@ -15,7 +15,8 @@ import debug from './debug';
|
|
15
15
|
import getIgnoreFilter from './get-ignore-filter';
|
16
16
|
import { getPlatformEnv } from './get-platform-env';
|
17
17
|
import { getPrefixedEnvVars } from './get-prefixed-env-vars';
|
18
|
-
|
18
|
+
import { cloneEnv } from './clone-env';
|
19
|
+
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, execAsync, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, };
|
19
20
|
export { EdgeFunction } from './edge-function';
|
20
21
|
export { readConfigFile } from './fs/read-config-file';
|
21
22
|
export { normalizePath } from './fs/normalize-path';
|
package/dist/index.js
CHANGED
@@ -30108,6 +30108,42 @@ exports.fromPromise = function (fn) {
|
|
30108
30108
|
}
|
30109
30109
|
|
30110
30110
|
|
30111
|
+
/***/ }),
|
30112
|
+
|
30113
|
+
/***/ 6548:
|
30114
|
+
/***/ ((__unused_webpack_module, exports) => {
|
30115
|
+
|
30116
|
+
"use strict";
|
30117
|
+
|
30118
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
30119
|
+
exports.cloneEnv = void 0;
|
30120
|
+
const { hasOwnProperty } = Object.prototype;
|
30121
|
+
/**
|
30122
|
+
* Clones zero or more objects into a single new object while ensuring that the
|
30123
|
+
* `PATH` environment variable is defined when the `PATH` or `Path` environment
|
30124
|
+
* variables are defined.
|
30125
|
+
*
|
30126
|
+
* @param {Object} [...envs] Objects and/or `process.env` to clone and merge
|
30127
|
+
* @returns {Object} The new object
|
30128
|
+
*/
|
30129
|
+
function cloneEnv(...envs) {
|
30130
|
+
return envs.reduce((obj, env) => {
|
30131
|
+
if (env === undefined || env === null) {
|
30132
|
+
return obj;
|
30133
|
+
}
|
30134
|
+
// the system path is called `Path` on Windows and Node.js will
|
30135
|
+
// automatically return the system path when accessing `PATH`,
|
30136
|
+
// however we lose this proxied value when we destructure and
|
30137
|
+
// thus we must explicitly copy it
|
30138
|
+
if (hasOwnProperty.call(env, 'PATH') || hasOwnProperty.call(env, 'Path')) {
|
30139
|
+
obj.PATH = env.PATH;
|
30140
|
+
}
|
30141
|
+
return Object.assign(obj, env);
|
30142
|
+
}, {});
|
30143
|
+
}
|
30144
|
+
exports.cloneEnv = cloneEnv;
|
30145
|
+
|
30146
|
+
|
30111
30147
|
/***/ }),
|
30112
30148
|
|
30113
30149
|
/***/ 1868:
|
@@ -30847,6 +30883,7 @@ const debug_1 = __importDefault(__webpack_require__(1868));
|
|
30847
30883
|
const errors_1 = __webpack_require__(3983);
|
30848
30884
|
const node_version_1 = __webpack_require__(7903);
|
30849
30885
|
const read_config_file_1 = __webpack_require__(7792);
|
30886
|
+
const clone_env_1 = __webpack_require__(6548);
|
30850
30887
|
// Only allow one `runNpmInstall()` invocation to run concurrently
|
30851
30888
|
const runNpmInstallSema = new async_sema_1.default(1);
|
30852
30889
|
function spawnAsync(command, args, opts = {}) {
|
@@ -30955,7 +30992,7 @@ async function runShellScript(fsPath, args = [], spawnOpts) {
|
|
30955
30992
|
exports.runShellScript = runShellScript;
|
30956
30993
|
function getSpawnOptions(meta, nodeVersion) {
|
30957
30994
|
const opts = {
|
30958
|
-
env:
|
30995
|
+
env: clone_env_1.cloneEnv(process.env),
|
30959
30996
|
};
|
30960
30997
|
if (!meta.isDev) {
|
30961
30998
|
let found = false;
|
@@ -31126,7 +31163,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
31126
31163
|
console.log('Installing dependencies...');
|
31127
31164
|
debug_1.default(`Installing to ${destPath}`);
|
31128
31165
|
const opts = { cwd: destPath, ...spawnOpts };
|
31129
|
-
const env =
|
31166
|
+
const env = clone_env_1.cloneEnv(opts.env || process.env);
|
31130
31167
|
delete env.NODE_ENV;
|
31131
31168
|
opts.env = getEnvForPackageManager({
|
31132
31169
|
cliType,
|
@@ -31140,6 +31177,17 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
31140
31177
|
commandArgs = args
|
31141
31178
|
.filter(a => a !== '--prefer-offline')
|
31142
31179
|
.concat(['install', '--no-audit', '--unsafe-perm']);
|
31180
|
+
if (nodeVersion?.major === 16 &&
|
31181
|
+
spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === '1' &&
|
31182
|
+
spawnOpts?.env?.ENABLE_EXPERIMENTAL_COREPACK !== '1') {
|
31183
|
+
// Starting in npm@8.6.0, if you ran `npm install --legacy-peer-deps`,
|
31184
|
+
// and then later ran `npm install`, it would fail. So the only way
|
31185
|
+
// to safely upgrade npm from npm@8.5.0 is to set this flag. The docs
|
31186
|
+
// say this flag is not recommended so its is behind a feature flag
|
31187
|
+
// so we can remove it in node@18, which can introduce breaking changes.
|
31188
|
+
// See https://docs.npmjs.com/cli/v8/using-npm/config#legacy-peer-deps
|
31189
|
+
commandArgs.push('--legacy-peer-deps');
|
31190
|
+
}
|
31143
31191
|
}
|
31144
31192
|
else if (cliType === 'pnpm') {
|
31145
31193
|
// PNPM's install command is similar to NPM's but without the audit nonsense
|
@@ -31233,10 +31281,7 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
|
31233
31281
|
cliType,
|
31234
31282
|
lockfileVersion,
|
31235
31283
|
nodeVersion: undefined,
|
31236
|
-
env:
|
31237
|
-
...process.env,
|
31238
|
-
...spawnOpts?.env,
|
31239
|
-
},
|
31284
|
+
env: clone_env_1.cloneEnv(process.env, spawnOpts?.env),
|
31240
31285
|
}),
|
31241
31286
|
};
|
31242
31287
|
if (cliType === 'npm') {
|
@@ -31499,7 +31544,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31499
31544
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
31500
31545
|
};
|
31501
31546
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
31502
|
-
exports.normalizePath = exports.readConfigFile = exports.EdgeFunction = exports.getIgnoreFilter = exports.scanParentDirs = exports.getLambdaOptionsFromFunction = exports.isSymbolicLink = exports.debug = exports.streamToBuffer = exports.getPrefixedEnvVars = exports.getPlatformEnv = exports.getSpawnOptions = exports.getDiscontinuedNodeVersions = exports.getLatestNodeVersion = exports.getNodeVersion = exports.getEnvForPackageManager = exports.runCustomInstallCommand = exports.runShellScript = exports.runPipInstall = exports.runBundleInstall = exports.runNpmInstall = exports.getNodeBinPath = exports.walkParentDirs = exports.spawnCommand = exports.execCommand = exports.runPackageJsonScript = exports.installDependencies = exports.getScriptName = exports.spawnAsync = exports.execAsync = exports.rename = exports.glob = exports.getWriteableDirectory = exports.downloadFile = exports.download = exports.Prerender = exports.createLambda = exports.NodejsLambda = exports.Lambda = exports.FileRef = exports.FileFsRef = exports.FileBlob = void 0;
|
31547
|
+
exports.normalizePath = exports.readConfigFile = exports.EdgeFunction = exports.cloneEnv = exports.getIgnoreFilter = exports.scanParentDirs = exports.getLambdaOptionsFromFunction = exports.isSymbolicLink = exports.debug = exports.streamToBuffer = exports.getPrefixedEnvVars = exports.getPlatformEnv = exports.getSpawnOptions = exports.getDiscontinuedNodeVersions = exports.getLatestNodeVersion = exports.getNodeVersion = exports.getEnvForPackageManager = exports.runCustomInstallCommand = exports.runShellScript = exports.runPipInstall = exports.runBundleInstall = exports.runNpmInstall = exports.getNodeBinPath = exports.walkParentDirs = exports.spawnCommand = exports.execCommand = exports.runPackageJsonScript = exports.installDependencies = exports.getScriptName = exports.spawnAsync = exports.execAsync = exports.rename = exports.glob = exports.getWriteableDirectory = exports.downloadFile = exports.download = exports.Prerender = exports.createLambda = exports.NodejsLambda = exports.Lambda = exports.FileRef = exports.FileFsRef = exports.FileBlob = void 0;
|
31503
31548
|
const file_blob_1 = __importDefault(__webpack_require__(2397));
|
31504
31549
|
exports.FileBlob = file_blob_1.default;
|
31505
31550
|
const file_fs_ref_1 = __importDefault(__webpack_require__(9331));
|
@@ -31556,6 +31601,8 @@ const get_platform_env_1 = __webpack_require__(4678);
|
|
31556
31601
|
Object.defineProperty(exports, "getPlatformEnv", ({ enumerable: true, get: function () { return get_platform_env_1.getPlatformEnv; } }));
|
31557
31602
|
const get_prefixed_env_vars_1 = __webpack_require__(6838);
|
31558
31603
|
Object.defineProperty(exports, "getPrefixedEnvVars", ({ enumerable: true, get: function () { return get_prefixed_env_vars_1.getPrefixedEnvVars; } }));
|
31604
|
+
const clone_env_1 = __webpack_require__(6548);
|
31605
|
+
Object.defineProperty(exports, "cloneEnv", ({ enumerable: true, get: function () { return clone_env_1.cloneEnv; } }));
|
31559
31606
|
var edge_function_1 = __webpack_require__(8038);
|
31560
31607
|
Object.defineProperty(exports, "EdgeFunction", ({ enumerable: true, get: function () { return edge_function_1.EdgeFunction; } }));
|
31561
31608
|
var read_config_file_1 = __webpack_require__(7792);
|
package/dist/types.d.ts
CHANGED
@@ -40,6 +40,7 @@ export interface Config {
|
|
40
40
|
devCommand?: string;
|
41
41
|
framework?: string | null;
|
42
42
|
nodeVersion?: string;
|
43
|
+
middleware?: boolean;
|
43
44
|
[key: string]: unknown;
|
44
45
|
}
|
45
46
|
export interface Meta {
|
@@ -302,6 +303,7 @@ export interface BuilderV2 {
|
|
302
303
|
version: 2;
|
303
304
|
build: BuildV2;
|
304
305
|
prepareCache?: PrepareCache;
|
306
|
+
shouldServe?: ShouldServe;
|
305
307
|
}
|
306
308
|
export interface BuilderV3 {
|
307
309
|
version: 3;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/build-utils",
|
3
|
-
"version": "5.4.
|
3
|
+
"version": "5.4.3",
|
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": "619ca9342156758efdb0db8adaf20e0d4a1493e4"
|
51
51
|
}
|