@vercel/client 13.0.1 → 13.0.2
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 +130 -107
- package/dist/create-deployment.js +130 -109
- package/dist/deploy.js +144 -116
- package/dist/errors.js +31 -8
- package/dist/index.js +49 -26
- package/dist/pkg.js +28 -5
- package/dist/types.js +33 -4
- package/dist/upload.js +205 -183
- package/dist/utils/fetch.js +40 -9
- package/dist/utils/get-polling-delay.js +46 -16
- package/dist/utils/hashes.js +80 -66
- package/dist/utils/index.js +249 -221
- package/dist/utils/query-string.js +41 -18
- package/dist/utils/readdir-recursive.js +85 -91
- package/dist/utils/ready-state.js +50 -18
- package/package.json +3 -3
|
@@ -1,114 +1,137 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 });
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var check_deployment_status_exports = {};
|
|
30
|
+
__export(check_deployment_status_exports, {
|
|
31
|
+
checkDeploymentStatus: () => checkDeploymentStatus
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(check_deployment_status_exports);
|
|
34
|
+
var import_sleep_promise = __toESM(require("sleep-promise"));
|
|
35
|
+
var import_utils = require("./utils");
|
|
36
|
+
var import_get_polling_delay = require("./utils/get-polling-delay");
|
|
37
|
+
var import_ready_state = require("./utils/ready-state");
|
|
38
|
+
var import_utils2 = require("./utils");
|
|
13
39
|
async function* checkDeploymentStatus(deployment, clientOptions) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
40
|
+
const { token, teamId, apiUrl, userAgent } = clientOptions;
|
|
41
|
+
const debug = (0, import_utils2.createDebug)(clientOptions.debug);
|
|
42
|
+
let deploymentState = deployment;
|
|
43
|
+
const apiDeployments = (0, import_utils.getApiDeploymentsUrl)({
|
|
44
|
+
builds: deployment.builds,
|
|
45
|
+
functions: deployment.functions
|
|
46
|
+
});
|
|
47
|
+
if ((0, import_ready_state.isDone)(deploymentState) && (0, import_ready_state.isAliasAssigned)(deploymentState)) {
|
|
48
|
+
debug(
|
|
49
|
+
`Deployment is already READY and aliases are assigned. Not running status checks`
|
|
50
|
+
);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
debug("Waiting for builds and the deployment to complete...");
|
|
54
|
+
const finishedEvents = /* @__PURE__ */ new Set();
|
|
55
|
+
const startTime = Date.now();
|
|
56
|
+
while (true) {
|
|
57
|
+
const deploymentData = await (0, import_utils.fetch)(
|
|
58
|
+
`${apiDeployments}/${deployment.id || deployment.deploymentId}${teamId ? `?teamId=${teamId}` : ""}`,
|
|
59
|
+
token,
|
|
60
|
+
{ apiUrl, userAgent, agent: clientOptions.agent }
|
|
61
|
+
);
|
|
62
|
+
const deploymentUpdate = await deploymentData.json();
|
|
63
|
+
if (deploymentUpdate.error) {
|
|
64
|
+
debug("Deployment status check has errorred");
|
|
65
|
+
return yield { type: "error", payload: deploymentUpdate.error };
|
|
25
66
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (deploymentUpdate.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
type: 'checks-conclusion-succeeded',
|
|
62
|
-
payload: deploymentUpdate,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
else if (deploymentUpdate.checksConclusion === 'failed') {
|
|
66
|
-
yield { type: 'checks-conclusion-failed', payload: deploymentUpdate };
|
|
67
|
-
}
|
|
68
|
-
else if (deploymentUpdate.checksConclusion === 'skipped') {
|
|
69
|
-
yield {
|
|
70
|
-
type: 'checks-conclusion-skipped',
|
|
71
|
-
payload: deploymentUpdate,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
else if (deploymentUpdate.checksConclusion === 'canceled') {
|
|
75
|
-
yield {
|
|
76
|
-
type: 'checks-conclusion-canceled',
|
|
77
|
-
payload: deploymentUpdate,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (deploymentUpdate.checksState === 'registered' &&
|
|
82
|
-
!finishedEvents.has('checks-registered')) {
|
|
83
|
-
finishedEvents.add('checks-registered');
|
|
84
|
-
yield { type: 'checks-registered', payload: deploymentUpdate };
|
|
85
|
-
}
|
|
86
|
-
if (deploymentUpdate.checksState === 'running' &&
|
|
87
|
-
!finishedEvents.has('checks-running')) {
|
|
88
|
-
finishedEvents.add('checks-running');
|
|
89
|
-
yield { type: 'checks-running', payload: deploymentUpdate };
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if ((0, ready_state_1.isAliasAssigned)(deploymentUpdate)) {
|
|
93
|
-
debug('Deployment alias assigned');
|
|
94
|
-
return yield { type: 'alias-assigned', payload: deploymentUpdate };
|
|
95
|
-
}
|
|
96
|
-
if ((0, ready_state_1.isAliasError)(deploymentUpdate)) {
|
|
97
|
-
return yield { type: 'error', payload: deploymentUpdate.aliasError };
|
|
98
|
-
}
|
|
99
|
-
if (deploymentUpdate.readyState === 'ERROR' &&
|
|
100
|
-
deploymentUpdate.errorCode === 'BUILD_FAILED') {
|
|
101
|
-
return yield { type: 'error', payload: deploymentUpdate };
|
|
102
|
-
}
|
|
103
|
-
if ((0, ready_state_1.isFailed)(deploymentUpdate)) {
|
|
104
|
-
return yield {
|
|
105
|
-
type: 'error',
|
|
106
|
-
payload: deploymentUpdate.error || deploymentUpdate,
|
|
107
|
-
};
|
|
67
|
+
if (deploymentUpdate.readyState === "BUILDING" && !finishedEvents.has("building")) {
|
|
68
|
+
debug("Deployment state changed to BUILDING");
|
|
69
|
+
finishedEvents.add("building");
|
|
70
|
+
yield { type: "building", payload: deploymentUpdate };
|
|
71
|
+
}
|
|
72
|
+
if (deploymentUpdate.readyState === "CANCELED" && !finishedEvents.has("canceled")) {
|
|
73
|
+
debug("Deployment state changed to CANCELED");
|
|
74
|
+
finishedEvents.add("canceled");
|
|
75
|
+
yield { type: "canceled", payload: deploymentUpdate };
|
|
76
|
+
}
|
|
77
|
+
if ((0, import_ready_state.isReady)(deploymentUpdate) && !finishedEvents.has("ready")) {
|
|
78
|
+
debug("Deployment state changed to READY");
|
|
79
|
+
finishedEvents.add("ready");
|
|
80
|
+
yield { type: "ready", payload: deploymentUpdate };
|
|
81
|
+
}
|
|
82
|
+
if (deploymentUpdate.checksState !== void 0) {
|
|
83
|
+
if (deploymentUpdate.checksState === "completed" && !finishedEvents.has("checks-completed")) {
|
|
84
|
+
finishedEvents.add("checks-completed");
|
|
85
|
+
if (deploymentUpdate.checksConclusion === "succeeded") {
|
|
86
|
+
yield {
|
|
87
|
+
type: "checks-conclusion-succeeded",
|
|
88
|
+
payload: deploymentUpdate
|
|
89
|
+
};
|
|
90
|
+
} else if (deploymentUpdate.checksConclusion === "failed") {
|
|
91
|
+
yield { type: "checks-conclusion-failed", payload: deploymentUpdate };
|
|
92
|
+
} else if (deploymentUpdate.checksConclusion === "skipped") {
|
|
93
|
+
yield {
|
|
94
|
+
type: "checks-conclusion-skipped",
|
|
95
|
+
payload: deploymentUpdate
|
|
96
|
+
};
|
|
97
|
+
} else if (deploymentUpdate.checksConclusion === "canceled") {
|
|
98
|
+
yield {
|
|
99
|
+
type: "checks-conclusion-canceled",
|
|
100
|
+
payload: deploymentUpdate
|
|
101
|
+
};
|
|
108
102
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
}
|
|
104
|
+
if (deploymentUpdate.checksState === "registered" && !finishedEvents.has("checks-registered")) {
|
|
105
|
+
finishedEvents.add("checks-registered");
|
|
106
|
+
yield { type: "checks-registered", payload: deploymentUpdate };
|
|
107
|
+
}
|
|
108
|
+
if (deploymentUpdate.checksState === "running" && !finishedEvents.has("checks-running")) {
|
|
109
|
+
finishedEvents.add("checks-running");
|
|
110
|
+
yield { type: "checks-running", payload: deploymentUpdate };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if ((0, import_ready_state.isAliasAssigned)(deploymentUpdate)) {
|
|
114
|
+
debug("Deployment alias assigned");
|
|
115
|
+
return yield { type: "alias-assigned", payload: deploymentUpdate };
|
|
116
|
+
}
|
|
117
|
+
if ((0, import_ready_state.isAliasError)(deploymentUpdate)) {
|
|
118
|
+
return yield { type: "error", payload: deploymentUpdate.aliasError };
|
|
119
|
+
}
|
|
120
|
+
if (deploymentUpdate.readyState === "ERROR" && deploymentUpdate.errorCode === "BUILD_FAILED") {
|
|
121
|
+
return yield { type: "error", payload: deploymentUpdate };
|
|
122
|
+
}
|
|
123
|
+
if ((0, import_ready_state.isFailed)(deploymentUpdate)) {
|
|
124
|
+
return yield {
|
|
125
|
+
type: "error",
|
|
126
|
+
payload: deploymentUpdate.error || deploymentUpdate
|
|
127
|
+
};
|
|
112
128
|
}
|
|
129
|
+
const elapsed = Date.now() - startTime;
|
|
130
|
+
const duration = (0, import_get_polling_delay.getPollingDelay)(elapsed);
|
|
131
|
+
await (0, import_sleep_promise.default)(duration);
|
|
132
|
+
}
|
|
113
133
|
}
|
|
114
|
-
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
checkDeploymentStatus
|
|
137
|
+
});
|
|
@@ -1,114 +1,135 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 });
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var create_deployment_exports = {};
|
|
30
|
+
__export(create_deployment_exports, {
|
|
31
|
+
default: () => buildCreateDeployment
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(create_deployment_exports);
|
|
34
|
+
var import_fs_extra = require("fs-extra");
|
|
35
|
+
var import_path = require("path");
|
|
36
|
+
var import_hashes = require("./utils/hashes");
|
|
37
|
+
var import_upload = require("./upload");
|
|
38
|
+
var import_utils = require("./utils");
|
|
39
|
+
var import_errors = require("./errors");
|
|
40
|
+
var import_build_utils = require("@vercel/build-utils");
|
|
41
|
+
var import_tar_fs = __toESM(require("tar-fs"));
|
|
42
|
+
var import_zlib = require("zlib");
|
|
15
43
|
function buildCreateDeployment() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
else if (!(0, path_1.isAbsolute)(path)) {
|
|
47
|
-
throw new errors_1.DeploymentError({
|
|
48
|
-
code: 'invalid_path',
|
|
49
|
-
message: `Provided path ${path} is not absolute`,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (clientOptions.isDirectory && !Array.isArray(path)) {
|
|
53
|
-
debug(`Provided 'path' is a directory.`);
|
|
54
|
-
}
|
|
55
|
-
else if (Array.isArray(path)) {
|
|
56
|
-
debug(`Provided 'path' is an array of file paths`);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
debug(`Provided 'path' is a single file`);
|
|
60
|
-
}
|
|
61
|
-
const { fileList } = await (0, utils_1.buildFileTree)(path, clientOptions, debug);
|
|
62
|
-
// This is a useful warning because it prevents people
|
|
63
|
-
// from getting confused about a deployment that renders 404.
|
|
64
|
-
if (fileList.length === 0) {
|
|
65
|
-
debug('Deployment path has no files. Yielding a warning event');
|
|
66
|
-
yield {
|
|
67
|
-
type: 'warning',
|
|
68
|
-
payload: 'There are no files inside your deployment.',
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
// Populate Files -> FileFsRef mapping
|
|
72
|
-
const workPath = typeof path === 'string' ? path : path[0];
|
|
73
|
-
let files;
|
|
74
|
-
if (clientOptions.archive === 'tgz') {
|
|
75
|
-
debug('Packing tarball');
|
|
76
|
-
const tarStream = tar_fs_1.default
|
|
77
|
-
.pack(workPath, {
|
|
78
|
-
entries: fileList.map(file => (0, path_1.relative)(workPath, file)),
|
|
79
|
-
})
|
|
80
|
-
.pipe((0, zlib_1.createGzip)());
|
|
81
|
-
const tarBuffer = await (0, build_utils_1.streamToBuffer)(tarStream);
|
|
82
|
-
debug('Packed tarball');
|
|
83
|
-
files = new Map([
|
|
84
|
-
[
|
|
85
|
-
(0, hashes_1.hash)(tarBuffer),
|
|
86
|
-
{
|
|
87
|
-
names: [(0, path_1.join)(workPath, '.vercel/source.tgz')],
|
|
88
|
-
data: tarBuffer,
|
|
89
|
-
mode: 0o666,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
]);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
files = await (0, hashes_1.hashes)(fileList);
|
|
96
|
-
}
|
|
97
|
-
debug(`Yielding a 'hashes-calculated' event with ${files.size} hashes`);
|
|
98
|
-
yield { type: 'hashes-calculated', payload: (0, hashes_1.mapToObject)(files) };
|
|
99
|
-
if (clientOptions.apiUrl) {
|
|
100
|
-
debug(`Using provided API URL: ${clientOptions.apiUrl}`);
|
|
101
|
-
}
|
|
102
|
-
if (clientOptions.userAgent) {
|
|
103
|
-
debug(`Using provided user agent: ${clientOptions.userAgent}`);
|
|
104
|
-
}
|
|
105
|
-
debug(`Setting platform version to harcoded value 2`);
|
|
106
|
-
deploymentOptions.version = 2;
|
|
107
|
-
debug(`Creating the deployment and starting upload...`);
|
|
108
|
-
for await (const event of (0, upload_1.upload)(files, clientOptions, deploymentOptions)) {
|
|
109
|
-
debug(`Yielding a '${event.type}' event`);
|
|
110
|
-
yield event;
|
|
44
|
+
return async function* createDeployment(clientOptions, deploymentOptions = {}) {
|
|
45
|
+
const { path } = clientOptions;
|
|
46
|
+
const debug = (0, import_utils.createDebug)(clientOptions.debug);
|
|
47
|
+
debug("Creating deployment...");
|
|
48
|
+
if (typeof path !== "string" && !Array.isArray(path)) {
|
|
49
|
+
debug(
|
|
50
|
+
`Error: 'path' is expected to be a string or an array. Received ${typeof path}`
|
|
51
|
+
);
|
|
52
|
+
throw new import_errors.DeploymentError({
|
|
53
|
+
code: "missing_path",
|
|
54
|
+
message: "Path not provided"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (typeof clientOptions.token !== "string") {
|
|
58
|
+
debug(
|
|
59
|
+
`Error: 'token' is expected to be a string. Received ${typeof clientOptions.token}`
|
|
60
|
+
);
|
|
61
|
+
throw new import_errors.DeploymentError({
|
|
62
|
+
code: "token_not_provided",
|
|
63
|
+
message: "Options object must include a `token`"
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
clientOptions.isDirectory = !Array.isArray(path) && (0, import_fs_extra.lstatSync)(path).isDirectory();
|
|
67
|
+
if (Array.isArray(path)) {
|
|
68
|
+
for (const filePath of path) {
|
|
69
|
+
if (!(0, import_path.isAbsolute)(filePath)) {
|
|
70
|
+
throw new import_errors.DeploymentError({
|
|
71
|
+
code: "invalid_path",
|
|
72
|
+
message: `Provided path ${filePath} is not absolute`
|
|
73
|
+
});
|
|
111
74
|
}
|
|
112
|
-
|
|
75
|
+
}
|
|
76
|
+
} else if (!(0, import_path.isAbsolute)(path)) {
|
|
77
|
+
throw new import_errors.DeploymentError({
|
|
78
|
+
code: "invalid_path",
|
|
79
|
+
message: `Provided path ${path} is not absolute`
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (clientOptions.isDirectory && !Array.isArray(path)) {
|
|
83
|
+
debug(`Provided 'path' is a directory.`);
|
|
84
|
+
} else if (Array.isArray(path)) {
|
|
85
|
+
debug(`Provided 'path' is an array of file paths`);
|
|
86
|
+
} else {
|
|
87
|
+
debug(`Provided 'path' is a single file`);
|
|
88
|
+
}
|
|
89
|
+
const { fileList } = await (0, import_utils.buildFileTree)(path, clientOptions, debug);
|
|
90
|
+
if (fileList.length === 0) {
|
|
91
|
+
debug("Deployment path has no files. Yielding a warning event");
|
|
92
|
+
yield {
|
|
93
|
+
type: "warning",
|
|
94
|
+
payload: "There are no files inside your deployment."
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const workPath = typeof path === "string" ? path : path[0];
|
|
98
|
+
let files;
|
|
99
|
+
if (clientOptions.archive === "tgz") {
|
|
100
|
+
debug("Packing tarball");
|
|
101
|
+
const tarStream = import_tar_fs.default.pack(workPath, {
|
|
102
|
+
entries: fileList.map((file) => (0, import_path.relative)(workPath, file))
|
|
103
|
+
}).pipe((0, import_zlib.createGzip)());
|
|
104
|
+
const tarBuffer = await (0, import_build_utils.streamToBuffer)(tarStream);
|
|
105
|
+
debug("Packed tarball");
|
|
106
|
+
files = /* @__PURE__ */ new Map([
|
|
107
|
+
[
|
|
108
|
+
(0, import_hashes.hash)(tarBuffer),
|
|
109
|
+
{
|
|
110
|
+
names: [(0, import_path.join)(workPath, ".vercel/source.tgz")],
|
|
111
|
+
data: tarBuffer,
|
|
112
|
+
mode: 438
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
]);
|
|
116
|
+
} else {
|
|
117
|
+
files = await (0, import_hashes.hashes)(fileList);
|
|
118
|
+
}
|
|
119
|
+
debug(`Yielding a 'hashes-calculated' event with ${files.size} hashes`);
|
|
120
|
+
yield { type: "hashes-calculated", payload: (0, import_hashes.mapToObject)(files) };
|
|
121
|
+
if (clientOptions.apiUrl) {
|
|
122
|
+
debug(`Using provided API URL: ${clientOptions.apiUrl}`);
|
|
123
|
+
}
|
|
124
|
+
if (clientOptions.userAgent) {
|
|
125
|
+
debug(`Using provided user agent: ${clientOptions.userAgent}`);
|
|
126
|
+
}
|
|
127
|
+
debug(`Setting platform version to harcoded value 2`);
|
|
128
|
+
deploymentOptions.version = 2;
|
|
129
|
+
debug(`Creating the deployment and starting upload...`);
|
|
130
|
+
for await (const event of (0, import_upload.upload)(files, clientOptions, deploymentOptions)) {
|
|
131
|
+
debug(`Yielding a '${event.type}' event`);
|
|
132
|
+
yield event;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
113
135
|
}
|
|
114
|
-
exports.default = buildCreateDeployment;
|