@vercel/client 13.0.1 → 13.0.3

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 CHANGED
@@ -1,130 +1,158 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deploy = void 0;
4
- const query_string_1 = require("./utils/query-string");
5
- const ready_state_1 = require("./utils/ready-state");
6
- const check_deployment_status_1 = require("./check-deployment-status");
7
- const utils_1 = require("./utils");
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 deploy_exports = {};
20
+ __export(deploy_exports, {
21
+ deploy: () => deploy
22
+ });
23
+ module.exports = __toCommonJS(deploy_exports);
24
+ var import_query_string = require("./utils/query-string");
25
+ var import_ready_state = require("./utils/ready-state");
26
+ var import_check_deployment_status = require("./check-deployment-status");
27
+ var import_utils = require("./utils");
8
28
  async function* postDeployment(files, clientOptions, deploymentOptions) {
9
- const debug = (0, utils_1.createDebug)(clientOptions.debug);
10
- const preparedFiles = (0, utils_1.prepareFiles)(files, clientOptions);
11
- const apiDeployments = (0, utils_1.getApiDeploymentsUrl)(deploymentOptions);
12
- debug('Sending deployment creation API request');
13
- try {
14
- const response = await (0, utils_1.fetch)(`${apiDeployments}${(0, query_string_1.generateQueryString)(clientOptions)}`, clientOptions.token, {
15
- method: 'POST',
16
- headers: {
17
- Accept: 'application/json',
18
- 'Content-Type': 'application/json',
19
- },
20
- body: JSON.stringify({
21
- ...deploymentOptions,
22
- files: preparedFiles,
23
- }),
24
- apiUrl: clientOptions.apiUrl,
25
- userAgent: clientOptions.userAgent,
26
- agent: clientOptions.agent,
27
- });
28
- const deployment = await response.json();
29
- if (clientOptions.debug) {
30
- // Wrapped because there is no need to
31
- // call JSON.stringify if we don't debug.
32
- debug('Deployment response:', JSON.stringify(deployment));
33
- }
34
- if (!response.ok || deployment.error) {
35
- debug('Error: Deployment request status is', response.status);
36
- // Return error object
37
- return yield {
38
- type: 'error',
39
- payload: deployment.error
40
- ? { ...deployment.error, status: response.status }
41
- : { ...deployment, status: response.status },
42
- };
43
- }
44
- const indications = new Set(['warning', 'notice', 'tip']);
45
- const regex = /^x-(?:vercel|now)-(warning|notice|tip)-(.*)$/;
46
- for (const [name, payload] of response.headers.entries()) {
47
- const match = name.match(regex);
48
- if (match) {
49
- const [, type, identifier] = match;
50
- const action = response.headers.get(`x-vercel-action-${identifier}`);
51
- const link = response.headers.get(`x-vercel-link-${identifier}`);
52
- if (indications.has(type)) {
53
- debug(`Deployment created with a ${type}: `, payload);
54
- yield { type, payload, action, link };
55
- }
56
- }
57
- }
58
- yield { type: 'created', payload: deployment };
29
+ const debug = (0, import_utils.createDebug)(clientOptions.debug);
30
+ const preparedFiles = (0, import_utils.prepareFiles)(files, clientOptions);
31
+ const apiDeployments = (0, import_utils.getApiDeploymentsUrl)(deploymentOptions);
32
+ debug("Sending deployment creation API request");
33
+ try {
34
+ const response = await (0, import_utils.fetch)(
35
+ `${apiDeployments}${(0, import_query_string.generateQueryString)(clientOptions)}`,
36
+ clientOptions.token,
37
+ {
38
+ method: "POST",
39
+ headers: {
40
+ Accept: "application/json",
41
+ "Content-Type": "application/json"
42
+ },
43
+ body: JSON.stringify({
44
+ ...deploymentOptions,
45
+ files: preparedFiles
46
+ }),
47
+ apiUrl: clientOptions.apiUrl,
48
+ userAgent: clientOptions.userAgent,
49
+ agent: clientOptions.agent
50
+ }
51
+ );
52
+ const deployment = await response.json();
53
+ if (clientOptions.debug) {
54
+ debug("Deployment response:", JSON.stringify(deployment));
59
55
  }
60
- catch (e) {
61
- return yield { type: 'error', payload: e };
56
+ if (!response.ok || deployment.error) {
57
+ debug("Error: Deployment request status is", response.status);
58
+ return yield {
59
+ type: "error",
60
+ payload: deployment.error ? { ...deployment.error, status: response.status } : { ...deployment, status: response.status }
61
+ };
62
62
  }
63
+ const indications = /* @__PURE__ */ new Set(["warning", "notice", "tip"]);
64
+ const regex = /^x-(?:vercel|now)-(warning|notice|tip)-(.*)$/;
65
+ for (const [name, payload] of response.headers.entries()) {
66
+ const match = name.match(regex);
67
+ if (match) {
68
+ const [, type, identifier] = match;
69
+ const action = response.headers.get(`x-vercel-action-${identifier}`);
70
+ const link = response.headers.get(`x-vercel-link-${identifier}`);
71
+ if (indications.has(type)) {
72
+ debug(`Deployment created with a ${type}: `, payload);
73
+ yield { type, payload, action, link };
74
+ }
75
+ }
76
+ }
77
+ yield { type: "created", payload: deployment };
78
+ } catch (e) {
79
+ return yield { type: "error", payload: e };
80
+ }
63
81
  }
64
82
  function getDefaultName(files, clientOptions) {
65
- const debug = (0, utils_1.createDebug)(clientOptions.debug);
66
- const { isDirectory, path } = clientOptions;
67
- if (isDirectory && typeof path === 'string') {
68
- debug('Provided path is a directory. Using last segment as default name');
69
- return path.split('/').pop() || path;
70
- }
71
- else {
72
- debug('Provided path is not a directory. Using last segment of the first file as default name');
73
- const filePath = Array.from(files.values())[0].names[0];
74
- return filePath.split('/').pop() || filePath;
75
- }
83
+ const debug = (0, import_utils.createDebug)(clientOptions.debug);
84
+ const { isDirectory, path } = clientOptions;
85
+ if (isDirectory && typeof path === "string") {
86
+ debug("Provided path is a directory. Using last segment as default name");
87
+ return path.split("/").pop() || path;
88
+ } else {
89
+ debug(
90
+ "Provided path is not a directory. Using last segment of the first file as default name"
91
+ );
92
+ const filePath = Array.from(files.values())[0].names[0];
93
+ return filePath.split("/").pop() || filePath;
94
+ }
76
95
  }
77
96
  async function* deploy(files, clientOptions, deploymentOptions) {
78
- const debug = (0, utils_1.createDebug)(clientOptions.debug);
79
- // Check if we should default to a static deployment
80
- if (!deploymentOptions.name) {
81
- deploymentOptions.version = 2;
82
- deploymentOptions.name =
83
- files.size === 1 ? 'file' : getDefaultName(files, clientOptions);
84
- if (deploymentOptions.name === 'file') {
85
- debug('Setting deployment name to "file" for single-file deployment');
86
- }
97
+ const debug = (0, import_utils.createDebug)(clientOptions.debug);
98
+ if (!deploymentOptions.name) {
99
+ deploymentOptions.version = 2;
100
+ deploymentOptions.name = files.size === 1 ? "file" : getDefaultName(files, clientOptions);
101
+ if (deploymentOptions.name === "file") {
102
+ debug('Setting deployment name to "file" for single-file deployment');
87
103
  }
88
- if (!deploymentOptions.name) {
89
- deploymentOptions.name =
90
- clientOptions.defaultName || getDefaultName(files, clientOptions);
91
- debug('No name provided. Defaulting to', deploymentOptions.name);
104
+ }
105
+ if (!deploymentOptions.name) {
106
+ deploymentOptions.name = clientOptions.defaultName || getDefaultName(files, clientOptions);
107
+ debug("No name provided. Defaulting to", deploymentOptions.name);
108
+ }
109
+ if (clientOptions.withCache) {
110
+ debug(
111
+ `'withCache' is provided. Force deploy will be performed with cache retention`
112
+ );
113
+ }
114
+ let deployment;
115
+ try {
116
+ debug("Creating deployment");
117
+ for await (const event of postDeployment(
118
+ files,
119
+ clientOptions,
120
+ deploymentOptions
121
+ )) {
122
+ if (event.type === "created") {
123
+ debug("Deployment created");
124
+ deployment = event.payload;
125
+ }
126
+ yield event;
92
127
  }
93
- if (clientOptions.withCache) {
94
- debug(`'withCache' is provided. Force deploy will be performed with cache retention`);
128
+ } catch (e) {
129
+ debug("An unexpected error occurred when creating the deployment");
130
+ return yield { type: "error", payload: e };
131
+ }
132
+ if (deployment) {
133
+ if ((0, import_ready_state.isReady)(deployment) && (0, import_ready_state.isAliasAssigned)(deployment)) {
134
+ debug("Deployment state changed to READY 3");
135
+ yield { type: "ready", payload: deployment };
136
+ debug("Deployment alias assigned");
137
+ return yield { type: "alias-assigned", payload: deployment };
95
138
  }
96
- let deployment;
97
139
  try {
98
- debug('Creating deployment');
99
- for await (const event of postDeployment(files, clientOptions, deploymentOptions)) {
100
- if (event.type === 'created') {
101
- debug('Deployment created');
102
- deployment = event.payload;
103
- }
104
- yield event;
105
- }
106
- }
107
- catch (e) {
108
- debug('An unexpected error occurred when creating the deployment');
109
- return yield { type: 'error', payload: e };
110
- }
111
- if (deployment) {
112
- if ((0, ready_state_1.isReady)(deployment) && (0, ready_state_1.isAliasAssigned)(deployment)) {
113
- debug('Deployment state changed to READY 3');
114
- yield { type: 'ready', payload: deployment };
115
- debug('Deployment alias assigned');
116
- return yield { type: 'alias-assigned', payload: deployment };
117
- }
118
- try {
119
- debug('Waiting for deployment to be ready...');
120
- for await (const event of (0, check_deployment_status_1.checkDeploymentStatus)(deployment, clientOptions)) {
121
- yield event;
122
- }
123
- }
124
- catch (e) {
125
- debug('An unexpected error occurred while waiting for deployment to be ready');
126
- return yield { type: 'error', payload: e };
127
- }
140
+ debug("Waiting for deployment to be ready...");
141
+ for await (const event of (0, import_check_deployment_status.checkDeploymentStatus)(
142
+ deployment,
143
+ clientOptions
144
+ )) {
145
+ yield event;
146
+ }
147
+ } catch (e) {
148
+ debug(
149
+ "An unexpected error occurred while waiting for deployment to be ready"
150
+ );
151
+ return yield { type: "error", payload: e };
128
152
  }
153
+ }
129
154
  }
130
- exports.deploy = deploy;
155
+ // Annotate the CommonJS export names for ESM import in node:
156
+ 0 && (module.exports = {
157
+ deploy
158
+ });
package/dist/errors.js CHANGED
@@ -1,11 +1,34 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeploymentError = void 0;
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 errors_exports = {};
20
+ __export(errors_exports, {
21
+ DeploymentError: () => DeploymentError
22
+ });
23
+ module.exports = __toCommonJS(errors_exports);
4
24
  class DeploymentError extends Error {
5
- constructor(err) {
6
- super(err.message);
7
- this.code = err.code;
8
- this.name = 'DeploymentError';
9
- }
25
+ constructor(err) {
26
+ super(err.message);
27
+ this.code = err.code;
28
+ this.name = "DeploymentError";
29
+ }
10
30
  }
11
- exports.DeploymentError = DeploymentError;
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ DeploymentError
34
+ });
package/dist/index.js CHANGED
@@ -1,29 +1,52 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
15
11
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
18
19
  };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.createDeployment = exports.buildFileTree = exports.getVercelIgnore = exports.checkDeploymentStatus = void 0;
21
- const create_deployment_1 = __importDefault(require("./create-deployment"));
22
- var check_deployment_status_1 = require("./check-deployment-status");
23
- Object.defineProperty(exports, "checkDeploymentStatus", { enumerable: true, get: function () { return check_deployment_status_1.checkDeploymentStatus; } });
24
- var index_1 = require("./utils/index");
25
- Object.defineProperty(exports, "getVercelIgnore", { enumerable: true, get: function () { return index_1.getVercelIgnore; } });
26
- Object.defineProperty(exports, "buildFileTree", { enumerable: true, get: function () { return index_1.buildFileTree; } });
27
- exports.createDeployment = (0, create_deployment_1.default)();
28
- __exportStar(require("./errors"), exports);
29
- __exportStar(require("./types"), exports);
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var src_exports = {};
31
+ __export(src_exports, {
32
+ buildFileTree: () => import_utils.buildFileTree,
33
+ checkDeploymentStatus: () => import_check_deployment_status.checkDeploymentStatus,
34
+ createDeployment: () => createDeployment,
35
+ getVercelIgnore: () => import_utils.getVercelIgnore
36
+ });
37
+ module.exports = __toCommonJS(src_exports);
38
+ var import_create_deployment = __toESM(require("./create-deployment"));
39
+ var import_check_deployment_status = require("./check-deployment-status");
40
+ var import_utils = require("./utils/index");
41
+ __reExport(src_exports, require("./errors"), module.exports);
42
+ __reExport(src_exports, require("./types"), module.exports);
43
+ const createDeployment = (0, import_create_deployment.default)();
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ buildFileTree,
47
+ checkDeploymentStatus,
48
+ createDeployment,
49
+ getVercelIgnore,
50
+ ...require("./errors"),
51
+ ...require("./types")
52
+ });
package/dist/pkg.js CHANGED
@@ -1,6 +1,29 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pkgVersion = void 0;
4
- //eslint-disable-next-line @typescript-eslint/no-var-requires
5
- const pkg = require('../package.json');
6
- exports.pkgVersion = pkg.version;
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 pkg_exports = {};
20
+ __export(pkg_exports, {
21
+ pkgVersion: () => pkgVersion
22
+ });
23
+ module.exports = __toCommonJS(pkg_exports);
24
+ const pkg = require("../package.json");
25
+ const pkgVersion = pkg.version;
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ pkgVersion
29
+ });
package/dist/types.js CHANGED
@@ -1,5 +1,34 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fileNameSymbol = exports.VALID_ARCHIVE_FORMATS = void 0;
4
- exports.VALID_ARCHIVE_FORMATS = ['tgz'];
5
- exports.fileNameSymbol = Symbol('fileName');
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 types_exports = {};
20
+ __export(types_exports, {
21
+ DeploymentEventType: () => import_utils.DeploymentEventType,
22
+ VALID_ARCHIVE_FORMATS: () => VALID_ARCHIVE_FORMATS,
23
+ fileNameSymbol: () => fileNameSymbol
24
+ });
25
+ module.exports = __toCommonJS(types_exports);
26
+ var import_utils = require("./utils");
27
+ const VALID_ARCHIVE_FORMATS = ["tgz"];
28
+ const fileNameSymbol = Symbol("fileName");
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ DeploymentEventType,
32
+ VALID_ARCHIVE_FORMATS,
33
+ fileNameSymbol
34
+ });