eoas 3.1.0 → 3.1.2-beta
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/init.js +14 -1
- package/dist/commands/publish.d.ts +1 -0
- package/dist/commands/publish.js +10 -3
- package/dist/commands/republish.d.ts +1 -0
- package/dist/commands/republish.js +9 -14
- package/dist/commands/rollback.d.ts +1 -0
- package/dist/commands/rollback.js +9 -14
- package/dist/lib/expoConfig.d.ts +7 -1
- package/dist/lib/expoConfig.js +45 -12
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -105,9 +105,22 @@ class Init extends core_1.Command {
|
|
|
105
105
|
.replace(/\\/g, '\\\\')
|
|
106
106
|
.replace(/'/g, "\\'")}'`,
|
|
107
107
|
enabled: true,
|
|
108
|
+
// Branch surfing: a build on a channel that allows it can be pointed at
|
|
109
|
+
// another branch at runtime, and expo-updates only accepts an override for
|
|
110
|
+
// header keys that already existed at build time — so these have to be
|
|
111
|
+
// declared here even when the value is empty. Dropping one of them does not
|
|
112
|
+
// disable the feature, it strips that header from every poll for the rest of
|
|
113
|
+
// the install; the picker refuses to appear rather than let that happen.
|
|
108
114
|
requestHeaders: {
|
|
109
|
-
'expo-channel-name':
|
|
115
|
+
'expo-channel-name': {
|
|
116
|
+
__comment: 'Declare as a literal if you surf branches: see xprem-branch below.',
|
|
117
|
+
value: 'process.env.RELEASE_CHANNEL',
|
|
118
|
+
},
|
|
110
119
|
'expo-app-id': appId,
|
|
120
|
+
'xprem-branch': {
|
|
121
|
+
__comment: 'Branch surfing — the branch to serve; empty means the channel decides.',
|
|
122
|
+
value: '',
|
|
123
|
+
},
|
|
111
124
|
},
|
|
112
125
|
};
|
|
113
126
|
const updateConfigSpinner = (0, ora_1.ora)('Updating Expo config').start();
|
|
@@ -8,6 +8,7 @@ export default class Publish extends Command {
|
|
|
8
8
|
channel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
9
|
disableRepositoryCheck: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
10
|
branch: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
serverUrl: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
12
|
nonInteractive: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
13
|
outputDir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
14
|
packageRunner: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
package/dist/commands/publish.js
CHANGED
|
@@ -49,6 +49,10 @@ class Publish extends core_1.Command {
|
|
|
49
49
|
description: 'Name of the branch to point to',
|
|
50
50
|
required: true,
|
|
51
51
|
}),
|
|
52
|
+
serverUrl: core_1.Flags.string({
|
|
53
|
+
description: 'URL of the self-hosted update server to publish to. Defaults to the origin of updates.url from your Expo config',
|
|
54
|
+
required: false,
|
|
55
|
+
}),
|
|
52
56
|
nonInteractive: core_1.Flags.boolean({
|
|
53
57
|
description: 'Run command in non-interactive mode',
|
|
54
58
|
default: false,
|
|
@@ -81,6 +85,7 @@ class Publish extends core_1.Command {
|
|
|
81
85
|
disableRepositoryCheck: flags.disableRepositoryCheck,
|
|
82
86
|
platform: flags.platform,
|
|
83
87
|
branch: flags.branch,
|
|
88
|
+
customServerUrl: flags.serverUrl,
|
|
84
89
|
nonInteractive: flags.nonInteractive,
|
|
85
90
|
outputDir: flags.outputDir,
|
|
86
91
|
packageRunner: (0, packageRunner_1.resolvePackageRunner)(flags.packageRunner, process.cwd()),
|
|
@@ -97,7 +102,7 @@ class Publish extends core_1.Command {
|
|
|
97
102
|
process.exit(1);
|
|
98
103
|
}
|
|
99
104
|
const { flags } = await this.parse(Publish);
|
|
100
|
-
const { platform, nonInteractive, branch, outputDir, packageRunner, providedDeprecatedChannel, disableRepositoryCheck, message, dumpSourcemap, rolloutPercentage, } = this.sanitizeFlags(flags);
|
|
105
|
+
const { platform, nonInteractive, branch, customServerUrl, outputDir, packageRunner, providedDeprecatedChannel, disableRepositoryCheck, message, dumpSourcemap, rolloutPercentage, } = this.sanitizeFlags(flags);
|
|
101
106
|
if (!branch) {
|
|
102
107
|
log_1.default.error('Branch name is required');
|
|
103
108
|
process.exit(1);
|
|
@@ -119,12 +124,14 @@ class Publish extends core_1.Command {
|
|
|
119
124
|
},
|
|
120
125
|
packageRunner,
|
|
121
126
|
});
|
|
122
|
-
const serverUrl = await (0, expoConfig_1.resolveServerUrl)(config).catch(e => {
|
|
127
|
+
const serverUrl = await (0, expoConfig_1.resolveServerUrl)(config, customServerUrl).catch(e => {
|
|
123
128
|
log_1.default.error(e.message);
|
|
124
129
|
process.exit(1);
|
|
125
130
|
});
|
|
126
131
|
const appId = (0, expoConfig_1.requireExpoAppId)(config);
|
|
127
|
-
|
|
132
|
+
// A URL passed on the command line needs no confirmation, and `eoas init`
|
|
133
|
+
// would not fix it anyway.
|
|
134
|
+
if (!nonInteractive && !customServerUrl) {
|
|
128
135
|
const confirmed = await (0, prompts_1.confirmAsync)({
|
|
129
136
|
message: `Is this the correct URL of your self-hosted update server? ${serverUrl}`,
|
|
130
137
|
name: 'export',
|
|
@@ -6,6 +6,7 @@ export default class Publish extends Command {
|
|
|
6
6
|
static flags: {
|
|
7
7
|
branch: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
8
|
platform: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
serverUrl: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
10
|
};
|
|
10
11
|
private sanitizeFlags;
|
|
11
12
|
run(): Promise<void>;
|
|
@@ -26,11 +26,16 @@ class Publish extends core_1.Command {
|
|
|
26
26
|
default: 'all',
|
|
27
27
|
required: true,
|
|
28
28
|
}),
|
|
29
|
+
serverUrl: core_1.Flags.string({
|
|
30
|
+
description: 'URL of the self-hosted update server to republish on. Defaults to the origin of updates.url from your Expo config',
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
29
33
|
};
|
|
30
34
|
sanitizeFlags(flags) {
|
|
31
35
|
return {
|
|
32
36
|
branch: flags.branch,
|
|
33
37
|
platform: flags.platform,
|
|
38
|
+
customServerUrl: flags.serverUrl,
|
|
34
39
|
};
|
|
35
40
|
}
|
|
36
41
|
async run() {
|
|
@@ -40,7 +45,7 @@ class Publish extends core_1.Command {
|
|
|
40
45
|
process.exit(1);
|
|
41
46
|
}
|
|
42
47
|
const { flags } = await this.parse(Publish);
|
|
43
|
-
const { branch, platform } = this.sanitizeFlags(flags);
|
|
48
|
+
const { branch, platform, customServerUrl } = this.sanitizeFlags(flags);
|
|
44
49
|
if (!branch) {
|
|
45
50
|
log_1.default.error('Branch name is required');
|
|
46
51
|
process.exit(1);
|
|
@@ -60,21 +65,11 @@ class Publish extends core_1.Command {
|
|
|
60
65
|
const privateConfig = await (0, expoConfig_1.getPrivateExpoConfigAsync)(projectDir, {
|
|
61
66
|
env: process.env,
|
|
62
67
|
});
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
log_1.default.error("Update url is not setup in your config. Please run 'eoas init' to setup the update url");
|
|
68
|
+
const baseUrl = await (0, expoConfig_1.resolveServerUrl)(privateConfig, customServerUrl).catch(e => {
|
|
69
|
+
log_1.default.error(e.message);
|
|
66
70
|
process.exit(1);
|
|
67
|
-
}
|
|
71
|
+
});
|
|
68
72
|
const appId = (0, expoConfig_1.requireExpoAppId)(privateConfig);
|
|
69
|
-
let baseUrl;
|
|
70
|
-
try {
|
|
71
|
-
const parsedUrl = new URL(updateUrl);
|
|
72
|
-
baseUrl = parsedUrl.origin;
|
|
73
|
-
}
|
|
74
|
-
catch (e) {
|
|
75
|
-
log_1.default.error('Invalid URL', e);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
73
|
let runtimeVersions;
|
|
79
74
|
try {
|
|
80
75
|
runtimeVersions = await (0, serverUpdates_1.fetchRuntimeVersions)({ baseUrl, appId, branch, credentials });
|
|
@@ -6,6 +6,7 @@ export default class Publish extends Command {
|
|
|
6
6
|
static flags: {
|
|
7
7
|
platform: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
8
|
branch: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
serverUrl: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
10
|
nonInteractive: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
11
|
};
|
|
11
12
|
private sanitizeFlags;
|
|
@@ -28,6 +28,10 @@ class Publish extends core_1.Command {
|
|
|
28
28
|
description: 'Name of the branch to point to',
|
|
29
29
|
required: true,
|
|
30
30
|
}),
|
|
31
|
+
serverUrl: core_1.Flags.string({
|
|
32
|
+
description: 'URL of the self-hosted update server to roll back on. Defaults to the origin of updates.url from your Expo config',
|
|
33
|
+
required: false,
|
|
34
|
+
}),
|
|
31
35
|
nonInteractive: core_1.Flags.boolean({
|
|
32
36
|
description: 'Run command in non-interactive mode',
|
|
33
37
|
default: false,
|
|
@@ -37,6 +41,7 @@ class Publish extends core_1.Command {
|
|
|
37
41
|
return {
|
|
38
42
|
platform: flags.platform,
|
|
39
43
|
branch: flags.branch,
|
|
44
|
+
customServerUrl: flags.serverUrl,
|
|
40
45
|
nonInteractive: flags.nonInteractive,
|
|
41
46
|
};
|
|
42
47
|
}
|
|
@@ -47,7 +52,7 @@ class Publish extends core_1.Command {
|
|
|
47
52
|
process.exit(1);
|
|
48
53
|
}
|
|
49
54
|
const { flags } = await this.parse(Publish);
|
|
50
|
-
const { platform, branch, nonInteractive } = this.sanitizeFlags(flags);
|
|
55
|
+
const { platform, branch, customServerUrl, nonInteractive } = this.sanitizeFlags(flags);
|
|
51
56
|
if (!branch) {
|
|
52
57
|
log_1.default.error('Branch name is required');
|
|
53
58
|
process.exit(1);
|
|
@@ -79,21 +84,11 @@ class Publish extends core_1.Command {
|
|
|
79
84
|
log_1.default.error('When using disableAntiBrickingMeasures, expo-updates is ignoring the embeded update of the app, please use republish command instead');
|
|
80
85
|
process.exit(1);
|
|
81
86
|
}
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
log_1.default.error("Update url is not setup in your config. Please run 'eoas init' to setup the update url");
|
|
87
|
+
const baseUrl = await (0, expoConfig_1.resolveServerUrl)(privateConfig, customServerUrl).catch(e => {
|
|
88
|
+
log_1.default.error(e.message);
|
|
85
89
|
process.exit(1);
|
|
86
|
-
}
|
|
90
|
+
});
|
|
87
91
|
const appId = (0, expoConfig_1.requireExpoAppId)(privateConfig);
|
|
88
|
-
let baseUrl;
|
|
89
|
-
try {
|
|
90
|
-
const parsedUrl = new URL(updateUrl);
|
|
91
|
-
baseUrl = parsedUrl.origin;
|
|
92
|
-
}
|
|
93
|
-
catch (e) {
|
|
94
|
-
log_1.default.error('Invalid URL', e);
|
|
95
|
-
process.exit(1);
|
|
96
|
-
}
|
|
97
92
|
const runtimeSpinner = (0, ora_1.ora)('🔄 Resolving runtime version...').start();
|
|
98
93
|
const runtimeVersions = [
|
|
99
94
|
...(!platform || platform === expoConfig_1.RequestedPlatform.All || platform === expoConfig_1.RequestedPlatform.Ios
|
package/dist/lib/expoConfig.d.ts
CHANGED
|
@@ -24,4 +24,10 @@ export declare function getExpoConfigUpdateUrl(config: ExpoConfig): string | und
|
|
|
24
24
|
export declare function getExpoAppId(config: ExpoConfig): string | undefined;
|
|
25
25
|
export declare function requireExpoAppId(config: ExpoConfig): string;
|
|
26
26
|
export declare function createOrModifyExpoConfigAsync(projectDir: string, exp: Record<string, any>): Promise<void>;
|
|
27
|
-
export
|
|
27
|
+
export type CommentedValue = {
|
|
28
|
+
__comment: string;
|
|
29
|
+
value: any;
|
|
30
|
+
};
|
|
31
|
+
/** Strips the comment wrappers, for the JSON path and for reading values back. */
|
|
32
|
+
export declare function unwrapValue(value: any): any;
|
|
33
|
+
export declare function resolveServerUrl(config: ExpoConfig, customServerUrl?: string): Promise<string>;
|
package/dist/lib/expoConfig.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveServerUrl = exports.createOrModifyExpoConfigAsync = exports.requireExpoAppId = exports.getExpoAppId = exports.getExpoConfigUpdateUrl = exports.getPublicExpoConfigAsync = exports.isUsingStaticExpoConfig = exports.ensureExpoConfigExists = exports.getPrivateExpoConfigAsync = exports.RequestedPlatform = void 0;
|
|
3
|
+
exports.resolveServerUrl = exports.unwrapValue = exports.createOrModifyExpoConfigAsync = exports.requireExpoAppId = exports.getExpoAppId = exports.getExpoConfigUpdateUrl = exports.getPublicExpoConfigAsync = exports.isUsingStaticExpoConfig = exports.ensureExpoConfigExists = exports.getPrivateExpoConfigAsync = exports.RequestedPlatform = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
// This file is copied from eas-cli[https://github.com/expo/eas-cli] to ensure consistent user experience across the CLI.
|
|
6
6
|
const config_1 = require("@expo/config");
|
|
@@ -254,7 +254,33 @@ function updateObjectExpression(j, configObject, updates) {
|
|
|
254
254
|
configObject.properties.push(newProperty);
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
|
+
// The key is deliberately underscored: it is a sentinel this module reads and
|
|
258
|
+
// strips, and it must not be mistakable for a real Expo config field.
|
|
259
|
+
function isCommented(value) {
|
|
260
|
+
if (typeof value !== 'object' || value === null || !('value' in value)) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
264
|
+
return typeof value.__comment === 'string';
|
|
265
|
+
}
|
|
266
|
+
/** Strips the comment wrappers, for the JSON path and for reading values back. */
|
|
267
|
+
function unwrapValue(value) {
|
|
268
|
+
if (isCommented(value)) {
|
|
269
|
+
return unwrapValue(value.value);
|
|
270
|
+
}
|
|
271
|
+
if (Array.isArray(value)) {
|
|
272
|
+
return value.map(unwrapValue);
|
|
273
|
+
}
|
|
274
|
+
if (typeof value === 'object' && value !== null) {
|
|
275
|
+
return Object.fromEntries(Object.entries(value).map(([key, val]) => [key, unwrapValue(val)]));
|
|
276
|
+
}
|
|
277
|
+
return value;
|
|
278
|
+
}
|
|
279
|
+
exports.unwrapValue = unwrapValue;
|
|
257
280
|
function createValueNode(j, value) {
|
|
281
|
+
if (isCommented(value)) {
|
|
282
|
+
return createValueNode(j, value.value);
|
|
283
|
+
}
|
|
258
284
|
if (typeof value === 'string' && value.startsWith('process.env.')) {
|
|
259
285
|
if (/^process\.env\.\w+$/.test(value)) {
|
|
260
286
|
return j.memberExpression(j.memberExpression(j.identifier('process'), j.identifier('env')), j.identifier(value.split('.')[2]));
|
|
@@ -262,8 +288,15 @@ function createValueNode(j, value) {
|
|
|
262
288
|
return parseExpressionNode(j, value);
|
|
263
289
|
}
|
|
264
290
|
if (typeof value === 'object' && value !== null) {
|
|
265
|
-
return j.objectExpression(Object.entries(value).map(([key, val]) =>
|
|
266
|
-
|
|
291
|
+
return j.objectExpression(Object.entries(value).map(([key, val]) => {
|
|
292
|
+
// Force stringLiteral pour garder les guillemets
|
|
293
|
+
const property = j.objectProperty(j.stringLiteral(key), createValueNode(j, val));
|
|
294
|
+
if (isCommented(val)) {
|
|
295
|
+
// eslint-disable-next-line no-underscore-dangle -- see isCommented
|
|
296
|
+
property.comments = [j.commentLine(` ${val.__comment}`, true, false)];
|
|
297
|
+
}
|
|
298
|
+
return property;
|
|
299
|
+
}));
|
|
267
300
|
}
|
|
268
301
|
return j.literal(value);
|
|
269
302
|
}
|
|
@@ -276,24 +309,24 @@ function parseExpressionNode(j, code) {
|
|
|
276
309
|
// contents (backslashes in Windows paths, quotes, ...).
|
|
277
310
|
function stringifyWithEnv(obj) {
|
|
278
311
|
const rawExpressions = [];
|
|
279
|
-
const json = JSON.stringify(obj, (_key, value) => typeof value === 'string' && value.startsWith('process.env.')
|
|
312
|
+
const json = JSON.stringify(unwrapValue(obj), (_key, value) => typeof value === 'string' && value.startsWith('process.env.')
|
|
280
313
|
? `__RAW_EXPR_${rawExpressions.push(value) - 1}__`
|
|
281
314
|
: value, 2);
|
|
282
315
|
return json.replace(/"__RAW_EXPR_(\d+)__"/g, (_match, index) => rawExpressions[Number(index)]);
|
|
283
316
|
}
|
|
284
|
-
|
|
285
|
-
|
|
317
|
+
// customServerUrl wins over the Expo config, so a project serving updates and
|
|
318
|
+
// receiving publishes on two different origins can point the CLI at the second
|
|
319
|
+
// one without touching its config.
|
|
320
|
+
async function resolveServerUrl(config, customServerUrl) {
|
|
321
|
+
const updateUrl = customServerUrl ?? getExpoConfigUpdateUrl(config);
|
|
286
322
|
if (!updateUrl) {
|
|
287
|
-
throw new Error(
|
|
323
|
+
throw new Error("Update url is not setup in your config. Please run 'eoas init' to setup the update url, or pass --serverUrl");
|
|
288
324
|
}
|
|
289
|
-
let baseUrl;
|
|
290
325
|
try {
|
|
291
|
-
|
|
292
|
-
baseUrl = parsedUrl.origin;
|
|
326
|
+
return new URL(updateUrl).origin;
|
|
293
327
|
}
|
|
294
328
|
catch {
|
|
295
|
-
throw new Error('Invalid update URL.');
|
|
329
|
+
throw new Error(customServerUrl ? 'Invalid --serverUrl value.' : 'Invalid update URL.');
|
|
296
330
|
}
|
|
297
|
-
return baseUrl;
|
|
298
331
|
}
|
|
299
332
|
exports.resolveServerUrl = resolveServerUrl;
|