@vercel/client 17.5.18 → 17.6.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/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/types.d.ts +6 -2
- package/dist/utils/index.d.ts +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/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Agent } from 'http';
|
|
2
|
-
import type { Builder, BuilderFunctions, Images, ProjectSettings, Cron, ExperimentalServices, ExperimentalServiceGroups, ExperimentalServicesV2 } from '@vercel/build-utils';
|
|
2
|
+
import type { Builder, BuilderFunctions, Images, ProjectSettings, Cron, ExperimentalServices, ExperimentalServiceGroups, ExperimentalServicesV2, Services } from '@vercel/build-utils';
|
|
3
3
|
import type { Header, Route, Redirect, Rewrite } from '@vercel/routing-utils';
|
|
4
4
|
export { DeploymentEventType } from './utils';
|
|
5
5
|
export interface Dictionary<T> {
|
|
@@ -147,7 +147,11 @@ export interface VercelConfig {
|
|
|
147
147
|
*/
|
|
148
148
|
experimentalServiceGroups?: ExperimentalServiceGroups;
|
|
149
149
|
/**
|
|
150
|
-
*
|
|
150
|
+
* Configures multiple services in this project.
|
|
151
|
+
*/
|
|
152
|
+
services?: Services;
|
|
153
|
+
/**
|
|
154
|
+
* @deprecated Use `services` instead.
|
|
151
155
|
*/
|
|
152
156
|
experimentalServicesV2?: ExperimentalServicesV2;
|
|
153
157
|
}
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/client",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.6.1",
|
|
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/build-utils": "13.32.1",
|
|
43
|
+
"@vercel/routing-utils": "6.3.1",
|
|
44
|
+
"@vercel/error-utils": "2.2.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "node ../../utils/build.mjs",
|