eas-cli 25.0.0 → 25.2.0

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.
Files changed (60) hide show
  1. package/README.md +285 -150
  2. package/build/analytics/AnalyticsManager.d.ts +6 -1
  3. package/build/analytics/AnalyticsManager.js +11 -1
  4. package/build/build/build.d.ts +2 -1
  5. package/build/build/build.js +5 -4
  6. package/build/build/context.d.ts +2 -0
  7. package/build/build/createContext.d.ts +3 -1
  8. package/build/build/createContext.js +2 -1
  9. package/build/build/freeTierLimitGuidance.d.ts +19 -0
  10. package/build/build/freeTierLimitGuidance.js +39 -0
  11. package/build/build/runBuildAndSubmit.d.ts +4 -1
  12. package/build/build/runBuildAndSubmit.js +4 -2
  13. package/build/commandUtils/EasCommand.d.ts +9 -0
  14. package/build/commandUtils/EasCommand.js +9 -0
  15. package/build/commandUtils/context/ExperimentationContextField.d.ts +13 -0
  16. package/build/commandUtils/context/ExperimentationContextField.js +79 -0
  17. package/build/commandUtils/context/contextUtils/createGraphqlClient.d.ts +3 -0
  18. package/build/commandUtils/context/contextUtils/createGraphqlClient.js +29 -2
  19. package/build/commandUtils/usageUtils.d.ts +14 -0
  20. package/build/commandUtils/usageUtils.js +40 -2
  21. package/build/commands/account/usage.js +55 -2
  22. package/build/commands/analytics.js +1 -1
  23. package/build/commands/build/index.d.ts +1 -0
  24. package/build/commands/build/index.js +3 -1
  25. package/build/commands/simulator/control.d.ts +26 -0
  26. package/build/commands/simulator/control.js +250 -0
  27. package/build/commands/simulator/index.d.ts +2 -0
  28. package/build/commands/simulator/index.js +28 -1
  29. package/build/commands/update/republish.d.ts +1 -1
  30. package/build/env.d.ts +6 -0
  31. package/build/env.js +6 -0
  32. package/build/experimentation/AnalyticsExposureLogger.d.ts +7 -0
  33. package/build/experimentation/AnalyticsExposureLogger.js +21 -0
  34. package/build/experimentation/ExperimentNamespace.d.ts +24 -0
  35. package/build/experimentation/ExperimentNamespace.js +69 -0
  36. package/build/experimentation/ExperimentOverrides.d.ts +17 -0
  37. package/build/experimentation/ExperimentOverrides.js +68 -0
  38. package/build/experimentation/ExperimentationClient.d.ts +32 -0
  39. package/build/experimentation/ExperimentationClient.js +125 -0
  40. package/build/experimentation/LazyExperimentationClient.d.ts +12 -0
  41. package/build/experimentation/LazyExperimentationClient.js +22 -0
  42. package/build/graphql/generated.d.ts +124 -0
  43. package/build/graphql/queries/AccountQuery.js +25 -0
  44. package/build/graphql/queries/ExperimentationConfigQuery.d.ts +10 -0
  45. package/build/graphql/queries/ExperimentationConfigQuery.js +49 -0
  46. package/build/graphql/queries/UserQuery.d.ts +3 -1
  47. package/build/graphql/queries/UserQuery.js +2 -1
  48. package/build/graphql/types/Account.js +5 -0
  49. package/build/help.d.ts +4 -0
  50. package/build/help.js +56 -0
  51. package/build/simulator/frameAncestors.d.ts +9 -0
  52. package/build/simulator/frameAncestors.js +66 -0
  53. package/build/simulator/hostActions.d.ts +70 -0
  54. package/build/simulator/hostActions.js +411 -0
  55. package/build/simulator/utils.d.ts +19 -2
  56. package/build/simulator/utils.js +68 -8
  57. package/build/user/SessionManager.d.ts +8 -1
  58. package/build/user/SessionManager.js +7 -2
  59. package/oclif.manifest.json +1164 -243
  60. package/package.json +8 -6
@@ -49,10 +49,17 @@ function displayBandwidthMetric(metric, indent = ' ') {
49
49
  log_1.default.log(`${indent}${metric.name} (additional usage): ${chalk_1.default.red(formatBytesDisplay(metric.overageValue))} (${(0, usageUtils_1.formatCurrency)(metric.overageCost)})`);
50
50
  }
51
51
  }
52
+ function formatMetricValue(value, maxDecimals) {
53
+ return value.toLocaleString(undefined, { maximumFractionDigits: maxDecimals });
54
+ }
55
+ function formatMinutes(minutes) {
56
+ return `${formatMetricValue(minutes, 1)} minutes`;
57
+ }
52
58
  function displayMetric(metric, indent = ' ') {
53
59
  const progressBar = (0, checkForOverages_1.createProgressBar)(metric.percentUsed, 20);
54
60
  const percentStr = `${metric.percentUsed}%`;
55
- const planUsageStr = `${(0, usageUtils_1.formatNumber)(metric.planValue)}/${(0, usageUtils_1.formatNumber)(metric.limit)} ${metric.unit ?? ''}`;
61
+ const maxDecimals = metric.maxDecimals ?? 0;
62
+ const planUsageStr = `${formatMetricValue(metric.planValue, maxDecimals)}/${formatMetricValue(metric.limit, maxDecimals)} ${metric.unit ?? ''}`;
56
63
  let color = chalk_1.default.green;
57
64
  if (metric.percentUsed >= 100) {
58
65
  color = chalk_1.default.red;
@@ -63,7 +70,26 @@ function displayMetric(metric, indent = ' ') {
63
70
  log_1.default.log(`${indent}${metric.name} (plan): ${color(planUsageStr)}`);
64
71
  log_1.default.log(`${indent}${progressBar} ${color(percentStr)}`);
65
72
  if (metric.overageValue > 0) {
66
- log_1.default.log(`${indent}${metric.name} (additional usage): ${chalk_1.default.red(`${(0, usageUtils_1.formatNumber)(metric.overageValue)} ${metric.unit ?? ''}`)} (${(0, usageUtils_1.formatCurrency)(metric.overageCost)})`);
73
+ log_1.default.log(`${indent}${metric.name} (additional usage): ${chalk_1.default.red(`${formatMetricValue(metric.overageValue, maxDecimals)} ${metric.unit ?? ''}`)} (${(0, usageUtils_1.formatCurrency)(metric.overageCost)})`);
74
+ }
75
+ }
76
+ function displaySimulatorUsage(simulator) {
77
+ log_1.default.newLine();
78
+ log_1.default.log(chalk_1.default.bold.underline('EAS Simulator'));
79
+ displayMetric(simulator.minutes);
80
+ if (simulator.jobTypeBreakdown) {
81
+ const { workflows, simulator: simulatorMinutes, other } = simulator.jobTypeBreakdown;
82
+ log_1.default.log(' Breakdown by job type:');
83
+ log_1.default.log(` Workflows: ${formatMinutes(workflows)}`);
84
+ log_1.default.log(` Simulator: ${formatMinutes(simulatorMinutes)}`);
85
+ if (other > 0) {
86
+ log_1.default.log(` Other jobs: ${formatMinutes(other)}`);
87
+ }
88
+ }
89
+ if (simulator.iosMinutes > 0 || simulator.androidMinutes > 0) {
90
+ log_1.default.log(' Simulator minutes by platform:');
91
+ log_1.default.log(` iOS: ${formatMinutes(simulator.iosMinutes)}`);
92
+ log_1.default.log(` Android: ${formatMinutes(simulator.androidMinutes)}`);
67
93
  }
68
94
  }
69
95
  function billingUrl(accountName) {
@@ -101,6 +127,9 @@ function displayUsage(data, usageData) {
101
127
  log_1.default.log(chalk_1.default.bold.underline('EAS Update'));
102
128
  displayMetric(data.updates.mau);
103
129
  displayBandwidthMetric(data.updates.bandwidth);
130
+ if (data.simulator) {
131
+ displaySimulatorUsage(data.simulator);
132
+ }
104
133
  log_1.default.newLine();
105
134
  log_1.default.log(chalk_1.default.bold.underline('Billing'));
106
135
  const upcomingInvoice = subscription?.upcomingInvoice;
@@ -142,6 +171,9 @@ function displayUsage(data, usageData) {
142
171
  if (data.updates.overageCostCents > 0) {
143
172
  log_1.default.log(` Updates: ${(0, usageUtils_1.formatCurrency)(data.updates.overageCostCents)}`);
144
173
  }
174
+ if (data.simulator && data.simulator.overageCostCents > 0) {
175
+ log_1.default.log(` Simulator: ${(0, usageUtils_1.formatCurrency)(data.simulator.overageCostCents)}`);
176
+ }
145
177
  }
146
178
  log_1.default.log(` Estimated bill: ${chalk_1.default.bold((0, usageUtils_1.formatCurrency)(data.estimatedBillCents))}`);
147
179
  }
@@ -302,6 +334,27 @@ class AccountUsage extends EasCommand_1.default {
302
334
  },
303
335
  overageCostCents: displayData.updates.overageCostCents,
304
336
  },
337
+ simulator: displayData.simulator
338
+ ? {
339
+ minutes: {
340
+ plan: {
341
+ used: displayData.simulator.minutes.planValue,
342
+ limit: displayData.simulator.minutes.limit,
343
+ percentUsed: displayData.simulator.minutes.percentUsed,
344
+ },
345
+ overage: {
346
+ count: displayData.simulator.minutes.overageValue,
347
+ costCents: displayData.simulator.minutes.overageCost,
348
+ },
349
+ },
350
+ byPlatform: {
351
+ ios: displayData.simulator.iosMinutes,
352
+ android: displayData.simulator.androidMinutes,
353
+ },
354
+ byJobType: displayData.simulator.jobTypeBreakdown ?? null,
355
+ overageCostCents: displayData.simulator.overageCostCents,
356
+ }
357
+ : null,
305
358
  billing: {
306
359
  addons: subscription?.addons ?? [],
307
360
  upcomingInvoice: subscription?.upcomingInvoice ?? null,
@@ -6,7 +6,7 @@ const AnalyticsManager_1 = require("../analytics/AnalyticsManager");
6
6
  const EasCommand_1 = tslib_1.__importDefault(require("../commandUtils/EasCommand"));
7
7
  const log_1 = tslib_1.__importDefault(require("../log"));
8
8
  class AnalyticsView extends EasCommand_1.default {
9
- static description = 'display or change analytics settings';
9
+ static description = 'display or change analytics settings (disabling analytics also disables experiments)';
10
10
  static args = {
11
11
  STATUS: core_1.Args.string({
12
12
  options: ['on', 'off'],
@@ -25,6 +25,7 @@ export default class Build extends EasCommand {
25
25
  'verbose-logs': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
26
26
  };
27
27
  static contextDefinition: {
28
+ experimentation: import("../../commandUtils/context/ExperimentationContextField").default;
28
29
  vcsClient: import("../../commandUtils/context/VcsClientContextField").default;
29
30
  analytics: import("../../commandUtils/context/AnalyticsContextField").default;
30
31
  projectDir: import("../../commandUtils/context/ProjectDirContextField").default;
@@ -108,6 +108,7 @@ class Build extends EasCommand_1.default {
108
108
  ...this.ContextOptions.ProjectDir,
109
109
  ...this.ContextOptions.Analytics,
110
110
  ...this.ContextOptions.Vcs,
111
+ ...this.ContextOptions.Experimentation,
111
112
  };
112
113
  async runAsync() {
113
114
  const { flags: rawFlags } = await this.parse(Build);
@@ -115,7 +116,7 @@ class Build extends EasCommand_1.default {
115
116
  (0, json_1.enableJsonOutput)();
116
117
  }
117
118
  const flags = this.sanitizeFlags(rawFlags);
118
- const { loggedIn: { actor, graphqlClient }, getDynamicPrivateProjectConfigAsync, projectDir, analytics, vcsClient, } = await this.getContextAsync(Build, {
119
+ const { loggedIn: { actor, graphqlClient }, getDynamicPrivateProjectConfigAsync, projectDir, analytics, vcsClient, experimentation, } = await this.getContextAsync(Build, {
119
120
  nonInteractive: flags.nonInteractive,
120
121
  withServerSideEnvironment: null,
121
122
  });
@@ -134,6 +135,7 @@ class Build extends EasCommand_1.default {
134
135
  flags: flagsWithPlatform,
135
136
  actor,
136
137
  getDynamicPrivateProjectConfigAsync,
138
+ experimentation,
137
139
  });
138
140
  this.maybeSuggestUsingEasBuildDev({
139
141
  buildProfiles,
@@ -0,0 +1,26 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ export default class SimulatorControl extends EasCommand {
3
+ static aliases: string[];
4
+ static description: string;
5
+ static strict: boolean;
6
+ static examples: string[];
7
+ static args: {
8
+ action: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
9
+ };
10
+ static flags: {
11
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
15
+ list: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
17
+ };
18
+ static contextDefinition: {
19
+ projectDir: import("../../commandUtils/context/ProjectDirContextField").default;
20
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
21
+ };
22
+ runAsync(): Promise<void>;
23
+ private printCatalog;
24
+ private printActionHelp;
25
+ private runActionAsync;
26
+ }
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const fs = tslib_1.__importStar(require("fs-extra"));
7
+ const path_1 = tslib_1.__importDefault(require("path"));
8
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
9
+ const flags_1 = require("../../commandUtils/flags");
10
+ const generated_1 = require("../../graphql/generated");
11
+ const DeviceRunSessionQuery_1 = require("../../graphql/queries/DeviceRunSessionQuery");
12
+ const log_1 = tslib_1.__importDefault(require("../../log"));
13
+ const ora_1 = require("../../ora");
14
+ const env_1 = require("../../simulator/env");
15
+ const hostActions_1 = require("../../simulator/hostActions");
16
+ const utils_1 = require("../../simulator/utils");
17
+ const json_1 = require("../../utils/json");
18
+ class SimulatorControl extends EasCommand_1.default {
19
+ static aliases = ['sim:control'];
20
+ static description = '[EXPERIMENTAL] run a serve-sim action on a remote iOS simulator session on EAS. Run without an action to list the actions the session supports. To save a screenshot locally, run `eas simulator:control screenshot.capture --output ./screenshot.png`.';
21
+ static strict = false;
22
+ static examples = [
23
+ '$ eas simulator:control',
24
+ '$ eas simulator:control --id <session-id>',
25
+ '$ eas simulator:control screenshot.capture --help',
26
+ '$ eas simulator:control clipboard.write -- --some-text',
27
+ '$ eas simulator:control hardwareKeyboard.set off',
28
+ '$ eas simulator:control permissions.set grant camera com.example.app',
29
+ '$ eas simulator:control app.install ./MyApp.ipa',
30
+ '$ eas simulator:control screenshot.capture --output ./screenshot.png',
31
+ '$ eas simulator:control screenshot.capture --output ./screenshot.png --id <session-id>',
32
+ ];
33
+ static args = {
34
+ action: core_1.Args.string({
35
+ description: 'Action to run, followed by its values in order or as name=value. Omit to list the actions. Put -- before values that start with --.',
36
+ }),
37
+ };
38
+ static flags = {
39
+ help: core_1.Flags.boolean({
40
+ char: 'h',
41
+ description: 'Show command help, or usage for the selected action from the session.',
42
+ }),
43
+ id: core_1.Flags.string({
44
+ description: `Simulator session ID. Defaults to ${env_1.SIMULATOR_DOTENV_FILE_NAME}.`,
45
+ }),
46
+ list: core_1.Flags.boolean({
47
+ description: 'List the actions the session supports.',
48
+ }),
49
+ output: core_1.Flags.string({
50
+ description: 'Local path to save a returned file. For screenshots, --output ./screenshot.png sets the local filename; omit it to save with a generated filename in the current directory.',
51
+ }),
52
+ ...flags_1.EasNonInteractiveAndJsonFlags,
53
+ };
54
+ static contextDefinition = {
55
+ ...this.ContextOptions.LoggedIn,
56
+ ...this.ContextOptions.ProjectDir,
57
+ };
58
+ async runAsync() {
59
+ const { args, argv, flags } = await this.parse(SimulatorControl);
60
+ const { json: jsonFlag, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
61
+ if (jsonFlag) {
62
+ (0, json_1.enableJsonOutput)();
63
+ }
64
+ if (flags.id === '') {
65
+ throw new Error('--id needs a simulator session ID.');
66
+ }
67
+ const action = flags.list && !flags.help ? undefined : args.action;
68
+ const { projectDir, loggedIn: { graphqlClient }, } = await this.getContextAsync(SimulatorControl, {
69
+ nonInteractive,
70
+ });
71
+ await (0, env_1.loadSimulatorEnvAsync)(projectDir);
72
+ const sessionId = flags.id ?? process.env[env_1.EAS_SIMULATOR_SESSION_ID];
73
+ if (!sessionId) {
74
+ throw new Error(`No simulator session ID provided. Pass --id, or run \`eas simulator:start\` first to write ${env_1.SIMULATOR_DOTENV_FILE_NAME}.`);
75
+ }
76
+ const spinner = (0, ora_1.ora)(`Connecting to simulator session ${sessionId}`).start();
77
+ let connection;
78
+ try {
79
+ let catalog;
80
+ try {
81
+ const session = await DeviceRunSessionQuery_1.DeviceRunSessionQuery.byIdAsync(graphqlClient, sessionId);
82
+ connection = await (0, hostActions_1.connectHostActionsAsync)(assertControllableSession(session));
83
+ catalog = await (0, hostActions_1.fetchHostActionCatalogAsync)(connection);
84
+ spinner.succeed(`Connected to simulator session ${sessionId}`);
85
+ }
86
+ catch (err) {
87
+ spinner.fail(`Failed to connect to simulator session ${sessionId}`);
88
+ throw err;
89
+ }
90
+ if (!action) {
91
+ this.printCatalog(catalog, jsonFlag);
92
+ return;
93
+ }
94
+ const entry = Object.hasOwn(catalog, action) ? catalog[action] : undefined;
95
+ if (!entry) {
96
+ throw new Error(`Unknown simulator action "${action}". Run \`eas simulator:control\` to see the actions.`);
97
+ }
98
+ if (flags.help) {
99
+ this.printActionHelp(action, entry, jsonFlag);
100
+ return;
101
+ }
102
+ await this.runActionAsync(connection, entry, {
103
+ sessionId,
104
+ action,
105
+ values: argv.slice(1).map(String),
106
+ outputPath: flags.output,
107
+ jsonFlag,
108
+ });
109
+ }
110
+ finally {
111
+ connection?.close();
112
+ }
113
+ }
114
+ printCatalog(catalog, jsonFlag) {
115
+ if (jsonFlag) {
116
+ (0, json_1.printJsonOnlyOutput)(catalog);
117
+ return;
118
+ }
119
+ const names = Object.keys(catalog).sort();
120
+ const width = Math.max(0, ...names.map(name => name.length)) + 3;
121
+ const columns = Math.max(1, Math.min(3, Math.floor((process.stdout.columns || 80) / width)));
122
+ const rows = Math.ceil(names.length / columns);
123
+ for (let row = 0; row < rows; row++) {
124
+ const cells = Array.from({ length: columns }, (_, column) => (names[row + column * rows] ?? '').padEnd(width));
125
+ log_1.default.log(cells.join('').trimEnd());
126
+ }
127
+ log_1.default.newLine();
128
+ log_1.default.log('For action usage: eas simulator:control <action> --help');
129
+ }
130
+ printActionHelp(action, entry, jsonFlag) {
131
+ if (jsonFlag) {
132
+ (0, json_1.printJsonOnlyOutput)({ ...entry, action });
133
+ return;
134
+ }
135
+ log_1.default.newLine();
136
+ log_1.default.log(` ${chalk_1.default.bold(action)}`);
137
+ if (entry.description) {
138
+ log_1.default.log(` ${entry.description}`);
139
+ }
140
+ log_1.default.newLine();
141
+ log_1.default.log(` ${chalk_1.default.bold('USAGE')}`);
142
+ log_1.default.log(` eas simulator:control ${(0, hostActions_1.formatHostActionUsage)(action, entry)}`);
143
+ const outputFlag = entry.output === 'base64' ? '--output <path>' : '[--output <path>]';
144
+ log_1.default.log(` ${entry.output ? `${outputFlag} ` : ''}[--id <session-id>] [--json]`);
145
+ log_1.default.newLine();
146
+ log_1.default.log(` ${chalk_1.default.bold('OPTIONS')}`);
147
+ log_1.default.log(` --id <session-id> Defaults to ${env_1.SIMULATOR_DOTENV_FILE_NAME}.`);
148
+ log_1.default.log(' --json Print the action schema as JSON. Implies --non-interactive.');
149
+ if (entry.output) {
150
+ log_1.default.log(entry.output === 'base64'
151
+ ? ' --output <path> Required local filename for the returned file.'
152
+ : ' --output <path> Local filename or existing directory.');
153
+ if (entry.output === 'path') {
154
+ log_1.default.log(' Omit to save with the generated filename.');
155
+ }
156
+ log_1.default.newLine();
157
+ log_1.default.log(' Action arguments refer to the simulator host. Use --output for the local filename.');
158
+ }
159
+ log_1.default.newLine();
160
+ }
161
+ async runActionAsync(connection, entry, { sessionId, action, values, outputPath, jsonFlag, }) {
162
+ const params = (0, hostActions_1.buildHostActionParams)(action, entry, values);
163
+ await (0, hostActions_1.assertHostActionOutputAsync)(action, entry, outputPath);
164
+ const localFile = await findLocalUploadAsync(entry, params);
165
+ const spinner = (0, ora_1.ora)(`Running ${action} on simulator session ${sessionId}`).start();
166
+ let uploadId;
167
+ let succeeded = false;
168
+ let output;
169
+ let savedFile;
170
+ try {
171
+ if (localFile) {
172
+ spinner.text = `Uploading ${localFile.path}`;
173
+ const upload = await (0, hostActions_1.uploadFileAsync)(connection, localFile.path);
174
+ uploadId = upload.uploadId;
175
+ params[localFile.param] = entry.uploadAs === 'id' ? upload.uploadId : upload.path;
176
+ spinner.text = `Running ${action} on simulator session ${sessionId}`;
177
+ }
178
+ const result = await connection.requestAsync(action, params);
179
+ if (result.exitCode !== 0) {
180
+ const detail = (result.stderr || result.stdout).trim() || `exit code ${result.exitCode}`;
181
+ throw new Error(`The simulator could not run ${action}: ${detail}`);
182
+ }
183
+ succeeded = true;
184
+ savedFile = await (0, hostActions_1.saveHostActionOutputAsync)(connection, entry, result.stdout, outputPath);
185
+ output = savedFile ? '' : result.stdout.trim();
186
+ spinner.succeed(`Ran ${action} on simulator session ${sessionId}`);
187
+ }
188
+ catch (err) {
189
+ spinner.fail(`Failed to run ${action} on simulator session ${sessionId}`);
190
+ throw err;
191
+ }
192
+ finally {
193
+ if (uploadId && (!entry.keepUpload || !succeeded)) {
194
+ await connection.requestAsync('upload.remove', { uploadId }).catch(() => { });
195
+ }
196
+ }
197
+ if (jsonFlag) {
198
+ (0, json_1.printJsonOnlyOutput)({
199
+ id: sessionId,
200
+ action,
201
+ output: parseJsonOutput(output),
202
+ file: savedFile,
203
+ });
204
+ return;
205
+ }
206
+ if (savedFile) {
207
+ log_1.default.log(`Saved ${savedFile}`);
208
+ }
209
+ else if (output) {
210
+ log_1.default.log(output);
211
+ }
212
+ }
213
+ }
214
+ exports.default = SimulatorControl;
215
+ async function findLocalUploadAsync({ upload: param, uploadWhen = {} }, params) {
216
+ const value = param ? params[param] : undefined;
217
+ const applies = Object.entries(uploadWhen).every(([name, expected]) => params[name] === expected);
218
+ if (!param || typeof value !== 'string' || !applies) {
219
+ return null;
220
+ }
221
+ const stat = await fs.stat(value).catch(() => null);
222
+ if (stat?.isDirectory()) {
223
+ throw new Error(`${value} is a folder. Pass the path of a file.`);
224
+ }
225
+ if (!stat && !path_1.default.isAbsolute(value)) {
226
+ throw new Error(`${value} does not exist on this computer. Pass the path of a local file, or an absolute path on the simulator host.`);
227
+ }
228
+ return stat ? { param, path: value } : null;
229
+ }
230
+ function assertControllableSession(session) {
231
+ if (session.status !== generated_1.DeviceRunSessionStatus.InProgress) {
232
+ throw new Error(`Simulator session ${session.id} is ${session.status.toLowerCase()}. Simulator actions need a running session. Start one with \`eas simulator:start\`.`);
233
+ }
234
+ if (session.platform !== generated_1.AppPlatform.Ios) {
235
+ throw new Error(`Simulator session ${session.id} runs on ${session.platform.toLowerCase()}. Simulator actions are available only for iOS sessions.`);
236
+ }
237
+ const access = session.remoteConfig ? (0, utils_1.getPreviewApiAccess)(session.remoteConfig) : null;
238
+ if (!access) {
239
+ throw new Error(`Simulator session ${session.id} does not expose a preview server with a token. Simulator actions use that server. Start a new session with \`eas simulator:start\`.`);
240
+ }
241
+ return access;
242
+ }
243
+ function parseJsonOutput(output) {
244
+ try {
245
+ return JSON.parse(output);
246
+ }
247
+ catch {
248
+ return output;
249
+ }
250
+ }
@@ -26,6 +26,8 @@ export default class Simulator extends EasCommand {
26
26
  'resource-class': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
27
27
  egress: import("@oclif/core/lib/interfaces").OptionFlag<"local" | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
28
28
  'egress-allow': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
29
+ 'cors-origin': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
30
+ 'frame-ancestor': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
29
31
  force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
30
32
  'out-config-type': import("@oclif/core/lib/interfaces").OptionFlag<"env" | "dotenv", import("@oclif/core/lib/interfaces").CustomOptions>;
31
33
  'public-link': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -17,6 +17,7 @@ const log_1 = tslib_1.__importStar(require("../../log"));
17
17
  const ora_1 = require("../../ora");
18
18
  const prompts_1 = require("../../prompts");
19
19
  const egress_1 = require("../../simulator/egress");
20
+ const frameAncestors_1 = require("../../simulator/frameAncestors");
20
21
  const networkCapture_1 = require("../../simulator/networkCapture");
21
22
  const env_1 = require("../../simulator/env");
22
23
  const expoGo_1 = require("../../simulator/expoGo");
@@ -120,6 +121,14 @@ class Simulator extends EasCommand_1.default {
120
121
  multiple: true,
121
122
  dependsOn: ['egress'],
122
123
  }),
124
+ 'cors-origin': core_1.Flags.string({
125
+ description: 'Origin of a page that may call the simulator preview API cross-origin, for example to render the device with @expo/hub-client, such as https://app.example.com or https://*.example.com. Repeat for multiple origins. Embedding the preview in a frame does not need this; use --frame-ancestor for that. The page still needs the printed preview URL and its token.',
126
+ multiple: true,
127
+ }),
128
+ 'frame-ancestor': core_1.Flags.string({
129
+ description: 'Origin of a page that may embed the simulator preview in a frame, such as https://app.example.com or https://*.example.com. Repeat for multiple origins. The embedding page loads the printed preview URL, which carries the session token, so anyone who can read that page can also control the simulator.',
130
+ multiple: true,
131
+ }),
123
132
  force: core_1.Flags.boolean({
124
133
  description: '[default: true] Create a new simulator session even when an existing simulator session is present in the environment.',
125
134
  default: true,
@@ -205,6 +214,20 @@ class Simulator extends EasCommand_1.default {
205
214
  catch (err) {
206
215
  throw new errors_1.EasCommandError(err instanceof Error ? err.message : String(err));
207
216
  }
217
+ let frameAncestors = [];
218
+ try {
219
+ frameAncestors = (0, frameAncestors_1.parseFrameAncestorList)(flags['frame-ancestor'] ?? []);
220
+ }
221
+ catch (err) {
222
+ throw new errors_1.EasCommandError(err instanceof Error ? err.message : String(err));
223
+ }
224
+ let corsOrigins = [];
225
+ try {
226
+ corsOrigins = (0, frameAncestors_1.parseCorsOriginList)(flags['cors-origin'] ?? []);
227
+ }
228
+ catch (err) {
229
+ throw new errors_1.EasCommandError(err instanceof Error ? err.message : String(err));
230
+ }
208
231
  if (flags['network-capture'] && platform !== generated_1.AppPlatform.Ios) {
209
232
  throw new errors_1.EasCommandError('Network capture is only supported on iOS simulator sessions. Re-run without --network-capture, or pass --platform ios.');
210
233
  }
@@ -263,6 +286,8 @@ class Simulator extends EasCommand_1.default {
263
286
  ...(openUrl ? { openUrl } : {}),
264
287
  ...(resourceClass ? { resourceClass } : {}),
265
288
  ...(egress ? { egress } : {}),
289
+ ...(frameAncestors.length ? { frameAncestors } : {}),
290
+ ...(corsOrigins.length ? { corsOrigins } : {}),
266
291
  requestOrigin: generated_1.DeviceRunSessionRequestOrigin.EasCli,
267
292
  ...agentIdentity,
268
293
  maxRunTimeMinutes: flags['max-duration-minutes'],
@@ -374,7 +399,7 @@ class Simulator extends EasCommand_1.default {
374
399
  name,
375
400
  type: flags.type,
376
401
  deviceRunSessionUrl,
377
- remoteConfig: (0, utils_1.sanitizeRemoteConfigForJson)(remoteConfig, deviceRunSessionPreviewUrl, flags['public-link']),
402
+ remoteConfig: (0, utils_1.sanitizeRemoteConfigForJson)(remoteConfig, deviceRunSessionPreviewUrl, flags['public-link'], { frameAncestors, corsOrigins }),
378
403
  });
379
404
  return;
380
405
  }
@@ -385,6 +410,8 @@ class Simulator extends EasCommand_1.default {
385
410
  sessionUrl: deviceRunSessionUrl,
386
411
  privatePreviewUrl: deviceRunSessionPreviewUrl,
387
412
  publicLink: flags['public-link'],
413
+ frameAncestors,
414
+ corsOrigins,
388
415
  platform,
389
416
  }));
390
417
  log_1.default.newLine();
@@ -10,7 +10,7 @@ export default class UpdateRepublish extends EasCommand {
10
10
  'destination-channel': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
11
  'destination-branch': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
12
  message: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
- platform: import("@oclif/core/lib/interfaces").OptionFlag<"android" | "ios" | "all" | "web", import("@oclif/core/lib/interfaces").CustomOptions>;
13
+ platform: import("@oclif/core/lib/interfaces").OptionFlag<"android" | "ios" | "web" | "all", import("@oclif/core/lib/interfaces").CustomOptions>;
14
14
  'private-key-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
15
15
  'rollout-percentage': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
16
16
  'force-end-active-rollout': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
package/build/env.d.ts CHANGED
@@ -20,5 +20,11 @@ declare const _default: {
20
20
  * Comma separated list of feature gate keys of feature gates to evaluate override to false.
21
21
  */
22
22
  featureGateDisable: string | undefined;
23
+ /**
24
+ * Comma separated list of experiment overrides in the form `namespace:param=value`.
25
+ * Overrides apply in every scope, even when analytics is disabled. A namespace with any override
26
+ * returns defaults for its other params and logs no exposure.
27
+ */
28
+ experimentOverride: string | undefined;
23
29
  };
24
30
  export default _default;
package/build/env.js CHANGED
@@ -22,4 +22,10 @@ exports.default = {
22
22
  * Comma separated list of feature gate keys of feature gates to evaluate override to false.
23
23
  */
24
24
  featureGateDisable: process.env.EAS_FG_DISABLE,
25
+ /**
26
+ * Comma separated list of experiment overrides in the form `namespace:param=value`.
27
+ * Overrides apply in every scope, even when analytics is disabled. A namespace with any override
28
+ * returns defaults for its other params and logs no exposure.
29
+ */
30
+ experimentOverride: process.env.EAS_EXPERIMENT_OVERRIDE,
25
31
  };
@@ -0,0 +1,7 @@
1
+ import type { ExposureData, ExposureLogger } from '@expo/experimentation';
2
+ import { Analytics } from '../analytics/AnalyticsManager';
3
+ export declare class AnalyticsExposureLogger implements ExposureLogger<Record<string, any>> {
4
+ private readonly analytics;
5
+ constructor(analytics: Analytics);
6
+ logExposure(data: ExposureData<Record<string, any>>): void;
7
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnalyticsExposureLogger = void 0;
4
+ const AnalyticsManager_1 = require("../analytics/AnalyticsManager");
5
+ class AnalyticsExposureLogger {
6
+ analytics;
7
+ constructor(analytics) {
8
+ this.analytics = analytics;
9
+ }
10
+ logExposure(data) {
11
+ const { variant } = data.params;
12
+ this.analytics.logEvent(AnalyticsManager_1.ExperimentationEvent.EXPERIMENT_VIEWED, {
13
+ experimentName: data.name,
14
+ // Analytics properties cannot be undefined. Fall back to all params when there is no variant.
15
+ variationName: variant !== undefined ? String(variant) : JSON.stringify(data.params),
16
+ // The unit is always a single value (actor ID, account ID, or device ID).
17
+ unit: String(data.unit[0]),
18
+ });
19
+ }
20
+ }
21
+ exports.AnalyticsExposureLogger = AnalyticsExposureLogger;
@@ -0,0 +1,24 @@
1
+ import type { Namespace } from '@expo/experimentation';
2
+ import { ExperimentOverrides } from './ExperimentOverrides';
3
+ export type ExperimentNamespace = {
4
+ getParam<T>(paramName: string, defaultValue: T): T;
5
+ isOverridden: boolean;
6
+ };
7
+ export declare const FALLBACK_NAMESPACE: ExperimentNamespace;
8
+ /** Serves overrides without consulting the real namespace, so no exposure is logged. */
9
+ export declare class OverrideFallbackNamespace implements ExperimentNamespace {
10
+ private readonly namespaceName;
11
+ private readonly overrides;
12
+ readonly isOverridden = true;
13
+ constructor(namespaceName: string, overrides: ExperimentOverrides);
14
+ getParam<T>(paramName: string, defaultValue: T): T;
15
+ }
16
+ /** Returns the default instead of throwing when the library rejects a param on first read. */
17
+ export declare class SafeNamespace implements ExperimentNamespace {
18
+ private readonly namespace;
19
+ private readonly namespaceName;
20
+ readonly isOverridden = false;
21
+ constructor(namespace: Namespace, namespaceName: string);
22
+ getParam<T>(paramName: string, defaultValue: T): T;
23
+ }
24
+ export declare function coerceOverrideValue<T>(overrideValue: string | undefined, defaultValue: T): T;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SafeNamespace = exports.OverrideFallbackNamespace = exports.FALLBACK_NAMESPACE = void 0;
4
+ exports.coerceOverrideValue = coerceOverrideValue;
5
+ const tslib_1 = require("tslib");
6
+ const log_1 = tslib_1.__importDefault(require("../log"));
7
+ exports.FALLBACK_NAMESPACE = {
8
+ getParam(_paramName, defaultValue) {
9
+ return defaultValue;
10
+ },
11
+ isOverridden: false,
12
+ };
13
+ /** Serves overrides without consulting the real namespace, so no exposure is logged. */
14
+ class OverrideFallbackNamespace {
15
+ namespaceName;
16
+ overrides;
17
+ isOverridden = true;
18
+ constructor(namespaceName, overrides) {
19
+ this.namespaceName = namespaceName;
20
+ this.overrides = overrides;
21
+ }
22
+ getParam(paramName, defaultValue) {
23
+ if (this.overrides.hasOverride(this.namespaceName, paramName)) {
24
+ return coerceOverrideValue(this.overrides.getOverride(this.namespaceName, paramName), defaultValue);
25
+ }
26
+ return defaultValue;
27
+ }
28
+ }
29
+ exports.OverrideFallbackNamespace = OverrideFallbackNamespace;
30
+ /** Returns the default instead of throwing when the library rejects a param on first read. */
31
+ class SafeNamespace {
32
+ namespace;
33
+ namespaceName;
34
+ isOverridden = false;
35
+ constructor(namespace, namespaceName) {
36
+ this.namespace = namespace;
37
+ this.namespaceName = namespaceName;
38
+ }
39
+ getParam(paramName, defaultValue) {
40
+ try {
41
+ return this.namespace.getParam(paramName, defaultValue);
42
+ }
43
+ catch (error) {
44
+ log_1.default.debug(`[experimentation] Failed to read param "${paramName}" from namespace "${this.namespaceName}". Returning the default.`, error);
45
+ return defaultValue;
46
+ }
47
+ }
48
+ }
49
+ exports.SafeNamespace = SafeNamespace;
50
+ function coerceOverrideValue(overrideValue, defaultValue) {
51
+ if (overrideValue === undefined || overrideValue.trim() === '') {
52
+ return defaultValue;
53
+ }
54
+ if (typeof defaultValue === 'boolean') {
55
+ const normalized = overrideValue.toLowerCase();
56
+ if (normalized === 'true') {
57
+ return true;
58
+ }
59
+ if (normalized === 'false') {
60
+ return false;
61
+ }
62
+ return defaultValue;
63
+ }
64
+ if (typeof defaultValue === 'number') {
65
+ const parsed = Number(overrideValue);
66
+ return (Number.isFinite(parsed) ? parsed : defaultValue);
67
+ }
68
+ return overrideValue;
69
+ }