eoas 1.0.39 → 2.0.1
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 +0 -4
- package/dist/commands/publish.js +82 -35
- package/dist/lib/assets.d.ts +4 -1
- package/package.json +1 -1
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
import { Config } from '@oclif/core/lib/config';
|
|
3
|
-
import { Client } from '../lib/vcs/vcs';
|
|
4
2
|
export default class Publish extends Command {
|
|
5
|
-
vcsClient: Client;
|
|
6
|
-
constructor(argv: string[], config: Config);
|
|
7
3
|
static args: {};
|
|
8
4
|
static description: string;
|
|
9
5
|
static examples: string[];
|
package/dist/commands/publish.js
CHANGED
|
@@ -21,11 +21,6 @@ const runtimeVersion_1 = require("../lib/runtimeVersion");
|
|
|
21
21
|
const vcs_1 = require("../lib/vcs");
|
|
22
22
|
const workflow_1 = require("../lib/workflow");
|
|
23
23
|
class Publish extends core_1.Command {
|
|
24
|
-
vcsClient;
|
|
25
|
-
constructor(argv, config) {
|
|
26
|
-
super(argv, config);
|
|
27
|
-
this.vcsClient = (0, vcs_1.resolveVcsClient)(false);
|
|
28
|
-
}
|
|
29
24
|
static args = {};
|
|
30
25
|
static description = 'Publish a new update to the self-hosted update server';
|
|
31
26
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -73,8 +68,9 @@ class Publish extends core_1.Command {
|
|
|
73
68
|
log_1.default.error('Channel name is required');
|
|
74
69
|
process.exit(1);
|
|
75
70
|
}
|
|
76
|
-
|
|
77
|
-
await
|
|
71
|
+
const vcsClient = (0, vcs_1.resolveVcsClient)(true);
|
|
72
|
+
await vcsClient.ensureRepoExistsAsync();
|
|
73
|
+
await (0, repo_1.ensureRepoIsCleanAsync)(vcsClient, nonInteractive);
|
|
78
74
|
const projectDir = process.cwd();
|
|
79
75
|
const hasExpo = (0, package_1.isExpoInstalled)(projectDir);
|
|
80
76
|
if (!hasExpo) {
|
|
@@ -115,31 +111,37 @@ class Publish extends core_1.Command {
|
|
|
115
111
|
const runtimeVersions = [
|
|
116
112
|
...(!platform || platform === expoConfig_1.RequestedPlatform.All || platform === expoConfig_1.RequestedPlatform.Ios
|
|
117
113
|
? [
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
{
|
|
115
|
+
runtimeVersion: (await (0, runtimeVersion_1.resolveRuntimeVersionAsync)({
|
|
116
|
+
exp: privateConfig,
|
|
117
|
+
platform: 'ios',
|
|
118
|
+
workflow: await (0, workflow_1.resolveWorkflowAsync)(projectDir, eas_build_job_1.Platform.IOS, vcsClient),
|
|
119
|
+
projectDir,
|
|
120
|
+
env: {
|
|
121
|
+
RELEASE_CHANNEL: channel,
|
|
122
|
+
},
|
|
123
|
+
}))?.runtimeVersion,
|
|
120
124
|
platform: 'ios',
|
|
121
|
-
|
|
122
|
-
projectDir,
|
|
123
|
-
env: {
|
|
124
|
-
RELEASE_CHANNEL: channel,
|
|
125
|
-
},
|
|
126
|
-
}))?.runtimeVersion,
|
|
125
|
+
},
|
|
127
126
|
]
|
|
128
127
|
: []),
|
|
129
128
|
...(!platform || platform === expoConfig_1.RequestedPlatform.All || platform === expoConfig_1.RequestedPlatform.Android
|
|
130
129
|
? [
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
{
|
|
131
|
+
runtimeVersion: (await (0, runtimeVersion_1.resolveRuntimeVersionAsync)({
|
|
132
|
+
exp: privateConfig,
|
|
133
|
+
platform: 'android',
|
|
134
|
+
workflow: await (0, workflow_1.resolveWorkflowAsync)(projectDir, eas_build_job_1.Platform.ANDROID, vcsClient),
|
|
135
|
+
projectDir,
|
|
136
|
+
env: {
|
|
137
|
+
RELEASE_CHANNEL: channel,
|
|
138
|
+
},
|
|
139
|
+
}))?.runtimeVersion,
|
|
133
140
|
platform: 'android',
|
|
134
|
-
|
|
135
|
-
projectDir,
|
|
136
|
-
env: {
|
|
137
|
-
RELEASE_CHANNEL: channel,
|
|
138
|
-
},
|
|
139
|
-
}))?.runtimeVersion,
|
|
141
|
+
},
|
|
140
142
|
]
|
|
141
143
|
: []),
|
|
142
|
-
].filter(
|
|
144
|
+
].filter(({ runtimeVersion }) => !!runtimeVersion);
|
|
143
145
|
if (!runtimeVersions.length) {
|
|
144
146
|
runtimeSpinner.fail('Could not resolve runtime versions for the requested platforms');
|
|
145
147
|
log_1.default.error('Could not resolve runtime versions for the requested platforms');
|
|
@@ -181,16 +183,21 @@ class Publish extends core_1.Command {
|
|
|
181
183
|
uploadFilesSpinner.fail('No files to upload');
|
|
182
184
|
process.exit(1);
|
|
183
185
|
}
|
|
186
|
+
let uploadUrls = [];
|
|
184
187
|
try {
|
|
185
|
-
|
|
188
|
+
uploadUrls = await Promise.all(runtimeVersions.map(async ({ runtimeVersion, platform }) => {
|
|
186
189
|
if (!runtimeVersion) {
|
|
187
190
|
throw new Error('Runtime version is not resolved');
|
|
188
191
|
}
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
return {
|
|
193
|
+
...(await (0, assets_1.requestUploadUrls)({
|
|
194
|
+
fileNames: files.map(file => file.path),
|
|
195
|
+
}, `${baseUrl}/requestUploadUrl/${branch}`, credentials, runtimeVersion)),
|
|
196
|
+
runtimeVersion,
|
|
197
|
+
platform,
|
|
198
|
+
};
|
|
192
199
|
}));
|
|
193
|
-
const allItems = uploadUrls.
|
|
200
|
+
const allItems = uploadUrls.flatMap(({ uploadRequests }) => uploadRequests);
|
|
194
201
|
await Promise.all(allItems.map(async (itm) => {
|
|
195
202
|
const isLocalBucketFileUpload = itm.requestUploadUrl.startsWith(`${baseUrl}/uploadLocalFile`);
|
|
196
203
|
const formData = new form_data_1.default();
|
|
@@ -244,15 +251,55 @@ class Publish extends core_1.Command {
|
|
|
244
251
|
}));
|
|
245
252
|
uploadFilesSpinner.succeed('✅ Files uploaded successfully');
|
|
246
253
|
}
|
|
247
|
-
catch {
|
|
254
|
+
catch (e) {
|
|
248
255
|
uploadFilesSpinner.fail('❌ Failed to upload static files');
|
|
256
|
+
log_1.default.error(e);
|
|
249
257
|
process.exit(1);
|
|
250
258
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
259
|
+
const markAsFinishedSpinner = (0, ora_1.ora)('🔗 Marking the updates as finished...').start();
|
|
260
|
+
const results = await Promise.all(uploadUrls.map(async ({ updateId, platform, runtimeVersion }) => {
|
|
261
|
+
const response = await (0, node_fetch_1.default)(`${baseUrl}/markUpdateAsUploaded/${branch}?platform=${platform}&updateId=${updateId}&runtimeVersion=${runtimeVersion}`, {
|
|
262
|
+
method: 'POST',
|
|
263
|
+
headers: {
|
|
264
|
+
...(0, auth_1.getAuthExpoHeaders)(credentials),
|
|
265
|
+
'Content-Type': 'application/json',
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
// If success and status code = 200
|
|
269
|
+
if (response.ok) {
|
|
270
|
+
log_1.default.withInfo(`✅ Update ready for ${platform}`);
|
|
271
|
+
return 'deployed';
|
|
272
|
+
}
|
|
273
|
+
// If response.status === 406 duplicate update
|
|
274
|
+
if (response.status === 406) {
|
|
275
|
+
log_1.default.withInfo(`⚠️ There is no change in the update for ${platform}, ignored...`);
|
|
276
|
+
return 'identical';
|
|
277
|
+
}
|
|
278
|
+
log_1.default.error('❌ Failed to mark the update as finished for platform', platform);
|
|
279
|
+
log_1.default.newLine();
|
|
280
|
+
log_1.default.error(await response.text());
|
|
281
|
+
return 'error';
|
|
282
|
+
}));
|
|
283
|
+
const erroredUpdates = results.filter(result => result === 'error');
|
|
284
|
+
const hasSuccess = results.some(result => result === 'deployed');
|
|
285
|
+
const allIdentical = results.every(result => result === 'identical');
|
|
286
|
+
if (allIdentical) {
|
|
287
|
+
markAsFinishedSpinner.warn('⚠️ No changes found in the update, nothing to deploy');
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (erroredUpdates.length) {
|
|
291
|
+
markAsFinishedSpinner.fail('❌ Some errors occurred while marking updates as finished');
|
|
292
|
+
throw new Error();
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
markAsFinishedSpinner.succeed(`\n✅ Your update has been successfully pushed to ${updateUrl}`);
|
|
296
|
+
}
|
|
297
|
+
if (hasSuccess) {
|
|
298
|
+
log_1.default.withInfo(`🔗 Channel: \`${channel}\``);
|
|
299
|
+
log_1.default.withInfo(`🌿 Branch: \`${branch}\``);
|
|
300
|
+
log_1.default.withInfo(`⏳ Deployed at: \`${new Date().toUTCString()}\`\n`);
|
|
301
|
+
log_1.default.withInfo('🔥 Your users will receive the latest update automatically!');
|
|
302
|
+
}
|
|
256
303
|
}
|
|
257
304
|
}
|
|
258
305
|
exports.default = Publish;
|
package/dist/lib/assets.d.ts
CHANGED
|
@@ -15,5 +15,8 @@ export interface RequestUploadUrlItem {
|
|
|
15
15
|
}
|
|
16
16
|
export declare function requestUploadUrls(body: {
|
|
17
17
|
fileNames: string[];
|
|
18
|
-
}, requestUploadUrl: string, auth: ExpoCredentials, runtimeVersion: string): Promise<
|
|
18
|
+
}, requestUploadUrl: string, auth: ExpoCredentials, runtimeVersion: string): Promise<{
|
|
19
|
+
uploadRequests: RequestUploadUrlItem[];
|
|
20
|
+
updateId: string;
|
|
21
|
+
}>;
|
|
19
22
|
export {};
|