in src/commands/apps/update.ts [51:97]
async run(client: AppCenterClient): Promise<CommandResult> {
const appAttributes: models.AppPatchRequest = {};
if (this.description) {
appAttributes.description = this.description;
}
if (this.displayName) {
appAttributes.displayName = this.displayName;
}
if (this.name) {
appAttributes.name = this.name;
}
if (this.release_type) {
if (this.release_type.length > APP_RELEASE_TYPE_VALIDATIONS.maxLength.rule) {
return failure(ErrorCodes.InvalidParameter, APP_RELEASE_TYPE_VALIDATIONS.maxLength.errorMessage);
}
if (!APP_RELEASE_TYPE_VALIDATIONS.matchRegexp.rule.test(this.release_type)) {
return failure(ErrorCodes.InvalidParameter, APP_RELEASE_TYPE_VALIDATIONS.matchRegexp.errorMessage);
}
appAttributes.releaseType = this.release_type;
}
const app = this.app;
const updateAppResponse = await out.progress(
"Updating app ...",
clientRequest<models.AppResponse>((cb) => client.appsOperations.update(app.appName, app.ownerName, { app: appAttributes }, cb))
);
const statusCode = updateAppResponse.response.statusCode;
if (statusCode >= 400) {
switch (statusCode) {
case 400:
return failure(ErrorCodes.Exception, "the request was rejected for an unknown reason");
case 404:
return failure(ErrorCodes.NotLoggedIn, `the app "${app.identifier}" could not be found`);
case 409:
return failure(ErrorCodes.InvalidParameter, `an app with the "name" ${app.appName} already exists`);
}
}
reportApp(updateAppResponse.result);
return success();
}