microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/extension/appcenter/codepush/releaseReact.ts
34lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. |
| 3 | |
| 4 | import { AppCenterClient, models } from "../api/index"; |
| 5 | import { ILogger, LogLevel } from "../../log/LogHelper"; |
| 6 | import { ICodePushReleaseParams } from "../command/commandParams"; |
| 7 | import { getQPromisifiedClientResult } from "../api/createClient"; |
| 8 | import * as Q from "q"; |
| 9 | import { CommandResult, success, failure, ErrorCodes } from "../command/commandResult"; |
| 10 | |
| 11 | export default class CodePushReleaseReact { |
| 12 | public static exec(client: AppCenterClient, params: ICodePushReleaseParams, logger: ILogger): Q.Promise<CommandResult> { |
| 13 | const app = params.app; |
| 14 | return getQPromisifiedClientResult(client.codepush.codePushDeploymentReleases.create( |
| 15 | app.appName, |
| 16 | params.deploymentName, |
| 17 | app.ownerName, |
| 18 | <string>params.appVersion, |
| 19 | { |
| 20 | deploymentName: params.deploymentName, |
| 21 | description: params.description, |
| 22 | disabled: params.isDisabled, |
| 23 | mandatory: params.isMandatory, |
| 24 | noDuplicateReleaseError: false, // TODO: remove it, not needed to send to server |
| 25 | rollout: params.rollout, |
| 26 | }) |
| 27 | ).then((result: models.CodePushRelease) => { |
| 28 | return success(result); |
| 29 | }).catch((e) => { |
| 30 | logger.log("An error occured on doing Code Push release", LogLevel.Error); |
| 31 | return failure(ErrorCodes.Exception, "An error occured on doing Code Push release"); |
| 32 | }); |
| 33 | } |
| 34 | } |