in src/commands/distribute/groups/update.ts [70:138]
public async run(client: AppCenterClient): Promise<CommandResult> {
const app = this.app;
// validate that string and file properties are not specified simultaneously
this.validateParameters();
// validating parameters and loading provided files (if any)
const testersToAdd = getUsersList(this.testersToAdd, this.testersToAddListFile, debug);
const testersToDelete = getUsersList(this.testersToDelete, this.testersToDeleteListFile, debug);
const newDistributionGroupNameValidation = this.isDistributionGroupNameFree(client, app, this.newDistributionGroupName);
// showing spinner while parameters are validated
const [testersToAddEmails, testersToDeleteEmails] = await out.progress(
"Validating parameters...",
Promise.all([testersToAdd, testersToDelete, newDistributionGroupNameValidation])
);
let deletedTestersEmails: string[];
if (testersToDeleteEmails.length) {
debug("Deleting testers from distribution group");
deletedTestersEmails = await this.deleteTestersFromDistributionGroup(client, app, testersToDeleteEmails);
} else {
deletedTestersEmails = [];
}
let addedTestersEmails: string[];
if (testersToAddEmails.length) {
debug("Adding testers to distribution group");
addedTestersEmails = await this.addTestersToDistributionGroup(client, app, testersToAddEmails);
} else {
addedTestersEmails = [];
}
if (deletedTestersEmails.length !== testersToDeleteEmails.length || addedTestersEmails.length !== testersToAddEmails.length) {
out.text("Updating the list of testers was partially successful");
}
let currentGroupName: string;
const options: { name?: string; isPublic?: boolean } = {};
if (!_.isNil(this.newDistributionGroupName)) {
debug("Renaming the distribution group");
options.name = this.newDistributionGroupName;
currentGroupName = this.newDistributionGroupName;
} else {
currentGroupName = this.distributionGroup;
}
if (this.makePublic) {
debug("Setting distribution group public status to true");
options.isPublic = true;
}
if (this.makePrivate) {
debug("Setting distribution group public status to false");
options.isPublic = false;
}
if (!_.isNil(options.name) || !_.isNil(options.isPublic)) {
await this.updateDistributionGroup(client, app, options);
}
out.text((result) => `Distribution group ${result.name} was successfully updated`, {
name: currentGroupName,
addedTesters: addedTestersEmails,
deletedTesters: deletedTestersEmails,
});
return success();
}