@vercel/build-utils 5.7.4 → 5.8.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/fs/download.d.ts +1 -0
- package/dist/fs/download.js +12 -2
- package/dist/fs/glob.js +32 -14
- package/dist/fs/run-user-scripts.js +3 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23666 -23582
- package/dist/lambda.js +3 -0
- package/package.json +8 -4
package/dist/fs/download.d.ts
CHANGED
@@ -3,6 +3,7 @@ import { File, Files, Meta } from '../types';
|
|
3
3
|
export interface DownloadedFiles {
|
4
4
|
[filePath: string]: FileFsRef;
|
5
5
|
}
|
6
|
+
export declare function isDirectory(mode: number): boolean;
|
6
7
|
export declare function isSymbolicLink(mode: number): boolean;
|
7
8
|
export declare function downloadFile(file: File, fsPath: string): Promise<FileFsRef>;
|
8
9
|
export default function download(files: Files, basePath: string, meta?: Meta): Promise<DownloadedFiles>;
|
package/dist/fs/download.js
CHANGED
@@ -3,14 +3,19 @@ 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.isSymbolicLink = void 0;
|
6
|
+
exports.downloadFile = exports.isSymbolicLink = exports.isDirectory = 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_IFDIR = 16384; /* 0040000 directory */
|
13
13
|
const S_IFLNK = 40960; /* 0120000 symbolic link */
|
14
|
+
const S_IFMT = 61440; /* 0170000 type of file */
|
15
|
+
function isDirectory(mode) {
|
16
|
+
return (mode & S_IFMT) === S_IFDIR;
|
17
|
+
}
|
18
|
+
exports.isDirectory = isDirectory;
|
14
19
|
function isSymbolicLink(mode) {
|
15
20
|
return (mode & S_IFMT) === S_IFLNK;
|
16
21
|
}
|
@@ -33,6 +38,11 @@ async function prepareSymlinkTarget(file, fsPath) {
|
|
33
38
|
}
|
34
39
|
async function downloadFile(file, fsPath) {
|
35
40
|
const { mode } = file;
|
41
|
+
if (isDirectory(mode)) {
|
42
|
+
await fs_extra_1.mkdirp(fsPath);
|
43
|
+
await fs_extra_1.chmod(fsPath, mode);
|
44
|
+
return file_fs_ref_1.default.fromFsPath({ mode, fsPath });
|
45
|
+
}
|
36
46
|
// If the source is a symlink, try to create it instead of copying the file.
|
37
47
|
// Note: creating symlinks on Windows requires admin priviliges or symlinks
|
38
48
|
// enabled in the group policy. We may want to improve the error message.
|
package/dist/fs/glob.js
CHANGED
@@ -12,13 +12,7 @@ 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
|
-
|
16
|
-
if (typeof opts === 'string') {
|
17
|
-
options = { cwd: opts };
|
18
|
-
}
|
19
|
-
else {
|
20
|
-
options = opts;
|
21
|
-
}
|
15
|
+
const options = typeof opts === 'string' ? { cwd: opts } : opts;
|
22
16
|
if (!options.cwd) {
|
23
17
|
throw new Error('Second argument (basePath) must be specified for names of resulting files');
|
24
18
|
}
|
@@ -27,20 +21,32 @@ async function glob(pattern, opts, mountpoint) {
|
|
27
21
|
}
|
28
22
|
const results = {};
|
29
23
|
const statCache = {};
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
const symlinks = {};
|
25
|
+
const files = await vanillaGlob(pattern, {
|
26
|
+
...options,
|
27
|
+
symlinks,
|
28
|
+
statCache,
|
29
|
+
stat: true,
|
30
|
+
dot: true,
|
31
|
+
});
|
32
|
+
const dirs = new Set();
|
33
|
+
const dirsWithEntries = new Set();
|
35
34
|
for (const relativePath of files) {
|
36
35
|
const fsPath = normalize_path_1.normalizePath(path_1.default.join(options.cwd, relativePath));
|
37
36
|
let stat = statCache[fsPath];
|
38
37
|
assert_1.default(stat, `statCache does not contain value for ${relativePath} (resolved to ${fsPath})`);
|
39
|
-
const isSymlink =
|
40
|
-
if (isSymlink || stat.isFile()) {
|
38
|
+
const isSymlink = symlinks[fsPath];
|
39
|
+
if (isSymlink || stat.isFile() || stat.isDirectory()) {
|
41
40
|
if (isSymlink) {
|
42
41
|
stat = await fs_extra_1.lstat(fsPath);
|
43
42
|
}
|
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
|
+
}
|
44
50
|
let finalPath = relativePath;
|
45
51
|
if (mountpoint) {
|
46
52
|
finalPath = path_1.default.join(mountpoint, finalPath);
|
@@ -48,6 +54,18 @@ async function glob(pattern, opts, mountpoint) {
|
|
48
54
|
results[finalPath] = new file_fs_ref_1.default({ mode: stat.mode, fsPath });
|
49
55
|
}
|
50
56
|
}
|
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
|
+
}
|
51
69
|
return results;
|
52
70
|
}
|
53
71
|
exports.default = glob;
|
@@ -60,6 +60,9 @@ function execAsync(command, args, opts = {}) {
|
|
60
60
|
child.on('close', (code, signal) => {
|
61
61
|
if (code === 0 || opts.ignoreNon0Exit) {
|
62
62
|
return resolve({
|
63
|
+
// ignoring the next line due to do some Node.js type issue when we removed hoisting of dependencies in https://github.com/vercel/vercel/pull/9198
|
64
|
+
// should eventually be fixed when this method is remove by https://github.com/vercel/vercel/pull/9200 or we update to Node 16
|
65
|
+
// @ts-ignore
|
63
66
|
code,
|
64
67
|
stdout: Buffer.concat(stdoutList).toString(),
|
65
68
|
stderr: Buffer.concat(stderrList).toString(),
|
package/dist/index.d.ts
CHANGED
@@ -4,7 +4,7 @@ import FileRef from './file-ref';
|
|
4
4
|
import { Lambda, createLambda, getLambdaOptionsFromFunction } from './lambda';
|
5
5
|
import { NodejsLambda } from './nodejs-lambda';
|
6
6
|
import { Prerender } from './prerender';
|
7
|
-
import download, { downloadFile, DownloadedFiles, isSymbolicLink } from './fs/download';
|
7
|
+
import download, { downloadFile, DownloadedFiles, isSymbolicLink, isDirectory } from './fs/download';
|
8
8
|
import getWriteableDirectory from './fs/get-writable-directory';
|
9
9
|
import glob, { GlobOptions } from './fs/glob';
|
10
10
|
import rename from './fs/rename';
|
@@ -16,7 +16,7 @@ import getIgnoreFilter from './get-ignore-filter';
|
|
16
16
|
import { getPlatformEnv } from './get-platform-env';
|
17
17
|
import { getPrefixedEnvVars } from './get-prefixed-env-vars';
|
18
18
|
import { cloneEnv } from './clone-env';
|
19
|
-
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, execAsync, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, };
|
19
|
+
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, execAsync, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, };
|
20
20
|
export { EdgeFunction } from './edge-function';
|
21
21
|
export { readConfigFile } from './fs/read-config-file';
|
22
22
|
export { normalizePath } from './fs/normalize-path';
|