Родитель
b9727d75c7
Коммит
9ec1a3136b
|
@ -1,15 +1,20 @@
|
|||
import * as vscode from "vscode";
|
||||
import AppCenterAppBuilder from "../../appCenterAppBuilder";
|
||||
import { Profile, UserOrOrganizationItem } from '../../helpers/interfaces';
|
||||
import { Constants } from "../../constants";
|
||||
import { AppCenterUrlBuilder } from "../../helpers/appCenterUrlBuilder";
|
||||
import { CreatedAppFromAppCenter, Profile, QuickPickAppItem, UserOrOrganizationItem } from '../../helpers/interfaces';
|
||||
import { MenuHelper } from "../../helpers/menuHelper";
|
||||
import { Utils } from "../../helpers/utils";
|
||||
import { Validators } from "../../helpers/validators";
|
||||
import { CustomQuickPickItem, VsCodeUtils } from '../../helpers/vsCodeUtils';
|
||||
import { CustomQuickPickItem, IButtonMessageItem, VsCodeUtils } from '../../helpers/vsCodeUtils';
|
||||
import { Strings } from '../../strings';
|
||||
import { models } from '../apis';
|
||||
import { Command } from './command';
|
||||
|
||||
export class CreateAppCommand extends Command {
|
||||
|
||||
protected userOrOrg: UserOrOrganizationItem;
|
||||
|
||||
public async run(): Promise<boolean | void> {
|
||||
if (!await super.run()) {
|
||||
return false;
|
||||
|
@ -104,4 +109,65 @@ export class CreateAppCommand extends Command {
|
|||
});
|
||||
}
|
||||
|
||||
protected async setCurrentApp(app: CreatedAppFromAppCenter) {
|
||||
return this.saveCurrentApp(
|
||||
`${this.userOrOrg.name}/${app.appName}`,
|
||||
Utils.toAppCenterOS(app.os),
|
||||
null,
|
||||
Constants.AppCenterDefaultTargetBinaryVersion,
|
||||
this.userOrOrg.isOrganization ? "organization" : "user",
|
||||
Constants.AppCenterDefaultIsMandatoryParam,
|
||||
app.appSecret
|
||||
);
|
||||
}
|
||||
|
||||
protected async pickApp(apps: CreatedAppFromAppCenter[]) {
|
||||
if (apps.length < 2) {
|
||||
VsCodeUtils.ShowErrorMessage(Strings.FailedToCreateAppInAppCenter);
|
||||
return;
|
||||
}
|
||||
|
||||
const messageItems: IButtonMessageItem[] = [];
|
||||
|
||||
messageItems.push({
|
||||
title: `Go to ${apps[0].appName}`,
|
||||
url: AppCenterUrlBuilder.GetAppCenterAppLink(this.userOrOrg.name, apps[0].appName, this.userOrOrg.isOrganization)
|
||||
});
|
||||
|
||||
messageItems.push({
|
||||
title: `Go to ${apps[1].appName}`,
|
||||
url: AppCenterUrlBuilder.GetAppCenterAppLink(this.userOrOrg.name, apps[1].appName, this.userOrOrg.isOrganization)
|
||||
});
|
||||
|
||||
VsCodeUtils.ShowInfoMessage(Strings.AppCreatedMsg(apps[0].appName, false, apps[1].appName), ...messageItems);
|
||||
|
||||
const options: QuickPickAppItem[] = [
|
||||
{
|
||||
label: apps[0].appName,
|
||||
description: "",
|
||||
target: `0`
|
||||
},
|
||||
{
|
||||
label: apps[1].appName,
|
||||
description: "",
|
||||
target: `1`
|
||||
}
|
||||
];
|
||||
await vscode.window.showQuickPick(options, { placeHolder: Strings.ChooseAppToBeSet })
|
||||
.then(async (selected: QuickPickAppItem) => {
|
||||
if (selected) {
|
||||
await this.setCurrentApp(apps[+selected.target]);
|
||||
const messageItems: IButtonMessageItem[] = [];
|
||||
const appUrl = AppCenterUrlBuilder.GetAppCenterAppLink(this.userOrOrg.name, apps[+selected.target].appName, this.userOrOrg.isOrganization);
|
||||
messageItems.push({
|
||||
title: Strings.AppCreatedBtnLabel,
|
||||
url: appUrl
|
||||
});
|
||||
return VsCodeUtils.ShowInfoMessage(Strings.AppCreatedMsg(apps[+selected.target].appName), ...messageItems);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import AppCenterAppBuilder from "../../appCenterAppBuilder";
|
||||
import { Constants } from "../../constants";
|
||||
import { AppCenterUrlBuilder } from "../../helpers/appCenterUrlBuilder";
|
||||
import { CommandParams, CreatedAppFromAppCenter, UserOrOrganizationItem } from '../../helpers/interfaces';
|
||||
import { CommandParams, CreatedAppFromAppCenter } from '../../helpers/interfaces';
|
||||
import { Utils } from "../../helpers/utils";
|
||||
import { IButtonMessageItem, VsCodeUtils } from '../../helpers/vsCodeUtils';
|
||||
import { Strings } from '../../strings';
|
||||
|
@ -15,8 +14,6 @@ export enum CreateNewAppOption {
|
|||
|
||||
export class CreateNewApp extends CreateAppCommand {
|
||||
|
||||
private userOrOrg: UserOrOrganizationItem;
|
||||
|
||||
constructor(params: CommandParams, private _option: CreateNewAppOption = CreateNewAppOption.Both) {
|
||||
super(params);
|
||||
}
|
||||
|
@ -82,50 +79,4 @@ export class CreateNewApp extends CreateAppCommand {
|
|||
});
|
||||
VsCodeUtils.ShowInfoMessage(Strings.AppCreatedMsg(apps[0].appName, true), ...messageItems);
|
||||
}
|
||||
|
||||
private async pickApp(apps: CreatedAppFromAppCenter[]) {
|
||||
if (apps.length < 2) {
|
||||
VsCodeUtils.ShowErrorMessage(Strings.FailedToCreateAppInAppCenter);
|
||||
return;
|
||||
}
|
||||
const messageItems: IButtonMessageItem[] = [];
|
||||
|
||||
messageItems.push({
|
||||
title: apps[0].appName,
|
||||
command: "0"
|
||||
});
|
||||
|
||||
messageItems.push({
|
||||
title: apps[1].appName,
|
||||
command: "1"
|
||||
});
|
||||
|
||||
VsCodeUtils.ShowInfoMessage(Strings.AppCreatedMsg(apps[0].appName, false, apps[1].appName), ...messageItems)
|
||||
.then(async (selection: IButtonMessageItem | undefined) => {
|
||||
if (selection) {
|
||||
await this.setCurrentApp(apps[+selection.command]);
|
||||
const messageItems: IButtonMessageItem[] = [];
|
||||
const appUrl = AppCenterUrlBuilder.GetAppCenterAppLink(this.userOrOrg.name, apps[+selection.command].appName, this.userOrOrg.isOrganization);
|
||||
messageItems.push({
|
||||
title: Strings.AppCreatedBtnLabel,
|
||||
url: appUrl
|
||||
});
|
||||
return VsCodeUtils.ShowInfoMessage(Strings.AppCreatedMsg(apps[+selection.command].appName), ...messageItems);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async setCurrentApp(app: CreatedAppFromAppCenter) {
|
||||
return this.saveCurrentApp(
|
||||
`${this.userOrOrg.name}/${app.appName}`,
|
||||
Utils.toAppCenterOS(app.os),
|
||||
null,
|
||||
Constants.AppCenterDefaultTargetBinaryVersion,
|
||||
this.userOrOrg.isOrganization ? "organization" : "user",
|
||||
Constants.AppCenterDefaultIsMandatoryParam,
|
||||
app.appSecret
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,6 +127,7 @@ export default class Start extends CreateAppCommand {
|
|||
if (userOrOrgItem == null) {
|
||||
return;
|
||||
}
|
||||
this.userOrOrg = userOrOrgItem;
|
||||
|
||||
const appCenterAppBuilder = new AppCenterAppBuilder(ideaName, userOrOrgItem, this.repositoryURL, this.client, this.logger);
|
||||
this.logger.info("Creating your iOS and Android app in App Center...");
|
||||
|
@ -184,6 +185,8 @@ export default class Start extends CreateAppCommand {
|
|||
${AppCenterAppBuilder.getiOSAppName(ideaName)}
|
||||
--------------------------------------------------------`;
|
||||
this.logger.info(successMessage);
|
||||
|
||||
this.pickApp(appCenterAppBuilder.getCreatedApps());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ export class Strings {
|
|||
public static ProvideFirstAppPromptMsg: string = "Choose the first app to be linked";
|
||||
public static ProvideSecondAppPromptMsg: string = "Choose the second app to be linked";
|
||||
public static ProvideVSTSProjectPromptMsg: string = "Please specify VSTS Project";
|
||||
public static ChooseAppToBeSet: string = "Choose which app you want to set as current";
|
||||
public static FetchDeploymentsStatusBarMessage: string = "Fetching CodePush deployments for you...";
|
||||
public static InvalidCurrentAppNameMsg: string = "Sorry, the app name isn't valid.";
|
||||
public static StatusBarAlreadyShown: string = "The status bar is already shown. Look, it's in the bottom left corner of the window, with your name/app name on it!";
|
||||
|
@ -232,7 +233,7 @@ export class Strings {
|
|||
// If two apps were created and user has chosen one of them as current, pass only current app name.
|
||||
public static AppCreatedMsg(appName: string, squash?: boolean, secondAppName?: string): string {
|
||||
if (secondAppName) {
|
||||
return `Apps ${appName} and ${secondAppName} have been created in App Center. Which one do you want to set as current?`;
|
||||
return `Apps ${appName} and ${secondAppName} have been created in App Center.`;
|
||||
} else {
|
||||
return squash ?
|
||||
`The app ${appName} has been created in App Center and set as current` :
|
||||
|
|
Загрузка…
Ссылка в новой задаче