eas-cli 21.4.0 → 21.6.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.
- package/README.md +454 -120
- package/build/build/local.js +64 -7
- package/build/commandUtils/workflow/compositeFunctions.d.ts +1 -0
- package/build/commandUtils/workflow/compositeFunctions.js +36 -0
- package/build/commandUtils/workflow/validation.js +3 -0
- package/build/commands/account/usage.d.ts +3 -0
- package/build/commands/account/usage.js +6 -5
- package/build/commands/integrations/posthog/connect.js +1 -1
- package/build/commands/project/new.d.ts +1 -1
- package/build/commands/simulator/availability.d.ts +1 -0
- package/build/commands/simulator/availability.js +9 -2
- package/build/commands/simulator/events.d.ts +1 -0
- package/build/commands/simulator/events.js +1 -0
- package/build/commands/simulator/exec.d.ts +1 -0
- package/build/commands/simulator/exec.js +1 -0
- package/build/commands/simulator/get.d.ts +1 -0
- package/build/commands/simulator/get.js +1 -0
- package/build/commands/simulator/{start.d.ts → index.d.ts} +1 -1
- package/build/commands/simulator/{start.js → index.js} +99 -29
- package/build/commands/simulator/list.d.ts +2 -0
- package/build/commands/simulator/list.js +7 -0
- package/build/commands/simulator/stop.d.ts +1 -0
- package/build/commands/simulator/stop.js +1 -0
- package/build/commands/submit/cancel.d.ts +20 -0
- package/build/commands/submit/cancel.js +116 -0
- package/build/commands/submit/list.d.ts +27 -0
- package/build/commands/submit/list.js +100 -0
- package/build/commands/submit/retry.d.ts +18 -0
- package/build/commands/submit/retry.js +123 -0
- package/build/commands/submit/status.d.ts +19 -0
- package/build/commands/submit/status.js +116 -0
- package/build/commands/submit/view.d.ts +17 -0
- package/build/commands/submit/view.js +96 -0
- package/build/graphql/generated.d.ts +580 -4
- package/build/graphql/generated.js +3 -0
- package/build/graphql/mutations/SubmissionMutation.d.ts +3 -1
- package/build/graphql/mutations/SubmissionMutation.js +33 -0
- package/build/graphql/queries/SubmissionQuery.d.ts +3 -2
- package/build/graphql/queries/SubmissionQuery.js +19 -2
- package/build/graphql/types/SubmissionWithSubmittedBuild.d.ts +1 -0
- package/build/graphql/types/SubmissionWithSubmittedBuild.js +25 -0
- package/build/simulator/utils.d.ts +7 -0
- package/build/simulator/utils.js +15 -1
- package/build/submit/queries.d.ts +34 -0
- package/build/submit/queries.js +94 -0
- package/build/submit/status.d.ts +31 -0
- package/build/submit/status.js +187 -0
- package/build/submit/utils/formatSubmission.d.ts +2 -0
- package/build/submit/utils/formatSubmission.js +78 -0
- package/build/utils/promise.d.ts +3 -2
- package/build/utils/promise.js +17 -3
- package/build/utils/terminalText.d.ts +1 -0
- package/build/utils/terminalText.js +14 -0
- package/build/utils/usage/checkForOverages.js +1 -1
- package/oclif.manifest.json +2247 -1726
- package/package.json +8 -5
package/build/build/local.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.runLocalBuildAsync = runLocalBuildAsync;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
7
7
|
const spawn_async_1 = tslib_1.__importDefault(require("@expo/spawn-async"));
|
|
8
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
9
|
const semver_1 = tslib_1.__importDefault(require("semver"));
|
|
9
10
|
const api_1 = require("../api");
|
|
10
11
|
const log_1 = tslib_1.__importDefault(require("../log"));
|
|
@@ -30,7 +31,12 @@ var LocalBuildMode;
|
|
|
30
31
|
LocalBuildMode["INTERNAL"] = "internal";
|
|
31
32
|
})(LocalBuildMode || (exports.LocalBuildMode = LocalBuildMode = {}));
|
|
32
33
|
async function runLocalBuildAsync(job, metadata, options, env) {
|
|
33
|
-
const { command, args } = await getCommandAndArgsAsync(
|
|
34
|
+
const { command, args } = await getCommandAndArgsAsync();
|
|
35
|
+
// The job carries build credentials, so it is passed to the plugin via an
|
|
36
|
+
// environment variable rather than a command-line argument. Otherwise it
|
|
37
|
+
// would be exposed in the process list and, on failure, in the spawn error
|
|
38
|
+
// message (which includes the command line) printed to stderr.
|
|
39
|
+
const pluginInput = Buffer.from(JSON.stringify({ job, metadata })).toString('base64');
|
|
34
40
|
let spinner;
|
|
35
41
|
if (!options.verbose) {
|
|
36
42
|
spinner = (0, ora_1.ora)().start(options.skipNativeBuild ? 'Preparing project' : 'Building project');
|
|
@@ -46,6 +52,7 @@ async function runLocalBuildAsync(job, metadata, options, env) {
|
|
|
46
52
|
const mergedEnv = {
|
|
47
53
|
...env,
|
|
48
54
|
...process.env,
|
|
55
|
+
EAS_LOCAL_BUILD_PLUGIN_INPUT: pluginInput,
|
|
49
56
|
EAS_LOCAL_BUILD_WORKINGDIR: options.workingdir ?? process.env.EAS_LOCAL_BUILD_WORKINGDIR,
|
|
50
57
|
__API_SERVER_URL: (0, api_1.getExpoApiBaseUrl)(),
|
|
51
58
|
...(options.skipCleanup || options.skipNativeBuild
|
|
@@ -55,11 +62,12 @@ async function runLocalBuildAsync(job, metadata, options, env) {
|
|
|
55
62
|
...(options.artifactsDir ? { EAS_LOCAL_BUILD_ARTIFACTS_DIR: options.artifactsDir } : {}),
|
|
56
63
|
...(options.artifactPath ? { EAS_LOCAL_BUILD_ARTIFACT_PATH: options.artifactPath } : {}),
|
|
57
64
|
};
|
|
58
|
-
// log command execution to assist in debugging local builds
|
|
65
|
+
// log command execution to assist in debugging local builds; redact the job
|
|
66
|
+
// input since it contains build credentials.
|
|
59
67
|
log_1.default.debug('Running local build, using local-build-plugin', {
|
|
60
68
|
command,
|
|
61
69
|
args,
|
|
62
|
-
env: mergedEnv,
|
|
70
|
+
env: { ...mergedEnv, EAS_LOCAL_BUILD_PLUGIN_INPUT: '[redacted]' },
|
|
63
71
|
});
|
|
64
72
|
const spawnPromise = (0, spawn_async_1.default)(command, args, {
|
|
65
73
|
stdio: options.verbose ? 'inherit' : 'pipe',
|
|
@@ -68,21 +76,70 @@ async function runLocalBuildAsync(job, metadata, options, env) {
|
|
|
68
76
|
childProcess = spawnPromise.child;
|
|
69
77
|
await spawnPromise;
|
|
70
78
|
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
// The plugin's build output is already streamed to the terminal; add a
|
|
81
|
+
// concise context summary to help debug the failure. Never dump the raw
|
|
82
|
+
// job/metadata, which contains build credentials.
|
|
83
|
+
spinner?.stop();
|
|
84
|
+
logLocalBuildDebugInfo(job, metadata);
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
71
87
|
finally {
|
|
72
88
|
process.removeListener('SIGINT', interruptHandler);
|
|
73
89
|
spinner?.stop();
|
|
74
90
|
}
|
|
75
91
|
}
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Logs an allowlisted, non-secret summary of the build's job/metadata to help
|
|
94
|
+
* a user debug a failed local build. Only known-safe fields are included —
|
|
95
|
+
* never the raw job/metadata (which carries credentials and other secrets).
|
|
96
|
+
*/
|
|
97
|
+
function logLocalBuildDebugInfo(job, metadata) {
|
|
98
|
+
// `platform` and `projectRootDirectory` live on the platform-specific job
|
|
99
|
+
// variants; read them defensively since this is best-effort logging.
|
|
100
|
+
const jobFields = job;
|
|
101
|
+
const trackingContext = metadata.trackingContext ?? {};
|
|
102
|
+
const fields = [
|
|
103
|
+
['Platform', jobFields.platform],
|
|
104
|
+
['Build profile', metadata.buildProfile],
|
|
105
|
+
['Workflow', metadata.workflow],
|
|
106
|
+
['Distribution', metadata.distribution],
|
|
107
|
+
['Credentials source', metadata.credentialsSource],
|
|
108
|
+
['Project root directory', jobFields.projectRootDirectory],
|
|
109
|
+
['Required package manager', metadata.requiredPackageManager],
|
|
110
|
+
['eas-cli version', metadata.cliVersion],
|
|
111
|
+
['SDK version', metadata.sdkVersion],
|
|
112
|
+
['Runtime version', metadata.runtimeVersion],
|
|
113
|
+
['React Native version', metadata.reactNativeVersion],
|
|
114
|
+
['Expo package version', metadata.expoPackageVersion],
|
|
115
|
+
['App version', metadata.appVersion],
|
|
116
|
+
['Fingerprint hash', metadata.fingerprintHash],
|
|
117
|
+
['Git commit', metadata.gitCommitHash],
|
|
118
|
+
['Git working tree dirty', metadata.isGitWorkingTreeDirty],
|
|
119
|
+
['Build tracking ID', trackingContext.tracking_id],
|
|
120
|
+
['Project ID', trackingContext.project_id],
|
|
121
|
+
];
|
|
122
|
+
const lines = fields
|
|
123
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
124
|
+
.map(([label, value]) => ` ${label}: ${String(value)}`);
|
|
125
|
+
if (lines.length === 0) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
log_1.default.newLine();
|
|
129
|
+
log_1.default.log(chalk_1.default.bold('Build context (for debugging this failed local build):'));
|
|
130
|
+
log_1.default.log(chalk_1.default.dim(lines.join('\n')));
|
|
131
|
+
}
|
|
132
|
+
async function getCommandAndArgsAsync() {
|
|
133
|
+
// The job/metadata payload is passed to the plugin via the
|
|
134
|
+
// EAS_LOCAL_BUILD_PLUGIN_INPUT environment variable, not as an argument.
|
|
78
135
|
if (process.env.EAS_LOCAL_BUILD_PLUGIN_PATH) {
|
|
79
136
|
return {
|
|
80
137
|
command: process.env.EAS_LOCAL_BUILD_PLUGIN_PATH,
|
|
81
|
-
args: [
|
|
138
|
+
args: [],
|
|
82
139
|
};
|
|
83
140
|
}
|
|
84
141
|
else {
|
|
85
|
-
const args = [`${PLUGIN_PACKAGE_NAME}@${PLUGIN_PACKAGE_VERSION}
|
|
142
|
+
const args = [`${PLUGIN_PACKAGE_NAME}@${PLUGIN_PACKAGE_VERSION}`];
|
|
86
143
|
if (await isAtLeastNpm7Async()) {
|
|
87
144
|
// npx shipped with npm >= 7.0.0 requires the "-y" flag to run commands without
|
|
88
145
|
// prompting the user to install a package that is used for the first time
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function validateWorkflowLocalCompositeFunctionsAsync(parsedYaml: any, projectDir: string): Promise<void>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateWorkflowLocalCompositeFunctionsAsync = validateWorkflowLocalCompositeFunctionsAsync;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const steps_1 = require("@expo/steps");
|
|
6
|
+
const log_1 = tslib_1.__importDefault(require("../../log"));
|
|
7
|
+
async function validateWorkflowLocalCompositeFunctionsAsync(parsedYaml, projectDir) {
|
|
8
|
+
await (0, steps_1.buildLocalCompositeFunctionCatalogAsync)(projectDir, {
|
|
9
|
+
rootSteps: stepsFromWorkflow(parsedYaml),
|
|
10
|
+
logger: {
|
|
11
|
+
debug: message => {
|
|
12
|
+
log_1.default.debug(message);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function stepsFromWorkflow(parsedYaml) {
|
|
18
|
+
const jobs = parsedYaml?.jobs;
|
|
19
|
+
if (!jobs || typeof jobs !== 'object') {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
return [
|
|
23
|
+
...Object.values(jobs).flatMap((job) => [
|
|
24
|
+
...(Array.isArray(job?.steps) ? job.steps : []),
|
|
25
|
+
...hookStepsFrom(job),
|
|
26
|
+
]),
|
|
27
|
+
...hookStepsFrom(parsedYaml?.defaults),
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
function hookStepsFrom(jobOrDefaults) {
|
|
31
|
+
const hooks = jobOrDefaults?.hooks;
|
|
32
|
+
if (!hooks || typeof hooks !== 'object') {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
return Object.values(hooks).flatMap((steps) => (Array.isArray(steps) ? steps : []));
|
|
36
|
+
}
|
|
@@ -9,6 +9,7 @@ const core_1 = require("@urql/core");
|
|
|
9
9
|
const fs_1 = require("fs");
|
|
10
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
11
|
const YAML = tslib_1.__importStar(require("yaml"));
|
|
12
|
+
const compositeFunctions_1 = require("./compositeFunctions");
|
|
12
13
|
const buildProfileUtils_1 = require("./buildProfileUtils");
|
|
13
14
|
const api_1 = require("../../api");
|
|
14
15
|
const WorkflowRevisionMutation_1 = require("../../graphql/mutations/WorkflowRevisionMutation");
|
|
@@ -36,6 +37,8 @@ async function validateWorkflowFileAsync(workflowFileContents, projectDir, graph
|
|
|
36
37
|
// Check that result passes validation against workflow schema
|
|
37
38
|
log_1.default.debug(`Validating workflow structure...`);
|
|
38
39
|
validateWorkflowStructure(parsedYaml, workflowSchema);
|
|
40
|
+
log_1.default.debug(`Validating workflow local composite functions...`);
|
|
41
|
+
await (0, compositeFunctions_1.validateWorkflowLocalCompositeFunctionsAsync)(parsedYaml, projectDir);
|
|
39
42
|
// Check for other errors using the server-side validation
|
|
40
43
|
log_1.default.debug(`Validating workflow on server...`);
|
|
41
44
|
await validateWorkflowOnServerAsync(graphqlClient, projectId, workflowFileContents);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
|
+
import { UsageDisplayData } from '../../commandUtils/usageUtils';
|
|
3
|
+
import { AccountFullUsageData } from '../../graphql/queries/AccountQuery';
|
|
4
|
+
export declare function displayUsage(data: UsageDisplayData, usageData: AccountFullUsageData): void;
|
|
2
5
|
export default class AccountUsage extends EasCommand {
|
|
3
6
|
static description: string;
|
|
4
7
|
static args: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.displayUsage = displayUsage;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const core_1 = require("@oclif/core");
|
|
5
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
@@ -45,7 +46,7 @@ function displayBandwidthMetric(metric, indent = ' ') {
|
|
|
45
46
|
log_1.default.log(`${indent}${metric.name} (plan): ${color(planUsageStr)}`);
|
|
46
47
|
log_1.default.log(`${indent}${progressBar} ${color(percentStr)}`);
|
|
47
48
|
if (metric.overageValue > 0) {
|
|
48
|
-
log_1.default.log(`${indent}${metric.name} (
|
|
49
|
+
log_1.default.log(`${indent}${metric.name} (additional usage): ${chalk_1.default.red(formatBytesDisplay(metric.overageValue))} (${(0, usageUtils_1.formatCurrency)(metric.overageCost)})`);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
function displayMetric(metric, indent = ' ') {
|
|
@@ -62,7 +63,7 @@ function displayMetric(metric, indent = ' ') {
|
|
|
62
63
|
log_1.default.log(`${indent}${metric.name} (plan): ${color(planUsageStr)}`);
|
|
63
64
|
log_1.default.log(`${indent}${progressBar} ${color(percentStr)}`);
|
|
64
65
|
if (metric.overageValue > 0) {
|
|
65
|
-
log_1.default.log(`${indent}${metric.name} (
|
|
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)})`);
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
function billingUrl(accountName) {
|
|
@@ -128,9 +129,9 @@ function displayUsage(data, usageData) {
|
|
|
128
129
|
log_1.default.log(` Base subscription: ${(0, usageUtils_1.formatCurrency)(data.recurringCents)}`);
|
|
129
130
|
}
|
|
130
131
|
if (data.totalOverageCostCents > 0) {
|
|
131
|
-
log_1.default.log(`
|
|
132
|
+
log_1.default.log(` Additional usage: ${chalk_1.default.yellow((0, usageUtils_1.formatCurrency)(data.totalOverageCostCents))}`);
|
|
132
133
|
if (data.builds.overageCostCents > 0) {
|
|
133
|
-
log_1.default.log(`
|
|
134
|
+
log_1.default.log(` Builds: ${(0, usageUtils_1.formatCurrency)(data.builds.overageCostCents)}`);
|
|
134
135
|
// Show breakdown by worker size
|
|
135
136
|
for (const overage of data.builds.overagesByWorkerSize) {
|
|
136
137
|
const platformName = overage.platform === generated_1.AppPlatform.Ios ? 'iOS' : 'Android';
|
|
@@ -139,7 +140,7 @@ function displayUsage(data, usageData) {
|
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
if (data.updates.overageCostCents > 0) {
|
|
142
|
-
log_1.default.log(`
|
|
143
|
+
log_1.default.log(` Updates: ${(0, usageUtils_1.formatCurrency)(data.updates.overageCostCents)}`);
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
log_1.default.log(` Estimated bill: ${chalk_1.default.bold((0, usageUtils_1.formatCurrency)(data.estimatedBillCents))}`);
|
|
@@ -39,7 +39,7 @@ const SDK_PACKAGES = [
|
|
|
39
39
|
'expo-device',
|
|
40
40
|
'expo-localization',
|
|
41
41
|
];
|
|
42
|
-
const SESSION_REPLAY_PACKAGE = 'posthog
|
|
42
|
+
const SESSION_REPLAY_PACKAGE = '@posthog/react-native-plugin';
|
|
43
43
|
const CONFIG_PLUGIN = 'posthog-react-native/expo';
|
|
44
44
|
const EAS_POSTHOG_API_KEY_ENV_VAR_NAME = 'EXPO_PUBLIC_POSTHOG_API_KEY';
|
|
45
45
|
const EAS_POSTHOG_HOST_ENV_VAR_NAME = 'EXPO_PUBLIC_POSTHOG_HOST';
|
|
@@ -25,7 +25,7 @@ export default class New extends EasCommand {
|
|
|
25
25
|
path: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
26
26
|
};
|
|
27
27
|
static flags: {
|
|
28
|
-
'package-manager': import("@oclif/core/lib/interfaces").OptionFlag<"npm" | "pnpm" | "
|
|
28
|
+
'package-manager': import("@oclif/core/lib/interfaces").OptionFlag<"npm" | "pnpm" | "yarn" | "bun", import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
29
29
|
};
|
|
30
30
|
static contextDefinition: {
|
|
31
31
|
loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
2
|
export default class SimulatorAvailability extends EasCommand {
|
|
3
3
|
static hidden: boolean;
|
|
4
|
+
static aliases: string[];
|
|
4
5
|
static description: string;
|
|
5
6
|
static flags: {
|
|
6
7
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
@@ -6,9 +6,11 @@ const flags_1 = require("../../commandUtils/flags");
|
|
|
6
6
|
const DeviceRunSessionAvailabilityQuery_1 = require("../../graphql/queries/DeviceRunSessionAvailabilityQuery");
|
|
7
7
|
const log_1 = tslib_1.__importDefault(require("../../log"));
|
|
8
8
|
const ora_1 = require("../../ora");
|
|
9
|
+
const utils_1 = require("../../simulator/utils");
|
|
9
10
|
const json_1 = require("../../utils/json");
|
|
10
11
|
class SimulatorAvailability extends EasCommand_1.default {
|
|
11
12
|
static hidden = true;
|
|
13
|
+
static aliases = ['sim:availability'];
|
|
12
14
|
static description = '[EXPERIMENTAL] check whether EAS Simulator is enabled for the current project account';
|
|
13
15
|
static flags = {
|
|
14
16
|
...flags_1.EasNonInteractiveAndJsonFlags,
|
|
@@ -38,14 +40,19 @@ class SimulatorAvailability extends EasCommand_1.default {
|
|
|
38
40
|
throw err;
|
|
39
41
|
}
|
|
40
42
|
if (jsonFlag) {
|
|
41
|
-
(0, json_1.printJsonOnlyOutput)({
|
|
43
|
+
(0, json_1.printJsonOnlyOutput)({
|
|
44
|
+
available,
|
|
45
|
+
accountName,
|
|
46
|
+
// Only present when gated, so scripts and agents can pass the waitlist link on.
|
|
47
|
+
...(available ? {} : { waitlistUrl: utils_1.EAS_SIMULATOR_WAITLIST_URL }),
|
|
48
|
+
});
|
|
42
49
|
return;
|
|
43
50
|
}
|
|
44
51
|
if (available) {
|
|
45
52
|
log_1.default.log(`✅ EAS Simulator is enabled for ${accountName}.`);
|
|
46
53
|
return;
|
|
47
54
|
}
|
|
48
|
-
log_1.default.log(
|
|
55
|
+
log_1.default.log((0, utils_1.formatSimulatorUnavailableMessage)(accountName));
|
|
49
56
|
}
|
|
50
57
|
}
|
|
51
58
|
exports.default = SimulatorAvailability;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
2
|
export default class SimulatorEvents extends EasCommand {
|
|
3
3
|
static hidden: boolean;
|
|
4
|
+
static aliases: string[];
|
|
4
5
|
static description: string;
|
|
5
6
|
static flags: {
|
|
6
7
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
@@ -15,6 +15,7 @@ const POLL_INTERVAL_MS = 5_000;
|
|
|
15
15
|
const POST_STOP_REFRESH_COUNT = 2;
|
|
16
16
|
class SimulatorEvents extends EasCommand_1.default {
|
|
17
17
|
static hidden = true;
|
|
18
|
+
static aliases = ['sim:events'];
|
|
18
19
|
static description = '[EXPERIMENTAL] show activity events from a remote simulator session';
|
|
19
20
|
static flags = {
|
|
20
21
|
id: core_1.Flags.string({
|
|
@@ -6,6 +6,7 @@ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasComm
|
|
|
6
6
|
const env_1 = require("../../simulator/env");
|
|
7
7
|
class SimulatorExec extends EasCommand_1.default {
|
|
8
8
|
static hidden = true;
|
|
9
|
+
static aliases = ['sim:exec'];
|
|
9
10
|
static description = `[EXPERIMENTAL] execute a simulator command with ${env_1.SIMULATOR_DOTENV_FILE_NAME} environment loaded`;
|
|
10
11
|
static strict = false;
|
|
11
12
|
static contextDefinition = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
2
|
export default class SimulatorGet extends EasCommand {
|
|
3
3
|
static hidden: boolean;
|
|
4
|
+
static aliases: string[];
|
|
4
5
|
static description: string;
|
|
5
6
|
static flags: {
|
|
6
7
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
@@ -16,6 +16,7 @@ const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields
|
|
|
16
16
|
const json_1 = require("../../utils/json");
|
|
17
17
|
class SimulatorGet extends EasCommand_1.default {
|
|
18
18
|
static hidden = true;
|
|
19
|
+
static aliases = ['sim:get'];
|
|
19
20
|
static description = '[EXPERIMENTAL] get info about a remote simulator session on EAS by its simulator session ID';
|
|
20
21
|
static flags = {
|
|
21
22
|
id: core_1.Flags.string({
|
|
@@ -5,9 +5,11 @@ const core_1 = require("@oclif/core");
|
|
|
5
5
|
const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
|
|
6
6
|
const url_1 = require("../../build/utils/url");
|
|
7
7
|
const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
|
|
8
|
+
const errors_1 = require("../../commandUtils/errors");
|
|
8
9
|
const flags_1 = require("../../commandUtils/flags");
|
|
9
10
|
const generated_1 = require("../../graphql/generated");
|
|
10
11
|
const DeviceRunSessionMutation_1 = require("../../graphql/mutations/DeviceRunSessionMutation");
|
|
12
|
+
const DeviceRunSessionAvailabilityQuery_1 = require("../../graphql/queries/DeviceRunSessionAvailabilityQuery");
|
|
11
13
|
const DeviceRunSessionQuery_1 = require("../../graphql/queries/DeviceRunSessionQuery");
|
|
12
14
|
const log_1 = tslib_1.__importStar(require("../../log"));
|
|
13
15
|
const ora_1 = require("../../ora");
|
|
@@ -27,9 +29,9 @@ const APP_PLATFORM_BY_FLAG_VALUE = {
|
|
|
27
29
|
android: generated_1.AppPlatform.Android,
|
|
28
30
|
ios: generated_1.AppPlatform.Ios,
|
|
29
31
|
};
|
|
30
|
-
class
|
|
32
|
+
class Simulator extends EasCommand_1.default {
|
|
31
33
|
static hidden = true;
|
|
32
|
-
static aliases = ['simulator'];
|
|
34
|
+
static aliases = ['simulator:start', 'sim', 'sim:start'];
|
|
33
35
|
static description = '[EXPERIMENTAL] start a remote simulator session on EAS and get instructions to connect to it';
|
|
34
36
|
static flags = {
|
|
35
37
|
platform: core_1.Flags.option({
|
|
@@ -70,14 +72,23 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
70
72
|
...this.ContextOptions.LoggedIn,
|
|
71
73
|
};
|
|
72
74
|
async runAsync() {
|
|
73
|
-
const { flags } = await this.parse(
|
|
75
|
+
const { flags } = await this.parse(Simulator);
|
|
74
76
|
const { json: jsonFlag, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
|
|
75
77
|
if (jsonFlag) {
|
|
76
78
|
(0, json_1.enableJsonOutput)();
|
|
77
79
|
}
|
|
78
|
-
const { projectId, projectDir, loggedIn: { graphqlClient }, } = await this.getContextAsync(
|
|
80
|
+
const { projectId, projectDir, loggedIn: { actor, graphqlClient }, } = await this.getContextAsync(Simulator, {
|
|
79
81
|
nonInteractive,
|
|
80
82
|
});
|
|
83
|
+
// The server would reject the session anyway, but check the gate first so gated
|
|
84
|
+
// accounts get the waitlist link instead of a generic permission error. Expo admins
|
|
85
|
+
// skip the check so they can work on any account and let the server decide.
|
|
86
|
+
if (!actor.isExpoAdmin) {
|
|
87
|
+
const { accountName, available } = await DeviceRunSessionAvailabilityQuery_1.DeviceRunSessionAvailabilityQuery.byAppIdAsync(graphqlClient, projectId);
|
|
88
|
+
if (!available) {
|
|
89
|
+
throw new errors_1.EasCommandError((0, utils_1.formatSimulatorUnavailableMessage)(accountName));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
81
92
|
// The server rejects blank names, so trim here and treat a whitespace-only
|
|
82
93
|
// --name as if it had been omitted rather than surfacing a validation error.
|
|
83
94
|
const name = flags.name?.trim() || undefined;
|
|
@@ -96,6 +107,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
96
107
|
const createSpinner = (0, ora_1.ora)('🚀 Creating simulator session').start();
|
|
97
108
|
let deviceRunSessionId;
|
|
98
109
|
let deviceRunSessionUrl;
|
|
110
|
+
let sessionInterrupt;
|
|
99
111
|
try {
|
|
100
112
|
const session = await DeviceRunSessionMutation_1.DeviceRunSessionMutation.createDeviceRunSessionAsync(graphqlClient, {
|
|
101
113
|
appId: projectId,
|
|
@@ -108,6 +120,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
108
120
|
deviceRunSessionId = session.id;
|
|
109
121
|
(0, nullthrows_1.default)(session.turtleJobRun?.id, 'Expected simulator session to start');
|
|
110
122
|
deviceRunSessionUrl = (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, deviceRunSessionId);
|
|
123
|
+
sessionInterrupt = registerSessionInterrupt(deviceRunSessionId);
|
|
111
124
|
const simulatorEnvWritten = !jsonFlag && flags['out-config-type'] === OUT_CONFIG_TYPE_VALUES.Dotenv
|
|
112
125
|
? await writeSimulatorEnvSafelyAsync(projectDir, {
|
|
113
126
|
[env_1.EAS_SIMULATOR_SESSION_ID]: deviceRunSessionId,
|
|
@@ -117,14 +130,21 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
117
130
|
}
|
|
118
131
|
catch (err) {
|
|
119
132
|
createSpinner.fail('Failed to create simulator session');
|
|
133
|
+
sessionInterrupt?.dispose();
|
|
120
134
|
throw err;
|
|
121
135
|
}
|
|
122
136
|
const pollSpinner = (0, ora_1.ora)(`⏳ Waiting for ${flags.type} session to be ready`).start();
|
|
123
137
|
const deadline = Date.now() + POLL_TIMEOUT_MS;
|
|
124
138
|
let remoteConfig;
|
|
125
139
|
try {
|
|
126
|
-
while (Date.now() < deadline) {
|
|
127
|
-
const session = await
|
|
140
|
+
while (!sessionInterrupt.signal.aborted && Date.now() < deadline) {
|
|
141
|
+
const session = await Promise.race([
|
|
142
|
+
DeviceRunSessionQuery_1.DeviceRunSessionQuery.byIdAsync(graphqlClient, deviceRunSessionId),
|
|
143
|
+
sessionInterrupt.abortPromise,
|
|
144
|
+
]);
|
|
145
|
+
if (!session) {
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
128
148
|
if (session.status === generated_1.DeviceRunSessionStatus.Errored ||
|
|
129
149
|
session.status === generated_1.DeviceRunSessionStatus.Stopped) {
|
|
130
150
|
throw new Error(`Simulator session ${deviceRunSessionId} ${session.status.toLowerCase()} before the ${flags.type} session was ready. ${(0, log_1.link)(deviceRunSessionUrl)}`);
|
|
@@ -140,17 +160,29 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
140
160
|
pollSpinner.succeed(`🎉 ${flags.type} session is ready`);
|
|
141
161
|
break;
|
|
142
162
|
}
|
|
143
|
-
await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS);
|
|
163
|
+
await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS, sessionInterrupt.signal);
|
|
144
164
|
}
|
|
145
165
|
}
|
|
146
166
|
catch (err) {
|
|
147
167
|
pollSpinner.fail(`Failed while polling for ${flags.type} session to be ready`);
|
|
148
168
|
await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
169
|
+
sessionInterrupt.dispose();
|
|
149
170
|
throw err;
|
|
150
171
|
}
|
|
172
|
+
if (sessionInterrupt.signal.aborted) {
|
|
173
|
+
await stopDeviceRunSessionAfterInterruptAsync({
|
|
174
|
+
graphqlClient,
|
|
175
|
+
deviceRunSessionId,
|
|
176
|
+
projectDir,
|
|
177
|
+
spinner: pollSpinner,
|
|
178
|
+
sessionInterrupt,
|
|
179
|
+
});
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
151
182
|
if (!remoteConfig) {
|
|
152
183
|
pollSpinner.fail(`Timed out waiting for ${flags.type} session to be ready`);
|
|
153
184
|
await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
185
|
+
sessionInterrupt.dispose();
|
|
154
186
|
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)}`);
|
|
155
187
|
}
|
|
156
188
|
if (flags['out-config-type'] === OUT_CONFIG_TYPE_VALUES.Dotenv) {
|
|
@@ -159,7 +191,18 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
159
191
|
[env_1.EAS_SIMULATOR_SESSION_ID]: deviceRunSessionId,
|
|
160
192
|
});
|
|
161
193
|
}
|
|
194
|
+
if (sessionInterrupt.signal.aborted) {
|
|
195
|
+
await stopDeviceRunSessionAfterInterruptAsync({
|
|
196
|
+
graphqlClient,
|
|
197
|
+
deviceRunSessionId,
|
|
198
|
+
projectDir,
|
|
199
|
+
spinner: pollSpinner,
|
|
200
|
+
sessionInterrupt,
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
162
204
|
if (jsonFlag) {
|
|
205
|
+
sessionInterrupt.dispose();
|
|
163
206
|
(0, json_1.printJsonOnlyOutput)({
|
|
164
207
|
id: deviceRunSessionId,
|
|
165
208
|
name,
|
|
@@ -173,6 +216,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
173
216
|
log_1.default.log((0, utils_1.formatRemoteSessionInstructions)(remoteConfig, flags['out-config-type']));
|
|
174
217
|
log_1.default.newLine();
|
|
175
218
|
if (nonInteractive) {
|
|
219
|
+
sessionInterrupt.dispose();
|
|
176
220
|
log_1.default.log(`When you are done, stop the session with: eas simulator:stop --id ${deviceRunSessionId}`);
|
|
177
221
|
return;
|
|
178
222
|
}
|
|
@@ -181,10 +225,11 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
181
225
|
deviceRunSessionId,
|
|
182
226
|
deviceRunSessionUrl,
|
|
183
227
|
projectDir,
|
|
228
|
+
sessionInterrupt,
|
|
184
229
|
});
|
|
185
230
|
}
|
|
186
231
|
}
|
|
187
|
-
exports.default =
|
|
232
|
+
exports.default = Simulator;
|
|
188
233
|
async function resolvePlatformAsync(platform, nonInteractive) {
|
|
189
234
|
if (platform) {
|
|
190
235
|
return APP_PLATFORM_BY_FLAG_VALUE[platform];
|
|
@@ -213,25 +258,9 @@ async function writeSimulatorEnvSafelyAsync(projectDir, environmentVariables) {
|
|
|
213
258
|
return false;
|
|
214
259
|
}
|
|
215
260
|
}
|
|
216
|
-
async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessionId, deviceRunSessionUrl, projectDir, }) {
|
|
261
|
+
async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessionId, deviceRunSessionUrl, projectDir, sessionInterrupt, }) {
|
|
217
262
|
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();
|
|
218
|
-
const
|
|
219
|
-
const { signal } = abortController;
|
|
220
|
-
const abortPromise = new Promise(resolve => {
|
|
221
|
-
signal.addEventListener('abort', () => {
|
|
222
|
-
resolve();
|
|
223
|
-
}, { once: true });
|
|
224
|
-
});
|
|
225
|
-
const sigintHandler = () => {
|
|
226
|
-
if (signal.aborted) {
|
|
227
|
-
// Force exit on a second Ctrl+C in case cleanup is hanging. The session may still be
|
|
228
|
-
// running on EAS, so tell the user how to make sure it gets terminated.
|
|
229
|
-
spinner.fail(`Aborted before the simulator session could be stopped. Run \`eas simulator:stop --id ${deviceRunSessionId}\` to terminate it and avoid unexpected charges.`);
|
|
230
|
-
process.exit(130);
|
|
231
|
-
}
|
|
232
|
-
abortController.abort();
|
|
233
|
-
};
|
|
234
|
-
process.on('SIGINT', sigintHandler);
|
|
263
|
+
const { signal } = sessionInterrupt;
|
|
235
264
|
try {
|
|
236
265
|
while (!signal.aborted) {
|
|
237
266
|
let session;
|
|
@@ -240,7 +269,7 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
|
|
|
240
269
|
}
|
|
241
270
|
catch (err) {
|
|
242
271
|
log_1.default.debug(`Failed to poll simulator session: ${err instanceof Error ? err.message : String(err)}`);
|
|
243
|
-
await
|
|
272
|
+
await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS, signal);
|
|
244
273
|
continue;
|
|
245
274
|
}
|
|
246
275
|
const jobRunStatus = session.turtleJobRun?.status;
|
|
@@ -256,8 +285,48 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
|
|
|
256
285
|
await resetSimulatorEnvVerboseAsync(projectDir);
|
|
257
286
|
return;
|
|
258
287
|
}
|
|
259
|
-
await
|
|
288
|
+
await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS, signal);
|
|
289
|
+
}
|
|
290
|
+
spinner.text = 'Stopping simulator session...';
|
|
291
|
+
const stopped = await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
292
|
+
if (stopped) {
|
|
293
|
+
spinner.succeed('Simulator session stopped');
|
|
294
|
+
await resetSimulatorEnvVerboseAsync(projectDir);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
spinner.fail(`Could not confirm the simulator session was stopped. Run \`eas simulator:stop --id ${deviceRunSessionId}\` to terminate it and avoid unexpected charges.`);
|
|
260
298
|
}
|
|
299
|
+
}
|
|
300
|
+
finally {
|
|
301
|
+
sessionInterrupt.dispose();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function registerSessionInterrupt(deviceRunSessionId) {
|
|
305
|
+
const abortController = new AbortController();
|
|
306
|
+
const { signal } = abortController;
|
|
307
|
+
const abortPromise = new Promise(resolve => {
|
|
308
|
+
signal.addEventListener('abort', () => {
|
|
309
|
+
resolve();
|
|
310
|
+
}, { once: true });
|
|
311
|
+
});
|
|
312
|
+
const sigintHandler = () => {
|
|
313
|
+
if (signal.aborted) {
|
|
314
|
+
// Force exit on a second Ctrl+C in case cleanup is hanging. The session may still be
|
|
315
|
+
// running on EAS, so tell the user how to make sure it gets terminated.
|
|
316
|
+
log_1.default.error(`Aborted before the simulator session could be stopped. Run \`eas simulator:stop --id ${deviceRunSessionId}\` to terminate it and avoid unexpected charges.`);
|
|
317
|
+
process.exit(130);
|
|
318
|
+
}
|
|
319
|
+
abortController.abort();
|
|
320
|
+
};
|
|
321
|
+
process.on('SIGINT', sigintHandler);
|
|
322
|
+
return {
|
|
323
|
+
signal,
|
|
324
|
+
abortPromise,
|
|
325
|
+
dispose: () => process.removeListener('SIGINT', sigintHandler),
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
async function stopDeviceRunSessionAfterInterruptAsync({ graphqlClient, deviceRunSessionId, projectDir, spinner, sessionInterrupt, }) {
|
|
329
|
+
try {
|
|
261
330
|
spinner.text = 'Stopping simulator session...';
|
|
262
331
|
const stopped = await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
263
332
|
if (stopped) {
|
|
@@ -269,8 +338,9 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
|
|
|
269
338
|
}
|
|
270
339
|
}
|
|
271
340
|
finally {
|
|
272
|
-
|
|
341
|
+
sessionInterrupt.dispose();
|
|
273
342
|
}
|
|
343
|
+
process.exit(130);
|
|
274
344
|
}
|
|
275
345
|
async function resetSimulatorEnvVerboseAsync(projectDir) {
|
|
276
346
|
try {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
2
|
export default class SimulatorList extends EasCommand {
|
|
3
3
|
static hidden: boolean;
|
|
4
|
+
static aliases: string[];
|
|
4
5
|
static description: string;
|
|
5
6
|
static flags: {
|
|
6
7
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
@@ -8,6 +9,7 @@ export default class SimulatorList extends EasCommand {
|
|
|
8
9
|
status: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
10
|
type: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
11
|
platform: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
13
|
limit: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
|
|
12
14
|
after: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
15
|
};
|