eoas 2.2.5 → 2.2.7
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.d.ts +1 -0
- package/dist/commands/publish.js +17 -12
- package/dist/lib/assets.d.ts +1 -1
- package/dist/lib/assets.js +6 -5
- package/dist/lib/fetch.d.ts +2 -0
- package/dist/lib/fetch.js +27 -0
- package/package.json +6 -5
|
@@ -8,6 +8,7 @@ export default class Publish extends Command {
|
|
|
8
8
|
channel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
9
|
branch: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
10
|
nonInteractive: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
outputDir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
12
|
};
|
|
12
13
|
private sanitizeFlags;
|
|
13
14
|
run(): Promise<void>;
|
package/dist/commands/publish.js
CHANGED
|
@@ -7,11 +7,11 @@ const core_1 = require("@oclif/core");
|
|
|
7
7
|
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
8
8
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
9
9
|
const mime_1 = tslib_1.__importDefault(require("mime"));
|
|
10
|
-
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
11
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
11
|
const assets_1 = require("../lib/assets");
|
|
13
12
|
const auth_1 = require("../lib/auth");
|
|
14
13
|
const expoConfig_1 = require("../lib/expoConfig");
|
|
14
|
+
const fetch_1 = require("../lib/fetch");
|
|
15
15
|
const log_1 = tslib_1.__importDefault(require("../lib/log"));
|
|
16
16
|
const ora_1 = require("../lib/ora");
|
|
17
17
|
const package_1 = require("../lib/package");
|
|
@@ -43,6 +43,10 @@ class Publish extends core_1.Command {
|
|
|
43
43
|
description: 'Run command in non-interactive mode',
|
|
44
44
|
default: false,
|
|
45
45
|
}),
|
|
46
|
+
outputDir: core_1.Flags.string({
|
|
47
|
+
description: "Where to write build output. You can override the default dist output directory if it's being used by something else",
|
|
48
|
+
default: 'dist',
|
|
49
|
+
}),
|
|
46
50
|
};
|
|
47
51
|
sanitizeFlags(flags) {
|
|
48
52
|
return {
|
|
@@ -50,6 +54,7 @@ class Publish extends core_1.Command {
|
|
|
50
54
|
branch: flags.branch,
|
|
51
55
|
nonInteractive: flags.nonInteractive,
|
|
52
56
|
channel: flags.channel,
|
|
57
|
+
outputDir: flags.outputDir,
|
|
53
58
|
};
|
|
54
59
|
}
|
|
55
60
|
async run() {
|
|
@@ -59,7 +64,7 @@ class Publish extends core_1.Command {
|
|
|
59
64
|
process.exit(1);
|
|
60
65
|
}
|
|
61
66
|
const { flags } = await this.parse(Publish);
|
|
62
|
-
const { platform, nonInteractive, branch, channel } = this.sanitizeFlags(flags);
|
|
67
|
+
const { platform, nonInteractive, branch, channel, outputDir } = this.sanitizeFlags(flags);
|
|
63
68
|
if (!branch) {
|
|
64
69
|
log_1.default.error('Branch name is required');
|
|
65
70
|
process.exit(1);
|
|
@@ -151,8 +156,8 @@ class Publish extends core_1.Command {
|
|
|
151
156
|
runtimeSpinner.succeed('✅ Runtime versions resolved');
|
|
152
157
|
const exportSpinner = (0, ora_1.ora)('📦 Exporting project files...').start();
|
|
153
158
|
try {
|
|
154
|
-
await (0, spawn_async_1.default)('rm', ['-rf',
|
|
155
|
-
const { stdout } = await (0, spawn_async_1.default)('npx', ['expo', 'export', '--output-dir',
|
|
159
|
+
await (0, spawn_async_1.default)('rm', ['-rf', outputDir], { cwd: projectDir });
|
|
160
|
+
const { stdout } = await (0, spawn_async_1.default)('npx', ['expo', 'export', '--output-dir', outputDir], {
|
|
156
161
|
cwd: projectDir,
|
|
157
162
|
env: {
|
|
158
163
|
...process.env,
|
|
@@ -174,12 +179,12 @@ class Publish extends core_1.Command {
|
|
|
174
179
|
process.exit(1);
|
|
175
180
|
}
|
|
176
181
|
// eslint-disable-next-line
|
|
177
|
-
fs_extra_1.default.writeJsonSync(path_1.default.join(projectDir,
|
|
182
|
+
fs_extra_1.default.writeJsonSync(path_1.default.join(projectDir, outputDir, 'expoConfig.json'), publicConfig, {
|
|
178
183
|
spaces: 2,
|
|
179
184
|
});
|
|
180
|
-
log_1.default.withInfo(
|
|
185
|
+
log_1.default.withInfo(`expoConfig.json file created in ${outputDir} directory`);
|
|
181
186
|
const uploadFilesSpinner = (0, ora_1.ora)('📤 Uploading files...').start();
|
|
182
|
-
const files = (0, assets_1.computeFilesRequests)(projectDir, platform || expoConfig_1.RequestedPlatform.All);
|
|
187
|
+
const files = (0, assets_1.computeFilesRequests)(projectDir, outputDir, platform || expoConfig_1.RequestedPlatform.All);
|
|
183
188
|
if (!files.length) {
|
|
184
189
|
uploadFilesSpinner.fail('No files to upload');
|
|
185
190
|
process.exit(1);
|
|
@@ -211,14 +216,14 @@ class Publish extends core_1.Command {
|
|
|
211
216
|
const formData = new form_data_1.default();
|
|
212
217
|
let file;
|
|
213
218
|
try {
|
|
214
|
-
file = fs_extra_1.default.createReadStream(path_1.default.join(projectDir,
|
|
219
|
+
file = fs_extra_1.default.createReadStream(path_1.default.join(projectDir, outputDir, itm.filePath));
|
|
215
220
|
}
|
|
216
221
|
catch {
|
|
217
222
|
throw new Error(`Failed to read file ${itm.filePath}`);
|
|
218
223
|
}
|
|
219
224
|
formData.append(itm.fileName, file);
|
|
220
225
|
if (isLocalBucketFileUpload) {
|
|
221
|
-
const response = await (0,
|
|
226
|
+
const response = await (0, fetch_1.fetchWithRetries)(itm.requestUploadUrl, {
|
|
222
227
|
method: 'PUT',
|
|
223
228
|
headers: {
|
|
224
229
|
...formData.getHeaders(),
|
|
@@ -242,8 +247,8 @@ class Publish extends core_1.Command {
|
|
|
242
247
|
if (!contentType) {
|
|
243
248
|
contentType = 'application/octet-stream';
|
|
244
249
|
}
|
|
245
|
-
const buffer = await fs_extra_1.default.readFile(path_1.default.join(projectDir,
|
|
246
|
-
const response = await (0,
|
|
250
|
+
const buffer = await fs_extra_1.default.readFile(path_1.default.join(projectDir, outputDir, itm.filePath));
|
|
251
|
+
const response = await (0, fetch_1.fetchWithRetries)(itm.requestUploadUrl, {
|
|
247
252
|
method: 'PUT',
|
|
248
253
|
headers: {
|
|
249
254
|
'Content-Type': contentType,
|
|
@@ -266,7 +271,7 @@ class Publish extends core_1.Command {
|
|
|
266
271
|
}
|
|
267
272
|
const markAsFinishedSpinner = (0, ora_1.ora)('🔗 Marking the updates as finished...').start();
|
|
268
273
|
const results = await Promise.all(uploadUrls.map(async ({ updateId, platform, runtimeVersion }) => {
|
|
269
|
-
const response = await (0,
|
|
274
|
+
const response = await (0, fetch_1.fetchWithRetries)(`${baseUrl}/markUpdateAsUploaded/${branch}?platform=${platform}&updateId=${updateId}&runtimeVersion=${runtimeVersion}`, {
|
|
270
275
|
method: 'POST',
|
|
271
276
|
headers: {
|
|
272
277
|
...(0, auth_1.getAuthExpoHeaders)(credentials),
|
package/dist/lib/assets.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ interface AssetToUpload {
|
|
|
7
7
|
name: string;
|
|
8
8
|
ext: string;
|
|
9
9
|
}
|
|
10
|
-
export declare function computeFilesRequests(projectDir: string, requestedPlatform: RequestedPlatform): AssetToUpload[];
|
|
10
|
+
export declare function computeFilesRequests(projectDir: string, outputDir: string, requestedPlatform: RequestedPlatform): AssetToUpload[];
|
|
11
11
|
export interface RequestUploadUrlItem {
|
|
12
12
|
requestUploadUrl: string;
|
|
13
13
|
fileName: string;
|
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()
|
|
@@ -54,8 +54,8 @@ function loadMetadata(distRoot) {
|
|
|
54
54
|
log_1.default.debug(`Loaded ${platforms.length} platform(s): ${platforms.join(', ')}`);
|
|
55
55
|
return metadata;
|
|
56
56
|
}
|
|
57
|
-
function computeFilesRequests(projectDir, requestedPlatform) {
|
|
58
|
-
const metadata = loadMetadata(path_1.default.join(projectDir,
|
|
57
|
+
function computeFilesRequests(projectDir, outputDir, requestedPlatform) {
|
|
58
|
+
const metadata = loadMetadata(path_1.default.join(projectDir, outputDir));
|
|
59
59
|
const assets = [
|
|
60
60
|
{ path: 'metadata.json', name: 'metadata.json', ext: 'json' },
|
|
61
61
|
{ path: 'expoConfig.json', name: 'expoConfig.json', ext: 'json' },
|
|
@@ -74,7 +74,7 @@ function computeFilesRequests(projectDir, 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eoas",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc --project tsconfig.json",
|
|
@@ -35,7 +35,9 @@
|
|
|
35
35
|
"@urql/exchange-retry": "1.2.0",
|
|
36
36
|
"better-opn": "3.0.2",
|
|
37
37
|
"chalk": "4.1.2",
|
|
38
|
+
"eslint": "^8.57.1",
|
|
38
39
|
"fast-glob": "3.3.2",
|
|
40
|
+
"fetch-retry": "^6.0.0",
|
|
39
41
|
"figures": "3.2.0",
|
|
40
42
|
"file-type": "^20.0.0",
|
|
41
43
|
"form-data": "^4.0.1",
|
|
@@ -47,19 +49,18 @@
|
|
|
47
49
|
"ignore": "5.3.0",
|
|
48
50
|
"joi": "17.11.0",
|
|
49
51
|
"jscodeshift": "^17.1.2",
|
|
52
|
+
"log-symbols": "^4.0.0",
|
|
50
53
|
"mime": "3.0.0",
|
|
51
54
|
"node-fetch": "^2.6.7",
|
|
52
55
|
"ora": "^5.1.0",
|
|
56
|
+
"prettier": "3.1.1",
|
|
53
57
|
"prompts": "^2.4.2",
|
|
54
58
|
"recast": "^0.23.9",
|
|
55
59
|
"resolve-from": "5.0.0",
|
|
56
60
|
"semver": "7.5.4",
|
|
57
61
|
"tar": "6.2.1",
|
|
58
62
|
"terminal-link": "2.1.1",
|
|
59
|
-
"uuid": "9.0.1"
|
|
60
|
-
"eslint": "^8.57.1",
|
|
61
|
-
"prettier": "3.1.1",
|
|
62
|
-
"log-symbols": "^4.0.0"
|
|
63
|
+
"uuid": "9.0.1"
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
65
66
|
"@babel/parser": "^7.26.7",
|