@vercel/build-utils 4.0.0 → 4.1.1-canary.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/detect-builders.d.ts +1 -1
- package/dist/detect-builders.js +13 -3
- package/dist/fs/get-glob-fs.d.ts +6 -0
- package/dist/fs/get-glob-fs.js +71 -0
- package/dist/get-project-paths.d.ts +9 -0
- package/dist/get-project-paths.js +39 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1471 -155
- package/dist/types.d.ts +2 -1
- package/dist/workspaces/get-workspace-package-paths.d.ts +11 -0
- package/dist/workspaces/get-workspace-package-paths.js +62 -0
- package/package.json +4 -4
package/dist/types.d.ts
CHANGED
@@ -377,7 +377,8 @@ export interface BuildResultV2Typical {
|
|
377
377
|
}
|
378
378
|
export declare type BuildResultV2 = BuildResultV2Typical | BuildResultBuildOutput;
|
379
379
|
export interface BuildResultV3 {
|
380
|
-
|
380
|
+
routes?: any[];
|
381
|
+
output: Lambda | EdgeFunction;
|
381
382
|
}
|
382
383
|
export declare type BuildV2 = (options: BuildOptions) => Promise<BuildResultV2>;
|
383
384
|
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": "4.
|
3
|
+
"version": "4.1.1-canary.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": "
|
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",
|
@@ -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": "
|
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": "
|
53
|
+
"gitHead": "4bf6295d7a1d6544f195d76a2a4aedb476fa7dc1"
|
54
54
|
}
|