eoas 2.2.4 → 2.2.6
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 +36 -11
- package/dist/lib/assets.d.ts +1 -1
- package/dist/lib/assets.js +2 -2
- package/package.json +7 -6
|
@@ -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
|
@@ -4,6 +4,7 @@ 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"));
|
|
7
8
|
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
8
9
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
9
10
|
const mime_1 = tslib_1.__importDefault(require("mime"));
|
|
@@ -20,6 +21,7 @@ const repo_1 = require("../lib/repo");
|
|
|
20
21
|
const runtimeVersion_1 = require("../lib/runtimeVersion");
|
|
21
22
|
const vcs_1 = require("../lib/vcs");
|
|
22
23
|
const workflow_1 = require("../lib/workflow");
|
|
24
|
+
const fetch = (0, fetch_retry_1.default)(node_fetch_1.default);
|
|
23
25
|
class Publish extends core_1.Command {
|
|
24
26
|
static args = {};
|
|
25
27
|
static description = 'Publish a new update to the self-hosted update server';
|
|
@@ -43,6 +45,10 @@ class Publish extends core_1.Command {
|
|
|
43
45
|
description: 'Run command in non-interactive mode',
|
|
44
46
|
default: false,
|
|
45
47
|
}),
|
|
48
|
+
outputDir: core_1.Flags.string({
|
|
49
|
+
description: "Where to write build output. You can override the default dist output directory if it's being used by something else",
|
|
50
|
+
default: 'dist',
|
|
51
|
+
}),
|
|
46
52
|
};
|
|
47
53
|
sanitizeFlags(flags) {
|
|
48
54
|
return {
|
|
@@ -50,6 +56,7 @@ class Publish extends core_1.Command {
|
|
|
50
56
|
branch: flags.branch,
|
|
51
57
|
nonInteractive: flags.nonInteractive,
|
|
52
58
|
channel: flags.channel,
|
|
59
|
+
outputDir: flags.outputDir,
|
|
53
60
|
};
|
|
54
61
|
}
|
|
55
62
|
async run() {
|
|
@@ -59,7 +66,7 @@ class Publish extends core_1.Command {
|
|
|
59
66
|
process.exit(1);
|
|
60
67
|
}
|
|
61
68
|
const { flags } = await this.parse(Publish);
|
|
62
|
-
const { platform, nonInteractive, branch, channel } = this.sanitizeFlags(flags);
|
|
69
|
+
const { platform, nonInteractive, branch, channel, outputDir } = this.sanitizeFlags(flags);
|
|
63
70
|
if (!branch) {
|
|
64
71
|
log_1.default.error('Branch name is required');
|
|
65
72
|
process.exit(1);
|
|
@@ -151,8 +158,8 @@ class Publish extends core_1.Command {
|
|
|
151
158
|
runtimeSpinner.succeed('✅ Runtime versions resolved');
|
|
152
159
|
const exportSpinner = (0, ora_1.ora)('📦 Exporting project files...').start();
|
|
153
160
|
try {
|
|
154
|
-
await (0, spawn_async_1.default)('rm', ['-rf',
|
|
155
|
-
const { stdout } = await (0, spawn_async_1.default)('npx', ['expo', 'export', '--output-dir',
|
|
161
|
+
await (0, spawn_async_1.default)('rm', ['-rf', outputDir], { cwd: projectDir });
|
|
162
|
+
const { stdout } = await (0, spawn_async_1.default)('npx', ['expo', 'export', '--output-dir', outputDir], {
|
|
156
163
|
cwd: projectDir,
|
|
157
164
|
env: {
|
|
158
165
|
...process.env,
|
|
@@ -174,12 +181,12 @@ class Publish extends core_1.Command {
|
|
|
174
181
|
process.exit(1);
|
|
175
182
|
}
|
|
176
183
|
// eslint-disable-next-line
|
|
177
|
-
fs_extra_1.default.writeJsonSync(path_1.default.join(projectDir,
|
|
184
|
+
fs_extra_1.default.writeJsonSync(path_1.default.join(projectDir, outputDir, 'expoConfig.json'), publicConfig, {
|
|
178
185
|
spaces: 2,
|
|
179
186
|
});
|
|
180
|
-
log_1.default.withInfo(
|
|
187
|
+
log_1.default.withInfo(`expoConfig.json file created in ${outputDir} directory`);
|
|
181
188
|
const uploadFilesSpinner = (0, ora_1.ora)('📤 Uploading files...').start();
|
|
182
|
-
const files = (0, assets_1.computeFilesRequests)(projectDir, platform || expoConfig_1.RequestedPlatform.All);
|
|
189
|
+
const files = (0, assets_1.computeFilesRequests)(projectDir, outputDir, platform || expoConfig_1.RequestedPlatform.All);
|
|
183
190
|
if (!files.length) {
|
|
184
191
|
uploadFilesSpinner.fail('No files to upload');
|
|
185
192
|
process.exit(1);
|
|
@@ -211,14 +218,14 @@ class Publish extends core_1.Command {
|
|
|
211
218
|
const formData = new form_data_1.default();
|
|
212
219
|
let file;
|
|
213
220
|
try {
|
|
214
|
-
file = fs_extra_1.default.createReadStream(path_1.default.join(projectDir,
|
|
221
|
+
file = fs_extra_1.default.createReadStream(path_1.default.join(projectDir, outputDir, itm.filePath));
|
|
215
222
|
}
|
|
216
223
|
catch {
|
|
217
224
|
throw new Error(`Failed to read file ${itm.filePath}`);
|
|
218
225
|
}
|
|
219
226
|
formData.append(itm.fileName, file);
|
|
220
227
|
if (isLocalBucketFileUpload) {
|
|
221
|
-
const response = await (
|
|
228
|
+
const response = await fetchWithRetries(itm.requestUploadUrl, {
|
|
222
229
|
method: 'PUT',
|
|
223
230
|
headers: {
|
|
224
231
|
...formData.getHeaders(),
|
|
@@ -242,8 +249,8 @@ class Publish extends core_1.Command {
|
|
|
242
249
|
if (!contentType) {
|
|
243
250
|
contentType = 'application/octet-stream';
|
|
244
251
|
}
|
|
245
|
-
const buffer = await fs_extra_1.default.readFile(path_1.default.join(projectDir,
|
|
246
|
-
const response = await (
|
|
252
|
+
const buffer = await fs_extra_1.default.readFile(path_1.default.join(projectDir, outputDir, itm.filePath));
|
|
253
|
+
const response = await fetchWithRetries(itm.requestUploadUrl, {
|
|
247
254
|
method: 'PUT',
|
|
248
255
|
headers: {
|
|
249
256
|
'Content-Type': contentType,
|
|
@@ -260,13 +267,14 @@ class Publish extends core_1.Command {
|
|
|
260
267
|
uploadFilesSpinner.succeed('✅ Files uploaded successfully');
|
|
261
268
|
}
|
|
262
269
|
catch (e) {
|
|
270
|
+
console.log('e', e);
|
|
263
271
|
uploadFilesSpinner.fail('❌ Failed to upload static files');
|
|
264
272
|
log_1.default.error(e);
|
|
265
273
|
process.exit(1);
|
|
266
274
|
}
|
|
267
275
|
const markAsFinishedSpinner = (0, ora_1.ora)('🔗 Marking the updates as finished...').start();
|
|
268
276
|
const results = await Promise.all(uploadUrls.map(async ({ updateId, platform, runtimeVersion }) => {
|
|
269
|
-
const response = await (
|
|
277
|
+
const response = await fetchWithRetries(`${baseUrl}/markUpdateAsUploaded/${branch}?platform=${platform}&updateId=${updateId}&runtimeVersion=${runtimeVersion}`, {
|
|
270
278
|
method: 'POST',
|
|
271
279
|
headers: {
|
|
272
280
|
...(0, auth_1.getAuthExpoHeaders)(credentials),
|
|
@@ -311,3 +319,20 @@ class Publish extends core_1.Command {
|
|
|
311
319
|
}
|
|
312
320
|
}
|
|
313
321
|
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.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
|
@@ -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' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eoas",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
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",
|
|
@@ -93,4 +94,4 @@
|
|
|
93
94
|
"/bin",
|
|
94
95
|
"/dist"
|
|
95
96
|
]
|
|
96
|
-
}
|
|
97
|
+
}
|