@vercel/build-utils 5.3.2 → 5.4.2

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/debug.js CHANGED
@@ -5,5 +5,8 @@ function debug(message, ...additional) {
5
5
  if (get_platform_env_1.getPlatformEnv('BUILDER_DEBUG')) {
6
6
  console.log(message, ...additional);
7
7
  }
8
+ else if (process.env.VERCEL_DEBUG_PREFIX) {
9
+ console.log(`${process.env.VERCEL_DEBUG_PREFIX}${message}`, ...additional);
10
+ }
8
11
  }
9
12
  exports.default = debug;
@@ -8,8 +8,7 @@ export interface ScanParentDirsResult {
8
8
  */
9
9
  cliType: CliType;
10
10
  /**
11
- * The file path of found `package.json` file, or `undefined` if none was
12
- * found.
11
+ * The file path of found `package.json` file, or `undefined` if not found.
13
12
  */
14
13
  packageJsonPath?: string;
15
14
  /**
@@ -18,8 +17,13 @@ export interface ScanParentDirsResult {
18
17
  */
19
18
  packageJson?: PackageJson;
20
19
  /**
21
- * The `lockfileVersion` number from the `package-lock.json` file,
22
- * when present.
20
+ * The file path of the lockfile (`yarn.lock`, `package-lock.json`, or `pnpm-lock.yaml`)
21
+ * or `undefined` if not found.
22
+ */
23
+ lockfilePath?: string;
24
+ /**
25
+ * The `lockfileVersion` number from lockfile (`package-lock.json` or `pnpm-lock.yaml`),
26
+ * or `undefined` if not found.
23
27
  */
24
28
  lockfileVersion?: number;
25
29
  }
@@ -95,21 +95,9 @@ async function execCommand(command, options = {}) {
95
95
  }
96
96
  exports.execCommand = execCommand;
97
97
  async function getNodeBinPath({ cwd, }) {
98
- const { code, stdout, stderr } = await execAsync('npm', ['bin'], {
99
- cwd,
100
- prettyCommand: 'npm bin',
101
- // in some rare cases, we saw `npm bin` exit with a non-0 code, but still
102
- // output the right bin path, so we ignore the exit code
103
- ignoreNon0Exit: true,
104
- });
105
- const nodeBinPath = stdout.trim();
106
- if (path_1.default.isAbsolute(nodeBinPath)) {
107
- return nodeBinPath;
108
- }
109
- throw new errors_1.NowBuildError({
110
- code: `BUILD_UTILS_GET_NODE_BIN_PATH`,
111
- message: `Running \`npm bin\` failed to return a valid bin path (code=${code}, stdout=${stdout}, stderr=${stderr})`,
112
- });
98
+ const { lockfilePath } = await scanParentDirs(cwd);
99
+ const dir = path_1.default.dirname(lockfilePath || cwd);
100
+ return path_1.default.join(dir, 'node_modules', '.bin');
113
101
  }
114
102
  exports.getNodeBinPath = getNodeBinPath;
115
103
  async function chmodPlusX(fsPath) {
@@ -202,6 +190,7 @@ async function scanParentDirs(destPath, readPackageJson = false) {
202
190
  start: destPath,
203
191
  filenames: ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml'],
204
192
  });
193
+ let lockfilePath;
205
194
  let lockfileVersion;
206
195
  let cliType = 'yarn';
207
196
  const [hasYarnLock, packageLockJson, pnpmLockYaml] = await Promise.all([
@@ -216,18 +205,26 @@ async function scanParentDirs(destPath, readPackageJson = false) {
216
205
  // Priority order is Yarn > pnpm > npm
217
206
  if (hasYarnLock) {
218
207
  cliType = 'yarn';
208
+ lockfilePath = yarnLockPath;
219
209
  }
220
210
  else if (pnpmLockYaml) {
221
211
  cliType = 'pnpm';
222
- // just ensure that it is read as a number and not a string
212
+ lockfilePath = pnpmLockPath;
223
213
  lockfileVersion = Number(pnpmLockYaml.lockfileVersion);
224
214
  }
225
215
  else if (packageLockJson) {
226
216
  cliType = 'npm';
217
+ lockfilePath = npmLockPath;
227
218
  lockfileVersion = packageLockJson.lockfileVersion;
228
219
  }
229
220
  const packageJsonPath = pkgJsonPath || undefined;
230
- return { cliType, packageJson, lockfileVersion, packageJsonPath };
221
+ return {
222
+ cliType,
223
+ packageJson,
224
+ lockfilePath,
225
+ lockfileVersion,
226
+ packageJsonPath,
227
+ };
231
228
  }
232
229
  exports.scanParentDirs = scanParentDirs;
233
230
  async function walkParentDirs({ base, start, filename, }) {
package/dist/index.js CHANGED
@@ -30121,6 +30121,9 @@ function debug(message, ...additional) {
30121
30121
  if (get_platform_env_1.getPlatformEnv('BUILDER_DEBUG')) {
30122
30122
  console.log(message, ...additional);
30123
30123
  }
30124
+ else if (process.env.VERCEL_DEBUG_PREFIX) {
30125
+ console.log(`${process.env.VERCEL_DEBUG_PREFIX}${message}`, ...additional);
30126
+ }
30124
30127
  }
30125
30128
  exports.default = debug;
30126
30129
 
@@ -30924,21 +30927,9 @@ async function execCommand(command, options = {}) {
30924
30927
  }
30925
30928
  exports.execCommand = execCommand;
30926
30929
  async function getNodeBinPath({ cwd, }) {
30927
- const { code, stdout, stderr } = await execAsync('npm', ['bin'], {
30928
- cwd,
30929
- prettyCommand: 'npm bin',
30930
- // in some rare cases, we saw `npm bin` exit with a non-0 code, but still
30931
- // output the right bin path, so we ignore the exit code
30932
- ignoreNon0Exit: true,
30933
- });
30934
- const nodeBinPath = stdout.trim();
30935
- if (path_1.default.isAbsolute(nodeBinPath)) {
30936
- return nodeBinPath;
30937
- }
30938
- throw new errors_1.NowBuildError({
30939
- code: `BUILD_UTILS_GET_NODE_BIN_PATH`,
30940
- message: `Running \`npm bin\` failed to return a valid bin path (code=${code}, stdout=${stdout}, stderr=${stderr})`,
30941
- });
30930
+ const { lockfilePath } = await scanParentDirs(cwd);
30931
+ const dir = path_1.default.dirname(lockfilePath || cwd);
30932
+ return path_1.default.join(dir, 'node_modules', '.bin');
30942
30933
  }
30943
30934
  exports.getNodeBinPath = getNodeBinPath;
30944
30935
  async function chmodPlusX(fsPath) {
@@ -31031,6 +31022,7 @@ async function scanParentDirs(destPath, readPackageJson = false) {
31031
31022
  start: destPath,
31032
31023
  filenames: ['yarn.lock', 'package-lock.json', 'pnpm-lock.yaml'],
31033
31024
  });
31025
+ let lockfilePath;
31034
31026
  let lockfileVersion;
31035
31027
  let cliType = 'yarn';
31036
31028
  const [hasYarnLock, packageLockJson, pnpmLockYaml] = await Promise.all([
@@ -31045,18 +31037,26 @@ async function scanParentDirs(destPath, readPackageJson = false) {
31045
31037
  // Priority order is Yarn > pnpm > npm
31046
31038
  if (hasYarnLock) {
31047
31039
  cliType = 'yarn';
31040
+ lockfilePath = yarnLockPath;
31048
31041
  }
31049
31042
  else if (pnpmLockYaml) {
31050
31043
  cliType = 'pnpm';
31051
- // just ensure that it is read as a number and not a string
31044
+ lockfilePath = pnpmLockPath;
31052
31045
  lockfileVersion = Number(pnpmLockYaml.lockfileVersion);
31053
31046
  }
31054
31047
  else if (packageLockJson) {
31055
31048
  cliType = 'npm';
31049
+ lockfilePath = npmLockPath;
31056
31050
  lockfileVersion = packageLockJson.lockfileVersion;
31057
31051
  }
31058
31052
  const packageJsonPath = pkgJsonPath || undefined;
31059
- return { cliType, packageJson, lockfileVersion, packageJsonPath };
31053
+ return {
31054
+ cliType,
31055
+ packageJson,
31056
+ lockfilePath,
31057
+ lockfileVersion,
31058
+ packageJsonPath,
31059
+ };
31060
31060
  }
31061
31061
  exports.scanParentDirs = scanParentDirs;
31062
31062
  async function walkParentDirs({ base, start, filename, }) {
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "5.3.2",
3
+ "version": "5.4.2",
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": "6700630feb23bdb4e94ea727911a9e10aa546361"
50
+ "gitHead": "d5537500d8957985c1ffb3798659a611cc2e5d5d"
51
51
  }