@vercel/build-utils 5.7.2 → 5.7.3
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/fs/download.d.ts +0 -1
- package/dist/fs/download.js +4 -13
- package/dist/fs/glob.js +14 -32
- package/dist/index.js +18 -45
- package/package.json +2 -2
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
@@ -30517,23 +30517,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30517
30517
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
30518
30518
|
};
|
30519
30519
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
30520
|
-
exports.downloadFile = exports.
|
30520
|
+
exports.downloadFile = exports.isSymbolicLink = void 0;
|
30521
30521
|
const path_1 = __importDefault(__webpack_require__(5622));
|
30522
30522
|
const debug_1 = __importDefault(__webpack_require__(1868));
|
30523
30523
|
const file_fs_ref_1 = __importDefault(__webpack_require__(9331));
|
30524
30524
|
const fs_extra_1 = __webpack_require__(5392);
|
30525
30525
|
const stream_to_buffer_1 = __importDefault(__webpack_require__(2560));
|
30526
|
-
const
|
30526
|
+
const S_IFMT = 61440; /* 0170000 type of file */
|
30527
|
+
const S_IFLNK = 40960; /* 0120000 symbolic link */
|
30527
30528
|
function isSymbolicLink(mode) {
|
30528
|
-
|
30529
|
-
return STAT.isSymbolicLink();
|
30529
|
+
return (mode & S_IFMT) === S_IFLNK;
|
30530
30530
|
}
|
30531
30531
|
exports.isSymbolicLink = isSymbolicLink;
|
30532
|
-
function isDirectory(mode) {
|
30533
|
-
STAT.mode = mode;
|
30534
|
-
return STAT.isDirectory();
|
30535
|
-
}
|
30536
|
-
exports.isDirectory = isDirectory;
|
30537
30532
|
async function prepareSymlinkTarget(file, fsPath) {
|
30538
30533
|
const mkdirPromise = fs_extra_1.mkdirp(path_1.default.dirname(fsPath));
|
30539
30534
|
if (file.type === 'FileFsRef') {
|
@@ -30552,10 +30547,6 @@ async function prepareSymlinkTarget(file, fsPath) {
|
|
30552
30547
|
}
|
30553
30548
|
async function downloadFile(file, fsPath) {
|
30554
30549
|
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
30550
|
// If the source is a symlink, try to create it instead of copying the file.
|
30560
30551
|
// Note: creating symlinks on Windows requires admin priviliges or symlinks
|
30561
30552
|
// enabled in the group policy. We may want to improve the error message.
|
@@ -30659,7 +30650,13 @@ const normalize_path_1 = __webpack_require__(6261);
|
|
30659
30650
|
const file_fs_ref_1 = __importDefault(__webpack_require__(9331));
|
30660
30651
|
const vanillaGlob = util_1.promisify(glob_1.default);
|
30661
30652
|
async function glob(pattern, opts, mountpoint) {
|
30662
|
-
|
30653
|
+
let options;
|
30654
|
+
if (typeof opts === 'string') {
|
30655
|
+
options = { cwd: opts };
|
30656
|
+
}
|
30657
|
+
else {
|
30658
|
+
options = opts;
|
30659
|
+
}
|
30663
30660
|
if (!options.cwd) {
|
30664
30661
|
throw new Error('Second argument (basePath) must be specified for names of resulting files');
|
30665
30662
|
}
|
@@ -30668,32 +30665,20 @@ async function glob(pattern, opts, mountpoint) {
|
|
30668
30665
|
}
|
30669
30666
|
const results = {};
|
30670
30667
|
const statCache = {};
|
30671
|
-
|
30672
|
-
|
30673
|
-
|
30674
|
-
|
30675
|
-
|
30676
|
-
stat: true,
|
30677
|
-
dot: true,
|
30678
|
-
});
|
30679
|
-
const dirs = new Set();
|
30680
|
-
const dirsWithEntries = new Set();
|
30668
|
+
options.symlinks = {};
|
30669
|
+
options.statCache = statCache;
|
30670
|
+
options.stat = true;
|
30671
|
+
options.dot = true;
|
30672
|
+
const files = await vanillaGlob(pattern, options);
|
30681
30673
|
for (const relativePath of files) {
|
30682
30674
|
const fsPath = normalize_path_1.normalizePath(path_1.default.join(options.cwd, relativePath));
|
30683
30675
|
let stat = statCache[fsPath];
|
30684
30676
|
assert_1.default(stat, `statCache does not contain value for ${relativePath} (resolved to ${fsPath})`);
|
30685
|
-
const isSymlink = symlinks[fsPath];
|
30686
|
-
if (isSymlink || stat.isFile()
|
30677
|
+
const isSymlink = options.symlinks[fsPath];
|
30678
|
+
if (isSymlink || stat.isFile()) {
|
30687
30679
|
if (isSymlink) {
|
30688
30680
|
stat = await fs_extra_1.lstat(fsPath);
|
30689
30681
|
}
|
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
30682
|
let finalPath = relativePath;
|
30698
30683
|
if (mountpoint) {
|
30699
30684
|
finalPath = path_1.default.join(mountpoint, finalPath);
|
@@ -30701,18 +30686,6 @@ async function glob(pattern, opts, mountpoint) {
|
|
30701
30686
|
results[finalPath] = new file_fs_ref_1.default({ mode: stat.mode, fsPath });
|
30702
30687
|
}
|
30703
30688
|
}
|
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
30689
|
return results;
|
30717
30690
|
}
|
30718
30691
|
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.3",
|
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": "d6cccd70f28969eec48b484b0e74b0942de9b6cd"
|
51
51
|
}
|