UNPKG

eas-cli

Version:
61 lines (60 loc) 2.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const core_1 = require("@oclif/core"); const assert_1 = tslib_1.__importDefault(require("assert")); const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand")); const flags_1 = require("../../commandUtils/flags"); const pagination_1 = require("../../commandUtils/pagination"); const queries_1 = require("../../devices/queries"); const projectUtils_1 = require("../../project/projectUtils"); const json_1 = require("../../utils/json"); class BuildList extends EasCommand_1.default { static description = 'list all registered devices for your account'; static flags = { 'apple-team-id': core_1.Flags.string(), ...pagination_1.EasPaginatedQueryFlags, ...flags_1.EasNonInteractiveAndJsonFlags, }; static contextDefinition = { ...this.ContextOptions.ProjectId, ...this.ContextOptions.LoggedIn, }; async runAsync() { const { flags } = await this.parse(BuildList); const paginatedQueryOptions = (0, pagination_1.getPaginatedQueryOptions)(flags); const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(BuildList, { nonInteractive: paginatedQueryOptions.nonInteractive, }); let appleTeamIdentifier = flags['apple-team-id']; let appleTeamName; if (paginatedQueryOptions.json) { (0, json_1.enableJsonOutput)(); } const account = await (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId); // if they don't provide a team id, fetch devices on their account if (!appleTeamIdentifier) { const selectedAppleTeam = await (0, queries_1.selectAppleTeamOnAccountAsync)(graphqlClient, { accountName: account.name, paginatedQueryOptions: { ...paginatedQueryOptions, offset: 0, limit: undefined, }, selectionPromptTitle: 'What Apple team would you like to list devices for?', }); appleTeamIdentifier = selectedAppleTeam.appleTeamIdentifier; appleTeamName = selectedAppleTeam.appleTeamName; } (0, assert_1.default)(appleTeamIdentifier, 'No team identifier is specified'); await (0, queries_1.listAndRenderAppleDevicesOnAppleTeamAsync)(graphqlClient, { accountName: account.name, appleTeam: { appleTeamIdentifier, appleTeamName, }, paginatedQueryOptions, }); } } exports.default = BuildList;