@vercel/client 10.3.1-canary.8 → 10.4.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/create-deployment.js +2 -6
- package/dist/utils/hashes.d.ts +0 -1
- package/dist/utils/hashes.js +1 -27
- package/dist/utils/index.d.ts +6 -6
- package/dist/utils/index.js +28 -27
- package/package.json +3 -3
|
@@ -53,7 +53,7 @@ function buildCreateDeployment() {
|
|
|
53
53
|
else {
|
|
54
54
|
debug(`Provided 'path' is a single file`);
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
const { fileList } = await utils_1.buildFileTree(path, clientOptions, debug);
|
|
57
57
|
let configPath;
|
|
58
58
|
if (!nowConfig) {
|
|
59
59
|
// If the user did not provide a config file, use the one in the root directory.
|
|
@@ -83,11 +83,7 @@ function buildCreateDeployment() {
|
|
|
83
83
|
payload: 'There are no files inside your deployment.',
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
const
|
|
87
|
-
const nftFileList = clientOptions.prebuilt
|
|
88
|
-
? await hashes_1.resolveNftJsonFiles(hashedFileMap)
|
|
89
|
-
: [];
|
|
90
|
-
const files = await hashes_1.hashes(nftFileList, hashedFileMap);
|
|
86
|
+
const files = await hashes_1.hashes(fileList);
|
|
91
87
|
debug(`Yielding a 'hashes-calculated' event with ${files.size} hashes`);
|
|
92
88
|
yield { type: 'hashes-calculated', payload: hashes_1.mapToObject(files) };
|
|
93
89
|
if (clientOptions.apiUrl) {
|
package/dist/utils/hashes.d.ts
CHANGED
|
@@ -20,4 +20,3 @@ export declare const mapToObject: (map: Map<string, DeploymentFile>) => {
|
|
|
20
20
|
* @return Map of hash digest to file object
|
|
21
21
|
*/
|
|
22
22
|
export declare function hashes(files: string[], map?: Map<string, DeploymentFile>): Promise<Map<string, DeploymentFile>>;
|
|
23
|
-
export declare function resolveNftJsonFiles(hashedFiles: Map<string, DeploymentFile>): Promise<string[]>;
|
package/dist/utils/hashes.js
CHANGED
|
@@ -3,11 +3,10 @@ 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.
|
|
6
|
+
exports.hashes = exports.mapToObject = void 0;
|
|
7
7
|
const crypto_1 = require("crypto");
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const async_sema_1 = require("async-sema");
|
|
10
|
-
const path_1 = require("path");
|
|
11
10
|
/**
|
|
12
11
|
* Computes a hash for the given buf.
|
|
13
12
|
*
|
|
@@ -66,28 +65,3 @@ async function hashes(files, map = new Map()) {
|
|
|
66
65
|
return map;
|
|
67
66
|
}
|
|
68
67
|
exports.hashes = hashes;
|
|
69
|
-
async function resolveNftJsonFiles(hashedFiles) {
|
|
70
|
-
const semaphore = new async_sema_1.Sema(100);
|
|
71
|
-
const existingFiles = Array.from(hashedFiles.values());
|
|
72
|
-
const resolvedFiles = new Set();
|
|
73
|
-
await Promise.all(existingFiles.map(async (file) => {
|
|
74
|
-
await semaphore.acquire();
|
|
75
|
-
const fsPath = file.names[0];
|
|
76
|
-
if (fsPath.endsWith('.nft.json')) {
|
|
77
|
-
const json = file.data.toString('utf8');
|
|
78
|
-
const { version, files } = JSON.parse(json);
|
|
79
|
-
if (version === 1 || version === 2) {
|
|
80
|
-
for (let f of files) {
|
|
81
|
-
const relPath = typeof f === 'string' ? f : f.input;
|
|
82
|
-
resolvedFiles.add(path_1.join(path_1.dirname(fsPath), relPath));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
console.error(`Invalid nft.json version: ${version}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
semaphore.release();
|
|
90
|
-
}));
|
|
91
|
-
return Array.from(resolvedFiles);
|
|
92
|
-
}
|
|
93
|
-
exports.resolveNftJsonFiles = resolveNftJsonFiles;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { DeploymentFile } from './hashes';
|
|
2
2
|
import { FetchOptions } from '@zeit/fetch';
|
|
3
3
|
import ignore from 'ignore';
|
|
4
|
+
import { VercelClientOptions, DeploymentOptions, VercelConfig } from '../types';
|
|
4
5
|
declare type Ignore = ReturnType<typeof ignore>;
|
|
5
|
-
|
|
6
|
-
export declare const API_FILES = "/v2/now/files";
|
|
6
|
+
export declare const API_FILES = "/v2/files";
|
|
7
7
|
declare const EVENTS_ARRAY: readonly ["hashes-calculated", "file-count", "file-uploaded", "all-files-uploaded", "created", "building", "ready", "alias-assigned", "warning", "error", "notice", "tip", "canceled", "checks-registered", "checks-completed", "checks-running", "checks-conclusion-succeeded", "checks-conclusion-failed", "checks-conclusion-skipped", "checks-conclusion-canceled"];
|
|
8
8
|
export declare type DeploymentEventType = typeof EVENTS_ARRAY[number];
|
|
9
9
|
export declare const EVENTS: Set<"warning" | "error" | "hashes-calculated" | "file-count" | "file-uploaded" | "all-files-uploaded" | "created" | "building" | "ready" | "alias-assigned" | "notice" | "tip" | "canceled" | "checks-registered" | "checks-completed" | "checks-running" | "checks-conclusion-succeeded" | "checks-conclusion-failed" | "checks-conclusion-skipped" | "checks-conclusion-canceled">;
|
|
10
|
-
export declare function getApiDeploymentsUrl(metadata?: Pick<DeploymentOptions, 'builds' | 'functions'>): "/v10/
|
|
11
|
-
export declare function parseVercelConfig(filePath?: string): Promise<
|
|
12
|
-
export declare function buildFileTree(path: string | string[], { isDirectory, prebuilt,
|
|
10
|
+
export declare function getApiDeploymentsUrl(metadata?: Pick<DeploymentOptions, 'builds' | 'functions'>): "/v10/deployments" | "/v13/deployments";
|
|
11
|
+
export declare function parseVercelConfig(filePath?: string): Promise<VercelConfig>;
|
|
12
|
+
export declare function buildFileTree(path: string | string[], { isDirectory, prebuilt, }: Pick<VercelClientOptions, 'isDirectory' | 'prebuilt'>, debug: Debug): Promise<{
|
|
13
13
|
fileList: string[];
|
|
14
14
|
ignoreList: string[];
|
|
15
15
|
}>;
|
|
16
|
-
export declare function getVercelIgnore(cwd: string | string[], prebuilt?: boolean
|
|
16
|
+
export declare function getVercelIgnore(cwd: string | string[], prebuilt?: boolean): Promise<{
|
|
17
17
|
ig: Ignore;
|
|
18
18
|
ignores: string[];
|
|
19
19
|
}>;
|
package/dist/utils/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const async_sema_1 = require("async-sema");
|
|
|
14
14
|
const fs_extra_1 = require("fs-extra");
|
|
15
15
|
const readdir_recursive_1 = __importDefault(require("./readdir-recursive"));
|
|
16
16
|
const semaphore = new async_sema_1.Sema(10);
|
|
17
|
-
exports.API_FILES = '/v2/
|
|
17
|
+
exports.API_FILES = '/v2/files';
|
|
18
18
|
const EVENTS_ARRAY = [
|
|
19
19
|
// File events
|
|
20
20
|
'hashes-calculated',
|
|
@@ -43,9 +43,9 @@ const EVENTS_ARRAY = [
|
|
|
43
43
|
exports.EVENTS = new Set(EVENTS_ARRAY);
|
|
44
44
|
function getApiDeploymentsUrl(metadata) {
|
|
45
45
|
if (metadata && metadata.builds && !metadata.functions) {
|
|
46
|
-
return '/v10/
|
|
46
|
+
return '/v10/deployments';
|
|
47
47
|
}
|
|
48
|
-
return '/v13/
|
|
48
|
+
return '/v13/deployments';
|
|
49
49
|
}
|
|
50
50
|
exports.getApiDeploymentsUrl = getApiDeploymentsUrl;
|
|
51
51
|
async function parseVercelConfig(filePath) {
|
|
@@ -71,10 +71,10 @@ const maybeRead = async function (path, default_) {
|
|
|
71
71
|
return default_;
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
async function buildFileTree(path, { isDirectory, prebuilt,
|
|
74
|
+
async function buildFileTree(path, { isDirectory, prebuilt, }, debug) {
|
|
75
75
|
const ignoreList = [];
|
|
76
76
|
let fileList;
|
|
77
|
-
let { ig, ignores } = await getVercelIgnore(path, prebuilt
|
|
77
|
+
let { ig, ignores } = await getVercelIgnore(path, prebuilt);
|
|
78
78
|
debug(`Found ${ignores.length} rules in .vercelignore`);
|
|
79
79
|
debug('Building file tree...');
|
|
80
80
|
if (isDirectory && !Array.isArray(path)) {
|
|
@@ -103,17 +103,19 @@ async function buildFileTree(path, { isDirectory, prebuilt, rootDirectory, }, de
|
|
|
103
103
|
return { fileList, ignoreList };
|
|
104
104
|
}
|
|
105
105
|
exports.buildFileTree = buildFileTree;
|
|
106
|
-
async function getVercelIgnore(cwd, prebuilt
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
async function getVercelIgnore(cwd, prebuilt) {
|
|
107
|
+
const ig = ignore_1.default();
|
|
108
|
+
let ignores;
|
|
109
109
|
if (prebuilt) {
|
|
110
|
-
|
|
110
|
+
const outputDir = '.vercel/output';
|
|
111
|
+
ignores = ['*'];
|
|
111
112
|
const parts = outputDir.split('/');
|
|
112
113
|
parts.forEach((_, i) => {
|
|
113
114
|
const level = parts.slice(0, i + 1).join('/');
|
|
114
115
|
ignores.push(`!${level}`);
|
|
115
116
|
});
|
|
116
117
|
ignores.push(`!${outputDir}/**`);
|
|
118
|
+
ig.add(ignores.join('\n'));
|
|
117
119
|
}
|
|
118
120
|
else {
|
|
119
121
|
ignores = [
|
|
@@ -141,26 +143,25 @@ async function getVercelIgnore(cwd, prebuilt, rootDirectory) {
|
|
|
141
143
|
'__pycache__',
|
|
142
144
|
'venv',
|
|
143
145
|
'CVS',
|
|
144
|
-
`.output`,
|
|
145
146
|
];
|
|
147
|
+
const cwds = Array.isArray(cwd) ? cwd : [cwd];
|
|
148
|
+
const files = await Promise.all(cwds.map(async (cwd) => {
|
|
149
|
+
const [vercelignore, nowignore] = await Promise.all([
|
|
150
|
+
maybeRead(path_1.join(cwd, '.vercelignore'), ''),
|
|
151
|
+
maybeRead(path_1.join(cwd, '.nowignore'), ''),
|
|
152
|
+
]);
|
|
153
|
+
if (vercelignore && nowignore) {
|
|
154
|
+
throw new build_utils_1.NowBuildError({
|
|
155
|
+
code: 'CONFLICTING_IGNORE_FILES',
|
|
156
|
+
message: 'Cannot use both a `.vercelignore` and `.nowignore` file. Please delete the `.nowignore` file.',
|
|
157
|
+
link: 'https://vercel.link/combining-old-and-new-config',
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return vercelignore || nowignore;
|
|
161
|
+
}));
|
|
162
|
+
const ignoreFile = files.join('\n');
|
|
163
|
+
ig.add(`${ignores.join('\n')}\n${clearRelative(ignoreFile)}`);
|
|
146
164
|
}
|
|
147
|
-
const cwds = Array.isArray(cwd) ? cwd : [cwd];
|
|
148
|
-
const files = await Promise.all(cwds.map(async (cwd) => {
|
|
149
|
-
const [vercelignore, nowignore] = await Promise.all([
|
|
150
|
-
maybeRead(path_1.join(cwd, '.vercelignore'), ''),
|
|
151
|
-
maybeRead(path_1.join(cwd, '.nowignore'), ''),
|
|
152
|
-
]);
|
|
153
|
-
if (vercelignore && nowignore) {
|
|
154
|
-
throw new build_utils_1.NowBuildError({
|
|
155
|
-
code: 'CONFLICTING_IGNORE_FILES',
|
|
156
|
-
message: 'Cannot use both a `.vercelignore` and `.nowignore` file. Please delete the `.nowignore` file.',
|
|
157
|
-
link: 'https://vercel.link/combining-old-and-new-config',
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
return vercelignore || nowignore;
|
|
161
|
-
}));
|
|
162
|
-
const ignoreFile = files.join('\n');
|
|
163
|
-
const ig = ignore_1.default().add(`${ignores.join('\n')}\n${clearRelative(ignoreFile)}`);
|
|
164
165
|
return { ig, ignores };
|
|
165
166
|
}
|
|
166
167
|
exports.getVercelIgnore = getVercelIgnore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/client",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"homepage": "https://vercel.com",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
]
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@vercel/build-utils": "2.
|
|
44
|
+
"@vercel/build-utils": "2.15.1",
|
|
45
45
|
"@zeit/fetch": "5.2.0",
|
|
46
46
|
"async-retry": "1.2.3",
|
|
47
47
|
"async-sema": "3.0.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"querystring": "^0.2.0",
|
|
54
54
|
"sleep-promise": "8.0.1"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "4a8504fc45092dc4a374bf7a518bd9a07f24fd41"
|
|
57
57
|
}
|