@vercel/client 18.11.2-snapshot-801db9d533c3 → 18.11.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/deploy.js +22 -3
- package/dist/types.d.ts +6 -0
- package/dist/utils/index.d.ts +9 -1
- package/dist/utils/index.js +21 -3
- package/package.json +3 -3
package/dist/deploy.js
CHANGED
|
@@ -27,7 +27,7 @@ var import_check_deployment_status = require("./check-deployment-status");
|
|
|
27
27
|
var import_utils = require("./utils");
|
|
28
28
|
async function* postDeployment(files, clientOptions, deploymentOptions) {
|
|
29
29
|
const debug = (0, import_utils.createDebug)(clientOptions.debug);
|
|
30
|
-
const
|
|
30
|
+
const inlineFiles = (0, import_utils.shouldInlineStaticFiles)(files) || clientOptions.firstDeployment === true && !clientOptions.prebuilt && !clientOptions.archive && (0, import_utils.shouldInlineSmallProject)(files);
|
|
31
31
|
const apiDeployments = (0, import_utils.getApiDeploymentsUrl)();
|
|
32
32
|
if (deploymentOptions?.builds && !deploymentOptions.functions) {
|
|
33
33
|
clientOptions.skipAutoDetectionConfirmation = true;
|
|
@@ -39,8 +39,7 @@ async function* postDeployment(files, clientOptions, deploymentOptions) {
|
|
|
39
39
|
deploymentOptions.customEnvironmentSlugOrId = deploymentOptions.target;
|
|
40
40
|
deploymentOptions.target = void 0;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
try {
|
|
42
|
+
const sendDeployment = async (preparedFiles) => {
|
|
44
43
|
const response = await (0, import_utils.fetchApi)(
|
|
45
44
|
`${apiDeployments}${(0, import_query_string.generateQueryString)(clientOptions)}`,
|
|
46
45
|
clientOptions.token,
|
|
@@ -69,6 +68,26 @@ async function* postDeployment(files, clientOptions, deploymentOptions) {
|
|
|
69
68
|
if (clientOptions.debug) {
|
|
70
69
|
debug("Deployment response:", JSON.stringify(deployment));
|
|
71
70
|
}
|
|
71
|
+
return { response, deployment };
|
|
72
|
+
};
|
|
73
|
+
debug("Sending deployment creation API request");
|
|
74
|
+
try {
|
|
75
|
+
const preparedFiles = (0, import_utils.prepareFiles)(files, clientOptions, inlineFiles);
|
|
76
|
+
if (inlineFiles) {
|
|
77
|
+
const inlined = preparedFiles.filter((file) => file.data !== void 0);
|
|
78
|
+
const bytes = inlined.reduce(
|
|
79
|
+
(total, file) => total + Buffer.byteLength(file.data, "base64"),
|
|
80
|
+
0
|
|
81
|
+
);
|
|
82
|
+
debug(`Sending ${inlined.length} files inline (${bytes} bytes)`);
|
|
83
|
+
}
|
|
84
|
+
let { response, deployment } = await sendDeployment(preparedFiles);
|
|
85
|
+
if (inlineFiles && deployment?.error?.code === "file_upload_failed") {
|
|
86
|
+
debug("Storing inline files failed. Retrying with file references");
|
|
87
|
+
({ response, deployment } = await sendDeployment(
|
|
88
|
+
(0, import_utils.prepareFiles)(files, clientOptions, false)
|
|
89
|
+
));
|
|
90
|
+
}
|
|
72
91
|
if (!response.ok || deployment.error) {
|
|
73
92
|
debug("Error: Deployment request status is", response.status);
|
|
74
93
|
return yield {
|
package/dist/types.d.ts
CHANGED
|
@@ -60,6 +60,12 @@ export interface VercelClientOptions {
|
|
|
60
60
|
apiUrl?: string;
|
|
61
61
|
force?: boolean;
|
|
62
62
|
prebuilt?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The project has no deployments yet, so the server has none of its files.
|
|
65
|
+
* A deployment of up to 1 MB is then sent inline, which skips the
|
|
66
|
+
* missing-files round trip without sending files the server already has.
|
|
67
|
+
*/
|
|
68
|
+
firstDeployment?: boolean;
|
|
63
69
|
vercelOutputDir?: string;
|
|
64
70
|
rootDirectory?: string | null;
|
|
65
71
|
withCache?: boolean;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -56,7 +56,15 @@ export interface PreparedFile {
|
|
|
56
56
|
* fall back to the regular build flow with no behavior change.
|
|
57
57
|
*/
|
|
58
58
|
export declare function shouldInlineStaticFiles(files: FilesMap): boolean;
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Whether a deployment is small enough to send inline in full (at most 1 MB
|
|
61
|
+
* of regular files). The API stores the files it doesn't have yet, so there
|
|
62
|
+
* is no `missing_files` round trip (create, upload, create again). Symlinks
|
|
63
|
+
* and files too large to hold in memory keep the whole set on the SHA path;
|
|
64
|
+
* directory entries carry no contents and stay as they are.
|
|
65
|
+
*/
|
|
66
|
+
export declare function shouldInlineSmallProject(files: FilesMap): boolean;
|
|
67
|
+
export declare const prepareFiles: (files: FilesMap, clientOptions: VercelClientOptions, inlineFiles?: boolean) => PreparedFile[];
|
|
60
68
|
export declare function createDebug(debug?: boolean): (...logs: string[]) => void;
|
|
61
69
|
export type Debug = ReturnType<typeof createDebug>;
|
|
62
70
|
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(utils_exports, {
|
|
|
38
38
|
needsNewDpopProof: () => needsNewDpopProof,
|
|
39
39
|
parseVercelConfig: () => parseVercelConfig,
|
|
40
40
|
prepareFiles: () => prepareFiles,
|
|
41
|
+
shouldInlineSmallProject: () => shouldInlineSmallProject,
|
|
41
42
|
shouldInlineStaticFiles: () => shouldInlineStaticFiles
|
|
42
43
|
});
|
|
43
44
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -536,9 +537,25 @@ function shouldInlineStaticFiles(files) {
|
|
|
536
537
|
}
|
|
537
538
|
return count > 0 && count <= MAX_INLINE_FILES && totalBytes <= MAX_INLINE_TOTAL_BYTES;
|
|
538
539
|
}
|
|
539
|
-
const
|
|
540
|
+
const MAX_INLINE_PROJECT_BYTES = 1024 * 1024;
|
|
541
|
+
const S_IFDIR = 16384;
|
|
542
|
+
function shouldInlineSmallProject(files) {
|
|
543
|
+
let totalBytes = 0;
|
|
544
|
+
let count = 0;
|
|
545
|
+
for (const file of files.values()) {
|
|
546
|
+
if ((file.mode & S_IFMT) === S_IFDIR)
|
|
547
|
+
continue;
|
|
548
|
+
if ((file.mode & S_IFMT) !== S_IFREG || !file.data)
|
|
549
|
+
return false;
|
|
550
|
+
count += file.names.length;
|
|
551
|
+
totalBytes += file.data.byteLength * file.names.length;
|
|
552
|
+
if (totalBytes > MAX_INLINE_PROJECT_BYTES)
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
return count > 0;
|
|
556
|
+
}
|
|
557
|
+
const prepareFiles = (files, clientOptions, inlineFiles = shouldInlineStaticFiles(files)) => {
|
|
540
558
|
const preparedFiles = [];
|
|
541
|
-
const inlineStaticFiles = shouldInlineStaticFiles(files);
|
|
542
559
|
for (const [sha, file] of files) {
|
|
543
560
|
for (const name of file.names) {
|
|
544
561
|
let fileName;
|
|
@@ -549,7 +566,7 @@ const prepareFiles = (files, clientOptions) => {
|
|
|
549
566
|
fileName = segments[segments.length - 1];
|
|
550
567
|
}
|
|
551
568
|
const normalizedName = isWin ? fileName.replace(/\\/g, "/") : fileName;
|
|
552
|
-
if (
|
|
569
|
+
if (inlineFiles && file.data) {
|
|
553
570
|
preparedFiles.push({
|
|
554
571
|
file: normalizedName,
|
|
555
572
|
data: file.data.toString("base64"),
|
|
@@ -591,5 +608,6 @@ function createDebug(debug) {
|
|
|
591
608
|
needsNewDpopProof,
|
|
592
609
|
parseVercelConfig,
|
|
593
610
|
prepareFiles,
|
|
611
|
+
shouldInlineSmallProject,
|
|
594
612
|
shouldInlineStaticFiles
|
|
595
613
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/client",
|
|
3
|
-
"version": "18.11.2
|
|
3
|
+
"version": "18.11.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"homepage": "https://vercel.com",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"querystring": "^0.2.0",
|
|
38
38
|
"sleep-promise": "8.0.1",
|
|
39
39
|
"tar-fs": "1.16.3",
|
|
40
|
-
"@vercel/build-utils": "15.3.0-snapshot-801db9d533c3",
|
|
41
40
|
"@vercel/error-utils": "2.2.1",
|
|
42
|
-
"@vercel/routing-utils": "6.6.1"
|
|
41
|
+
"@vercel/routing-utils": "6.6.1",
|
|
42
|
+
"@vercel/build-utils": "15.3.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "node ../../utils/build.mjs",
|