eas-cli 26.0.0 → 27.1.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 +216 -146
- package/build/build/build.js +6 -0
- package/build/build/errors.d.ts +2 -0
- package/build/build/errors.js +4 -1
- package/build/build/evaluateConfigWithEnvVarsAsync.js +1 -3
- package/build/build/utils/expoTokenRole.d.ts +4 -0
- package/build/build/utils/expoTokenRole.js +14 -0
- package/build/commandUtils/EasCommand.js +3 -3
- package/build/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.js +2 -1
- package/build/commandUtils/workflow/referencedFiles.d.ts +6 -0
- package/build/commandUtils/workflow/referencedFiles.js +63 -0
- package/build/commandUtils/workflow/types.d.ts +1 -1
- package/build/commandUtils/workflow/utils.js +34 -5
- package/build/commands/account/login.js +6 -0
- package/build/commands/account/view.d.ts +0 -7
- package/build/commands/account/view.js +4 -74
- package/build/commands/simulator/control.js +41 -6
- package/build/commands/simulator/logs.d.ts +22 -0
- package/build/commands/simulator/logs.js +188 -0
- package/build/commands/workflow/cancel.js +9 -20
- package/build/commands/workflow/run.js +9 -0
- package/build/commands/workflow/runs.js +1 -1
- package/build/graphql/generated.d.ts +294 -5
- package/build/graphql/generated.js +25 -4
- package/build/graphql/mutations/WorkflowRevisionMutation.d.ts +3 -2
- package/build/graphql/mutations/WorkflowRevisionMutation.js +12 -3
- package/build/graphql/queries/WorkflowRunQuery.js +6 -0
- package/build/graphql/types/WorkflowRun.js +1 -0
- package/build/help.js +13 -6
- package/build/log.d.ts +2 -0
- package/build/log.js +10 -0
- package/build/project/projectStatus.js +1 -0
- package/build/simulator/artifacts.d.ts +9 -0
- package/build/simulator/artifacts.js +97 -0
- package/build/simulator/download.d.ts +2 -0
- package/build/simulator/download.js +57 -0
- package/build/simulator/events.js +2 -10
- package/build/simulator/preview.d.ts +26 -0
- package/build/simulator/preview.js +156 -0
- package/build/simulator/utils.d.ts +5 -0
- package/build/simulator/utils.js +42 -0
- package/build/user/accountPermissions.d.ts +11 -0
- package/build/user/accountPermissions.js +89 -0
- package/oclif.manifest.json +544 -396
- package/package.json +6 -6
package/build/build/build.js
CHANGED
|
@@ -17,6 +17,7 @@ const graphql_1 = require("./graphql");
|
|
|
17
17
|
const local_1 = require("./local");
|
|
18
18
|
const logs_1 = require("./logs");
|
|
19
19
|
const metadata_1 = require("./metadata");
|
|
20
|
+
const expoTokenRole_1 = require("./utils/expoTokenRole");
|
|
20
21
|
const printBuildInfo_1 = require("./utils/printBuildInfo");
|
|
21
22
|
const repository_1 = require("./utils/repository");
|
|
22
23
|
const url_1 = require("./utils/url");
|
|
@@ -44,6 +45,7 @@ function resolveBuildParamsInput(ctx, metadata) {
|
|
|
44
45
|
resourceClass: ctx.resourceClass,
|
|
45
46
|
sdkVersion: metadata.sdkVersion,
|
|
46
47
|
reactNativeVersion: metadata.reactNativeVersion,
|
|
48
|
+
expoTokenRole: (0, expoTokenRole_1.resolveJobExpoTokenRole)(ctx.buildProfile),
|
|
47
49
|
};
|
|
48
50
|
}
|
|
49
51
|
async function prepareBuildRequestForPlatformAsync(builder) {
|
|
@@ -166,6 +168,10 @@ async function handleBuildRequestErrorAsync(error, platform, accountName, freeTi
|
|
|
166
168
|
else if (graphQLErrorCode === 'EAS_BUILD_TOO_MANY_PENDING_BUILDS') {
|
|
167
169
|
throw new errors_1.EasBuildTooManyPendingBuildsError(`You have already reached the maximum number of pending ${platform_1.requestedPlatformDisplayNames[platform]} builds for your account. Try again later.`);
|
|
168
170
|
}
|
|
171
|
+
else if (graphQLErrorCode === 'UNAUTHORIZED') {
|
|
172
|
+
const requestId = graphQLErrors[0]?.extensions?.requestId;
|
|
173
|
+
throw new errors_1.EasBuildUnauthorizedError(`${graphQLErrors[0]?.message}${requestId ? `\nRequest ID: ${requestId}` : ''}\n\nRun ${chalk_1.default.bold('eas whoami')} to check the user you are logged in as and your permission grant. Run ${chalk_1.default.bold('eas login')} to change the user or permission grant.\n\nIf your build profile in eas.json uses ${chalk_1.default.bold('permissions.account.role')}, it may mean your credentials do not grant the requested role.`);
|
|
174
|
+
}
|
|
169
175
|
else if (Array.isArray(error?.graphQLErrors)) {
|
|
170
176
|
const errorDetails = formatBuildRequestErrorDetails(error, graphQLErrors);
|
|
171
177
|
throw new Error(`Build request failed. Make sure you are using the latest eas-cli version. If the problem persists, report the issue.${errorDetails}`);
|
package/build/build/errors.d.ts
CHANGED
|
@@ -21,5 +21,7 @@ export declare class EasBuildDownForMaintenanceError extends EasCommandError {
|
|
|
21
21
|
}
|
|
22
22
|
export declare class EasBuildTooManyPendingBuildsError extends EasCommandError {
|
|
23
23
|
}
|
|
24
|
+
export declare class EasBuildUnauthorizedError extends EasCommandError {
|
|
25
|
+
}
|
|
24
26
|
export declare class EasBuildProjectArchiveUploadError extends EasCommandError {
|
|
25
27
|
}
|
package/build/build/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EasBuildProjectArchiveUploadError = exports.EasBuildTooManyPendingBuildsError = exports.EasBuildDownForMaintenanceError = exports.RequestValidationError = exports.EasBuildLegacyResourceClassNotAvailableError = exports.EasBuildResourceClassNotAvailableInFreeTierError = exports.EasBuildFreeTierIosLimitExceededError = exports.EasBuildFreeTierLimitExceededError = exports.EasBuildFreeTierDisabledAndroidError = exports.EasBuildFreeTierDisabledIOSError = exports.EasBuildFreeTierDisabledError = exports.TurtleDeprecatedJobFormatError = void 0;
|
|
3
|
+
exports.EasBuildProjectArchiveUploadError = exports.EasBuildUnauthorizedError = exports.EasBuildTooManyPendingBuildsError = exports.EasBuildDownForMaintenanceError = exports.RequestValidationError = exports.EasBuildLegacyResourceClassNotAvailableError = exports.EasBuildResourceClassNotAvailableInFreeTierError = exports.EasBuildFreeTierIosLimitExceededError = exports.EasBuildFreeTierLimitExceededError = exports.EasBuildFreeTierDisabledAndroidError = exports.EasBuildFreeTierDisabledIOSError = exports.EasBuildFreeTierDisabledError = exports.TurtleDeprecatedJobFormatError = void 0;
|
|
4
4
|
const errors_1 = require("../commandUtils/errors");
|
|
5
5
|
class TurtleDeprecatedJobFormatError extends errors_1.EasCommandError {
|
|
6
6
|
}
|
|
@@ -35,6 +35,9 @@ exports.EasBuildDownForMaintenanceError = EasBuildDownForMaintenanceError;
|
|
|
35
35
|
class EasBuildTooManyPendingBuildsError extends errors_1.EasCommandError {
|
|
36
36
|
}
|
|
37
37
|
exports.EasBuildTooManyPendingBuildsError = EasBuildTooManyPendingBuildsError;
|
|
38
|
+
class EasBuildUnauthorizedError extends errors_1.EasCommandError {
|
|
39
|
+
}
|
|
40
|
+
exports.EasBuildUnauthorizedError = EasBuildUnauthorizedError;
|
|
38
41
|
class EasBuildProjectArchiveUploadError extends errors_1.EasCommandError {
|
|
39
42
|
}
|
|
40
43
|
exports.EasBuildProjectArchiveUploadError = EasBuildProjectArchiveUploadError;
|
|
@@ -54,9 +54,7 @@ async function resolveEnvVarsAsync({ buildProfile, buildProfileName, graphqlClie
|
|
|
54
54
|
}
|
|
55
55
|
catch (e) {
|
|
56
56
|
log_1.default.error(`Failed to pull env variables for environment ${environment} from EAS servers`);
|
|
57
|
-
|
|
58
|
-
log_1.default.error('This can possibly be a bug in EAS/EAS CLI. Report it here: https://github.com/expo/eas-cli/issues');
|
|
59
|
-
return { ...buildProfile.env };
|
|
57
|
+
throw e;
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
60
|
function resolveSuggestedEnvironmentForBuildProfileConfiguration(buildProfile) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Platform } from '@expo/eas-build-job';
|
|
2
|
+
import { BuildProfile } from '@expo/eas-json';
|
|
3
|
+
import { JobExpoTokenRole } from '../../graphql/generated';
|
|
4
|
+
export declare function resolveJobExpoTokenRole<T extends Platform>(profile: BuildProfile<T>): JobExpoTokenRole | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveJobExpoTokenRole = resolveJobExpoTokenRole;
|
|
4
|
+
const eas_json_1 = require("@expo/eas-json");
|
|
5
|
+
const generated_1 = require("../../graphql/generated");
|
|
6
|
+
const easJsonJobExpoTokenRoleToJobExpoTokenRoleMapping = {
|
|
7
|
+
[eas_json_1.JobExpoTokenRole.RUNNER]: generated_1.JobExpoTokenRole.Runner,
|
|
8
|
+
[eas_json_1.JobExpoTokenRole.DEVELOPER]: generated_1.JobExpoTokenRole.Developer,
|
|
9
|
+
[eas_json_1.JobExpoTokenRole.RELEASE_MANAGER]: generated_1.JobExpoTokenRole.ReleaseManager,
|
|
10
|
+
};
|
|
11
|
+
function resolveJobExpoTokenRole(profile) {
|
|
12
|
+
const role = profile.permissions?.account.role;
|
|
13
|
+
return role ? easJsonJobExpoTokenRoleToJobExpoTokenRoleMapping[role] : undefined;
|
|
14
|
+
}
|
|
@@ -196,7 +196,7 @@ class EasCommand extends core_1.Command {
|
|
|
196
196
|
let baseMessage = `${commandId} command failed.`;
|
|
197
197
|
if (err instanceof errors_1.EasCommandError) {
|
|
198
198
|
if (!err.messageAlreadyPrinted) {
|
|
199
|
-
log_1.default.
|
|
199
|
+
log_1.default.errorToStderr(err.message);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
else if (err instanceof core_2.CombinedError && err?.graphQLErrors) {
|
|
@@ -227,11 +227,11 @@ class EasCommand extends core_1.Command {
|
|
|
227
227
|
const cleanMessage = err.networkError
|
|
228
228
|
? `${cleanGQLErrorsMessage}\n${err.networkError.message}`
|
|
229
229
|
: cleanGQLErrorsMessage;
|
|
230
|
-
log_1.default.
|
|
230
|
+
log_1.default.errorToStderr(cleanMessage);
|
|
231
231
|
baseMessage = BASE_GRAPHQL_ERROR_MESSAGE;
|
|
232
232
|
}
|
|
233
233
|
else {
|
|
234
|
-
log_1.default.
|
|
234
|
+
log_1.default.errorToStderr(err.message);
|
|
235
235
|
}
|
|
236
236
|
log_1.default.debug(err);
|
|
237
237
|
sentry_1.default.withScope(scope => {
|
|
@@ -95,7 +95,8 @@ let ranEnsureEasCliIsNotInDependencies = false;
|
|
|
95
95
|
async function findProjectDirAndVerifyProjectSetupAsync({ cwd, } = {}) {
|
|
96
96
|
const projectDir = await findProjectRootAsync({ cwd });
|
|
97
97
|
await applyCliConfigAsync(projectDir);
|
|
98
|
-
|
|
98
|
+
// The notice is advice for a person. Programs that run eas-cli read stderr for its errors.
|
|
99
|
+
if (!ranEnsureEasCliIsNotInDependencies && process.stderr.isTTY) {
|
|
99
100
|
ranEnsureEasCliIsNotInDependencies = true;
|
|
100
101
|
await ensureEasCliIsNotInDependenciesAsync(projectDir);
|
|
101
102
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WorkflowReferencedFileInput } from '../../graphql/generated';
|
|
2
|
+
export declare function collectReferencedWorkflowFilesAsync({ projectDir, rootFileName, rootYamlConfig, }: {
|
|
3
|
+
projectDir: string;
|
|
4
|
+
rootFileName: string;
|
|
5
|
+
rootYamlConfig: string;
|
|
6
|
+
}): Promise<WorkflowReferencedFileInput[]>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectReferencedWorkflowFilesAsync = collectReferencedWorkflowFilesAsync;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const parse_1 = require("./parse");
|
|
8
|
+
const WORKFLOW_CALL_USES_REGEX = /^\.\/\.eas\/workflows\/(?:(?!\$\{\{)[^/\\])+\.ya?ml$/;
|
|
9
|
+
async function collectReferencedWorkflowFilesAsync({ projectDir, rootFileName, rootYamlConfig, }) {
|
|
10
|
+
let rootYaml;
|
|
11
|
+
try {
|
|
12
|
+
rootYaml = (0, parse_1.parsedYamlFromWorkflowContents)({ yamlConfig: rootYamlConfig });
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
const collectedFileNames = new Set([rootFileName]);
|
|
18
|
+
const referencedFiles = [];
|
|
19
|
+
const pendingCalls = getWorkflowCalls(rootFileName, rootYaml);
|
|
20
|
+
for (const call of pendingCalls) {
|
|
21
|
+
const fileName = path_1.default.posix.basename(call.uses);
|
|
22
|
+
if (collectedFileNames.has(fileName)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
collectedFileNames.add(fileName);
|
|
26
|
+
const { yamlConfig, parsedYaml } = await readReferencedWorkflowFileAsync(projectDir, fileName, call);
|
|
27
|
+
referencedFiles.push({ fileName, yamlConfig });
|
|
28
|
+
pendingCalls.push(...getWorkflowCalls(fileName, parsedYaml));
|
|
29
|
+
}
|
|
30
|
+
return referencedFiles;
|
|
31
|
+
}
|
|
32
|
+
function getWorkflowCalls(callerFileName, parsedYaml) {
|
|
33
|
+
const jobs = parsedYaml?.jobs;
|
|
34
|
+
if (!jobs || typeof jobs !== 'object') {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
return Object.entries(jobs).flatMap(([callerJobKey, job]) => {
|
|
38
|
+
const uses = job?.uses;
|
|
39
|
+
return typeof uses === 'string' && WORKFLOW_CALL_USES_REGEX.test(uses)
|
|
40
|
+
? [{ callerFileName, callerJobKey, uses }]
|
|
41
|
+
: [];
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async function readReferencedWorkflowFileAsync(projectDir, fileName, { callerFileName, callerJobKey, uses }) {
|
|
45
|
+
const filePath = path_1.default.join(projectDir, '.eas', 'workflows', fileName);
|
|
46
|
+
const describeCall = `Job "${callerJobKey}" in ${callerFileName} uses ${uses}, but ${filePath}`;
|
|
47
|
+
let yamlConfig;
|
|
48
|
+
try {
|
|
49
|
+
yamlConfig = await fs_1.default.promises.readFile(filePath, 'utf8');
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error.code === 'ENOENT') {
|
|
53
|
+
throw new Error(`${describeCall} does not exist.`);
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`${describeCall} could not be read: ${error.message}`);
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
return { yamlConfig, parsedYaml: (0, parse_1.parsedYamlFromWorkflowContents)({ yamlConfig }) };
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw new Error(`${describeCall} is not valid YAML: ${error.message}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -16,11 +16,12 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
|
16
16
|
const fs = tslib_1.__importStar(require("node:fs"));
|
|
17
17
|
const logs_1 = require("./logs");
|
|
18
18
|
const types_1 = require("./types");
|
|
19
|
+
const url_1 = require("../../build/utils/url");
|
|
19
20
|
const generated_1 = require("../../graphql/generated");
|
|
20
21
|
const format_1 = require("../logs/format");
|
|
21
22
|
const watcher_1 = require("../logs/watcher");
|
|
22
23
|
const WorkflowRunQuery_1 = require("../../graphql/queries/WorkflowRunQuery");
|
|
23
|
-
const log_1 = tslib_1.
|
|
24
|
+
const log_1 = tslib_1.__importStar(require("../../log"));
|
|
24
25
|
const ora_1 = require("../../ora");
|
|
25
26
|
const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields"));
|
|
26
27
|
const centrifuge_1 = require("../../utils/centrifuge");
|
|
@@ -78,7 +79,7 @@ function choiceFromWorkflowJob(job, index) {
|
|
|
78
79
|
}
|
|
79
80
|
function processWorkflowRuns(runs) {
|
|
80
81
|
return runs.map(run => {
|
|
81
|
-
const finishedAt = run.status
|
|
82
|
+
const finishedAt = isWorkflowRunFinal(run.status) ? (run.finalizedAt ?? null) : null;
|
|
82
83
|
const { triggerType, trigger } = computeTriggerInfoForWorkflowRun(run);
|
|
83
84
|
return {
|
|
84
85
|
id: run.id,
|
|
@@ -129,6 +130,19 @@ function isJobCompleted(status) {
|
|
|
129
130
|
return false;
|
|
130
131
|
}
|
|
131
132
|
}
|
|
133
|
+
function isWorkflowRunFinal(status) {
|
|
134
|
+
switch (status) {
|
|
135
|
+
case generated_1.WorkflowRunStatus.Success:
|
|
136
|
+
case generated_1.WorkflowRunStatus.Failure:
|
|
137
|
+
case generated_1.WorkflowRunStatus.Canceled:
|
|
138
|
+
return true;
|
|
139
|
+
case generated_1.WorkflowRunStatus.New:
|
|
140
|
+
case generated_1.WorkflowRunStatus.Waiting:
|
|
141
|
+
case generated_1.WorkflowRunStatus.InProgress:
|
|
142
|
+
case generated_1.WorkflowRunStatus.ActionRequired:
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
132
146
|
async function logsForFailedWorkflowRunAsync(graphqlClient, workflowRun) {
|
|
133
147
|
const jobs = workflowRun.jobs.filter(job => job.status === generated_1.WorkflowJobStatus.Failure);
|
|
134
148
|
return await Promise.all(jobs.map(async (job) => {
|
|
@@ -213,13 +227,12 @@ async function maybeReadStdinAsync() {
|
|
|
213
227
|
}
|
|
214
228
|
async function showWorkflowStatusAsync(graphqlClient, { workflowRunId, spinnerUsesStdErr, waitForCompletion = true, }) {
|
|
215
229
|
log_1.default.log('Waiting for workflow run to complete. You can press Ctrl+C to exit.');
|
|
230
|
+
const waitingToStartPrefixText = (0, chalk_1.default) `{bold.yellow Workflow run is waiting to start:}`;
|
|
216
231
|
const spinner = (0, ora_1.ora)({
|
|
217
232
|
stream: spinnerUsesStdErr ? process.stderr : process.stdout,
|
|
218
233
|
text: '',
|
|
219
234
|
}).start();
|
|
220
|
-
(0, ora_1.updateSpinnerText)(spinner, {
|
|
221
|
-
prefixText: (0, chalk_1.default) `{bold.yellow Workflow run is waiting to start:}`,
|
|
222
|
-
});
|
|
235
|
+
(0, ora_1.updateSpinnerText)(spinner, { prefixText: waitingToStartPrefixText });
|
|
223
236
|
const watcher = new watcher_1.LogsWatcher(() => (0, centrifuge_1.createRealtimeLogsClient)(graphqlClient), () => {
|
|
224
237
|
renderActiveWorkflowRun();
|
|
225
238
|
});
|
|
@@ -234,7 +247,23 @@ async function showWorkflowStatusAsync(graphqlClient, { workflowRunId, spinnerUs
|
|
|
234
247
|
failedFetchesCount = 0;
|
|
235
248
|
switch (workflowRun.status) {
|
|
236
249
|
case generated_1.WorkflowRunStatus.New:
|
|
250
|
+
// A queued run returns to NEW once its concurrency group frees up.
|
|
251
|
+
(0, ora_1.updateSpinnerText)(spinner, { prefixText: waitingToStartPrefixText });
|
|
237
252
|
break;
|
|
253
|
+
case generated_1.WorkflowRunStatus.Waiting: {
|
|
254
|
+
const { blockingWorkflowRun, workflow: { app }, } = workflowRun;
|
|
255
|
+
// The blocking run is in the same app: concurrency groups are app-scoped.
|
|
256
|
+
const actionRequiredSuffix = blockingWorkflowRun?.status === generated_1.WorkflowRunStatus.ActionRequired
|
|
257
|
+
? ` — it needs your action first: ${(0, log_1.link)((0, url_1.getWorkflowRunUrl)(app.ownerAccount.name, app.slug, blockingWorkflowRun.id))}`
|
|
258
|
+
: '';
|
|
259
|
+
const reason = blockingWorkflowRun
|
|
260
|
+
? `Waiting for ${blockingWorkflowRun.name}${actionRequiredSuffix}`
|
|
261
|
+
: 'Waiting for its concurrency group';
|
|
262
|
+
(0, ora_1.updateSpinnerText)(spinner, {
|
|
263
|
+
prefixText: (0, chalk_1.default) `{bold.yellow Workflow run is queued:} ${reason}`,
|
|
264
|
+
});
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
238
267
|
case generated_1.WorkflowRunStatus.InProgress: {
|
|
239
268
|
(0, ora_1.updateSpinnerText)(spinner, {
|
|
240
269
|
prefixText: (0, chalk_1.default) `{bold.green Workflow run is in progress:}`,
|
|
@@ -8,6 +8,7 @@ const flags_1 = require("../../commandUtils/flags");
|
|
|
8
8
|
const log_1 = tslib_1.__importDefault(require("../../log"));
|
|
9
9
|
const prompts_1 = require("../../prompts");
|
|
10
10
|
const User_1 = require("../../user/User");
|
|
11
|
+
const accountPermissions_1 = require("../../user/accountPermissions");
|
|
11
12
|
const deviceLogin_1 = require("../../user/deviceLogin");
|
|
12
13
|
class AccountLogin extends EasCommand_1.default {
|
|
13
14
|
static description = 'log in with your Expo account';
|
|
@@ -59,6 +60,11 @@ class AccountLogin extends EasCommand_1.default {
|
|
|
59
60
|
}
|
|
60
61
|
if (actor && !resume) {
|
|
61
62
|
log_1.default.warn(`You are already logged in as ${chalk_1.default.bold((0, User_1.getActorDisplayName)(actor))}.`);
|
|
63
|
+
const { hasLimitedAccount } = (0, accountPermissions_1.logAccountPermissions)(actor);
|
|
64
|
+
if (hasLimitedAccount) {
|
|
65
|
+
log_1.default.newLine();
|
|
66
|
+
log_1.default.log('The permissions granted during authentication limit your access to some accounts. Log in again and change the permission grant.');
|
|
67
|
+
}
|
|
62
68
|
const shouldContinue = nonInteractive ||
|
|
63
69
|
(await (0, prompts_1.confirmAsync)({
|
|
64
70
|
message: 'Do you want to continue?',
|
|
@@ -6,11 +6,4 @@ export default class AccountView extends EasCommand {
|
|
|
6
6
|
maybeLoggedIn: import("../../commandUtils/context/MaybeLoggedInContextField").default;
|
|
7
7
|
};
|
|
8
8
|
runAsync(): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Whether the scopes of the credential used for this command remove any of the permissions that
|
|
11
|
-
* the viewer's role grants on the account.
|
|
12
|
-
*/
|
|
13
|
-
private static isLimitedByCredentials;
|
|
14
|
-
private static getLabelForPermissions;
|
|
15
|
-
private static getLabelForRole;
|
|
16
9
|
}
|
|
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
5
5
|
const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
|
|
6
|
-
const generated_1 = require("../../graphql/generated");
|
|
7
6
|
const log_1 = tslib_1.__importDefault(require("../../log"));
|
|
8
7
|
const User_1 = require("../../user/User");
|
|
9
|
-
const
|
|
8
|
+
const accountPermissions_1 = require("../../user/accountPermissions");
|
|
10
9
|
class AccountView extends EasCommand_1.default {
|
|
11
10
|
static description = 'show the username you are logged in as';
|
|
12
11
|
static aliases = ['whoami'];
|
|
@@ -24,29 +23,10 @@ class AccountView extends EasCommand_1.default {
|
|
|
24
23
|
if ('email' in actor) {
|
|
25
24
|
log_1.default.log(actor.email);
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// this command limit the permissions on it
|
|
30
|
-
const accountExcludingPersonalAccount = actor.accounts.filter(account => !('username' in actor) || account.name !== actor.username);
|
|
31
|
-
const hasLimitedAccount = actor.accounts.some(AccountView.isLimitedByCredentials);
|
|
32
|
-
if (accountExcludingPersonalAccount.length > 0 || hasLimitedAccount) {
|
|
26
|
+
const { hasLimitedAccount } = (0, accountPermissions_1.logAccountPermissions)(actor);
|
|
27
|
+
if (hasLimitedAccount) {
|
|
33
28
|
log_1.default.newLine();
|
|
34
|
-
log_1.default.log('
|
|
35
|
-
actor.accounts.forEach(account => {
|
|
36
|
-
const { permissions, effectivePermissions } = account.viewerUserPermission2;
|
|
37
|
-
const roleLabel = AccountView.getLabelForPermissions(permissions);
|
|
38
|
-
if (AccountView.isLimitedByCredentials(account)) {
|
|
39
|
-
const effectiveRoleLabel = AccountView.getLabelForPermissions(effectivePermissions);
|
|
40
|
-
log_1.default.log(`• ${account.name} (Role: ${roleLabel}, ${chalk_1.default.yellow(`limited to ${effectiveRoleLabel} by the current credentials`)})`);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
log_1.default.log(`• ${account.name} (Role: ${roleLabel})`);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
if (hasLimitedAccount) {
|
|
47
|
-
log_1.default.newLine();
|
|
48
|
-
log_1.default.log(`The permissions granted during authentication limit your access to some accounts. Run ${chalk_1.default.bold('eas login')} to change the permission grant.`);
|
|
49
|
-
}
|
|
29
|
+
log_1.default.log(`The permissions granted during authentication limit your access to some accounts. Run ${chalk_1.default.bold('eas login')} to change the permission grant.`);
|
|
50
30
|
}
|
|
51
31
|
}
|
|
52
32
|
else {
|
|
@@ -54,55 +34,5 @@ class AccountView extends EasCommand_1.default {
|
|
|
54
34
|
process.exit(1);
|
|
55
35
|
}
|
|
56
36
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Whether the scopes of the credential used for this command remove any of the permissions that
|
|
59
|
-
* the viewer's role grants on the account.
|
|
60
|
-
*/
|
|
61
|
-
static isLimitedByCredentials(account) {
|
|
62
|
-
const { permissions, effectivePermissions } = account.viewerUserPermission2;
|
|
63
|
-
return permissions.some(permission => !effectivePermissions.includes(permission));
|
|
64
|
-
}
|
|
65
|
-
static getLabelForPermissions(permissions) {
|
|
66
|
-
const role = (0, roles_1.getRoleForPermissions)(permissions);
|
|
67
|
-
if (role !== generated_1.Role.Custom) {
|
|
68
|
-
return AccountView.getLabelForRole(role);
|
|
69
|
-
}
|
|
70
|
-
if (permissions.length === 0) {
|
|
71
|
-
return 'No permissions';
|
|
72
|
-
}
|
|
73
|
-
return `Custom: ${permissions
|
|
74
|
-
.map(permission => permission.toLowerCase().replaceAll('_', ' '))
|
|
75
|
-
.join(', ')}`;
|
|
76
|
-
}
|
|
77
|
-
static getLabelForRole(role) {
|
|
78
|
-
switch (role) {
|
|
79
|
-
case generated_1.Role.Owner:
|
|
80
|
-
return 'Owner';
|
|
81
|
-
case generated_1.Role.Admin:
|
|
82
|
-
return 'Admin';
|
|
83
|
-
case generated_1.Role.Developer:
|
|
84
|
-
return 'Developer';
|
|
85
|
-
case generated_1.Role.ReleaseManager:
|
|
86
|
-
return 'Release Manager';
|
|
87
|
-
case generated_1.Role.Runner:
|
|
88
|
-
return 'Runner';
|
|
89
|
-
case generated_1.Role.ViewOnly:
|
|
90
|
-
return 'Viewer';
|
|
91
|
-
case generated_1.Role.Custom:
|
|
92
|
-
case generated_1.Role.HasAdmin:
|
|
93
|
-
case generated_1.Role.NotAdmin:
|
|
94
|
-
return 'Custom';
|
|
95
|
-
// A role added to the API after this version of the CLI was published. TypeScript narrows
|
|
96
|
-
// `role` to `never` here, but the server can still send one, so render its name rather than
|
|
97
|
-
// returning undefined.
|
|
98
|
-
default: {
|
|
99
|
-
const unknownRole = role;
|
|
100
|
-
return unknownRole
|
|
101
|
-
.split('_')
|
|
102
|
-
.map(word => word.charAt(0) + word.slice(1).toLowerCase())
|
|
103
|
-
.join(' ');
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
37
|
}
|
|
108
38
|
exports.default = AccountView;
|
|
@@ -113,7 +113,7 @@ class SimulatorControl extends EasCommand_1.default {
|
|
|
113
113
|
}
|
|
114
114
|
printCatalog(catalog, jsonFlag) {
|
|
115
115
|
if (jsonFlag) {
|
|
116
|
-
(0, json_1.printJsonOnlyOutput)(catalog);
|
|
116
|
+
(0, json_1.printJsonOnlyOutput)(Object.fromEntries(Object.entries(catalog).map(([name, entry]) => [name, withUploadPathHelp(entry)])));
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
119
|
const names = Object.keys(catalog).sort();
|
|
@@ -129,7 +129,7 @@ class SimulatorControl extends EasCommand_1.default {
|
|
|
129
129
|
}
|
|
130
130
|
printActionHelp(action, entry, jsonFlag) {
|
|
131
131
|
if (jsonFlag) {
|
|
132
|
-
(0, json_1.printJsonOnlyOutput)({ ...entry, action });
|
|
132
|
+
(0, json_1.printJsonOnlyOutput)({ ...withUploadPathHelp(entry), action });
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
log_1.default.newLine();
|
|
@@ -156,6 +156,11 @@ class SimulatorControl extends EasCommand_1.default {
|
|
|
156
156
|
log_1.default.newLine();
|
|
157
157
|
log_1.default.log(' Action arguments refer to the simulator host. Use --output for the local filename.');
|
|
158
158
|
}
|
|
159
|
+
const uploadHelp = uploadPathHelp(entry);
|
|
160
|
+
if (uploadHelp) {
|
|
161
|
+
log_1.default.newLine();
|
|
162
|
+
log_1.default.log(` ${uploadHelp}`);
|
|
163
|
+
}
|
|
159
164
|
log_1.default.newLine();
|
|
160
165
|
}
|
|
161
166
|
async runActionAsync(connection, entry, { sessionId, action, values, outputPath, jsonFlag, }) {
|
|
@@ -212,18 +217,48 @@ class SimulatorControl extends EasCommand_1.default {
|
|
|
212
217
|
}
|
|
213
218
|
}
|
|
214
219
|
exports.default = SimulatorControl;
|
|
215
|
-
|
|
220
|
+
function uploadPathHelp(entry) {
|
|
221
|
+
if (!entry.upload) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
return entry.uploadAs === 'id'
|
|
225
|
+
? 'This action requires a local file to upload. host: paths are not supported.'
|
|
226
|
+
: 'File paths are local. Use host:/absolute/path for files on the simulator host.';
|
|
227
|
+
}
|
|
228
|
+
function withUploadPathHelp(entry) {
|
|
229
|
+
const help = uploadPathHelp(entry);
|
|
230
|
+
return help
|
|
231
|
+
? { ...entry, description: [entry.description, help].filter(Boolean).join('\n\n') }
|
|
232
|
+
: entry;
|
|
233
|
+
}
|
|
234
|
+
async function findLocalUploadAsync({ upload: param, uploadWhen = {}, uploadAs }, params) {
|
|
216
235
|
const value = param ? params[param] : undefined;
|
|
217
236
|
const applies = Object.entries(uploadWhen).every(([name, expected]) => params[name] === expected);
|
|
218
237
|
if (!param || typeof value !== 'string' || !applies) {
|
|
219
238
|
return null;
|
|
220
239
|
}
|
|
221
|
-
|
|
240
|
+
if (value.startsWith('host:')) {
|
|
241
|
+
if (uploadAs === 'id') {
|
|
242
|
+
throw new Error('This action requires a local file to upload; host: paths are not supported.');
|
|
243
|
+
}
|
|
244
|
+
const hostPath = value.slice('host:'.length);
|
|
245
|
+
if (!path_1.default.posix.isAbsolute(hostPath)) {
|
|
246
|
+
throw new Error(`A host: path must be absolute, for example host:/tmp/app.tar.gz. For a local filename beginning with host:, use ./${value}.`);
|
|
247
|
+
}
|
|
248
|
+
params[param] = hostPath;
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
const stat = await fs.stat(value).catch((error) => {
|
|
252
|
+
if (error.code === 'ENOENT' || error.code === 'ENOTDIR') {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
throw error;
|
|
256
|
+
});
|
|
222
257
|
if (stat?.isDirectory()) {
|
|
223
258
|
throw new Error(`${value} is a folder. Pass the path of a file.`);
|
|
224
259
|
}
|
|
225
|
-
if (!stat
|
|
226
|
-
throw new Error(`${value} does not exist on this computer. Pass
|
|
260
|
+
if (!stat) {
|
|
261
|
+
throw new Error(`${value} does not exist on this computer. Pass a local file, or prefix an absolute simulator-host path with host:.`);
|
|
227
262
|
}
|
|
228
263
|
return stat ? { param, path: value } : null;
|
|
229
264
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
|
+
export default class SimulatorLogs extends EasCommand {
|
|
3
|
+
static aliases: string[];
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
artifact: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
follow: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
scope: import("@oclif/core/lib/interfaces").OptionFlag<"all" | "user-apps", import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
limit: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
|
+
timestamp: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
};
|
|
17
|
+
static contextDefinition: {
|
|
18
|
+
projectDir: import("../../commandUtils/context/ProjectDirContextField").default;
|
|
19
|
+
loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
|
|
20
|
+
};
|
|
21
|
+
runAsync(): Promise<void>;
|
|
22
|
+
}
|