eoas 3.1.0 → 3.1.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.
@@ -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>;
@@ -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
- if (!nonInteractive) {
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 updateUrl = (0, expoConfig_1.getExpoConfigUpdateUrl)(privateConfig);
64
- if (!updateUrl) {
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 updateUrl = (0, expoConfig_1.getExpoConfigUpdateUrl)(privateConfig);
83
- if (!updateUrl) {
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
@@ -24,4 +24,4 @@ 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 declare function resolveServerUrl(config: ExpoConfig): Promise<string>;
27
+ export declare function resolveServerUrl(config: ExpoConfig, customServerUrl?: string): Promise<string>;
@@ -281,19 +281,19 @@ function stringifyWithEnv(obj) {
281
281
  : value, 2);
282
282
  return json.replace(/"__RAW_EXPR_(\d+)__"/g, (_match, index) => rawExpressions[Number(index)]);
283
283
  }
284
- async function resolveServerUrl(config) {
285
- const updateUrl = config.updates?.url;
284
+ // customServerUrl wins over the Expo config, so a project serving updates and
285
+ // receiving publishes on two different origins can point the CLI at the second
286
+ // one without touching its config.
287
+ async function resolveServerUrl(config, customServerUrl) {
288
+ const updateUrl = customServerUrl ?? getExpoConfigUpdateUrl(config);
286
289
  if (!updateUrl) {
287
- throw new Error('No update URL found in the Expo config.');
290
+ throw new Error("Update url is not setup in your config. Please run 'eoas init' to setup the update url, or pass --serverUrl");
288
291
  }
289
- let baseUrl;
290
292
  try {
291
- const parsedUrl = new URL(updateUrl);
292
- baseUrl = parsedUrl.origin;
293
+ return new URL(updateUrl).origin;
293
294
  }
294
295
  catch {
295
- throw new Error('Invalid update URL.');
296
+ throw new Error(customServerUrl ? 'Invalid --serverUrl value.' : 'Invalid update URL.');
296
297
  }
297
- return baseUrl;
298
298
  }
299
299
  exports.resolveServerUrl = resolveServerUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eoas",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build": "tsc --project tsconfig.json",