@vercel/build-utils 9.2.1 → 9.3.1
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/CHANGELOG.md +14 -0
- package/dist/fs/run-user-scripts.js +44 -39
- package/dist/index.js +53 -44
- package/dist/trace/trace.d.ts +1 -3
- package/dist/trace/trace.js +9 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# @vercel/build-utils
|
2
2
|
|
3
|
+
## 9.3.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [build-utils] extract install command specific logic into helper ([#13049](https://github.com/vercel/vercel/pull/13049))
|
8
|
+
|
9
|
+
- [build-utils] remove dead node 16 check ([#13047](https://github.com/vercel/vercel/pull/13047))
|
10
|
+
|
11
|
+
## 9.3.0
|
12
|
+
|
13
|
+
### Minor Changes
|
14
|
+
|
15
|
+
- Support process tracing ([#12894](https://github.com/vercel/vercel/pull/12894))
|
16
|
+
|
3
17
|
## 9.2.1
|
4
18
|
|
5
19
|
### Patch Changes
|
@@ -423,6 +423,45 @@ async function walkParentDirsMulti({
|
|
423
423
|
function isSet(v) {
|
424
424
|
return v?.constructor?.name === "Set";
|
425
425
|
}
|
426
|
+
async function runInstallCommand({
|
427
|
+
packageManager,
|
428
|
+
args,
|
429
|
+
opts
|
430
|
+
}) {
|
431
|
+
const getInstallCommandForPackageManager = (packageManager2, args2) => {
|
432
|
+
switch (packageManager2) {
|
433
|
+
case "npm":
|
434
|
+
return {
|
435
|
+
prettyCommand: "npm install",
|
436
|
+
commandArguments: args2.filter((a) => a !== "--prefer-offline").concat(["install", "--no-audit", "--unsafe-perm"])
|
437
|
+
};
|
438
|
+
case "pnpm":
|
439
|
+
return {
|
440
|
+
prettyCommand: "pnpm install",
|
441
|
+
// PNPM's install command is similar to NPM's but without the audit nonsense
|
442
|
+
// @see options https://pnpm.io/cli/install
|
443
|
+
commandArguments: args2.filter((a) => a !== "--prefer-offline").concat(["install", "--unsafe-perm"])
|
444
|
+
};
|
445
|
+
case "bun":
|
446
|
+
return {
|
447
|
+
prettyCommand: "bun install",
|
448
|
+
// @see options https://bun.sh/docs/cli/install
|
449
|
+
commandArguments: ["install", ...args2]
|
450
|
+
};
|
451
|
+
case "yarn":
|
452
|
+
return {
|
453
|
+
prettyCommand: "yarn install",
|
454
|
+
commandArguments: ["install", ...args2]
|
455
|
+
};
|
456
|
+
}
|
457
|
+
};
|
458
|
+
const { commandArguments, prettyCommand } = getInstallCommandForPackageManager(packageManager, args);
|
459
|
+
opts.prettyCommand = prettyCommand;
|
460
|
+
if (process.env.NPM_ONLY_PRODUCTION) {
|
461
|
+
commandArguments.push("--production");
|
462
|
+
}
|
463
|
+
await spawnAsync(packageManager, commandArguments, opts);
|
464
|
+
}
|
426
465
|
async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion) {
|
427
466
|
if (meta?.isDev) {
|
428
467
|
(0, import_debug.default)("Skipping dependency installation because dev mode is enabled");
|
@@ -473,45 +512,11 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
473
512
|
packageJsonEngines: packageJson?.engines,
|
474
513
|
turboSupportsCorepackHome
|
475
514
|
});
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
opts
|
480
|
-
|
481
|
-
if (isPotentiallyBrokenNpm && spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === "1") {
|
482
|
-
commandArgs.push("--legacy-peer-deps");
|
483
|
-
}
|
484
|
-
} else if (cliType === "pnpm") {
|
485
|
-
opts.prettyCommand = "pnpm install";
|
486
|
-
commandArgs = args.filter((a) => a !== "--prefer-offline").concat(["install", "--unsafe-perm"]);
|
487
|
-
} else if (cliType === "bun") {
|
488
|
-
opts.prettyCommand = "bun install";
|
489
|
-
commandArgs = ["install", ...args];
|
490
|
-
} else {
|
491
|
-
opts.prettyCommand = "yarn install";
|
492
|
-
commandArgs = ["install", ...args];
|
493
|
-
}
|
494
|
-
if (process.env.NPM_ONLY_PRODUCTION) {
|
495
|
-
commandArgs.push("--production");
|
496
|
-
}
|
497
|
-
try {
|
498
|
-
await spawnAsync(cliType, commandArgs, opts);
|
499
|
-
} catch (err) {
|
500
|
-
const potentialErrorPath = import_path.default.join(
|
501
|
-
process.env.HOME || "/",
|
502
|
-
".npm",
|
503
|
-
"eresolve-report.txt"
|
504
|
-
);
|
505
|
-
if (isPotentiallyBrokenNpm && !commandArgs.includes("--legacy-peer-deps") && import_fs_extra.default.existsSync(potentialErrorPath)) {
|
506
|
-
console.warn(
|
507
|
-
'Warning: Retrying "Install Command" with `--legacy-peer-deps` which may accept a potentially broken dependency and slow install time.'
|
508
|
-
);
|
509
|
-
commandArgs.push("--legacy-peer-deps");
|
510
|
-
await spawnAsync(cliType, commandArgs, opts);
|
511
|
-
} else {
|
512
|
-
throw err;
|
513
|
-
}
|
514
|
-
}
|
515
|
+
await runInstallCommand({
|
516
|
+
packageManager: cliType,
|
517
|
+
args,
|
518
|
+
opts
|
519
|
+
});
|
515
520
|
(0, import_debug.default)(`Install complete [${Date.now() - installTime}ms]`);
|
516
521
|
return true;
|
517
522
|
} finally {
|
package/dist/index.js
CHANGED
@@ -23436,6 +23436,45 @@ async function walkParentDirsMulti({
|
|
23436
23436
|
function isSet(v) {
|
23437
23437
|
return v?.constructor?.name === "Set";
|
23438
23438
|
}
|
23439
|
+
async function runInstallCommand({
|
23440
|
+
packageManager,
|
23441
|
+
args,
|
23442
|
+
opts
|
23443
|
+
}) {
|
23444
|
+
const getInstallCommandForPackageManager = (packageManager2, args2) => {
|
23445
|
+
switch (packageManager2) {
|
23446
|
+
case "npm":
|
23447
|
+
return {
|
23448
|
+
prettyCommand: "npm install",
|
23449
|
+
commandArguments: args2.filter((a) => a !== "--prefer-offline").concat(["install", "--no-audit", "--unsafe-perm"])
|
23450
|
+
};
|
23451
|
+
case "pnpm":
|
23452
|
+
return {
|
23453
|
+
prettyCommand: "pnpm install",
|
23454
|
+
// PNPM's install command is similar to NPM's but without the audit nonsense
|
23455
|
+
// @see options https://pnpm.io/cli/install
|
23456
|
+
commandArguments: args2.filter((a) => a !== "--prefer-offline").concat(["install", "--unsafe-perm"])
|
23457
|
+
};
|
23458
|
+
case "bun":
|
23459
|
+
return {
|
23460
|
+
prettyCommand: "bun install",
|
23461
|
+
// @see options https://bun.sh/docs/cli/install
|
23462
|
+
commandArguments: ["install", ...args2]
|
23463
|
+
};
|
23464
|
+
case "yarn":
|
23465
|
+
return {
|
23466
|
+
prettyCommand: "yarn install",
|
23467
|
+
commandArguments: ["install", ...args2]
|
23468
|
+
};
|
23469
|
+
}
|
23470
|
+
};
|
23471
|
+
const { commandArguments, prettyCommand } = getInstallCommandForPackageManager(packageManager, args);
|
23472
|
+
opts.prettyCommand = prettyCommand;
|
23473
|
+
if (process.env.NPM_ONLY_PRODUCTION) {
|
23474
|
+
commandArguments.push("--production");
|
23475
|
+
}
|
23476
|
+
await spawnAsync(packageManager, commandArguments, opts);
|
23477
|
+
}
|
23439
23478
|
async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion) {
|
23440
23479
|
if (meta?.isDev) {
|
23441
23480
|
debug("Skipping dependency installation because dev mode is enabled");
|
@@ -23486,45 +23525,11 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
23486
23525
|
packageJsonEngines: packageJson?.engines,
|
23487
23526
|
turboSupportsCorepackHome
|
23488
23527
|
});
|
23489
|
-
|
23490
|
-
|
23491
|
-
|
23492
|
-
opts
|
23493
|
-
|
23494
|
-
if (isPotentiallyBrokenNpm && spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === "1") {
|
23495
|
-
commandArgs.push("--legacy-peer-deps");
|
23496
|
-
}
|
23497
|
-
} else if (cliType === "pnpm") {
|
23498
|
-
opts.prettyCommand = "pnpm install";
|
23499
|
-
commandArgs = args.filter((a) => a !== "--prefer-offline").concat(["install", "--unsafe-perm"]);
|
23500
|
-
} else if (cliType === "bun") {
|
23501
|
-
opts.prettyCommand = "bun install";
|
23502
|
-
commandArgs = ["install", ...args];
|
23503
|
-
} else {
|
23504
|
-
opts.prettyCommand = "yarn install";
|
23505
|
-
commandArgs = ["install", ...args];
|
23506
|
-
}
|
23507
|
-
if (process.env.NPM_ONLY_PRODUCTION) {
|
23508
|
-
commandArgs.push("--production");
|
23509
|
-
}
|
23510
|
-
try {
|
23511
|
-
await spawnAsync(cliType, commandArgs, opts);
|
23512
|
-
} catch (err) {
|
23513
|
-
const potentialErrorPath = import_path5.default.join(
|
23514
|
-
process.env.HOME || "/",
|
23515
|
-
".npm",
|
23516
|
-
"eresolve-report.txt"
|
23517
|
-
);
|
23518
|
-
if (isPotentiallyBrokenNpm && !commandArgs.includes("--legacy-peer-deps") && import_fs_extra7.default.existsSync(potentialErrorPath)) {
|
23519
|
-
console.warn(
|
23520
|
-
'Warning: Retrying "Install Command" with `--legacy-peer-deps` which may accept a potentially broken dependency and slow install time.'
|
23521
|
-
);
|
23522
|
-
commandArgs.push("--legacy-peer-deps");
|
23523
|
-
await spawnAsync(cliType, commandArgs, opts);
|
23524
|
-
} else {
|
23525
|
-
throw err;
|
23526
|
-
}
|
23527
|
-
}
|
23528
|
+
await runInstallCommand({
|
23529
|
+
packageManager: cliType,
|
23530
|
+
args,
|
23531
|
+
opts
|
23532
|
+
});
|
23528
23533
|
debug(`Install complete [${Date.now() - installTime}ms]`);
|
23529
23534
|
return true;
|
23530
23535
|
} finally {
|
@@ -24231,6 +24236,7 @@ var buildsSchema = {
|
|
24231
24236
|
|
24232
24237
|
// src/trace/trace.ts
|
24233
24238
|
var import_node_crypto = require("crypto");
|
24239
|
+
var NUM_OF_MICROSEC_IN_NANOSEC = BigInt("1000");
|
24234
24240
|
function mapUndefinedAttributes(attrs) {
|
24235
24241
|
return Object.fromEntries(
|
24236
24242
|
Object.entries(attrs ?? {}).filter(
|
@@ -24250,23 +24256,26 @@ var Span = class _Span {
|
|
24250
24256
|
this.attrs = mapUndefinedAttributes(attrs);
|
24251
24257
|
this.status = "started";
|
24252
24258
|
this.id = (0, import_node_crypto.randomUUID)();
|
24253
|
-
this._start = Date.now();
|
24254
24259
|
this._reporter = reporter;
|
24260
|
+
this.now = Date.now();
|
24261
|
+
this._start = process.hrtime.bigint();
|
24255
24262
|
}
|
24256
24263
|
stop() {
|
24257
24264
|
if (this.status === "stopped") {
|
24258
24265
|
throw new Error(`Cannot stop a span which is already stopped`);
|
24259
24266
|
}
|
24260
24267
|
this.status = "stopped";
|
24261
|
-
const
|
24268
|
+
const end = process.hrtime.bigint();
|
24269
|
+
const duration = Number((end - this._start) / NUM_OF_MICROSEC_IN_NANOSEC);
|
24270
|
+
const timestamp = Number(this._start / NUM_OF_MICROSEC_IN_NANOSEC);
|
24262
24271
|
const traceEvent = {
|
24263
24272
|
name: this.name,
|
24264
|
-
duration
|
24265
|
-
timestamp
|
24273
|
+
duration,
|
24274
|
+
timestamp,
|
24266
24275
|
id: this.id,
|
24267
24276
|
parentId: this.parentId,
|
24268
24277
|
tags: this.attrs,
|
24269
|
-
startTime: this.
|
24278
|
+
startTime: this.now
|
24270
24279
|
};
|
24271
24280
|
if (this._reporter) {
|
24272
24281
|
this._reporter.report(traceEvent);
|
package/dist/trace/trace.d.ts
CHANGED
@@ -9,9 +9,6 @@ export type TraceEvent = {
|
|
9
9
|
startTime: number;
|
10
10
|
};
|
11
11
|
export type Reporter = {
|
12
|
-
flushAll: (opts?: {
|
13
|
-
end: boolean;
|
14
|
-
}) => Promise<void> | void;
|
15
12
|
report: (event: TraceEvent) => void;
|
16
13
|
};
|
17
14
|
interface Attributes {
|
@@ -24,6 +21,7 @@ export declare class Span {
|
|
24
21
|
private attrs;
|
25
22
|
private status;
|
26
23
|
private _start;
|
24
|
+
private now;
|
27
25
|
private _reporter;
|
28
26
|
constructor({ name, parentId, attrs, reporter, }: {
|
29
27
|
name: string;
|
package/dist/trace/trace.js
CHANGED
@@ -22,6 +22,7 @@ __export(trace_exports, {
|
|
22
22
|
});
|
23
23
|
module.exports = __toCommonJS(trace_exports);
|
24
24
|
var import_node_crypto = require("node:crypto");
|
25
|
+
const NUM_OF_MICROSEC_IN_NANOSEC = BigInt("1000");
|
25
26
|
function mapUndefinedAttributes(attrs) {
|
26
27
|
return Object.fromEntries(
|
27
28
|
Object.entries(attrs ?? {}).filter(
|
@@ -41,23 +42,26 @@ class Span {
|
|
41
42
|
this.attrs = mapUndefinedAttributes(attrs);
|
42
43
|
this.status = "started";
|
43
44
|
this.id = (0, import_node_crypto.randomUUID)();
|
44
|
-
this._start = Date.now();
|
45
45
|
this._reporter = reporter;
|
46
|
+
this.now = Date.now();
|
47
|
+
this._start = process.hrtime.bigint();
|
46
48
|
}
|
47
49
|
stop() {
|
48
50
|
if (this.status === "stopped") {
|
49
51
|
throw new Error(`Cannot stop a span which is already stopped`);
|
50
52
|
}
|
51
53
|
this.status = "stopped";
|
52
|
-
const
|
54
|
+
const end = process.hrtime.bigint();
|
55
|
+
const duration = Number((end - this._start) / NUM_OF_MICROSEC_IN_NANOSEC);
|
56
|
+
const timestamp = Number(this._start / NUM_OF_MICROSEC_IN_NANOSEC);
|
53
57
|
const traceEvent = {
|
54
58
|
name: this.name,
|
55
|
-
duration
|
56
|
-
timestamp
|
59
|
+
duration,
|
60
|
+
timestamp,
|
57
61
|
id: this.id,
|
58
62
|
parentId: this.parentId,
|
59
63
|
tags: this.attrs,
|
60
|
-
startTime: this.
|
64
|
+
startTime: this.now
|
61
65
|
};
|
62
66
|
if (this._reporter) {
|
63
67
|
this._reporter.report(traceEvent);
|