@vercel/client 17.6.0 → 17.6.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/collect-deployment-files.d.ts +14 -0
- package/dist/collect-deployment-files.js +95 -0
- package/dist/create-deployment.js +7 -56
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/inspect-deployment-files.d.ts +16 -0
- package/dist/inspect-deployment-files.js +63 -0
- package/dist/upload.js +40 -20
- package/dist/utils/hashes.d.ts +5 -0
- package/dist/utils/hashes.js +17 -2
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { VercelClientOptions } from './types';
|
|
2
|
+
import { type Debug } from './utils';
|
|
3
|
+
import { type FilesMap } from './utils/hashes';
|
|
4
|
+
type CollectDeploymentFilesOptions = Pick<VercelClientOptions, 'archive' | 'bulkRedirectsPath' | 'isDirectory' | 'prebuilt' | 'projectName' | 'rootDirectory' | 'vercelOutputDir'>;
|
|
5
|
+
export interface CollectedDeploymentFiles {
|
|
6
|
+
fileList: string[];
|
|
7
|
+
filesMap: FilesMap;
|
|
8
|
+
workPath: string;
|
|
9
|
+
isDirectory: boolean;
|
|
10
|
+
ignoreList: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function assertDeploymentPath(path: VercelClientOptions['path'] | undefined, debug: Debug): asserts path is VercelClientOptions['path'];
|
|
13
|
+
export declare function collectDeploymentFiles(path: VercelClientOptions['path'] | undefined, clientOptions: CollectDeploymentFilesOptions, debug: Debug): Promise<CollectedDeploymentFiles>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var collect_deployment_files_exports = {};
|
|
20
|
+
__export(collect_deployment_files_exports, {
|
|
21
|
+
assertDeploymentPath: () => assertDeploymentPath,
|
|
22
|
+
collectDeploymentFiles: () => collectDeploymentFiles
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(collect_deployment_files_exports);
|
|
25
|
+
var import_error_utils = require("@vercel/error-utils");
|
|
26
|
+
var import_fs_extra = require("fs-extra");
|
|
27
|
+
var import_path = require("path");
|
|
28
|
+
var import_errors = require("./errors");
|
|
29
|
+
var import_utils = require("./utils");
|
|
30
|
+
var import_archive = require("./utils/archive");
|
|
31
|
+
var import_hashes = require("./utils/hashes");
|
|
32
|
+
function assertDeploymentPath(path, debug) {
|
|
33
|
+
if (typeof path !== "string" && !Array.isArray(path)) {
|
|
34
|
+
debug(
|
|
35
|
+
`Error: 'path' is expected to be a string or an array. Received ${typeof path}`
|
|
36
|
+
);
|
|
37
|
+
throw new import_errors.DeploymentError({
|
|
38
|
+
code: "missing_path",
|
|
39
|
+
message: "Path not provided"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function collectDeploymentFiles(path, clientOptions, debug) {
|
|
44
|
+
assertDeploymentPath(path, debug);
|
|
45
|
+
const isDirectory = !Array.isArray(path) && (0, import_fs_extra.lstatSync)(path).isDirectory();
|
|
46
|
+
clientOptions.isDirectory = isDirectory;
|
|
47
|
+
if (Array.isArray(path)) {
|
|
48
|
+
for (const filePath of path) {
|
|
49
|
+
if (!(0, import_path.isAbsolute)(filePath)) {
|
|
50
|
+
throw new import_errors.DeploymentError({
|
|
51
|
+
code: "invalid_path",
|
|
52
|
+
message: `Provided path ${filePath} is not absolute`
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else if (!(0, import_path.isAbsolute)(path)) {
|
|
57
|
+
throw new import_errors.DeploymentError({
|
|
58
|
+
code: "invalid_path",
|
|
59
|
+
message: `Provided path ${path} is not absolute`
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (isDirectory && !Array.isArray(path)) {
|
|
63
|
+
debug(`Provided 'path' is a directory.`);
|
|
64
|
+
} else if (Array.isArray(path)) {
|
|
65
|
+
debug(`Provided 'path' is an array of file paths`);
|
|
66
|
+
} else {
|
|
67
|
+
debug(`Provided 'path' is a single file`);
|
|
68
|
+
}
|
|
69
|
+
const { fileList, ignoreList } = await (0, import_utils.buildFileTree)(
|
|
70
|
+
path,
|
|
71
|
+
clientOptions,
|
|
72
|
+
debug
|
|
73
|
+
);
|
|
74
|
+
const workPath = typeof path === "string" ? path : path[0];
|
|
75
|
+
let filesMap;
|
|
76
|
+
try {
|
|
77
|
+
filesMap = clientOptions.archive === "tgz" ? await (0, import_archive.createTgzFiles)(workPath, fileList, debug) : await (0, import_hashes.hashes)(fileList);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
if (clientOptions.prebuilt && (0, import_error_utils.isErrnoException)(err) && err.code === "ENOENT" && err.path) {
|
|
80
|
+
const errPath = (0, import_path.relative)(workPath, err.path);
|
|
81
|
+
err.message = `File does not exist: "${(0, import_path.relative)(workPath, errPath)}"`;
|
|
82
|
+
if (errPath.split(import_path.sep).includes("node_modules")) {
|
|
83
|
+
err.message = `Please ensure project dependencies have been installed:
|
|
84
|
+
${err.message}`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
return { fileList, filesMap, workPath, isDirectory, ignoreList };
|
|
90
|
+
}
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
assertDeploymentPath,
|
|
94
|
+
collectDeploymentFiles
|
|
95
|
+
});
|
|
@@ -21,29 +21,18 @@ __export(create_deployment_exports, {
|
|
|
21
21
|
default: () => buildCreateDeployment
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(create_deployment_exports);
|
|
24
|
-
var import_fs_extra = require("fs-extra");
|
|
25
|
-
var import_path = require("path");
|
|
26
24
|
var import_hashes = require("./utils/hashes");
|
|
27
25
|
var import_deploy = require("./deploy");
|
|
28
26
|
var import_upload = require("./upload");
|
|
29
27
|
var import_utils = require("./utils");
|
|
30
28
|
var import_errors = require("./errors");
|
|
31
|
-
var
|
|
32
|
-
var import_archive = require("./utils/archive");
|
|
29
|
+
var import_collect_deployment_files = require("./collect-deployment-files");
|
|
33
30
|
function buildCreateDeployment() {
|
|
34
31
|
return async function* createDeployment(clientOptions, deploymentOptions = {}) {
|
|
35
32
|
const { path } = clientOptions;
|
|
36
33
|
const debug = (0, import_utils.createDebug)(clientOptions.debug);
|
|
37
34
|
debug("Creating deployment...");
|
|
38
|
-
|
|
39
|
-
debug(
|
|
40
|
-
`Error: 'path' is expected to be a string or an array. Received ${typeof path}`
|
|
41
|
-
);
|
|
42
|
-
throw new import_errors.DeploymentError({
|
|
43
|
-
code: "missing_path",
|
|
44
|
-
message: "Path not provided"
|
|
45
|
-
});
|
|
46
|
-
}
|
|
35
|
+
(0, import_collect_deployment_files.assertDeploymentPath)(path, debug);
|
|
47
36
|
if (typeof clientOptions.token !== "string") {
|
|
48
37
|
debug(
|
|
49
38
|
`Error: 'token' is expected to be a string. Received ${typeof clientOptions.token}`
|
|
@@ -69,30 +58,11 @@ function buildCreateDeployment() {
|
|
|
69
58
|
yield* (0, import_deploy.deploy)(/* @__PURE__ */ new Map(), clientOptions, deploymentOptions);
|
|
70
59
|
return;
|
|
71
60
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
code: "invalid_path",
|
|
78
|
-
message: `Provided path ${filePath} is not absolute`
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
} else if (!(0, import_path.isAbsolute)(path)) {
|
|
83
|
-
throw new import_errors.DeploymentError({
|
|
84
|
-
code: "invalid_path",
|
|
85
|
-
message: `Provided path ${path} is not absolute`
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (clientOptions.isDirectory && !Array.isArray(path)) {
|
|
89
|
-
debug(`Provided 'path' is a directory.`);
|
|
90
|
-
} else if (Array.isArray(path)) {
|
|
91
|
-
debug(`Provided 'path' is an array of file paths`);
|
|
92
|
-
} else {
|
|
93
|
-
debug(`Provided 'path' is a single file`);
|
|
94
|
-
}
|
|
95
|
-
const { fileList } = await (0, import_utils.buildFileTree)(path, clientOptions, debug);
|
|
61
|
+
const { fileList, filesMap: files } = await (0, import_collect_deployment_files.collectDeploymentFiles)(
|
|
62
|
+
path,
|
|
63
|
+
clientOptions,
|
|
64
|
+
debug
|
|
65
|
+
);
|
|
96
66
|
if (fileList.length === 0) {
|
|
97
67
|
debug("Deployment path has no files. Yielding a warning event");
|
|
98
68
|
yield {
|
|
@@ -100,25 +70,6 @@ function buildCreateDeployment() {
|
|
|
100
70
|
payload: "There are no files inside your deployment."
|
|
101
71
|
};
|
|
102
72
|
}
|
|
103
|
-
const workPath = typeof path === "string" ? path : path[0];
|
|
104
|
-
let files;
|
|
105
|
-
try {
|
|
106
|
-
if (clientOptions.archive === "tgz") {
|
|
107
|
-
files = await (0, import_archive.createTgzFiles)(workPath, fileList, debug);
|
|
108
|
-
} else {
|
|
109
|
-
files = await (0, import_hashes.hashes)(fileList);
|
|
110
|
-
}
|
|
111
|
-
} catch (err) {
|
|
112
|
-
if (clientOptions.prebuilt && (0, import_error_utils.isErrnoException)(err) && err.code === "ENOENT" && err.path) {
|
|
113
|
-
const errPath = (0, import_path.relative)(workPath, err.path);
|
|
114
|
-
err.message = `File does not exist: "${(0, import_path.relative)(workPath, errPath)}"`;
|
|
115
|
-
if (errPath.split(import_path.sep).includes("node_modules")) {
|
|
116
|
-
err.message = `Please ensure project dependencies have been installed:
|
|
117
|
-
${err.message}`;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
throw err;
|
|
121
|
-
}
|
|
122
73
|
debug(`Yielding a 'hashes-calculated' event with ${files.size} hashes`);
|
|
123
74
|
yield { type: "hashes-calculated", payload: (0, import_hashes.mapToObject)(files) };
|
|
124
75
|
if (clientOptions.apiUrl) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { continueDeployment } from './continue';
|
|
2
2
|
export { checkDeploymentStatus } from './check-deployment-status';
|
|
3
|
+
export { inspectDeploymentFiles } from './inspect-deployment-files';
|
|
3
4
|
export { getVercelIgnore, buildFileTree } from './utils/index';
|
|
4
5
|
export declare const createDeployment: (clientOptions: import("./types").VercelClientOptions, deploymentOptions?: import("./types").DeploymentOptions) => AsyncIterableIterator<{
|
|
5
6
|
type: import("./types").DeploymentEventType;
|
package/dist/index.js
CHANGED
|
@@ -33,12 +33,14 @@ __export(src_exports, {
|
|
|
33
33
|
checkDeploymentStatus: () => import_check_deployment_status.checkDeploymentStatus,
|
|
34
34
|
continueDeployment: () => import_continue.continueDeployment,
|
|
35
35
|
createDeployment: () => createDeployment,
|
|
36
|
-
getVercelIgnore: () => import_utils.getVercelIgnore
|
|
36
|
+
getVercelIgnore: () => import_utils.getVercelIgnore,
|
|
37
|
+
inspectDeploymentFiles: () => import_inspect_deployment_files.inspectDeploymentFiles
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(src_exports);
|
|
39
40
|
var import_create_deployment = __toESM(require("./create-deployment"));
|
|
40
41
|
var import_continue = require("./continue");
|
|
41
42
|
var import_check_deployment_status = require("./check-deployment-status");
|
|
43
|
+
var import_inspect_deployment_files = require("./inspect-deployment-files");
|
|
42
44
|
var import_utils = require("./utils/index");
|
|
43
45
|
__reExport(src_exports, require("./errors"), module.exports);
|
|
44
46
|
__reExport(src_exports, require("./types"), module.exports);
|
|
@@ -50,6 +52,7 @@ const createDeployment = (0, import_create_deployment.default)();
|
|
|
50
52
|
continueDeployment,
|
|
51
53
|
createDeployment,
|
|
52
54
|
getVercelIgnore,
|
|
55
|
+
inspectDeploymentFiles,
|
|
53
56
|
...require("./errors"),
|
|
54
57
|
...require("./types")
|
|
55
58
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { VercelClientOptions } from './types';
|
|
2
|
+
export interface DeploymentFileItem {
|
|
3
|
+
path: string;
|
|
4
|
+
size: number;
|
|
5
|
+
mode: number;
|
|
6
|
+
sha?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DeploymentFileSummary {
|
|
9
|
+
basePath: string;
|
|
10
|
+
fileCount: number;
|
|
11
|
+
totalSize: number;
|
|
12
|
+
ignoredCount: number;
|
|
13
|
+
files: DeploymentFileItem[];
|
|
14
|
+
ignored: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare function inspectDeploymentFiles(clientOptions: Pick<VercelClientOptions, 'archive' | 'bulkRedirectsPath' | 'debug' | 'path' | 'prebuilt' | 'projectName' | 'rootDirectory' | 'vercelOutputDir'>): Promise<DeploymentFileSummary>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var inspect_deployment_files_exports = {};
|
|
20
|
+
__export(inspect_deployment_files_exports, {
|
|
21
|
+
inspectDeploymentFiles: () => inspectDeploymentFiles
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(inspect_deployment_files_exports);
|
|
24
|
+
var import_path = require("path");
|
|
25
|
+
var import_collect_deployment_files = require("./collect-deployment-files");
|
|
26
|
+
var import_utils = require("./utils");
|
|
27
|
+
async function inspectDeploymentFiles(clientOptions) {
|
|
28
|
+
const { path } = clientOptions;
|
|
29
|
+
const debug = (0, import_utils.createDebug)(clientOptions.debug);
|
|
30
|
+
const { filesMap, workPath, isDirectory, ignoreList } = await (0, import_collect_deployment_files.collectDeploymentFiles)(path, { ...clientOptions }, debug);
|
|
31
|
+
const files = [];
|
|
32
|
+
let totalSize = 0;
|
|
33
|
+
for (const [sha, file] of filesMap) {
|
|
34
|
+
const size = file.data?.byteLength || file.data?.length || 0;
|
|
35
|
+
for (const name of file.names) {
|
|
36
|
+
const pathName = isDirectory ? (0, import_path.relative)(workPath, name) : name.split(import_path.sep).at(-1) || name;
|
|
37
|
+
const normalizedPath = pathName.split(import_path.sep).join("/");
|
|
38
|
+
const deploymentFile = {
|
|
39
|
+
path: normalizedPath,
|
|
40
|
+
size,
|
|
41
|
+
mode: file.mode
|
|
42
|
+
};
|
|
43
|
+
if (typeof sha !== "undefined") {
|
|
44
|
+
deploymentFile.sha = sha;
|
|
45
|
+
}
|
|
46
|
+
files.push(deploymentFile);
|
|
47
|
+
totalSize += size;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
files.sort((a, b) => a.path.localeCompare(b.path));
|
|
51
|
+
return {
|
|
52
|
+
basePath: workPath,
|
|
53
|
+
fileCount: files.length,
|
|
54
|
+
totalSize,
|
|
55
|
+
ignoredCount: ignoreList.length,
|
|
56
|
+
files,
|
|
57
|
+
ignored: ignoreList.sort()
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
inspectDeploymentFiles
|
|
63
|
+
});
|
package/dist/upload.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(upload_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(upload_exports);
|
|
36
36
|
var import_http = __toESM(require("http"));
|
|
37
37
|
var import_https = __toESM(require("https"));
|
|
38
|
+
var import_fs = require("fs");
|
|
38
39
|
var import_stream = require("stream");
|
|
39
40
|
var import_node_events = require("node:events");
|
|
40
41
|
var import_async_retry = __toESM(require("async-retry"));
|
|
@@ -137,27 +138,46 @@ async function* uploadFiles(options) {
|
|
|
137
138
|
semaphore.release();
|
|
138
139
|
return bail(new Error("Upload aborted"));
|
|
139
140
|
}
|
|
140
|
-
const { data } = file;
|
|
141
|
-
if (typeof data === "undefined") {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
141
|
+
const { data, size, names } = file;
|
|
144
142
|
uploadProgress.bytesUploaded = 0;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
143
|
+
let body;
|
|
144
|
+
let contentLength;
|
|
145
|
+
if (typeof data !== "undefined") {
|
|
146
|
+
contentLength = data.length;
|
|
147
|
+
const buffered = new import_stream.Readable();
|
|
148
|
+
const originalRead = buffered.read.bind(buffered);
|
|
149
|
+
buffered.read = function(...args) {
|
|
150
|
+
const chunk = originalRead(...args);
|
|
151
|
+
if (chunk) {
|
|
152
|
+
uploadProgress.bytesUploaded += chunk.length;
|
|
153
|
+
uploadProgress.emit("progress");
|
|
154
|
+
}
|
|
155
|
+
return chunk;
|
|
156
|
+
};
|
|
157
|
+
const chunkSize = 16384;
|
|
158
|
+
for (let i = 0; i < data.length; i += chunkSize) {
|
|
159
|
+
const chunk = data.slice(i, i + chunkSize);
|
|
160
|
+
buffered.push(chunk);
|
|
152
161
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
162
|
+
buffered.push(null);
|
|
163
|
+
body = buffered;
|
|
164
|
+
} else if (typeof size === "number") {
|
|
165
|
+
contentLength = size;
|
|
166
|
+
const fileStream = (0, import_fs.createReadStream)(names[0]);
|
|
167
|
+
const counter = new import_stream.Transform({
|
|
168
|
+
transform(chunk, _encoding, callback) {
|
|
169
|
+
uploadProgress.bytesUploaded += chunk.length;
|
|
170
|
+
uploadProgress.emit("progress");
|
|
171
|
+
callback(null, chunk);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
fileStream.on("error", (err2) => counter.destroy(err2));
|
|
175
|
+
counter.on("close", () => fileStream.destroy());
|
|
176
|
+
body = fileStream.pipe(counter);
|
|
177
|
+
} else {
|
|
178
|
+
semaphore.release();
|
|
179
|
+
return;
|
|
159
180
|
}
|
|
160
|
-
body.push(null);
|
|
161
181
|
let err;
|
|
162
182
|
let result;
|
|
163
183
|
const abortController = new AbortController();
|
|
@@ -171,9 +191,9 @@ async function* uploadFiles(options) {
|
|
|
171
191
|
method: "POST",
|
|
172
192
|
headers: {
|
|
173
193
|
"Content-Type": "application/octet-stream",
|
|
174
|
-
"Content-Length":
|
|
194
|
+
"Content-Length": contentLength,
|
|
175
195
|
"x-now-digest": sha,
|
|
176
|
-
"x-now-size":
|
|
196
|
+
"x-now-size": contentLength
|
|
177
197
|
},
|
|
178
198
|
body,
|
|
179
199
|
teamId: options.teamId,
|
package/dist/utils/hashes.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ export interface DeploymentFile {
|
|
|
2
2
|
names: string[];
|
|
3
3
|
data?: Buffer;
|
|
4
4
|
mode: number;
|
|
5
|
+
/**
|
|
6
|
+
* Byte length of the file's content. Always set for real files; used to send
|
|
7
|
+
* `Content-Length` when a file is streamed (i.e. has no in-memory `data`).
|
|
8
|
+
*/
|
|
9
|
+
size?: number;
|
|
5
10
|
}
|
|
6
11
|
export type FilesMap = Map<string | undefined, DeploymentFile>;
|
|
7
12
|
/**
|
package/dist/utils/hashes.js
CHANGED
|
@@ -36,9 +36,17 @@ module.exports = __toCommonJS(hashes_exports);
|
|
|
36
36
|
var import_crypto = require("crypto");
|
|
37
37
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
38
38
|
var import_async_sema = require("async-sema");
|
|
39
|
+
const MAX_BUFFER_FILE_SIZE = 2 ** 31 - 1;
|
|
39
40
|
function hash(buf) {
|
|
40
41
|
return (0, import_crypto.createHash)("sha1").update(Uint8Array.from(buf)).digest("hex");
|
|
41
42
|
}
|
|
43
|
+
async function hashFile(path) {
|
|
44
|
+
const digest = (0, import_crypto.createHash)("sha1");
|
|
45
|
+
for await (const chunk of import_fs_extra.default.createReadStream(path)) {
|
|
46
|
+
digest.update(Uint8Array.from(chunk));
|
|
47
|
+
}
|
|
48
|
+
return digest.digest("hex");
|
|
49
|
+
}
|
|
42
50
|
const mapToObject = (map) => {
|
|
43
51
|
const obj = {};
|
|
44
52
|
for (const [key, value] of map) {
|
|
@@ -56,16 +64,23 @@ async function hashes(files, map = /* @__PURE__ */ new Map()) {
|
|
|
56
64
|
const stat = await import_fs_extra.default.lstat(name);
|
|
57
65
|
const mode = stat.mode;
|
|
58
66
|
let data;
|
|
67
|
+
let size;
|
|
59
68
|
const isDirectory = stat.isDirectory();
|
|
60
69
|
let h;
|
|
61
70
|
if (!isDirectory) {
|
|
62
71
|
if (stat.isSymbolicLink()) {
|
|
63
72
|
const link = await import_fs_extra.default.readlink(name);
|
|
64
73
|
data = Buffer.from(link, "utf8");
|
|
74
|
+
size = data.length;
|
|
75
|
+
h = hash(data);
|
|
76
|
+
} else if (stat.size > MAX_BUFFER_FILE_SIZE) {
|
|
77
|
+
size = stat.size;
|
|
78
|
+
h = await hashFile(name);
|
|
65
79
|
} else {
|
|
66
80
|
data = await import_fs_extra.default.readFile(name);
|
|
81
|
+
size = data.length;
|
|
82
|
+
h = hash(data);
|
|
67
83
|
}
|
|
68
|
-
h = hash(data);
|
|
69
84
|
}
|
|
70
85
|
const entry = map.get(h);
|
|
71
86
|
if (entry) {
|
|
@@ -73,7 +88,7 @@ async function hashes(files, map = /* @__PURE__ */ new Map()) {
|
|
|
73
88
|
names.add(name);
|
|
74
89
|
entry.names = [...names];
|
|
75
90
|
} else {
|
|
76
|
-
map.set(h, { names: [name], data, mode });
|
|
91
|
+
map.set(h, { names: [name], data, mode, size });
|
|
77
92
|
}
|
|
78
93
|
semaphore.release();
|
|
79
94
|
})
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -35,5 +35,5 @@ export interface PreparedFile {
|
|
|
35
35
|
}
|
|
36
36
|
export declare const prepareFiles: (files: FilesMap, clientOptions: VercelClientOptions) => PreparedFile[];
|
|
37
37
|
export declare function createDebug(debug?: boolean): (...logs: string[]) => void;
|
|
38
|
-
type Debug = ReturnType<typeof createDebug>;
|
|
38
|
+
export type Debug = ReturnType<typeof createDebug>;
|
|
39
39
|
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -341,7 +341,7 @@ const prepareFiles = (files, clientOptions) => {
|
|
|
341
341
|
}
|
|
342
342
|
preparedFiles.push({
|
|
343
343
|
file: isWin ? fileName.replace(/\\/g, "/") : fileName,
|
|
344
|
-
size: file.data?.byteLength
|
|
344
|
+
size: file.data?.byteLength ?? file.size,
|
|
345
345
|
mode: file.mode,
|
|
346
346
|
sha: sha || void 0
|
|
347
347
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/client",
|
|
3
|
-
"version": "17.6.
|
|
3
|
+
"version": "17.6.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"homepage": "https://vercel.com",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"querystring": "^0.2.0",
|
|
40
40
|
"sleep-promise": "8.0.1",
|
|
41
41
|
"tar-fs": "1.16.3",
|
|
42
|
-
"@vercel/
|
|
43
|
-
"@vercel/
|
|
44
|
-
"@vercel/
|
|
42
|
+
"@vercel/routing-utils": "6.4.0",
|
|
43
|
+
"@vercel/build-utils": "13.32.1",
|
|
44
|
+
"@vercel/error-utils": "2.2.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "node ../../utils/build.mjs",
|