@vercel/client 10.3.1-canary.3 → 10.3.1-canary.6
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/upload.js +14 -5
- package/dist/utils/hashes.js +10 -2
- package/dist/utils/index.js +2 -2
- package/dist/utils/readdir-recursive.d.ts +5 -0
- package/dist/utils/readdir-recursive.js +100 -0
- package/package.json +5 -4
package/dist/upload.js
CHANGED
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.upload = void 0;
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
7
|
const https_1 = require("https");
|
|
9
8
|
const async_retry_1 = __importDefault(require("async-retry"));
|
|
10
9
|
const async_sema_1 = require("async-sema");
|
|
10
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
12
|
const errors_1 = require("./errors");
|
|
13
13
|
const deploy_1 = require("./deploy");
|
|
@@ -67,7 +67,14 @@ async function* upload(files, clientOptions, deploymentOptions) {
|
|
|
67
67
|
}
|
|
68
68
|
await semaphore.acquire();
|
|
69
69
|
const fPath = file.names[0];
|
|
70
|
-
|
|
70
|
+
let body = null;
|
|
71
|
+
const stat = await fs_extra_1.default.lstat(fPath);
|
|
72
|
+
if (stat.isSymbolicLink()) {
|
|
73
|
+
body = await fs_extra_1.default.readlink(fPath);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
body = fs_extra_1.default.createReadStream(fPath);
|
|
77
|
+
}
|
|
71
78
|
const { data } = file;
|
|
72
79
|
let err;
|
|
73
80
|
let result;
|
|
@@ -81,7 +88,7 @@ async function* upload(files, clientOptions, deploymentOptions) {
|
|
|
81
88
|
'x-now-digest': sha,
|
|
82
89
|
'x-now-size': data.length,
|
|
83
90
|
},
|
|
84
|
-
body
|
|
91
|
+
body,
|
|
85
92
|
teamId,
|
|
86
93
|
apiUrl,
|
|
87
94
|
userAgent,
|
|
@@ -111,8 +118,10 @@ async function* upload(files, clientOptions, deploymentOptions) {
|
|
|
111
118
|
err = new Error(e);
|
|
112
119
|
}
|
|
113
120
|
finally {
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
if (body && typeof body !== 'string') {
|
|
122
|
+
body.close();
|
|
123
|
+
body.destroy();
|
|
124
|
+
}
|
|
116
125
|
}
|
|
117
126
|
semaphore.release();
|
|
118
127
|
if (err) {
|
package/dist/utils/hashes.js
CHANGED
|
@@ -41,8 +41,16 @@ async function hashes(files, map = new Map()) {
|
|
|
41
41
|
const semaphore = new async_sema_1.Sema(100);
|
|
42
42
|
await Promise.all(files.map(async (name) => {
|
|
43
43
|
await semaphore.acquire();
|
|
44
|
-
const
|
|
45
|
-
const
|
|
44
|
+
const stat = await fs_extra_1.default.lstat(name);
|
|
45
|
+
const mode = stat.mode;
|
|
46
|
+
let data = null;
|
|
47
|
+
if (stat.isSymbolicLink()) {
|
|
48
|
+
const link = await fs_extra_1.default.readlink(name);
|
|
49
|
+
data = Buffer.from(link, 'utf8');
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
data = await fs_extra_1.default.readFile(name);
|
|
53
|
+
}
|
|
46
54
|
const h = hash(data);
|
|
47
55
|
const entry = map.get(h);
|
|
48
56
|
if (entry) {
|
package/dist/utils/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const pkg_1 = require("../pkg");
|
|
|
12
12
|
const build_utils_1 = require("@vercel/build-utils");
|
|
13
13
|
const async_sema_1 = require("async-sema");
|
|
14
14
|
const fs_extra_1 = require("fs-extra");
|
|
15
|
-
const
|
|
15
|
+
const readdir_recursive_1 = __importDefault(require("./readdir-recursive"));
|
|
16
16
|
const semaphore = new async_sema_1.Sema(10);
|
|
17
17
|
exports.API_FILES = '/v2/now/files';
|
|
18
18
|
const EVENTS_ARRAY = [
|
|
@@ -87,7 +87,7 @@ async function buildFileTree(path, { isDirectory, prebuilt, rootDirectory, }, de
|
|
|
87
87
|
}
|
|
88
88
|
return ignored;
|
|
89
89
|
};
|
|
90
|
-
fileList = await
|
|
90
|
+
fileList = await readdir_recursive_1.default(path, [ignores]);
|
|
91
91
|
debug(`Found ${fileList.length} files in the specified directory`);
|
|
92
92
|
}
|
|
93
93
|
else if (Array.isArray(path)) {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
The MIT License (MIT)
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2014 Jamison Dance
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
/*
|
|
30
|
+
based on https://github.com/jergason/recursive-readdir
|
|
31
|
+
primary changes:
|
|
32
|
+
- use `lstat` instead of `stat` so that symlinks are not followed
|
|
33
|
+
*/
|
|
34
|
+
const fs_1 = __importDefault(require("fs"));
|
|
35
|
+
const path_1 = __importDefault(require("path"));
|
|
36
|
+
const minimatch_1 = __importDefault(require("minimatch"));
|
|
37
|
+
function patternMatcher(pattern) {
|
|
38
|
+
return function (path, stats) {
|
|
39
|
+
const minimatcher = new minimatch_1.default.Minimatch(pattern, { matchBase: true });
|
|
40
|
+
return (!minimatcher.negate || stats.isFile()) && minimatcher.match(path);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function toMatcherFunction(ignoreEntry) {
|
|
44
|
+
if (typeof ignoreEntry === 'function') {
|
|
45
|
+
return ignoreEntry;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return patternMatcher(ignoreEntry);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function readdir(path, ignores) {
|
|
52
|
+
ignores = ignores.map(toMatcherFunction);
|
|
53
|
+
let list = [];
|
|
54
|
+
return new Promise(function (resolve, reject) {
|
|
55
|
+
fs_1.default.readdir(path, function (err, files) {
|
|
56
|
+
if (err) {
|
|
57
|
+
return reject(err);
|
|
58
|
+
}
|
|
59
|
+
let pending = files.length;
|
|
60
|
+
if (!pending) {
|
|
61
|
+
return resolve(list);
|
|
62
|
+
}
|
|
63
|
+
files.forEach(function (file) {
|
|
64
|
+
const filePath = path_1.default.join(path, file);
|
|
65
|
+
fs_1.default.lstat(filePath, function (_err, stats) {
|
|
66
|
+
if (_err) {
|
|
67
|
+
return reject(_err);
|
|
68
|
+
}
|
|
69
|
+
const matches = ignores.some(matcher => matcher(filePath, stats));
|
|
70
|
+
if (matches) {
|
|
71
|
+
pending -= 1;
|
|
72
|
+
if (!pending) {
|
|
73
|
+
return resolve(list);
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
if (stats.isDirectory()) {
|
|
78
|
+
readdir(filePath, ignores)
|
|
79
|
+
.then(function (res) {
|
|
80
|
+
list = list.concat(res);
|
|
81
|
+
pending -= 1;
|
|
82
|
+
if (!pending) {
|
|
83
|
+
return resolve(list);
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
.catch(reject);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
list.push(filePath);
|
|
90
|
+
pending -= 1;
|
|
91
|
+
if (!pending) {
|
|
92
|
+
return resolve(list);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
exports.default = readdir;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/client",
|
|
3
|
-
"version": "10.3.1-canary.
|
|
3
|
+
"version": "10.3.1-canary.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"homepage": "https://vercel.com",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@types/async-retry": "1.4.1",
|
|
26
26
|
"@types/fs-extra": "7.0.0",
|
|
27
27
|
"@types/jest": "27.0.1",
|
|
28
|
+
"@types/minimatch": "3.0.5",
|
|
28
29
|
"@types/ms": "0.7.30",
|
|
29
30
|
"@types/node": "12.0.4",
|
|
30
31
|
"@types/node-fetch": "2.5.4",
|
|
@@ -40,17 +41,17 @@
|
|
|
40
41
|
]
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@vercel/build-utils": "2.14.1-canary.
|
|
44
|
+
"@vercel/build-utils": "2.14.1-canary.6",
|
|
44
45
|
"@zeit/fetch": "5.2.0",
|
|
45
46
|
"async-retry": "1.2.3",
|
|
46
47
|
"async-sema": "3.0.0",
|
|
47
48
|
"fs-extra": "8.0.1",
|
|
48
49
|
"ignore": "4.0.6",
|
|
50
|
+
"minimatch": "5.0.1",
|
|
49
51
|
"ms": "2.1.2",
|
|
50
52
|
"node-fetch": "2.6.1",
|
|
51
53
|
"querystring": "^0.2.0",
|
|
52
|
-
"recursive-readdir": "2.2.2",
|
|
53
54
|
"sleep-promise": "8.0.1"
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "9dde99f19ef62f7ea8addc19fab9a1ff025aa4ae"
|
|
56
57
|
}
|