@vercel/build-utils 5.7.2 → 5.7.4
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.js +3 -1
- package/dist/fs/download.d.ts +0 -1
- package/dist/fs/download.js +4 -13
- package/dist/fs/glob.js +14 -32
- package/dist/index.js +21 -46
- package/package.json +2 -2
package/dist/clone-env.js
CHANGED
@@ -23,7 +23,9 @@ function cloneEnv(...envs) {
|
|
23
23
|
// however we lose this proxied value when we destructure and
|
24
24
|
// thus we must explicitly copy it, but we must also remove the
|
25
25
|
// `Path` property since we can't have both a `PATH` and `Path`
|
26
|
-
obj.
|
26
|
+
if (obj.Path !== undefined) {
|
27
|
+
obj.PATH = obj.Path;
|
28
|
+
}
|
27
29
|
delete obj.Path;
|
28
30
|
}
|
29
31
|
return obj;
|
package/dist/fs/download.d.ts
CHANGED
@@ -4,6 +4,5 @@ export interface DownloadedFiles {
|
|
4
4
|
[filePath: string]: FileFsRef;
|
5
5
|
}
|
6
6
|
export declare function isSymbolicLink(mode: number): boolean;
|
7
|
-
export declare function isDirectory(mode: number): boolean;
|
8
7
|
export declare function downloadFile(file: File, fsPath: string): Promise<FileFsRef>;
|
9
8
|
export default function download(files: Files, basePath: string, meta?: Meta): Promise<DownloadedFiles>;
|
package/dist/fs/download.js
CHANGED
@@ -3,23 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.downloadFile = exports.
|
6
|
+
exports.downloadFile = exports.isSymbolicLink = void 0;
|
7
7
|
const path_1 = __importDefault(require("path"));
|
8
8
|
const debug_1 = __importDefault(require("../debug"));
|
9
9
|
const file_fs_ref_1 = __importDefault(require("../file-fs-ref"));
|
10
10
|
const fs_extra_1 = require("fs-extra");
|
11
11
|
const stream_to_buffer_1 = __importDefault(require("./stream-to-buffer"));
|
12
|
-
const
|
12
|
+
const S_IFMT = 61440; /* 0170000 type of file */
|
13
|
+
const S_IFLNK = 40960; /* 0120000 symbolic link */
|
13
14
|
function isSymbolicLink(mode) {
|
14
|
-
|
15
|
-
return STAT.isSymbolicLink();
|
15
|
+
return (mode & S_IFMT) === S_IFLNK;
|
16
16
|
}
|
17
17
|
exports.isSymbolicLink = isSymbolicLink;
|
18
|
-
function isDirectory(mode) {
|
19
|
-
STAT.mode = mode;
|
20
|
-
return STAT.isDirectory();
|
21
|
-
}
|
22
|
-
exports.isDirectory = isDirectory;
|
23
18
|
async function prepareSymlinkTarget(file, fsPath) {
|
24
19
|
const mkdirPromise = fs_extra_1.mkdirp(path_1.default.dirname(fsPath));
|
25
20
|
if (file.type === 'FileFsRef') {
|
@@ -38,10 +33,6 @@ async function prepareSymlinkTarget(file, fsPath) {
|
|
38
33
|
}
|
39
34
|
async function downloadFile(file, fsPath) {
|
40
35
|
const { mode } = file;
|
41
|
-
if (isDirectory(mode)) {
|
42
|
-
await fs_extra_1.mkdirp(fsPath);
|
43
|
-
return file_fs_ref_1.default.fromFsPath({ mode, fsPath });
|
44
|
-
}
|
45
36
|
// If the source is a symlink, try to create it instead of copying the file.
|
46
37
|
// Note: creating symlinks on Windows requires admin priviliges or symlinks
|
47
38
|
// enabled in the group policy. We may want to improve the error message.
|
package/dist/fs/glob.js
CHANGED
@@ -12,7 +12,13 @@ const normalize_path_1 = require("./normalize-path");
|
|
12
12
|
const file_fs_ref_1 = __importDefault(require("../file-fs-ref"));
|
13
13
|
const vanillaGlob = util_1.promisify(glob_1.default);
|
14
14
|
async function glob(pattern, opts, mountpoint) {
|
15
|
-
|
15
|
+
let options;
|
16
|
+
if (typeof opts === 'string') {
|
17
|
+
options = { cwd: opts };
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
options = opts;
|
21
|
+
}
|
16
22
|
if (!options.cwd) {
|
17
23
|
throw new Error('Second argument (basePath) must be specified for names of resulting files');
|
18
24
|
}
|
@@ -21,32 +27,20 @@ async function glob(pattern, opts, mountpoint) {
|
|
21
27
|
}
|
22
28
|
const results = {};
|
23
29
|
const statCache = {};
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
stat: true,
|
30
|
-
dot: true,
|
31
|
-
});
|
32
|
-
const dirs = new Set();
|
33
|
-
const dirsWithEntries = new Set();
|
30
|
+
options.symlinks = {};
|
31
|
+
options.statCache = statCache;
|
32
|
+
options.stat = true;
|
33
|
+
options.dot = true;
|
34
|
+
const files = await vanillaGlob(pattern, options);
|
34
35
|
for (const relativePath of files) {
|
35
36
|
const fsPath = normalize_path_1.normalizePath(path_1.default.join(options.cwd, relativePath));
|
36
37
|
let stat = statCache[fsPath];
|
37
38
|
assert_1.default(stat, `statCache does not contain value for ${relativePath} (resolved to ${fsPath})`);
|
38
|
-
const isSymlink = symlinks[fsPath];
|
39
|
-
if (isSymlink || stat.isFile()
|
39
|
+
const isSymlink = options.symlinks[fsPath];
|
40
|
+
if (isSymlink || stat.isFile()) {
|
40
41
|
if (isSymlink) {
|
41
42
|
stat = await fs_extra_1.lstat(fsPath);
|
42
43
|
}
|
43
|
-
// Some bookkeeping to track which directories already have entries within
|
44
|
-
const dirname = path_1.default.dirname(relativePath);
|
45
|
-
dirsWithEntries.add(dirname);
|
46
|
-
if (stat.isDirectory()) {
|
47
|
-
dirs.add(relativePath);
|
48
|
-
continue;
|
49
|
-
}
|
50
44
|
let finalPath = relativePath;
|
51
45
|
if (mountpoint) {
|
52
46
|
finalPath = path_1.default.join(mountpoint, finalPath);
|
@@ -54,18 +48,6 @@ async function glob(pattern, opts, mountpoint) {
|
|
54
48
|
results[finalPath] = new file_fs_ref_1.default({ mode: stat.mode, fsPath });
|
55
49
|
}
|
56
50
|
}
|
57
|
-
// Add empty directory entries
|
58
|
-
for (const relativePath of dirs) {
|
59
|
-
if (dirsWithEntries.has(relativePath))
|
60
|
-
continue;
|
61
|
-
let finalPath = relativePath;
|
62
|
-
if (mountpoint) {
|
63
|
-
finalPath = path_1.default.join(mountpoint, finalPath);
|
64
|
-
}
|
65
|
-
const fsPath = normalize_path_1.normalizePath(path_1.default.join(options.cwd, relativePath));
|
66
|
-
const stat = statCache[fsPath];
|
67
|
-
results[finalPath] = new file_fs_ref_1.default({ mode: stat.mode, fsPath });
|
68
|
-
}
|
69
51
|
return results;
|
70
52
|
}
|
71
53
|
exports.default = glob;
|
package/dist/index.js
CHANGED
@@ -30139,7 +30139,9 @@ function cloneEnv(...envs) {
|
|
30139
30139
|
// however we lose this proxied value when we destructure and
|
30140
30140
|
// thus we must explicitly copy it, but we must also remove the
|
30141
30141
|
// `Path` property since we can't have both a `PATH` and `Path`
|
30142
|
-
obj.
|
30142
|
+
if (obj.Path !== undefined) {
|
30143
|
+
obj.PATH = obj.Path;
|
30144
|
+
}
|
30143
30145
|
delete obj.Path;
|
30144
30146
|
}
|
30145
30147
|
return obj;
|
@@ -30517,23 +30519,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30517
30519
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
30518
30520
|
};
|
30519
30521
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
30520
|
-
exports.downloadFile = exports.
|
30522
|
+
exports.downloadFile = exports.isSymbolicLink = void 0;
|
30521
30523
|
const path_1 = __importDefault(__webpack_require__(5622));
|
30522
30524
|
const debug_1 = __importDefault(__webpack_require__(1868));
|
30523
30525
|
const file_fs_ref_1 = __importDefault(__webpack_require__(9331));
|
30524
30526
|
const fs_extra_1 = __webpack_require__(5392);
|
30525
30527
|
const stream_to_buffer_1 = __importDefault(__webpack_require__(2560));
|
30526
|
-
const
|
30528
|
+
const S_IFMT = 61440; /* 0170000 type of file */
|
30529
|
+
const S_IFLNK = 40960; /* 0120000 symbolic link */
|
30527
30530
|
function isSymbolicLink(mode) {
|
30528
|
-
|
30529
|
-
return STAT.isSymbolicLink();
|
30531
|
+
return (mode & S_IFMT) === S_IFLNK;
|
30530
30532
|
}
|
30531
30533
|
exports.isSymbolicLink = isSymbolicLink;
|
30532
|
-
function isDirectory(mode) {
|
30533
|
-
STAT.mode = mode;
|
30534
|
-
return STAT.isDirectory();
|
30535
|
-
}
|
30536
|
-
exports.isDirectory = isDirectory;
|
30537
30534
|
async function prepareSymlinkTarget(file, fsPath) {
|
30538
30535
|
const mkdirPromise = fs_extra_1.mkdirp(path_1.default.dirname(fsPath));
|
30539
30536
|
if (file.type === 'FileFsRef') {
|
@@ -30552,10 +30549,6 @@ async function prepareSymlinkTarget(file, fsPath) {
|
|
30552
30549
|
}
|
30553
30550
|
async function downloadFile(file, fsPath) {
|
30554
30551
|
const { mode } = file;
|
30555
|
-
if (isDirectory(mode)) {
|
30556
|
-
await fs_extra_1.mkdirp(fsPath);
|
30557
|
-
return file_fs_ref_1.default.fromFsPath({ mode, fsPath });
|
30558
|
-
}
|
30559
30552
|
// If the source is a symlink, try to create it instead of copying the file.
|
30560
30553
|
// Note: creating symlinks on Windows requires admin priviliges or symlinks
|
30561
30554
|
// enabled in the group policy. We may want to improve the error message.
|
@@ -30659,7 +30652,13 @@ const normalize_path_1 = __webpack_require__(6261);
|
|
30659
30652
|
const file_fs_ref_1 = __importDefault(__webpack_require__(9331));
|
30660
30653
|
const vanillaGlob = util_1.promisify(glob_1.default);
|
30661
30654
|
async function glob(pattern, opts, mountpoint) {
|
30662
|
-
|
30655
|
+
let options;
|
30656
|
+
if (typeof opts === 'string') {
|
30657
|
+
options = { cwd: opts };
|
30658
|
+
}
|
30659
|
+
else {
|
30660
|
+
options = opts;
|
30661
|
+
}
|
30663
30662
|
if (!options.cwd) {
|
30664
30663
|
throw new Error('Second argument (basePath) must be specified for names of resulting files');
|
30665
30664
|
}
|
@@ -30668,32 +30667,20 @@ async function glob(pattern, opts, mountpoint) {
|
|
30668
30667
|
}
|
30669
30668
|
const results = {};
|
30670
30669
|
const statCache = {};
|
30671
|
-
|
30672
|
-
|
30673
|
-
|
30674
|
-
|
30675
|
-
|
30676
|
-
stat: true,
|
30677
|
-
dot: true,
|
30678
|
-
});
|
30679
|
-
const dirs = new Set();
|
30680
|
-
const dirsWithEntries = new Set();
|
30670
|
+
options.symlinks = {};
|
30671
|
+
options.statCache = statCache;
|
30672
|
+
options.stat = true;
|
30673
|
+
options.dot = true;
|
30674
|
+
const files = await vanillaGlob(pattern, options);
|
30681
30675
|
for (const relativePath of files) {
|
30682
30676
|
const fsPath = normalize_path_1.normalizePath(path_1.default.join(options.cwd, relativePath));
|
30683
30677
|
let stat = statCache[fsPath];
|
30684
30678
|
assert_1.default(stat, `statCache does not contain value for ${relativePath} (resolved to ${fsPath})`);
|
30685
|
-
const isSymlink = symlinks[fsPath];
|
30686
|
-
if (isSymlink || stat.isFile()
|
30679
|
+
const isSymlink = options.symlinks[fsPath];
|
30680
|
+
if (isSymlink || stat.isFile()) {
|
30687
30681
|
if (isSymlink) {
|
30688
30682
|
stat = await fs_extra_1.lstat(fsPath);
|
30689
30683
|
}
|
30690
|
-
// Some bookkeeping to track which directories already have entries within
|
30691
|
-
const dirname = path_1.default.dirname(relativePath);
|
30692
|
-
dirsWithEntries.add(dirname);
|
30693
|
-
if (stat.isDirectory()) {
|
30694
|
-
dirs.add(relativePath);
|
30695
|
-
continue;
|
30696
|
-
}
|
30697
30684
|
let finalPath = relativePath;
|
30698
30685
|
if (mountpoint) {
|
30699
30686
|
finalPath = path_1.default.join(mountpoint, finalPath);
|
@@ -30701,18 +30688,6 @@ async function glob(pattern, opts, mountpoint) {
|
|
30701
30688
|
results[finalPath] = new file_fs_ref_1.default({ mode: stat.mode, fsPath });
|
30702
30689
|
}
|
30703
30690
|
}
|
30704
|
-
// Add empty directory entries
|
30705
|
-
for (const relativePath of dirs) {
|
30706
|
-
if (dirsWithEntries.has(relativePath))
|
30707
|
-
continue;
|
30708
|
-
let finalPath = relativePath;
|
30709
|
-
if (mountpoint) {
|
30710
|
-
finalPath = path_1.default.join(mountpoint, finalPath);
|
30711
|
-
}
|
30712
|
-
const fsPath = normalize_path_1.normalizePath(path_1.default.join(options.cwd, relativePath));
|
30713
|
-
const stat = statCache[fsPath];
|
30714
|
-
results[finalPath] = new file_fs_ref_1.default({ mode: stat.mode, fsPath });
|
30715
|
-
}
|
30716
30691
|
return results;
|
30717
30692
|
}
|
30718
30693
|
exports.default = glob;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/build-utils",
|
3
|
-
"version": "5.7.
|
3
|
+
"version": "5.7.4",
|
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": "721cd3afcbff994fa96704b4eb79e5f6da7ab73c"
|
51
51
|
}
|