@vercel/build-utils 5.0.6 → 5.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/fs/download.d.ts +2 -1
- package/dist/fs/download.js +20 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +728 -714
- package/package.json +3 -3
package/dist/fs/download.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import FileFsRef from '../file-fs-ref';
|
2
|
-
import { Files, Meta } from '../types';
|
2
|
+
import { File, Files, Meta } from '../types';
|
3
3
|
export interface DownloadedFiles {
|
4
4
|
[filePath: string]: FileFsRef;
|
5
5
|
}
|
6
6
|
export declare function isSymbolicLink(mode: number): boolean;
|
7
|
+
export declare function downloadFile(file: File, fsPath: string): Promise<FileFsRef>;
|
7
8
|
export default function download(files: Files, basePath: string, meta?: Meta): Promise<DownloadedFiles>;
|
package/dist/fs/download.js
CHANGED
@@ -3,7 +3,7 @@ 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.isSymbolicLink = void 0;
|
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"));
|
@@ -22,7 +22,7 @@ async function prepareSymlinkTarget(file, fsPath) {
|
|
22
22
|
return target;
|
23
23
|
}
|
24
24
|
if (file.type === 'FileRef' || file.type === 'FileBlob') {
|
25
|
-
const targetPathBufferPromise =
|
25
|
+
const targetPathBufferPromise = stream_to_buffer_1.default(await file.toStreamAsync());
|
26
26
|
const [targetPathBuffer] = await Promise.all([
|
27
27
|
targetPathBufferPromise,
|
28
28
|
mkdirPromise,
|
@@ -33,6 +33,9 @@ async function prepareSymlinkTarget(file, fsPath) {
|
|
33
33
|
}
|
34
34
|
async function downloadFile(file, fsPath) {
|
35
35
|
const { mode } = file;
|
36
|
+
// If the source is a symlink, try to create it instead of copying the file.
|
37
|
+
// Note: creating symlinks on Windows requires admin priviliges or symlinks
|
38
|
+
// enabled in the group policy. We may want to improve the error message.
|
36
39
|
if (isSymbolicLink(mode)) {
|
37
40
|
const target = await prepareSymlinkTarget(file, fsPath);
|
38
41
|
await fs_extra_1.symlink(target, fsPath);
|
@@ -41,6 +44,7 @@ async function downloadFile(file, fsPath) {
|
|
41
44
|
const stream = file.toStream();
|
42
45
|
return file_fs_ref_1.default.fromStream({ mode, stream, fsPath });
|
43
46
|
}
|
47
|
+
exports.downloadFile = downloadFile;
|
44
48
|
async function removeFile(basePath, fileMatched) {
|
45
49
|
const file = path_1.default.join(basePath, fileMatched);
|
46
50
|
await fs_extra_1.remove(file);
|
@@ -67,6 +71,20 @@ async function download(files, basePath, meta) {
|
|
67
71
|
if (Array.isArray(filesChanged) && !filesChanged.includes(name)) {
|
68
72
|
return;
|
69
73
|
}
|
74
|
+
// Some builders resolve symlinks and return both
|
75
|
+
// a file, node_modules/<symlink>/package.json, and
|
76
|
+
// node_modules/<symlink>, a symlink.
|
77
|
+
// Removing the file matches how the yazl lambda zip
|
78
|
+
// behaves so we can use download() with `vercel build`.
|
79
|
+
const parts = name.split('/');
|
80
|
+
for (let i = 1; i < parts.length; i++) {
|
81
|
+
const dir = parts.slice(0, i).join('/');
|
82
|
+
const parent = files[dir];
|
83
|
+
if (parent && isSymbolicLink(parent.mode)) {
|
84
|
+
console.warn(`Warning: file "${name}" is within a symlinked directory "${dir}" and will be ignored`);
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
}
|
70
88
|
const file = files[name];
|
71
89
|
const fsPath = path_1.default.join(basePath, name);
|
72
90
|
files2[name] = await downloadFile(file, fsPath);
|
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, { DownloadedFiles, isSymbolicLink } from './fs/download';
|
7
|
+
import download, { downloadFile, DownloadedFiles, isSymbolicLink } 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';
|
@@ -14,7 +14,7 @@ import streamToBuffer from './fs/stream-to-buffer';
|
|
14
14
|
import debug from './debug';
|
15
15
|
import getIgnoreFilter from './get-ignore-filter';
|
16
16
|
import { getPlatformEnv } from './get-platform-env';
|
17
|
-
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, 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, streamToBuffer, debug, isSymbolicLink, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, };
|
17
|
+
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, streamToBuffer, debug, isSymbolicLink, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, };
|
18
18
|
export { EdgeFunction } from './edge-function';
|
19
19
|
export { readConfigFile } from './fs/read-config-file';
|
20
20
|
export { normalizePath } from './fs/normalize-path';
|