eas-cli
Version:
EAS command line tool
144 lines (143 loc) • 6.45 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
const flags_1 = require("../../commandUtils/flags");
const EndRollout_1 = require("../../rollout/actions/EndRollout");
const ManageRollout_1 = require("../../rollout/actions/ManageRollout");
const NonInteractiveRollout_1 = require("../../rollout/actions/NonInteractiveRollout");
const RolloutMainMenu_1 = require("../../rollout/actions/RolloutMainMenu");
const json_1 = require("../../utils/json");
var ActionRawFlagValue;
(function (ActionRawFlagValue) {
ActionRawFlagValue["CREATE"] = "create";
ActionRawFlagValue["EDIT"] = "edit";
ActionRawFlagValue["END"] = "end";
ActionRawFlagValue["VIEW"] = "view";
})(ActionRawFlagValue || (ActionRawFlagValue = {}));
class ChannelRollout extends EasCommand_1.default {
static description = 'Roll a new branch out on a channel incrementally.';
static args = [
{
name: 'channel',
description: 'channel on which the rollout should be done',
},
];
static flags = {
action: core_1.Flags.enum({
description: 'Rollout action to perform',
options: Object.values(ActionRawFlagValue),
required: false,
relationships: [
{
type: 'all',
flags: [
{
name: 'percent',
// eslint-disable-next-line async-protect/async-suffix
when: async (flags) => {
return (!!flags['non-interactive'] &&
(flags['action'] === ActionRawFlagValue.CREATE ||
flags['action'] === ActionRawFlagValue.EDIT));
},
},
{
name: 'outcome',
// eslint-disable-next-line async-protect/async-suffix
when: async (flags) => !!flags['non-interactive'] && flags['action'] === ActionRawFlagValue.END,
},
{
name: 'branch',
// eslint-disable-next-line async-protect/async-suffix
when: async (flags) => !!flags['non-interactive'] && flags['action'] === ActionRawFlagValue.CREATE,
},
{
name: 'runtime-version',
// eslint-disable-next-line async-protect/async-suffix
when: async (flags) => !!flags['non-interactive'] && flags['action'] === ActionRawFlagValue.CREATE,
},
],
},
],
}),
percent: core_1.Flags.integer({
description: 'Percent of users to send to the new branch. Use with --action=edit or --action=create',
required: false,
}),
outcome: core_1.Flags.enum({
description: 'End outcome of rollout. Use with --action=end',
options: Object.values(EndRollout_1.EndOutcome),
required: false,
}),
branch: core_1.Flags.string({
description: 'Branch to roll out. Use with --action=create',
required: false,
}),
'runtime-version': core_1.Flags.string({
description: 'Runtime version to target. Use with --action=create',
required: false,
}),
'private-key-path': core_1.Flags.string({
description: `File containing the PEM-encoded private key corresponding to the certificate in expo-updates' configuration. Defaults to a file named "private-key.pem" in the certificate's directory. Only relevant if you are using code signing: https://docs.expo.dev/eas-update/code-signing/`,
required: false,
}),
...flags_1.EasNonInteractiveAndJsonFlags,
};
static contextDefinition = {
...this.ContextOptions.ProjectConfig,
...this.ContextOptions.Vcs,
...this.ContextOptions.LoggedIn,
};
async runAsync() {
const { args, flags } = await this.parse(ChannelRollout);
const argsAndFlags = this.sanitizeArgsAndFlags({ ...flags, ...args });
const { privateProjectConfig: { exp, projectId, projectDir }, vcsClient, loggedIn: { graphqlClient }, } = await this.getContextAsync(ChannelRollout, {
nonInteractive: argsAndFlags.nonInteractive,
withServerSideEnvironment: null,
});
if (argsAndFlags.json) {
(0, json_1.enableJsonOutput)();
}
const app = { projectId, exp, projectDir };
const ctx = {
nonInteractive: argsAndFlags.nonInteractive,
graphqlClient,
app,
vcsClient,
};
if (argsAndFlags.nonInteractive) {
await new NonInteractiveRollout_1.NonInteractiveRollout(argsAndFlags).runAsync(ctx);
}
else {
await new RolloutMainMenu_1.RolloutMainMenu(argsAndFlags).runAsync(ctx);
}
}
getAction(action) {
switch (action) {
case ActionRawFlagValue.CREATE:
return RolloutMainMenu_1.MainMenuActions.CREATE_NEW;
case ActionRawFlagValue.EDIT:
return ManageRollout_1.ManageRolloutActions.EDIT;
case ActionRawFlagValue.END:
return ManageRollout_1.ManageRolloutActions.END;
case ActionRawFlagValue.VIEW:
return ManageRollout_1.ManageRolloutActions.VIEW;
}
}
sanitizeArgsAndFlags(rawFlags) {
const action = rawFlags.action;
return {
channelName: rawFlags.channel,
percent: rawFlags.percent,
outcome: rawFlags.outcome,
branchNameToRollout: rawFlags.branch,
runtimeVersion: rawFlags['runtime-version'],
privateKeyPath: rawFlags['private-key-path'] ?? null,
action: action ? this.getAction(action) : undefined,
nonInteractive: rawFlags['non-interactive'],
json: rawFlags.json,
};
}
}
exports.default = ChannelRollout;
;