eoas 2.2.6 → 2.2.8
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/commands/publish.js +4 -24
- package/dist/lib/assets.js +4 -3
- package/dist/lib/fetch.d.ts +2 -0
- package/dist/lib/fetch.js +27 -0
- package/package.json +2 -2
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -6
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -7
package/dist/commands/publish.js
CHANGED
|
@@ -4,15 +4,14 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
5
5
|
const spawn_async_1 = tslib_1.__importDefault(require("@expo/spawn-async"));
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
7
|
-
const fetch_retry_1 = tslib_1.__importDefault(require("fetch-retry"));
|
|
8
7
|
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
9
8
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
10
9
|
const mime_1 = tslib_1.__importDefault(require("mime"));
|
|
11
|
-
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
12
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
11
|
const assets_1 = require("../lib/assets");
|
|
14
12
|
const auth_1 = require("../lib/auth");
|
|
15
13
|
const expoConfig_1 = require("../lib/expoConfig");
|
|
14
|
+
const fetch_1 = require("../lib/fetch");
|
|
16
15
|
const log_1 = tslib_1.__importDefault(require("../lib/log"));
|
|
17
16
|
const ora_1 = require("../lib/ora");
|
|
18
17
|
const package_1 = require("../lib/package");
|
|
@@ -21,7 +20,6 @@ const repo_1 = require("../lib/repo");
|
|
|
21
20
|
const runtimeVersion_1 = require("../lib/runtimeVersion");
|
|
22
21
|
const vcs_1 = require("../lib/vcs");
|
|
23
22
|
const workflow_1 = require("../lib/workflow");
|
|
24
|
-
const fetch = (0, fetch_retry_1.default)(node_fetch_1.default);
|
|
25
23
|
class Publish extends core_1.Command {
|
|
26
24
|
static args = {};
|
|
27
25
|
static description = 'Publish a new update to the self-hosted update server';
|
|
@@ -225,7 +223,7 @@ class Publish extends core_1.Command {
|
|
|
225
223
|
}
|
|
226
224
|
formData.append(itm.fileName, file);
|
|
227
225
|
if (isLocalBucketFileUpload) {
|
|
228
|
-
const response = await fetchWithRetries(itm.requestUploadUrl, {
|
|
226
|
+
const response = await (0, fetch_1.fetchWithRetries)(itm.requestUploadUrl, {
|
|
229
227
|
method: 'PUT',
|
|
230
228
|
headers: {
|
|
231
229
|
...formData.getHeaders(),
|
|
@@ -250,7 +248,7 @@ class Publish extends core_1.Command {
|
|
|
250
248
|
contentType = 'application/octet-stream';
|
|
251
249
|
}
|
|
252
250
|
const buffer = await fs_extra_1.default.readFile(path_1.default.join(projectDir, outputDir, itm.filePath));
|
|
253
|
-
const response = await fetchWithRetries(itm.requestUploadUrl, {
|
|
251
|
+
const response = await (0, fetch_1.fetchWithRetries)(itm.requestUploadUrl, {
|
|
254
252
|
method: 'PUT',
|
|
255
253
|
headers: {
|
|
256
254
|
'Content-Type': contentType,
|
|
@@ -267,14 +265,13 @@ class Publish extends core_1.Command {
|
|
|
267
265
|
uploadFilesSpinner.succeed('✅ Files uploaded successfully');
|
|
268
266
|
}
|
|
269
267
|
catch (e) {
|
|
270
|
-
console.log('e', e);
|
|
271
268
|
uploadFilesSpinner.fail('❌ Failed to upload static files');
|
|
272
269
|
log_1.default.error(e);
|
|
273
270
|
process.exit(1);
|
|
274
271
|
}
|
|
275
272
|
const markAsFinishedSpinner = (0, ora_1.ora)('🔗 Marking the updates as finished...').start();
|
|
276
273
|
const results = await Promise.all(uploadUrls.map(async ({ updateId, platform, runtimeVersion }) => {
|
|
277
|
-
const response = await fetchWithRetries(`${baseUrl}/markUpdateAsUploaded/${branch}?platform=${platform}&updateId=${updateId}&runtimeVersion=${runtimeVersion}`, {
|
|
274
|
+
const response = await (0, fetch_1.fetchWithRetries)(`${baseUrl}/markUpdateAsUploaded/${branch}?platform=${platform}&updateId=${updateId}&runtimeVersion=${runtimeVersion}`, {
|
|
278
275
|
method: 'POST',
|
|
279
276
|
headers: {
|
|
280
277
|
...(0, auth_1.getAuthExpoHeaders)(credentials),
|
|
@@ -319,20 +316,3 @@ class Publish extends core_1.Command {
|
|
|
319
316
|
}
|
|
320
317
|
}
|
|
321
318
|
exports.default = Publish;
|
|
322
|
-
async function fetchWithRetries(url, options) {
|
|
323
|
-
return await fetch(url, {
|
|
324
|
-
...options,
|
|
325
|
-
retryDelay(attempt) {
|
|
326
|
-
return Math.pow(2, attempt) * 500;
|
|
327
|
-
},
|
|
328
|
-
retries: 3,
|
|
329
|
-
retryOn: (attempt, error) => {
|
|
330
|
-
console.log(error);
|
|
331
|
-
if (error) {
|
|
332
|
-
log_1.default.warn(`Retry ${attempt} after network error:`, error.message);
|
|
333
|
-
return true;
|
|
334
|
-
}
|
|
335
|
-
return false;
|
|
336
|
-
},
|
|
337
|
-
});
|
|
338
|
-
}
|
package/dist/lib/assets.js
CHANGED
|
@@ -4,10 +4,10 @@ exports.requestUploadUrls = exports.computeFilesRequests = exports.MetadataJoi =
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
6
6
|
const joi_1 = tslib_1.__importDefault(require("joi"));
|
|
7
|
-
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
8
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
8
|
const auth_1 = require("./auth");
|
|
10
9
|
const expoConfig_1 = require("./expoConfig");
|
|
10
|
+
const fetch_1 = require("./fetch");
|
|
11
11
|
const log_1 = tslib_1.__importDefault(require("./log"));
|
|
12
12
|
const fileMetadataJoi = joi_1.default.object({
|
|
13
13
|
assets: joi_1.default.array()
|
|
@@ -74,7 +74,7 @@ function computeFilesRequests(projectDir, outputDir, requestedPlatform) {
|
|
|
74
74
|
}
|
|
75
75
|
exports.computeFilesRequests = computeFilesRequests;
|
|
76
76
|
async function requestUploadUrls({ body, requestUploadUrl, auth, runtimeVersion, platform, commitHash, }) {
|
|
77
|
-
const response = await (0,
|
|
77
|
+
const response = await (0, fetch_1.fetchWithRetries)(`${requestUploadUrl}?runtimeVersion=${runtimeVersion}&platform=${platform}&commitHash=${commitHash || ''}`, {
|
|
78
78
|
method: 'POST',
|
|
79
79
|
headers: {
|
|
80
80
|
...(0, auth_1.getAuthExpoHeaders)(auth),
|
|
@@ -83,7 +83,8 @@ async function requestUploadUrls({ body, requestUploadUrl, auth, runtimeVersion,
|
|
|
83
83
|
body: JSON.stringify(body),
|
|
84
84
|
});
|
|
85
85
|
if (!response.ok) {
|
|
86
|
-
|
|
86
|
+
const text = await response.text();
|
|
87
|
+
throw new Error(`Failed to request upload URL: ${text}`);
|
|
87
88
|
}
|
|
88
89
|
return await response.json();
|
|
89
90
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchWithRetries = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fetch_retry_1 = tslib_1.__importDefault(require("fetch-retry"));
|
|
6
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
7
|
+
const log_1 = tslib_1.__importDefault(require("./log"));
|
|
8
|
+
const fetch = (0, fetch_retry_1.default)(node_fetch_1.default);
|
|
9
|
+
async function fetchWithRetries(url, options) {
|
|
10
|
+
return await fetch(url, {
|
|
11
|
+
...options,
|
|
12
|
+
retryDelay(attempt) {
|
|
13
|
+
return Math.pow(2, attempt) * 500;
|
|
14
|
+
},
|
|
15
|
+
retryOn: (attempt, error) => {
|
|
16
|
+
if (attempt > 3) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (error) {
|
|
20
|
+
log_1.default.warn(`Retry ${attempt} after network error:`, error.message);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.fetchWithRetries = fetchWithRetries;
|
package/package.json
CHANGED
package/bin/dev.cmd
DELETED
package/bin/dev.js
DELETED
package/bin/run.cmd
DELETED