eas-cli 21.4.0 → 21.5.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 +238 -116
- package/build/build/local.js +64 -7
- package/build/commandUtils/workflow/compositeFunctions.d.ts +1 -0
- package/build/commandUtils/workflow/compositeFunctions.js +64 -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/start.js +83 -24
- 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/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 +1064 -564
- package/package.json +5 -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,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateWorkflowLocalCompositeFunctionsAsync = validateWorkflowLocalCompositeFunctionsAsync;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
6
|
+
const steps_1 = require("@expo/steps");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
|
+
const YAML = tslib_1.__importStar(require("yaml"));
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const log_1 = tslib_1.__importDefault(require("../../log"));
|
|
12
|
+
const COMPOSITE_FUNCTION_FILE_EXTENSIONS = ['yml', 'yaml'];
|
|
13
|
+
async function validateWorkflowLocalCompositeFunctionsAsync(parsedYaml, projectDir) {
|
|
14
|
+
await (0, steps_1.buildCompositeFunctionCatalogFromStepsAsync)({
|
|
15
|
+
rootSteps: stepsFromWorkflow(parsedYaml),
|
|
16
|
+
loadCompositeFunction: compositeFunctionPath => loadLocalCompositeFunctionConfigAsync(projectDir, compositeFunctionPath),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async function loadLocalCompositeFunctionConfigAsync(projectDir, compositeFunctionPath) {
|
|
20
|
+
const resolvedPath = (0, steps_1.resolveLocalCompositeFunctionPath)(projectDir, compositeFunctionPath);
|
|
21
|
+
for (const ext of COMPOSITE_FUNCTION_FILE_EXTENSIONS) {
|
|
22
|
+
const config = await readCompositeFunctionConfigFileAsync(compositeFunctionPath, path_1.default.join(resolvedPath, `function.${ext}`));
|
|
23
|
+
if (config) {
|
|
24
|
+
log_1.default.debug(`Validated local composite function "${compositeFunctionPath}"`);
|
|
25
|
+
return config;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`Local composite function "${compositeFunctionPath}" was referenced by a step but no such composite function exists. A local composite function is resolved from a "function.yml" (or "function.yaml") file at the referenced path relative to the EAS project root (e.g. "uses: ${compositeFunctionPath}" resolves "${compositeFunctionPath}/function.yml"). The recommended convention is to keep composite functions under ".eas/functions/<name>".`);
|
|
29
|
+
}
|
|
30
|
+
async function readCompositeFunctionConfigFileAsync(compositeFunctionPath, absolutePath) {
|
|
31
|
+
let rawContents;
|
|
32
|
+
try {
|
|
33
|
+
rawContents = await fs_1.promises.readFile(absolutePath, 'utf-8');
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
if (err?.code === 'ENOENT') {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`Failed to read local composite function "${compositeFunctionPath}" from ${absolutePath}`, {
|
|
40
|
+
cause: err,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
let parsed;
|
|
44
|
+
try {
|
|
45
|
+
parsed = YAML.parse(rawContents);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
throw new Error(`Failed to parse local composite function "${compositeFunctionPath}" YAML at ${absolutePath}`, {
|
|
49
|
+
cause: err,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const result = eas_build_job_1.CompositeFunctionConfigZ.safeParse(parsed);
|
|
53
|
+
if (!result.success) {
|
|
54
|
+
throw new Error(`Invalid composite function "${compositeFunctionPath}": ${zod_1.z.prettifyError(result.error)}`);
|
|
55
|
+
}
|
|
56
|
+
return result.data;
|
|
57
|
+
}
|
|
58
|
+
function stepsFromWorkflow(parsedYaml) {
|
|
59
|
+
const jobs = parsedYaml?.jobs;
|
|
60
|
+
if (!jobs || typeof jobs !== 'object') {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
return Object.values(jobs).flatMap((job) => (Array.isArray(job?.steps) ? job.steps : []));
|
|
64
|
+
}
|
|
@@ -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;
|
|
@@ -96,6 +96,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
96
96
|
const createSpinner = (0, ora_1.ora)('🚀 Creating simulator session').start();
|
|
97
97
|
let deviceRunSessionId;
|
|
98
98
|
let deviceRunSessionUrl;
|
|
99
|
+
let sessionInterrupt;
|
|
99
100
|
try {
|
|
100
101
|
const session = await DeviceRunSessionMutation_1.DeviceRunSessionMutation.createDeviceRunSessionAsync(graphqlClient, {
|
|
101
102
|
appId: projectId,
|
|
@@ -108,6 +109,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
108
109
|
deviceRunSessionId = session.id;
|
|
109
110
|
(0, nullthrows_1.default)(session.turtleJobRun?.id, 'Expected simulator session to start');
|
|
110
111
|
deviceRunSessionUrl = (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, deviceRunSessionId);
|
|
112
|
+
sessionInterrupt = registerSessionInterrupt(deviceRunSessionId);
|
|
111
113
|
const simulatorEnvWritten = !jsonFlag && flags['out-config-type'] === OUT_CONFIG_TYPE_VALUES.Dotenv
|
|
112
114
|
? await writeSimulatorEnvSafelyAsync(projectDir, {
|
|
113
115
|
[env_1.EAS_SIMULATOR_SESSION_ID]: deviceRunSessionId,
|
|
@@ -117,14 +119,21 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
117
119
|
}
|
|
118
120
|
catch (err) {
|
|
119
121
|
createSpinner.fail('Failed to create simulator session');
|
|
122
|
+
sessionInterrupt?.dispose();
|
|
120
123
|
throw err;
|
|
121
124
|
}
|
|
122
125
|
const pollSpinner = (0, ora_1.ora)(`⏳ Waiting for ${flags.type} session to be ready`).start();
|
|
123
126
|
const deadline = Date.now() + POLL_TIMEOUT_MS;
|
|
124
127
|
let remoteConfig;
|
|
125
128
|
try {
|
|
126
|
-
while (Date.now() < deadline) {
|
|
127
|
-
const session = await
|
|
129
|
+
while (!sessionInterrupt.signal.aborted && Date.now() < deadline) {
|
|
130
|
+
const session = await Promise.race([
|
|
131
|
+
DeviceRunSessionQuery_1.DeviceRunSessionQuery.byIdAsync(graphqlClient, deviceRunSessionId),
|
|
132
|
+
sessionInterrupt.abortPromise,
|
|
133
|
+
]);
|
|
134
|
+
if (!session) {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
128
137
|
if (session.status === generated_1.DeviceRunSessionStatus.Errored ||
|
|
129
138
|
session.status === generated_1.DeviceRunSessionStatus.Stopped) {
|
|
130
139
|
throw new Error(`Simulator session ${deviceRunSessionId} ${session.status.toLowerCase()} before the ${flags.type} session was ready. ${(0, log_1.link)(deviceRunSessionUrl)}`);
|
|
@@ -140,17 +149,29 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
140
149
|
pollSpinner.succeed(`🎉 ${flags.type} session is ready`);
|
|
141
150
|
break;
|
|
142
151
|
}
|
|
143
|
-
await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS);
|
|
152
|
+
await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS, sessionInterrupt.signal);
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
catch (err) {
|
|
147
156
|
pollSpinner.fail(`Failed while polling for ${flags.type} session to be ready`);
|
|
148
157
|
await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
158
|
+
sessionInterrupt.dispose();
|
|
149
159
|
throw err;
|
|
150
160
|
}
|
|
161
|
+
if (sessionInterrupt.signal.aborted) {
|
|
162
|
+
await stopDeviceRunSessionAfterInterruptAsync({
|
|
163
|
+
graphqlClient,
|
|
164
|
+
deviceRunSessionId,
|
|
165
|
+
projectDir,
|
|
166
|
+
spinner: pollSpinner,
|
|
167
|
+
sessionInterrupt,
|
|
168
|
+
});
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
151
171
|
if (!remoteConfig) {
|
|
152
172
|
pollSpinner.fail(`Timed out waiting for ${flags.type} session to be ready`);
|
|
153
173
|
await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
174
|
+
sessionInterrupt.dispose();
|
|
154
175
|
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
176
|
}
|
|
156
177
|
if (flags['out-config-type'] === OUT_CONFIG_TYPE_VALUES.Dotenv) {
|
|
@@ -159,7 +180,18 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
159
180
|
[env_1.EAS_SIMULATOR_SESSION_ID]: deviceRunSessionId,
|
|
160
181
|
});
|
|
161
182
|
}
|
|
183
|
+
if (sessionInterrupt.signal.aborted) {
|
|
184
|
+
await stopDeviceRunSessionAfterInterruptAsync({
|
|
185
|
+
graphqlClient,
|
|
186
|
+
deviceRunSessionId,
|
|
187
|
+
projectDir,
|
|
188
|
+
spinner: pollSpinner,
|
|
189
|
+
sessionInterrupt,
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
162
193
|
if (jsonFlag) {
|
|
194
|
+
sessionInterrupt.dispose();
|
|
163
195
|
(0, json_1.printJsonOnlyOutput)({
|
|
164
196
|
id: deviceRunSessionId,
|
|
165
197
|
name,
|
|
@@ -173,6 +205,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
173
205
|
log_1.default.log((0, utils_1.formatRemoteSessionInstructions)(remoteConfig, flags['out-config-type']));
|
|
174
206
|
log_1.default.newLine();
|
|
175
207
|
if (nonInteractive) {
|
|
208
|
+
sessionInterrupt.dispose();
|
|
176
209
|
log_1.default.log(`When you are done, stop the session with: eas simulator:stop --id ${deviceRunSessionId}`);
|
|
177
210
|
return;
|
|
178
211
|
}
|
|
@@ -181,6 +214,7 @@ class SimulatorStart extends EasCommand_1.default {
|
|
|
181
214
|
deviceRunSessionId,
|
|
182
215
|
deviceRunSessionUrl,
|
|
183
216
|
projectDir,
|
|
217
|
+
sessionInterrupt,
|
|
184
218
|
});
|
|
185
219
|
}
|
|
186
220
|
}
|
|
@@ -213,25 +247,9 @@ async function writeSimulatorEnvSafelyAsync(projectDir, environmentVariables) {
|
|
|
213
247
|
return false;
|
|
214
248
|
}
|
|
215
249
|
}
|
|
216
|
-
async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessionId, deviceRunSessionUrl, projectDir, }) {
|
|
250
|
+
async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessionId, deviceRunSessionUrl, projectDir, sessionInterrupt, }) {
|
|
217
251
|
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);
|
|
252
|
+
const { signal } = sessionInterrupt;
|
|
235
253
|
try {
|
|
236
254
|
while (!signal.aborted) {
|
|
237
255
|
let session;
|
|
@@ -240,7 +258,7 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
|
|
|
240
258
|
}
|
|
241
259
|
catch (err) {
|
|
242
260
|
log_1.default.debug(`Failed to poll simulator session: ${err instanceof Error ? err.message : String(err)}`);
|
|
243
|
-
await
|
|
261
|
+
await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS, signal);
|
|
244
262
|
continue;
|
|
245
263
|
}
|
|
246
264
|
const jobRunStatus = session.turtleJobRun?.status;
|
|
@@ -256,8 +274,48 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
|
|
|
256
274
|
await resetSimulatorEnvVerboseAsync(projectDir);
|
|
257
275
|
return;
|
|
258
276
|
}
|
|
259
|
-
await
|
|
277
|
+
await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS, signal);
|
|
278
|
+
}
|
|
279
|
+
spinner.text = 'Stopping simulator session...';
|
|
280
|
+
const stopped = await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
281
|
+
if (stopped) {
|
|
282
|
+
spinner.succeed('Simulator session stopped');
|
|
283
|
+
await resetSimulatorEnvVerboseAsync(projectDir);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
spinner.fail(`Could not confirm the simulator session was stopped. Run \`eas simulator:stop --id ${deviceRunSessionId}\` to terminate it and avoid unexpected charges.`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
finally {
|
|
290
|
+
sessionInterrupt.dispose();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function registerSessionInterrupt(deviceRunSessionId) {
|
|
294
|
+
const abortController = new AbortController();
|
|
295
|
+
const { signal } = abortController;
|
|
296
|
+
const abortPromise = new Promise(resolve => {
|
|
297
|
+
signal.addEventListener('abort', () => {
|
|
298
|
+
resolve();
|
|
299
|
+
}, { once: true });
|
|
300
|
+
});
|
|
301
|
+
const sigintHandler = () => {
|
|
302
|
+
if (signal.aborted) {
|
|
303
|
+
// Force exit on a second Ctrl+C in case cleanup is hanging. The session may still be
|
|
304
|
+
// running on EAS, so tell the user how to make sure it gets terminated.
|
|
305
|
+
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.`);
|
|
306
|
+
process.exit(130);
|
|
260
307
|
}
|
|
308
|
+
abortController.abort();
|
|
309
|
+
};
|
|
310
|
+
process.on('SIGINT', sigintHandler);
|
|
311
|
+
return {
|
|
312
|
+
signal,
|
|
313
|
+
abortPromise,
|
|
314
|
+
dispose: () => process.removeListener('SIGINT', sigintHandler),
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
async function stopDeviceRunSessionAfterInterruptAsync({ graphqlClient, deviceRunSessionId, projectDir, spinner, sessionInterrupt, }) {
|
|
318
|
+
try {
|
|
261
319
|
spinner.text = 'Stopping simulator session...';
|
|
262
320
|
const stopped = await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
|
|
263
321
|
if (stopped) {
|
|
@@ -269,8 +327,9 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
|
|
|
269
327
|
}
|
|
270
328
|
}
|
|
271
329
|
finally {
|
|
272
|
-
|
|
330
|
+
sessionInterrupt.dispose();
|
|
273
331
|
}
|
|
332
|
+
process.exit(130);
|
|
274
333
|
}
|
|
275
334
|
async function resetSimulatorEnvVerboseAsync(projectDir) {
|
|
276
335
|
try {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
|
+
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
|
3
|
+
import { AppPlatform } from '../../graphql/generated';
|
|
4
|
+
import { RequestedPlatform } from '../../platform';
|
|
5
|
+
export declare function selectSubmissionToCancelAsync(graphqlClient: ExpoGraphqlClient, projectId: string, projectDisplayName: string, platform?: AppPlatform): Promise<string | null>;
|
|
6
|
+
export default class SubmissionCancel extends EasCommand {
|
|
7
|
+
static description: string;
|
|
8
|
+
static args: {
|
|
9
|
+
SUBMISSION_ID: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
10
|
+
};
|
|
11
|
+
static flags: {
|
|
12
|
+
platform: import("@oclif/core/lib/interfaces").OptionFlag<RequestedPlatform | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
static contextDefinition: {
|
|
16
|
+
loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
|
|
17
|
+
projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
|
|
18
|
+
};
|
|
19
|
+
runAsync(): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectSubmissionToCancelAsync = selectSubmissionToCancelAsync;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
|
|
7
|
+
const flags_1 = require("../../commandUtils/flags");
|
|
8
|
+
const generated_1 = require("../../graphql/generated");
|
|
9
|
+
const SubmissionMutation_1 = require("../../graphql/mutations/SubmissionMutation");
|
|
10
|
+
const log_1 = tslib_1.__importDefault(require("../../log"));
|
|
11
|
+
const ora_1 = require("../../ora");
|
|
12
|
+
const platform_1 = require("../../platform");
|
|
13
|
+
const projectUtils_1 = require("../../project/projectUtils");
|
|
14
|
+
const prompts_1 = require("../../prompts");
|
|
15
|
+
const queries_1 = require("../../submit/queries");
|
|
16
|
+
const CANCELLABLE_STATUSES = [
|
|
17
|
+
generated_1.SubmissionStatus.AwaitingBuild,
|
|
18
|
+
generated_1.SubmissionStatus.InQueue,
|
|
19
|
+
generated_1.SubmissionStatus.InProgress,
|
|
20
|
+
];
|
|
21
|
+
async function selectSubmissionToCancelAsync(graphqlClient, projectId, projectDisplayName, platform) {
|
|
22
|
+
const spinner = (0, ora_1.ora)().start('Fetching the uncompleted submissions…');
|
|
23
|
+
let cancellableSubmissions;
|
|
24
|
+
try {
|
|
25
|
+
cancellableSubmissions = await (0, queries_1.getRecentSubmissionsWithStatusesAsync)(graphqlClient, {
|
|
26
|
+
projectId,
|
|
27
|
+
platform,
|
|
28
|
+
statuses: CANCELLABLE_STATUSES,
|
|
29
|
+
});
|
|
30
|
+
spinner.stop();
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
spinner.fail(`Something went wrong and we couldn't fetch the submissions for the project ${projectDisplayName}.`);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
if (cancellableSubmissions.length === 0) {
|
|
37
|
+
log_1.default.warn(`We couldn't find any uncompleted submissions for the project ${projectDisplayName}.`);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const submissionId = await (0, prompts_1.selectAsync)('Which submission do you want to cancel?', cancellableSubmissions.map(submission => ({
|
|
42
|
+
title: (0, queries_1.formatSubmissionChoice)(submission),
|
|
43
|
+
value: submission.id,
|
|
44
|
+
})));
|
|
45
|
+
return (await (0, prompts_1.confirmAsync)({
|
|
46
|
+
message: 'Are you sure you want to cancel it?',
|
|
47
|
+
}))
|
|
48
|
+
? submissionId
|
|
49
|
+
: null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class SubmissionCancel extends EasCommand_1.default {
|
|
53
|
+
static description = 'cancel a submission';
|
|
54
|
+
static args = {
|
|
55
|
+
SUBMISSION_ID: core_1.Args.string({}),
|
|
56
|
+
};
|
|
57
|
+
static flags = {
|
|
58
|
+
...flags_1.EASNonInteractiveFlag,
|
|
59
|
+
platform: core_1.Flags.option({
|
|
60
|
+
char: 'p',
|
|
61
|
+
description: 'Filter submissions by the platform if submission ID is not provided',
|
|
62
|
+
options: Object.values(platform_1.RequestedPlatform),
|
|
63
|
+
})(),
|
|
64
|
+
};
|
|
65
|
+
static contextDefinition = {
|
|
66
|
+
...this.ContextOptions.ProjectId,
|
|
67
|
+
...this.ContextOptions.LoggedIn,
|
|
68
|
+
};
|
|
69
|
+
async runAsync() {
|
|
70
|
+
const { args: { SUBMISSION_ID: submissionIdFromArg }, flags: { 'non-interactive': nonInteractive, platform }, } = await this.parse(SubmissionCancel);
|
|
71
|
+
if (submissionIdFromArg && platform) {
|
|
72
|
+
throw new Error('Submission ID cannot be used together with the platform flag. The flag is used to filter the list of submissions when not providing the submission ID');
|
|
73
|
+
}
|
|
74
|
+
if (!submissionIdFromArg && nonInteractive) {
|
|
75
|
+
throw new Error('Submission ID must be provided in non-interactive mode');
|
|
76
|
+
}
|
|
77
|
+
const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(SubmissionCancel, {
|
|
78
|
+
nonInteractive,
|
|
79
|
+
});
|
|
80
|
+
let submissionId = submissionIdFromArg ?? null;
|
|
81
|
+
if (!submissionId) {
|
|
82
|
+
const displayName = await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId);
|
|
83
|
+
submissionId = await selectSubmissionToCancelAsync(graphqlClient, projectId, displayName, toAppPlatform(platform));
|
|
84
|
+
if (!submissionId) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const spinner = (0, ora_1.ora)().start('Canceling the submission…');
|
|
89
|
+
try {
|
|
90
|
+
const { status } = await SubmissionMutation_1.SubmissionMutation.cancelSubmissionAsync(graphqlClient, submissionId);
|
|
91
|
+
if (status === generated_1.SubmissionStatus.Canceled) {
|
|
92
|
+
spinner.succeed('Submission canceled');
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
spinner.text = 'Submission is already completed';
|
|
96
|
+
spinner.stopAndPersist();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
spinner.fail(`Something went wrong and we couldn't cancel your submission ${submissionId}`);
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.default = SubmissionCancel;
|
|
106
|
+
const toAppPlatform = (requestedPlatform) => {
|
|
107
|
+
if (!requestedPlatform || requestedPlatform === platform_1.RequestedPlatform.All) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
else if (requestedPlatform === platform_1.RequestedPlatform.Android) {
|
|
111
|
+
return generated_1.AppPlatform.Android;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return generated_1.AppPlatform.Ios;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
|
+
import { RequestedPlatform } from '../../platform';
|
|
3
|
+
declare enum SubmissionStatus {
|
|
4
|
+
AWAITING_BUILD = "awaiting-build",
|
|
5
|
+
IN_QUEUE = "in-queue",
|
|
6
|
+
IN_PROGRESS = "in-progress",
|
|
7
|
+
FINISHED = "finished",
|
|
8
|
+
ERRORED = "errored",
|
|
9
|
+
CANCELED = "canceled"
|
|
10
|
+
}
|
|
11
|
+
export default class SubmissionList extends EasCommand {
|
|
12
|
+
static description: string;
|
|
13
|
+
static flags: {
|
|
14
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
limit: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
|
|
17
|
+
offset: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
18
|
+
platform: import("@oclif/core/lib/interfaces").OptionFlag<RequestedPlatform | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
19
|
+
status: import("@oclif/core/lib/interfaces").OptionFlag<SubmissionStatus | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
20
|
+
};
|
|
21
|
+
static contextDefinition: {
|
|
22
|
+
loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
|
|
23
|
+
projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
|
|
24
|
+
};
|
|
25
|
+
runAsync(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|