@vercel/client 12.2.31 → 12.3.1
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/check-deployment-status.js +5 -2
- package/dist/create-deployment.js +1 -1
- package/dist/deploy.d.ts +2 -2
- package/dist/upload.d.ts +2 -2
- package/dist/upload.js +4 -0
- package/dist/utils/get-polling-delay.d.ts +1 -0
- package/dist/utils/get-polling-delay.js +20 -0
- package/dist/utils/hashes.d.ts +4 -5
- package/dist/utils/hashes.js +14 -8
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.js +2 -2
- package/dist/utils/readdir-recursive.js +4 -0
- package/package.json +3 -3
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.checkDeploymentStatus = void 0;
|
|
7
7
|
const sleep_promise_1 = __importDefault(require("sleep-promise"));
|
|
8
|
-
const ms_1 = __importDefault(require("ms"));
|
|
9
8
|
const utils_1 = require("./utils");
|
|
9
|
+
const get_polling_delay_1 = require("./utils/get-polling-delay");
|
|
10
10
|
const ready_state_1 = require("./utils/ready-state");
|
|
11
11
|
const utils_2 = require("./utils");
|
|
12
12
|
/* eslint-disable */
|
|
@@ -26,6 +26,7 @@ async function* checkDeploymentStatus(deployment, clientOptions) {
|
|
|
26
26
|
// Build polling
|
|
27
27
|
debug('Waiting for builds and the deployment to complete...');
|
|
28
28
|
const finishedEvents = new Set();
|
|
29
|
+
const startTime = Date.now();
|
|
29
30
|
while (true) {
|
|
30
31
|
// Deployment polling
|
|
31
32
|
const deploymentData = await utils_1.fetch(`${apiDeployments}/${deployment.id || deployment.deploymentId}${teamId ? `?teamId=${teamId}` : ''}`, token, { apiUrl, userAgent });
|
|
@@ -105,7 +106,9 @@ async function* checkDeploymentStatus(deployment, clientOptions) {
|
|
|
105
106
|
payload: deploymentUpdate.error || deploymentUpdate,
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
+
const elapsed = Date.now() - startTime;
|
|
110
|
+
const duration = get_polling_delay_1.getPollingDelay(elapsed);
|
|
111
|
+
await sleep_promise_1.default(duration);
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
exports.checkDeploymentStatus = checkDeploymentStatus;
|
|
@@ -58,7 +58,7 @@ function buildCreateDeployment() {
|
|
|
58
58
|
else {
|
|
59
59
|
debug(`Provided 'path' is a single file`);
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
const { fileList } = await utils_1.buildFileTree(path, clientOptions, debug);
|
|
62
62
|
// This is a useful warning because it prevents people
|
|
63
63
|
// from getting confused about a deployment that renders 404.
|
|
64
64
|
if (fileList.length === 0) {
|
package/dist/deploy.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FilesMap } from './utils/hashes';
|
|
2
2
|
import { DeploymentOptions, VercelClientOptions } from './types';
|
|
3
|
-
export declare function deploy(files:
|
|
3
|
+
export declare function deploy(files: FilesMap, clientOptions: VercelClientOptions, deploymentOptions: DeploymentOptions): AsyncIterableIterator<{
|
|
4
4
|
type: string;
|
|
5
5
|
payload: any;
|
|
6
6
|
}>;
|
package/dist/upload.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FilesMap } from './utils/hashes';
|
|
2
2
|
import { VercelClientOptions, DeploymentOptions } from './types';
|
|
3
|
-
export declare function upload(files:
|
|
3
|
+
export declare function upload(files: FilesMap, clientOptions: VercelClientOptions, deploymentOptions: DeploymentOptions): AsyncIterableIterator<any>;
|
package/dist/upload.js
CHANGED
|
@@ -77,6 +77,10 @@ async function* upload(files, clientOptions, deploymentOptions) {
|
|
|
77
77
|
}
|
|
78
78
|
await semaphore.acquire();
|
|
79
79
|
const { data } = file;
|
|
80
|
+
if (typeof data === 'undefined') {
|
|
81
|
+
// Directories don't need to be uploaded
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
80
84
|
uploadProgress.bytesUploaded = 0;
|
|
81
85
|
// Split out into chunks
|
|
82
86
|
const body = new stream_1.Readable();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPollingDelay(elapsed: number): number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPollingDelay = void 0;
|
|
7
|
+
const ms_1 = __importDefault(require("ms"));
|
|
8
|
+
function getPollingDelay(elapsed) {
|
|
9
|
+
if (elapsed <= ms_1.default('15s')) {
|
|
10
|
+
return ms_1.default('1s');
|
|
11
|
+
}
|
|
12
|
+
if (elapsed <= ms_1.default('1m')) {
|
|
13
|
+
return ms_1.default('5s');
|
|
14
|
+
}
|
|
15
|
+
if (elapsed <= ms_1.default('5m')) {
|
|
16
|
+
return ms_1.default('15s');
|
|
17
|
+
}
|
|
18
|
+
return ms_1.default('30s');
|
|
19
|
+
}
|
|
20
|
+
exports.getPollingDelay = getPollingDelay;
|
package/dist/utils/hashes.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
export interface DeploymentFile {
|
|
3
3
|
names: string[];
|
|
4
|
-
data
|
|
4
|
+
data?: Buffer;
|
|
5
5
|
mode: number;
|
|
6
6
|
}
|
|
7
|
+
export declare type FilesMap = Map<string | undefined, DeploymentFile>;
|
|
7
8
|
/**
|
|
8
9
|
* Computes a hash for the given buf.
|
|
9
10
|
*
|
|
@@ -16,9 +17,7 @@ export declare function hash(buf: Buffer): string;
|
|
|
16
17
|
* @param map with hashed files
|
|
17
18
|
* @return {object}
|
|
18
19
|
*/
|
|
19
|
-
export declare const mapToObject: (map:
|
|
20
|
-
[key: string]: DeploymentFile;
|
|
21
|
-
};
|
|
20
|
+
export declare const mapToObject: (map: FilesMap) => Record<string, DeploymentFile>;
|
|
22
21
|
/**
|
|
23
22
|
* Computes hashes for the contents of each file given.
|
|
24
23
|
*
|
|
@@ -26,4 +25,4 @@ export declare const mapToObject: (map: Map<string, DeploymentFile>) => {
|
|
|
26
25
|
* @param map - optional map of files to append
|
|
27
26
|
* @return Map of hash digest to file object
|
|
28
27
|
*/
|
|
29
|
-
export declare function hashes(files: string[], map?: Map<string, DeploymentFile>): Promise<
|
|
28
|
+
export declare function hashes(files: string[], map?: Map<string | undefined, DeploymentFile>): Promise<FilesMap>;
|
package/dist/utils/hashes.js
CHANGED
|
@@ -25,6 +25,8 @@ exports.hash = hash;
|
|
|
25
25
|
const mapToObject = (map) => {
|
|
26
26
|
const obj = {};
|
|
27
27
|
for (const [key, value] of map) {
|
|
28
|
+
if (typeof key === 'undefined')
|
|
29
|
+
continue;
|
|
28
30
|
obj[key] = value;
|
|
29
31
|
}
|
|
30
32
|
return obj;
|
|
@@ -43,15 +45,19 @@ async function hashes(files, map = new Map()) {
|
|
|
43
45
|
await semaphore.acquire();
|
|
44
46
|
const stat = await fs_extra_1.default.lstat(name);
|
|
45
47
|
const mode = stat.mode;
|
|
46
|
-
let data
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
let data;
|
|
49
|
+
const isDirectory = stat.isDirectory();
|
|
50
|
+
let h;
|
|
51
|
+
if (!isDirectory) {
|
|
52
|
+
if (stat.isSymbolicLink()) {
|
|
53
|
+
const link = await fs_extra_1.default.readlink(name);
|
|
54
|
+
data = Buffer.from(link, 'utf8');
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
data = await fs_extra_1.default.readFile(name);
|
|
58
|
+
}
|
|
59
|
+
h = hash(data);
|
|
50
60
|
}
|
|
51
|
-
else {
|
|
52
|
-
data = await fs_extra_1.default.readFile(name);
|
|
53
|
-
}
|
|
54
|
-
const h = hash(data);
|
|
55
61
|
const entry = map.get(h);
|
|
56
62
|
if (entry) {
|
|
57
63
|
const names = new Set(entry.names);
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FilesMap } from './hashes';
|
|
2
2
|
import { FetchOptions } from '@zeit/fetch';
|
|
3
3
|
import ignore from 'ignore';
|
|
4
4
|
import { VercelClientOptions, DeploymentOptions, VercelConfig } from '../types';
|
|
@@ -29,11 +29,11 @@ interface FetchOpts extends FetchOptions {
|
|
|
29
29
|
export declare const fetch: (url: string, token: string, opts?: FetchOpts, debugEnabled?: boolean | undefined, useNodeFetch?: boolean | undefined) => Promise<any>;
|
|
30
30
|
export interface PreparedFile {
|
|
31
31
|
file: string;
|
|
32
|
-
sha
|
|
33
|
-
size
|
|
32
|
+
sha?: string;
|
|
33
|
+
size?: number;
|
|
34
34
|
mode: number;
|
|
35
35
|
}
|
|
36
|
-
export declare const prepareFiles: (files:
|
|
36
|
+
export declare const prepareFiles: (files: FilesMap, clientOptions: VercelClientOptions) => PreparedFile[];
|
|
37
37
|
export declare function createDebug(debug?: boolean): (...logs: string[]) => void;
|
|
38
38
|
declare type Debug = ReturnType<typeof createDebug>;
|
|
39
39
|
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -222,9 +222,9 @@ const prepareFiles = (files, clientOptions) => {
|
|
|
222
222
|
}
|
|
223
223
|
preparedFiles.push({
|
|
224
224
|
file: isWin ? fileName.replace(/\\/g, '/') : fileName,
|
|
225
|
-
size: file.data
|
|
225
|
+
size: file.data?.byteLength || file.data?.length,
|
|
226
226
|
mode: file.mode,
|
|
227
|
-
sha,
|
|
227
|
+
sha: sha || undefined,
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
}
|
|
@@ -77,6 +77,10 @@ function readdir(path, ignores) {
|
|
|
77
77
|
if (stats.isDirectory()) {
|
|
78
78
|
readdir(filePath, ignores)
|
|
79
79
|
.then(function (res) {
|
|
80
|
+
if (res.length === 0) {
|
|
81
|
+
// Empty directories get returned
|
|
82
|
+
list.push(filePath);
|
|
83
|
+
}
|
|
80
84
|
list = list.concat(res);
|
|
81
85
|
pending -= 1;
|
|
82
86
|
if (!pending) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/client",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"homepage": "https://vercel.com",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@vercel/build-utils": "5.
|
|
46
|
+
"@vercel/build-utils": "5.9.0",
|
|
47
47
|
"@vercel/routing-utils": "2.1.8",
|
|
48
48
|
"@zeit/fetch": "5.2.0",
|
|
49
49
|
"async-retry": "1.2.3",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"sleep-promise": "8.0.1",
|
|
58
58
|
"tar-fs": "1.16.3"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "4ccdcde463560dc44da89edf52523419fc56ab62"
|
|
61
61
|
}
|