microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.6.5

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/appcenter/codepush/release.ts

40lines · 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
4import { AppCenterClient, models } from "../api/index";
5import { ILogger, LogLevel } from "../../log/LogHelper";
6import { ICodePushReleaseParams } from "../command/commandParams";
7import * as Q from "q";
8import { CommandResult, success, failure, ErrorCodes } from "../command/commandResult";
9import { appcenterCodePushRelease } from "./release-strategy/appcenterCodePushRelease";
10import { legacyCodePushRelease } from "./release-strategy/legacyCodePushRelease";
11import { SettingsHelper } from "../../settingsHelper";
12
13// Use old service endpoint unless we will fix issue with 1MB payload limitation for new one
14const useLegacyCodePushServer: boolean = SettingsHelper.getLegacyCodePushServiceEnabled();
15
16export default class CodePushRelease {
17 public static exec(client: AppCenterClient, params: ICodePushReleaseParams, logger: ILogger): Q.Promise<CommandResult> {
18 return ((): Q.Promise<CodePushRelease> => {
19 if (useLegacyCodePushServer) {
20 return legacyCodePushRelease(params, <string>params.token, SettingsHelper.getLegacyCodePushEndpoint());
21 } else {
22 return appcenterCodePushRelease(client, params);
23 }
24 })().then((result: models.CodePushRelease) => {
25 return success(result);
26 }).catch((error) => {
27 if (error && error.reposnse && error.response.statusCode === 409) {
28 logger.log(error.response.body, LogLevel.Error);
29 return failure(ErrorCodes.Exception, error.response.body);
30 }
31
32 logger.log("An error occured on doing Code Push release", LogLevel.Error);
33 if (typeof error === "string") {
34 return failure(ErrorCodes.Exception, error);
35 } else {
36 return failure(ErrorCodes.Exception, "An error occured on doing Code Push release");
37 }
38 });
39 }
40}