eas-cli 20.4.0 → 20.5.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/README.md +114 -114
- package/build/build/context.d.ts +2 -2
- package/build/build/createContext.d.ts +2 -2
- package/build/build/local.d.ts +2 -2
- package/build/build/utils/url.d.ts +1 -0
- package/build/build/utils/url.js +4 -0
- package/build/commands/integrations/posthog/connect.d.ts +3 -0
- package/build/commands/integrations/posthog/connect.js +66 -12
- package/build/commands/simulator/get.js +8 -10
- package/build/commands/simulator/list.js +7 -13
- package/build/commands/simulator/start.js +27 -27
- package/build/commands/simulator/stop.js +5 -5
- package/build/fingerprint/utils.d.ts +2 -2
- package/build/graphql/generated.d.ts +302 -4
- package/build/graphql/generated.js +40 -4
- package/build/graphql/mutations/PostHogMutation.d.ts +2 -2
- package/build/graphql/mutations/PostHogMutation.js +13 -7
- package/build/graphql/queries/AccountQuery.js +5 -0
- package/build/graphql/queries/PostHogQuery.d.ts +3 -1
- package/build/graphql/queries/PostHogQuery.js +5 -2
- package/build/graphql/types/PostHogConnection.d.ts +8 -0
- package/build/project/ios/entitlements.d.ts +2 -1
- package/build/project/ios/target.d.ts +15 -1
- package/build/project/ios/target.js +23 -0
- package/build/submit/context.d.ts +2 -2
- package/build/utils/usage/checkForOverages.d.ts +15 -3
- package/build/utils/usage/checkForOverages.js +80 -21
- package/oclif.manifest.json +144 -144
- package/package.json +6 -6
package/build/build/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExpoConfig } from '@expo/config';
|
|
2
|
-
import { Platform, Workflow } from '@expo/eas-build-job';
|
|
2
|
+
import { Env, Platform, Workflow } from '@expo/eas-build-job';
|
|
3
3
|
import { BuildProfile, EasJson } from '@expo/eas-json';
|
|
4
4
|
import { LoggerLevel } from '@expo/logger';
|
|
5
5
|
import { NodePackageManager } from '@expo/package-manager';
|
|
@@ -60,5 +60,5 @@ export interface BuildContext<T extends Platform> {
|
|
|
60
60
|
loggerLevel?: LoggerLevel;
|
|
61
61
|
isVerboseLoggingEnabled: boolean;
|
|
62
62
|
whatToTest?: string;
|
|
63
|
-
env:
|
|
63
|
+
env: Env;
|
|
64
64
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Platform } from '@expo/eas-build-job';
|
|
1
|
+
import { Env, Platform } from '@expo/eas-build-job';
|
|
2
2
|
import { BuildProfile, EasJson, ResourceClass } from '@expo/eas-json';
|
|
3
3
|
import { LoggerLevel } from '@expo/logger';
|
|
4
4
|
import { BuildContext } from './context';
|
|
@@ -32,5 +32,5 @@ export declare function createBuildContextAsync<T extends Platform>({ buildProfi
|
|
|
32
32
|
refreshAdHocProvisioningProfile?: boolean;
|
|
33
33
|
isVerboseLoggingEnabled: boolean;
|
|
34
34
|
whatToTest?: string;
|
|
35
|
-
env:
|
|
35
|
+
env: Env;
|
|
36
36
|
}): Promise<BuildContext<T>>;
|
package/build/build/local.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Job, Metadata } from '@expo/eas-build-job';
|
|
1
|
+
import { Env, Job, Metadata } from '@expo/eas-build-job';
|
|
2
2
|
export declare enum LocalBuildMode {
|
|
3
3
|
/**
|
|
4
4
|
* Local build that users can run on their own machines. Instead
|
|
@@ -25,4 +25,4 @@ export interface LocalBuildOptions {
|
|
|
25
25
|
workingdir?: string;
|
|
26
26
|
verbose?: boolean;
|
|
27
27
|
}
|
|
28
|
-
export declare function runLocalBuildAsync(job: Job, metadata: Metadata, options: LocalBuildOptions, env:
|
|
28
|
+
export declare function runLocalBuildAsync(job: Job, metadata: Metadata, options: LocalBuildOptions, env: Env): Promise<void>;
|
|
@@ -5,6 +5,7 @@ export declare function getArtifactUrl(artifactId: string): string;
|
|
|
5
5
|
export declare function getInternalDistributionInstallUrl(build: BuildFragment): string;
|
|
6
6
|
export declare function getUpdateGroupUrl(accountName: string, projectName: string, updateGroupId: string): string;
|
|
7
7
|
export declare function getWorkflowRunUrl(accountName: string, projectName: string, workflowRunId: string): string;
|
|
8
|
+
export declare function getDeviceRunSessionUrl(accountName: string, projectName: string, deviceRunSessionId: string): string;
|
|
8
9
|
/**
|
|
9
10
|
* @deprecated Links to the raw job-run page; prefer a higher-level URL (e.g. the workflow run
|
|
10
11
|
* or the feature-specific dashboard) that gives users more context. Use this only for internal
|
package/build/build/utils/url.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.getArtifactUrl = getArtifactUrl;
|
|
|
6
6
|
exports.getInternalDistributionInstallUrl = getInternalDistributionInstallUrl;
|
|
7
7
|
exports.getUpdateGroupUrl = getUpdateGroupUrl;
|
|
8
8
|
exports.getWorkflowRunUrl = getWorkflowRunUrl;
|
|
9
|
+
exports.getDeviceRunSessionUrl = getDeviceRunSessionUrl;
|
|
9
10
|
exports.getBareJobRunUrl = getBareJobRunUrl;
|
|
10
11
|
exports.getProjectGitHubSettingsUrl = getProjectGitHubSettingsUrl;
|
|
11
12
|
exports.getHostingDeploymentsUrl = getHostingDeploymentsUrl;
|
|
@@ -39,6 +40,9 @@ function getUpdateGroupUrl(accountName, projectName, updateGroupId) {
|
|
|
39
40
|
function getWorkflowRunUrl(accountName, projectName, workflowRunId) {
|
|
40
41
|
return new URL(`/accounts/${encodeURIComponent(accountName)}/projects/${encodeURIComponent(projectName)}/workflows/${workflowRunId}`, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
|
|
41
42
|
}
|
|
43
|
+
function getDeviceRunSessionUrl(accountName, projectName, deviceRunSessionId) {
|
|
44
|
+
return new URL(`/accounts/${encodeURIComponent(accountName)}/projects/${encodeURIComponent(projectName)}/simulator-sessions/${encodeURIComponent(deviceRunSessionId)}`, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
|
|
45
|
+
}
|
|
42
46
|
/**
|
|
43
47
|
* @deprecated Links to the raw job-run page; prefer a higher-level URL (e.g. the workflow run
|
|
44
48
|
* or the feature-specific dashboard) that gives users more context. Use this only for internal
|
|
@@ -15,6 +15,9 @@ export default class IntegrationsPostHogConnect extends EasCommand {
|
|
|
15
15
|
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
16
16
|
};
|
|
17
17
|
runAsync(): Promise<void>;
|
|
18
|
+
private startConnectionAsync;
|
|
19
|
+
private completePendingConnectionViaBrowserAsync;
|
|
20
|
+
private pollForConnectionAsync;
|
|
18
21
|
private resolveFeaturesAsync;
|
|
19
22
|
private resolveCliApiKeyAsync;
|
|
20
23
|
private resolveRegionAsync;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const spawn_async_1 = tslib_1.__importDefault(require("@expo/spawn-async"));
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
|
+
const better_opn_1 = tslib_1.__importDefault(require("better-opn"));
|
|
6
7
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
8
|
const dotenv_1 = tslib_1.__importDefault(require("dotenv"));
|
|
8
9
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
@@ -45,6 +46,10 @@ const EAS_POSTHOG_HOST_ENV_VAR_NAME = 'EXPO_PUBLIC_POSTHOG_HOST';
|
|
|
45
46
|
const POSTHOG_CLI_API_KEY_ENV_VAR_NAME = 'POSTHOG_CLI_API_KEY';
|
|
46
47
|
const POSTHOG_CLI_PROJECT_ID_ENV_VAR_NAME = 'POSTHOG_CLI_PROJECT_ID';
|
|
47
48
|
const POSTHOG_CLI_HOST_ENV_VAR_NAME = 'POSTHOG_CLI_HOST';
|
|
49
|
+
// Match the server's 15-minute pending-row TTL — timing out sooner would strand an approval
|
|
50
|
+
// the user completes within the window.
|
|
51
|
+
const CONNECTION_POLL_INTERVAL_MS = 2_000;
|
|
52
|
+
const CONNECTION_POLL_TIMEOUT_MS = 15 * 60 * 1_000;
|
|
48
53
|
const PERSONAL_API_KEY_SETTINGS_PATH = '/settings/user-api-keys';
|
|
49
54
|
const ERROR_TRACKING_NEEDS_KEY_MESSAGE = `Error tracking needs a PostHog personal API key in non-interactive mode. Pass --posthog-cli-api-key (create one in PostHog under Settings → Personal API keys (${PERSONAL_API_KEY_SETTINGS_PATH}) with the "Source map upload" preset), or drop --error-tracking.`;
|
|
50
55
|
function getSpawnErrorOutput(error) {
|
|
@@ -104,18 +109,7 @@ class IntegrationsPostHogConnect extends EasCommand_1.default {
|
|
|
104
109
|
}
|
|
105
110
|
else {
|
|
106
111
|
const region = await this.resolveRegionAsync(regionFlag, nonInteractive);
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
connection = await PostHogMutation_1.PostHogMutation.createPostHogAccountRequestAsync(graphqlClient, {
|
|
110
|
-
accountId: account.id,
|
|
111
|
-
region,
|
|
112
|
-
});
|
|
113
|
-
spinner.succeed(`Created PostHog organization ${chalk_1.default.bold(connection.posthogOrganizationName)}`);
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
spinner.fail('Failed to create PostHog organization');
|
|
117
|
-
throw error;
|
|
118
|
-
}
|
|
112
|
+
connection = await this.startConnectionAsync(graphqlClient, account, region, nonInteractive);
|
|
119
113
|
}
|
|
120
114
|
let project = await PostHogQuery_1.PostHogQuery.getPostHogProjectByAppIdAsync(graphqlClient, projectId);
|
|
121
115
|
if (project) {
|
|
@@ -213,6 +207,66 @@ class IntegrationsPostHogConnect extends EasCommand_1.default {
|
|
|
213
207
|
}
|
|
214
208
|
this.printNextSteps(project, features, manualSteps);
|
|
215
209
|
}
|
|
210
|
+
async startConnectionAsync(graphqlClient, account, region, nonInteractive) {
|
|
211
|
+
const spinner = (0, ora_1.ora)('Creating PostHog organization').start();
|
|
212
|
+
let result;
|
|
213
|
+
try {
|
|
214
|
+
result = await PostHogMutation_1.PostHogMutation.startPostHogConnectionAsync(graphqlClient, {
|
|
215
|
+
accountId: account.id,
|
|
216
|
+
region,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
spinner.fail('Failed to create PostHog organization');
|
|
221
|
+
throw error;
|
|
222
|
+
}
|
|
223
|
+
if (result.__typename === 'PostHogOrganizationConnection') {
|
|
224
|
+
spinner.succeed(`Created PostHog organization ${chalk_1.default.bold(result.posthogOrganizationName)}`);
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
spinner.stop();
|
|
228
|
+
if (nonInteractive) {
|
|
229
|
+
throw new Error(`The email on the ${chalk_1.default.bold(account.name)} account already has a PostHog account, which must be connected by approving it in a browser. Re-run \`eas integrations:posthog:connect\` interactively to finish connecting.`);
|
|
230
|
+
}
|
|
231
|
+
return await this.completePendingConnectionViaBrowserAsync(graphqlClient, account, result);
|
|
232
|
+
}
|
|
233
|
+
async completePendingConnectionViaBrowserAsync(graphqlClient, account, pending) {
|
|
234
|
+
log_1.default.addNewLineIfNone();
|
|
235
|
+
log_1.default.log(`The email on the ${chalk_1.default.bold(account.name)} account already has a PostHog account. Approve connecting it to Expo in your browser.`);
|
|
236
|
+
const opened = await (0, better_opn_1.default)(pending.url).catch(() => false);
|
|
237
|
+
log_1.default.log(opened
|
|
238
|
+
? `Opened ${(0, log_1.link)(pending.url)}`
|
|
239
|
+
: `Open this URL to approve the connection: ${(0, log_1.link)(pending.url)}`);
|
|
240
|
+
const spinner = (0, ora_1.ora)('Waiting for you to approve the connection in PostHog (up to 15 minutes; press Ctrl-C to cancel)').start();
|
|
241
|
+
try {
|
|
242
|
+
const connection = await this.pollForConnectionAsync(graphqlClient, account.id);
|
|
243
|
+
spinner.succeed(`Connected PostHog organization ${chalk_1.default.bold(connection.posthogOrganizationName)}`);
|
|
244
|
+
return connection;
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
spinner.fail("Couldn't confirm the PostHog connection");
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async pollForConnectionAsync(graphqlClient, accountId) {
|
|
252
|
+
const deadline = Date.now() + CONNECTION_POLL_TIMEOUT_MS;
|
|
253
|
+
while (true) {
|
|
254
|
+
let connection = null;
|
|
255
|
+
try {
|
|
256
|
+
connection = await PostHogQuery_1.PostHogQuery.getPostHogOrganizationConnectionByAccountIdAsync(graphqlClient, accountId, { useCache: false });
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
log_1.default.debug(`Polling for the PostHog connection failed, will retry: ${error}`);
|
|
260
|
+
}
|
|
261
|
+
if (connection) {
|
|
262
|
+
return connection;
|
|
263
|
+
}
|
|
264
|
+
if (Date.now() >= deadline) {
|
|
265
|
+
throw new Error('Timed out waiting for the PostHog connection. If you approved it in your browser, re-run `eas integrations:posthog:connect` — it will pick up the connection. If not, approve it and try again.');
|
|
266
|
+
}
|
|
267
|
+
await new Promise(resolve => setTimeout(resolve, CONNECTION_POLL_INTERVAL_MS));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
216
270
|
async resolveFeaturesAsync(flags, cliApiKey, nonInteractive) {
|
|
217
271
|
const sessionReplayFlag = flags['session-replay'];
|
|
218
272
|
const errorTrackingFlag = flags['error-tracking'];
|
|
@@ -14,10 +14,10 @@ const utils_1 = require("../../simulator/utils");
|
|
|
14
14
|
const json_1 = require("../../utils/json");
|
|
15
15
|
class SimulatorGet extends EasCommand_1.default {
|
|
16
16
|
static hidden = true;
|
|
17
|
-
static description = '[EXPERIMENTAL] get info about a remote simulator session on EAS by its
|
|
17
|
+
static description = '[EXPERIMENTAL] get info about a remote simulator session on EAS by its simulator session ID';
|
|
18
18
|
static flags = {
|
|
19
19
|
id: core_1.Flags.string({
|
|
20
|
-
description: `
|
|
20
|
+
description: `Simulator session ID. Defaults to ${env_1.SIMULATOR_DOTENV_FILE_NAME}.`,
|
|
21
21
|
}),
|
|
22
22
|
...flags_1.EasNonInteractiveAndJsonFlags,
|
|
23
23
|
};
|
|
@@ -39,25 +39,23 @@ class SimulatorGet extends EasCommand_1.default {
|
|
|
39
39
|
if (!flagId) {
|
|
40
40
|
throw new Error(`No simulator session ID provided. Pass --id, or run \`eas simulator:start\` first to write ${env_1.SIMULATOR_DOTENV_FILE_NAME}.`);
|
|
41
41
|
}
|
|
42
|
-
const fetchSpinner = (0, ora_1.ora)(`Fetching
|
|
42
|
+
const fetchSpinner = (0, ora_1.ora)(`Fetching simulator session ${flagId}`).start();
|
|
43
43
|
let session;
|
|
44
44
|
try {
|
|
45
45
|
session = await DeviceRunSessionQuery_1.DeviceRunSessionQuery.byIdAsync(graphqlClient, flagId);
|
|
46
|
-
fetchSpinner.succeed(`Fetched
|
|
46
|
+
fetchSpinner.succeed(`Fetched simulator session ${session.id}`);
|
|
47
47
|
}
|
|
48
48
|
catch (err) {
|
|
49
|
-
fetchSpinner.fail(`Failed to fetch
|
|
49
|
+
fetchSpinner.fail(`Failed to fetch simulator session ${flagId}`);
|
|
50
50
|
throw err;
|
|
51
51
|
}
|
|
52
|
-
const
|
|
53
|
-
? (0, url_1.getBareJobRunUrl)(session.app.ownerAccount.name, session.app.slug, session.turtleJobRun.id)
|
|
54
|
-
: '';
|
|
52
|
+
const deviceRunSessionUrl = (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, session.id);
|
|
55
53
|
if (jsonFlag) {
|
|
56
54
|
(0, json_1.printJsonOnlyOutput)({
|
|
57
55
|
id: session.id,
|
|
58
56
|
type: (0, utils_1.deviceRunSessionTypeToFlagValue)(session.type),
|
|
59
57
|
status: session.status,
|
|
60
|
-
|
|
58
|
+
deviceRunSessionUrl,
|
|
61
59
|
remoteConfig: session.remoteConfig,
|
|
62
60
|
});
|
|
63
61
|
return;
|
|
@@ -66,7 +64,7 @@ class SimulatorGet extends EasCommand_1.default {
|
|
|
66
64
|
log_1.default.log(`ID: ${session.id}`);
|
|
67
65
|
log_1.default.log(`Type: ${session.type}`);
|
|
68
66
|
log_1.default.log(`Status: ${session.status}`);
|
|
69
|
-
log_1.default.log(`URL: ${
|
|
67
|
+
log_1.default.log(`URL: ${(0, log_1.link)(deviceRunSessionUrl)}`);
|
|
70
68
|
if (session.status === generated_1.DeviceRunSessionStatus.InProgress) {
|
|
71
69
|
log_1.default.newLine();
|
|
72
70
|
if (session.remoteConfig) {
|
|
@@ -80,7 +80,7 @@ class SimulatorList extends EasCommand_1.default {
|
|
|
80
80
|
filter.platforms = flags.platform.map(value => PLATFORM_BY_FLAG_VALUE[value]);
|
|
81
81
|
}
|
|
82
82
|
const limit = flags.limit ?? DEFAULT_LIMIT;
|
|
83
|
-
const fetchSpinner = jsonFlag ? null : (0, ora_1.ora)('Fetching
|
|
83
|
+
const fetchSpinner = jsonFlag ? null : (0, ora_1.ora)('Fetching simulator sessions').start();
|
|
84
84
|
let connection;
|
|
85
85
|
try {
|
|
86
86
|
connection = await DeviceRunSessionQuery_1.DeviceRunSessionQuery.listByAppIdAsync(graphqlClient, {
|
|
@@ -89,10 +89,10 @@ class SimulatorList extends EasCommand_1.default {
|
|
|
89
89
|
after: flags.after,
|
|
90
90
|
filter: Object.keys(filter).length > 0 ? filter : undefined,
|
|
91
91
|
});
|
|
92
|
-
fetchSpinner?.succeed(`Fetched ${connection.edges.length}
|
|
92
|
+
fetchSpinner?.succeed(`Fetched ${connection.edges.length} simulator session(s)`);
|
|
93
93
|
}
|
|
94
94
|
catch (err) {
|
|
95
|
-
fetchSpinner?.fail('Failed to fetch
|
|
95
|
+
fetchSpinner?.fail('Failed to fetch simulator sessions');
|
|
96
96
|
throw err;
|
|
97
97
|
}
|
|
98
98
|
const sessions = connection.edges.map(edge => edge.node);
|
|
@@ -106,9 +106,7 @@ class SimulatorList extends EasCommand_1.default {
|
|
|
106
106
|
createdAt: session.createdAt,
|
|
107
107
|
startedAt: session.startedAt ?? undefined,
|
|
108
108
|
finishedAt: session.finishedAt ?? undefined,
|
|
109
|
-
|
|
110
|
-
? (0, url_1.getBareJobRunUrl)(session.app.ownerAccount.name, session.app.slug, session.turtleJobRun.id)
|
|
111
|
-
: undefined,
|
|
109
|
+
deviceRunSessionUrl: (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, session.id),
|
|
112
110
|
})),
|
|
113
111
|
pageInfo: connection.pageInfo,
|
|
114
112
|
});
|
|
@@ -116,24 +114,20 @@ class SimulatorList extends EasCommand_1.default {
|
|
|
116
114
|
}
|
|
117
115
|
if (sessions.length === 0) {
|
|
118
116
|
log_1.default.newLine();
|
|
119
|
-
log_1.default.log('No
|
|
117
|
+
log_1.default.log('No simulator sessions found.');
|
|
120
118
|
return;
|
|
121
119
|
}
|
|
122
120
|
log_1.default.newLine();
|
|
123
121
|
const formattedEntries = sessions.map(session => {
|
|
124
|
-
const
|
|
125
|
-
? (0, url_1.getBareJobRunUrl)(session.app.ownerAccount.name, session.app.slug, session.turtleJobRun.id)
|
|
126
|
-
: null;
|
|
122
|
+
const deviceRunSessionUrl = (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, session.id);
|
|
127
123
|
const lines = [
|
|
128
124
|
`ID: ${session.id}`,
|
|
129
125
|
`Type: ${session.type}`,
|
|
130
126
|
`Status: ${session.status}`,
|
|
131
127
|
`Platform: ${session.platform}`,
|
|
132
128
|
`Created: ${(0, date_1.fromNow)(new Date(session.createdAt))} ago`,
|
|
129
|
+
`URL: ${(0, log_1.link)(deviceRunSessionUrl)}`,
|
|
133
130
|
];
|
|
134
|
-
if (jobRunUrl) {
|
|
135
|
-
lines.push(`URL: ${(0, log_1.link)(jobRunUrl)}`);
|
|
136
|
-
}
|
|
137
131
|
return lines.join('\n');
|
|
138
132
|
});
|
|
139
133
|
log_1.default.log(formattedEntries.join(`\n\n${chalk_1.default.dim('———')}\n\n`));
|
|
@@ -31,19 +31,19 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
31
31
|
required: true,
|
|
32
32
|
})(),
|
|
33
33
|
type: core_1.Flags.option({
|
|
34
|
-
description: 'Type of
|
|
34
|
+
description: 'Type of simulator session to create',
|
|
35
35
|
options: Object.values(utils_1.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES),
|
|
36
36
|
default: utils_1.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES[generated_1.DeviceRunSessionType.AgentDevice],
|
|
37
37
|
})(),
|
|
38
38
|
'package-version': core_1.Flags.string({
|
|
39
|
-
description: 'Version of the package backing the
|
|
39
|
+
description: 'Version of the package backing the simulator session (e.g. "0.1.3-alpha.3"). Defaults to "latest" when omitted.',
|
|
40
40
|
}),
|
|
41
41
|
'max-duration-minutes': core_1.Flags.integer({
|
|
42
|
-
description: 'Maximum duration of the
|
|
42
|
+
description: 'Maximum duration of the simulator session in minutes before it is automatically stopped. Only customizable on paid plans. Defaults to a value derived from the job run priority when omitted.',
|
|
43
43
|
min: 0,
|
|
44
44
|
}),
|
|
45
45
|
force: core_1.Flags.boolean({
|
|
46
|
-
description: '[default: true] Create a new
|
|
46
|
+
description: '[default: true] Create a new simulator session even when an existing simulator session is present in the environment.',
|
|
47
47
|
default: true,
|
|
48
48
|
allowNo: true,
|
|
49
49
|
}),
|
|
@@ -71,7 +71,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
71
71
|
await (0, env_1.loadSimulatorEnvAsync)(projectDir);
|
|
72
72
|
const existingDeviceRunSessionId = process.env[env_1.EAS_SIMULATOR_SESSION_ID];
|
|
73
73
|
if (existingDeviceRunSessionId && !flags.force) {
|
|
74
|
-
throw new Error(`Existing simulator session in environment. Use --force to create a new
|
|
74
|
+
throw new Error(`Existing simulator session in environment. Use --force to create a new simulator session.`);
|
|
75
75
|
}
|
|
76
76
|
if (existingDeviceRunSessionId) {
|
|
77
77
|
log_1.default.warn(` Overwriting previous simulator session (id: ${existingDeviceRunSessionId}). ` +
|
|
@@ -80,9 +80,9 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
80
80
|
log_1.default.newLine();
|
|
81
81
|
}
|
|
82
82
|
const platform = flags.platform === 'android' ? generated_1.AppPlatform.Android : generated_1.AppPlatform.Ios;
|
|
83
|
-
const createSpinner = (0, ora_1.ora)('🚀 Creating
|
|
83
|
+
const createSpinner = (0, ora_1.ora)('🚀 Creating simulator session').start();
|
|
84
84
|
let deviceRunSessionId;
|
|
85
|
-
let
|
|
85
|
+
let deviceRunSessionUrl;
|
|
86
86
|
try {
|
|
87
87
|
const session = await DeviceRunSessionMutation_1.DeviceRunSessionMutation.createDeviceRunSessionAsync(graphqlClient, {
|
|
88
88
|
appId: projectId,
|
|
@@ -92,17 +92,17 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
92
92
|
maxRunTimeMinutes: flags['max-duration-minutes'],
|
|
93
93
|
});
|
|
94
94
|
deviceRunSessionId = session.id;
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
(0, nullthrows_1.default)(session.turtleJobRun?.id, 'Expected simulator session to start');
|
|
96
|
+
deviceRunSessionUrl = (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, deviceRunSessionId);
|
|
97
97
|
const simulatorEnvWritten = !jsonFlag && flags['out-config-type'] === OUT_CONFIG_TYPE_VALUES.Dotenv
|
|
98
98
|
? await writeSimulatorEnvSafelyAsync(projectDir, {
|
|
99
99
|
[env_1.EAS_SIMULATOR_SESSION_ID]: deviceRunSessionId,
|
|
100
100
|
})
|
|
101
101
|
: false;
|
|
102
|
-
createSpinner.succeed(`
|
|
102
|
+
createSpinner.succeed(`Simulator session created (id: ${deviceRunSessionId}${simulatorEnvWritten ? `, saved to ${env_1.SIMULATOR_DOTENV_FILE_NAME}` : ''}) ${(0, log_1.link)(deviceRunSessionUrl)}`);
|
|
103
103
|
}
|
|
104
104
|
catch (err) {
|
|
105
|
-
createSpinner.fail('Failed to create
|
|
105
|
+
createSpinner.fail('Failed to create simulator session');
|
|
106
106
|
throw err;
|
|
107
107
|
}
|
|
108
108
|
const pollSpinner = (0, ora_1.ora)(`⏳ Waiting for ${flags.type} session to be ready`).start();
|
|
@@ -113,13 +113,13 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
113
113
|
const session = await DeviceRunSessionQuery_1.DeviceRunSessionQuery.byIdAsync(graphqlClient, deviceRunSessionId);
|
|
114
114
|
if (session.status === generated_1.DeviceRunSessionStatus.Errored ||
|
|
115
115
|
session.status === generated_1.DeviceRunSessionStatus.Stopped) {
|
|
116
|
-
throw new Error(`
|
|
116
|
+
throw new Error(`Simulator session ${deviceRunSessionId} ${session.status.toLowerCase()} before the ${flags.type} session was ready. ${(0, log_1.link)(deviceRunSessionUrl)}`);
|
|
117
117
|
}
|
|
118
118
|
const jobRunStatus = session.turtleJobRun?.status;
|
|
119
119
|
if (jobRunStatus === generated_1.JobRunStatus.Errored ||
|
|
120
120
|
jobRunStatus === generated_1.JobRunStatus.Canceled ||
|
|
121
121
|
jobRunStatus === generated_1.JobRunStatus.Finished) {
|
|
122
|
-
throw new Error(`Turtle job run for
|
|
122
|
+
throw new Error(`Turtle job run for simulator session ${deviceRunSessionId} ${jobRunStatus.toLowerCase()} before the ${flags.type} session was ready. ${(0, log_1.link)(deviceRunSessionUrl)}`);
|
|
123
123
|
}
|
|
124
124
|
if (session.remoteConfig) {
|
|
125
125
|
remoteConfig = session.remoteConfig;
|
|
@@ -137,7 +137,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
137
137
|
if (!remoteConfig) {
|
|
138
138
|
pollSpinner.fail(`Timed out waiting for ${flags.type} session to be ready`);
|
|
139
139
|
await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
140
|
-
throw new Error(`Timed out after ${Math.round(POLL_TIMEOUT_MS / 1000)}s waiting for ${flags.type} session to be ready. ${(0, log_1.link)(
|
|
140
|
+
throw new Error(`Timed out after ${Math.round(POLL_TIMEOUT_MS / 1000)}s waiting for ${flags.type} session to be ready. ${(0, log_1.link)(deviceRunSessionUrl)}`);
|
|
141
141
|
}
|
|
142
142
|
if (flags['out-config-type'] === OUT_CONFIG_TYPE_VALUES.Dotenv) {
|
|
143
143
|
await writeSimulatorEnvSafelyAsync(projectDir, {
|
|
@@ -149,7 +149,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
149
149
|
(0, json_1.printJsonOnlyOutput)({
|
|
150
150
|
id: deviceRunSessionId,
|
|
151
151
|
type: flags.type,
|
|
152
|
-
|
|
152
|
+
deviceRunSessionUrl,
|
|
153
153
|
remoteConfig,
|
|
154
154
|
});
|
|
155
155
|
return;
|
|
@@ -164,7 +164,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
164
164
|
await waitForSessionEndOrInterruptAsync({
|
|
165
165
|
graphqlClient,
|
|
166
166
|
deviceRunSessionId,
|
|
167
|
-
|
|
167
|
+
deviceRunSessionUrl,
|
|
168
168
|
projectDir,
|
|
169
169
|
});
|
|
170
170
|
}
|
|
@@ -180,8 +180,8 @@ async function writeSimulatorEnvSafelyAsync(projectDir, environmentVariables) {
|
|
|
180
180
|
return false;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessionId,
|
|
184
|
-
const spinner = (0, ora_1.ora)(`
|
|
183
|
+
async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessionId, deviceRunSessionUrl, projectDir, }) {
|
|
184
|
+
const spinner = (0, ora_1.ora)(`Simulator session active — press Ctrl+C to stop, or run \`eas simulator:stop --id ${deviceRunSessionId}\` from another shell`).start();
|
|
185
185
|
const abortController = new AbortController();
|
|
186
186
|
const { signal } = abortController;
|
|
187
187
|
const abortPromise = new Promise(resolve => {
|
|
@@ -193,7 +193,7 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
|
|
|
193
193
|
if (signal.aborted) {
|
|
194
194
|
// Force exit on a second Ctrl+C in case cleanup is hanging. The session may still be
|
|
195
195
|
// running on EAS, so tell the user how to make sure it gets terminated.
|
|
196
|
-
spinner.fail(`Aborted before the
|
|
196
|
+
spinner.fail(`Aborted before the simulator session could be stopped. Run \`eas simulator:stop --id ${deviceRunSessionId}\` to terminate it and avoid unexpected charges.`);
|
|
197
197
|
process.exit(130);
|
|
198
198
|
}
|
|
199
199
|
abortController.abort();
|
|
@@ -206,33 +206,33 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
|
|
|
206
206
|
session = await DeviceRunSessionQuery_1.DeviceRunSessionQuery.byIdAsync(graphqlClient, deviceRunSessionId);
|
|
207
207
|
}
|
|
208
208
|
catch (err) {
|
|
209
|
-
log_1.default.debug(`Failed to poll
|
|
209
|
+
log_1.default.debug(`Failed to poll simulator session: ${err instanceof Error ? err.message : String(err)}`);
|
|
210
210
|
await Promise.race([(0, promise_1.sleepAsync)(POLL_INTERVAL_MS), abortPromise]);
|
|
211
211
|
continue;
|
|
212
212
|
}
|
|
213
213
|
const jobRunStatus = session.turtleJobRun?.status;
|
|
214
214
|
if (session.status === generated_1.DeviceRunSessionStatus.Errored ||
|
|
215
215
|
jobRunStatus === generated_1.JobRunStatus.Errored) {
|
|
216
|
-
spinner.fail(`
|
|
217
|
-
throw new Error(`
|
|
216
|
+
spinner.fail(`Simulator session errored. ${(0, log_1.link)(deviceRunSessionUrl)}`);
|
|
217
|
+
throw new Error(`Simulator session ${deviceRunSessionId} errored.`);
|
|
218
218
|
}
|
|
219
219
|
if (session.status === generated_1.DeviceRunSessionStatus.Stopped ||
|
|
220
220
|
jobRunStatus === generated_1.JobRunStatus.Canceled ||
|
|
221
221
|
jobRunStatus === generated_1.JobRunStatus.Finished) {
|
|
222
|
-
spinner.succeed(`
|
|
222
|
+
spinner.succeed(`Simulator session ended. ${(0, log_1.link)(deviceRunSessionUrl)}`);
|
|
223
223
|
await resetSimulatorEnvVerboseAsync(projectDir);
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
226
226
|
await Promise.race([(0, promise_1.sleepAsync)(POLL_INTERVAL_MS), abortPromise]);
|
|
227
227
|
}
|
|
228
|
-
spinner.text = 'Stopping
|
|
228
|
+
spinner.text = 'Stopping simulator session...';
|
|
229
229
|
const stopped = await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
230
230
|
if (stopped) {
|
|
231
|
-
spinner.succeed('
|
|
231
|
+
spinner.succeed('Simulator session stopped');
|
|
232
232
|
await resetSimulatorEnvVerboseAsync(projectDir);
|
|
233
233
|
}
|
|
234
234
|
else {
|
|
235
|
-
spinner.fail(`Could not confirm the
|
|
235
|
+
spinner.fail(`Could not confirm the simulator session was stopped. Run \`eas simulator:stop --id ${deviceRunSessionId}\` to terminate it and avoid unexpected charges.`);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
finally {
|
|
@@ -255,7 +255,7 @@ async function ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRun
|
|
|
255
255
|
}
|
|
256
256
|
catch (err) {
|
|
257
257
|
// Cleanup is best-effort; surface the failure but don't mask the original error.
|
|
258
|
-
log_1.default.warn(`Failed to stop
|
|
258
|
+
log_1.default.warn(`Failed to stop simulator session ${deviceRunSessionId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
259
259
|
return false;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
@@ -10,10 +10,10 @@ const env_1 = require("../../simulator/env");
|
|
|
10
10
|
const json_1 = require("../../utils/json");
|
|
11
11
|
class SimulatorStop extends EasCommand_1.default {
|
|
12
12
|
static hidden = true;
|
|
13
|
-
static description = '[EXPERIMENTAL] stop a remote simulator session on EAS by its
|
|
13
|
+
static description = '[EXPERIMENTAL] stop a remote simulator session on EAS by its simulator session ID';
|
|
14
14
|
static flags = {
|
|
15
15
|
id: core_1.Flags.string({
|
|
16
|
-
description: `
|
|
16
|
+
description: `Simulator session ID. Defaults to ${env_1.SIMULATOR_DOTENV_FILE_NAME}.`,
|
|
17
17
|
}),
|
|
18
18
|
...flags_1.EasNonInteractiveAndJsonFlags,
|
|
19
19
|
};
|
|
@@ -35,14 +35,14 @@ class SimulatorStop extends EasCommand_1.default {
|
|
|
35
35
|
if (!flagId) {
|
|
36
36
|
throw new Error(`No simulator session ID provided. Pass --id, or run \`eas simulator:start\` first to write ${env_1.SIMULATOR_DOTENV_FILE_NAME}.`);
|
|
37
37
|
}
|
|
38
|
-
const stopSpinner = (0, ora_1.ora)(`🛑 Stopping
|
|
38
|
+
const stopSpinner = (0, ora_1.ora)(`🛑 Stopping simulator session ${flagId}`).start();
|
|
39
39
|
let session;
|
|
40
40
|
try {
|
|
41
41
|
session = await DeviceRunSessionMutation_1.DeviceRunSessionMutation.ensureDeviceRunSessionStoppedAsync(graphqlClient, flagId);
|
|
42
|
-
stopSpinner.succeed(`🎉
|
|
42
|
+
stopSpinner.succeed(`🎉 Simulator session ${session.id} is ${session.status.toLowerCase()}`);
|
|
43
43
|
}
|
|
44
44
|
catch (err) {
|
|
45
|
-
stopSpinner.fail(`Failed to stop
|
|
45
|
+
stopSpinner.fail(`Failed to stop simulator session ${flagId}`);
|
|
46
46
|
throw err;
|
|
47
47
|
}
|
|
48
48
|
if (jsonFlag) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Platform } from '@expo/eas-build-job';
|
|
1
|
+
import { Env, Platform } from '@expo/eas-build-job';
|
|
2
2
|
import { Fingerprint } from './types';
|
|
3
3
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
|
4
4
|
import { AppPlatform } from '../graphql/generated';
|
|
5
5
|
import { Client } from '../vcs/vcs';
|
|
6
6
|
export declare function getFingerprintInfoFromLocalProjectForPlatformsAsync(graphqlClient: ExpoGraphqlClient, projectDir: string, projectId: string, vcsClient: Client, platforms: AppPlatform[], { env }?: {
|
|
7
|
-
env?:
|
|
7
|
+
env?: Env;
|
|
8
8
|
}): Promise<Fingerprint>;
|
|
9
9
|
export declare function appPlatformToPlatform(platform: AppPlatform): Platform;
|
|
10
10
|
export declare function appPlatformToString(platform: AppPlatform): string;
|