@vercel/build-utils 3.1.1 → 4.1.0

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/lambda.js CHANGED
@@ -114,7 +114,7 @@ async function createZip(files) {
114
114
  }
115
115
  exports.createZip = createZip;
116
116
  async function getLambdaOptionsFromFunction({ sourceFile, config, }) {
117
- if (config === null || config === void 0 ? void 0 : config.functions) {
117
+ if (config?.functions) {
118
118
  for (const [pattern, fn] of Object.entries(config.functions)) {
119
119
  if (sourceFile === pattern || minimatch_1.default(sourceFile, pattern)) {
120
120
  return {
package/dist/types.d.ts CHANGED
@@ -76,7 +76,7 @@ export interface BuildOptions {
76
76
  * is the Git Repository Root. This is only relevant for Monorepos.
77
77
  * See https://vercel.com/blog/monorepos
78
78
  */
79
- repoRootPath?: string;
79
+ repoRootPath: string;
80
80
  /**
81
81
  * An arbitrary object passed by the user in the build definition defined
82
82
  * in `vercel.json`.
@@ -111,7 +111,7 @@ export interface PrepareCacheOptions {
111
111
  * is the Git Repository Root. This is only relevant for Monorepos.
112
112
  * See https://vercel.com/blog/monorepos
113
113
  */
114
- repoRootPath?: string;
114
+ repoRootPath: string;
115
115
  /**
116
116
  * An arbitrary object passed by the user in the build definition defined
117
117
  * in `vercel.json`.
@@ -261,6 +261,7 @@ export interface PackageJson {
261
261
  readonly preferGlobal?: boolean;
262
262
  readonly private?: boolean;
263
263
  readonly publishConfig?: PackageJson.PublishConfig;
264
+ readonly packageManager?: string;
264
265
  }
265
266
  export interface NodeVersion {
266
267
  major: number;
@@ -376,7 +377,7 @@ export interface BuildResultV2Typical {
376
377
  }
377
378
  export declare type BuildResultV2 = BuildResultV2Typical | BuildResultBuildOutput;
378
379
  export interface BuildResultV3 {
379
- output: Lambda;
380
+ output: Lambda | EdgeFunction;
380
381
  }
381
382
  export declare type BuildV2 = (options: BuildOptions) => Promise<BuildResultV2>;
382
383
  export declare type BuildV3 = (options: BuildOptions) => Promise<BuildResultV3>;
@@ -0,0 +1,11 @@
1
+ import { DetectorFilesystem } from '../detectors/filesystem';
2
+ import { Workspace } from './get-workspaces';
3
+ interface GetPackagePathOptions {
4
+ fs: DetectorFilesystem;
5
+ }
6
+ export interface GetWorkspacePackagePathsOptions extends GetPackagePathOptions {
7
+ fs: DetectorFilesystem;
8
+ workspace: Workspace;
9
+ }
10
+ export declare function getWorkspacePackagePaths({ fs, workspace, }: GetWorkspacePackagePathsOptions): Promise<string[]>;
11
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getWorkspacePackagePaths = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const js_yaml_1 = __importDefault(require("js-yaml"));
9
+ const glob_1 = __importDefault(require("glob"));
10
+ const get_glob_fs_1 = require("../fs/get-glob-fs");
11
+ const normalize_path_1 = require("../fs/normalize-path");
12
+ const posixPath = path_1.default.posix;
13
+ async function getWorkspacePackagePaths({ fs, workspace, }) {
14
+ const { type, rootPath } = workspace;
15
+ const workspaceFs = fs.chdir(rootPath);
16
+ let results = [];
17
+ switch (type) {
18
+ case 'yarn':
19
+ case 'npm':
20
+ results = await getPackageJsonWorkspacePackagePaths({ fs: workspaceFs });
21
+ break;
22
+ case 'pnpm':
23
+ results = await getPnpmWorkspacePackagePaths({ fs: workspaceFs });
24
+ break;
25
+ default:
26
+ throw new Error(`Unknown workspace implementation: ${type}`);
27
+ }
28
+ return results.map(packagePath => {
29
+ return posixPath.join(rootPath, posixPath.dirname(packagePath));
30
+ });
31
+ }
32
+ exports.getWorkspacePackagePaths = getWorkspacePackagePaths;
33
+ async function getPackagePaths(packages, fs) {
34
+ return (await Promise.all(packages.map(packageGlob => new Promise((resolve, reject) => {
35
+ glob_1.default(normalize_path_1.normalizePath(posixPath.join(packageGlob, 'package.json')), {
36
+ cwd: '/',
37
+ fs: get_glob_fs_1.getGlobFs(fs),
38
+ }, (err, matches) => {
39
+ if (err)
40
+ reject(err);
41
+ else
42
+ resolve(matches);
43
+ });
44
+ })))).flat();
45
+ }
46
+ async function getPackageJsonWorkspacePackagePaths({ fs, }) {
47
+ const packageJsonAsBuffer = await fs.readFile('package.json');
48
+ const { workspaces } = JSON.parse(packageJsonAsBuffer.toString());
49
+ let packages = [];
50
+ if (Array.isArray(workspaces)) {
51
+ packages = workspaces;
52
+ }
53
+ else {
54
+ packages = workspaces?.packages ?? [];
55
+ }
56
+ return getPackagePaths(packages, fs);
57
+ }
58
+ async function getPnpmWorkspacePackagePaths({ fs, }) {
59
+ const pnpmWorkspaceAsBuffer = await fs.readFile('pnpm-workspace.yaml');
60
+ const { packages = [] } = js_yaml_1.default.load(pnpmWorkspaceAsBuffer.toString());
61
+ return getPackagePaths(packages, fs);
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "3.1.1",
3
+ "version": "4.1.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -23,7 +23,7 @@
23
23
  "@types/cross-spawn": "6.0.0",
24
24
  "@types/end-of-stream": "^1.4.0",
25
25
  "@types/fs-extra": "9.0.13",
26
- "@types/glob": "^7.1.1",
26
+ "@types/glob": "7.2.0",
27
27
  "@types/jest": "27.4.1",
28
28
  "@types/js-yaml": "3.12.1",
29
29
  "@types/ms": "0.7.31",
@@ -31,7 +31,7 @@
31
31
  "@types/node-fetch": "^2.1.6",
32
32
  "@types/semver": "6.0.0",
33
33
  "@types/yazl": "2.4.2",
34
- "@vercel/frameworks": "1.0.0",
34
+ "@vercel/frameworks": "1.0.1",
35
35
  "@vercel/ncc": "0.24.0",
36
36
  "aggregate-error": "3.0.1",
37
37
  "async-retry": "1.2.3",
@@ -40,7 +40,7 @@
40
40
  "cross-spawn": "6.0.5",
41
41
  "end-of-stream": "1.4.1",
42
42
  "fs-extra": "10.0.0",
43
- "glob": "7.1.3",
43
+ "glob": "8.0.3",
44
44
  "into-stream": "5.0.0",
45
45
  "js-yaml": "3.13.1",
46
46
  "minimatch": "3.0.4",
@@ -50,5 +50,5 @@
50
50
  "typescript": "4.3.4",
51
51
  "yazl": "2.5.1"
52
52
  },
53
- "gitHead": "ad436313e155b0e07cb14475e11c5c12e1b36f75"
53
+ "gitHead": "0c7b54edad6adf48505abf2cbec01691b85963bb"
54
54
  }