diff --git a/cli/script/command-executor.ts b/cli/script/command-executor.ts index c566ffcc..f2f917ed 100644 --- a/cli/script/command-executor.ts +++ b/cli/script/command-executor.ts @@ -152,24 +152,8 @@ function appList(command: cli.IAppListCommand): Promise { throwForInvalidOutputFormat(command.format); var apps: App[]; return sdk.getApps() - .then((retrievedApps: App[]): Promise => { - apps = retrievedApps; - var deploymentListPromises: Promise[] = apps.map((app: App) => { - - return sdk.getDeployments(app.name) - .then((deployments: Deployment[]) => { - var deploymentList: string[] = deployments - .map((deployment: Deployment) => deployment.name) - .sort((first: string, second: string) => { - return first.toLowerCase().localeCompare(second.toLowerCase()); - }); - return deploymentList; - }); - }); - return Q.all(deploymentListPromises); - }) - .then((deploymentLists: string[][]): void => { - printAppList(command.format, apps, deploymentLists); + .then((retrievedApps: App[]): void => { + printAppList(command.format, retrievedApps); }); } @@ -632,20 +616,14 @@ function formatDate(unixOffset: number): string { } } -function printAppList(format: string, apps: App[], deploymentLists: string[][]): void { +function printAppList(format: string, apps: App[]): void { if (format === "json") { - var dataSource: any[] = apps.map((app: App, index: number) => { - var augmentedApp: any = app; - augmentedApp.deployments = deploymentLists[index]; - return augmentedApp; - }); - - printJson(dataSource); + printJson(apps); } else if (format === "table") { var headers = ["Name", "Deployments"]; printTable(headers, (dataSource: any[]): void => { apps.forEach((app: App, index: number): void => { - var row = [app.name, wordwrap(50)(deploymentLists[index].join(", "))]; + var row = [app.name, wordwrap(50)(app.deployments.join(", "))]; dataSource.push(row); }); }); diff --git a/cli/test/cli.ts b/cli/test/cli.ts index 2a6ca0ce..73efe2e4 100644 --- a/cli/test/cli.ts +++ b/cli/test/cli.ts @@ -72,10 +72,12 @@ export class SdkStub { public getApps(): Promise { return Q([{ name: "a", - collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } } + collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } }, + deployments: [ "Production", "Staging" ] }, { name: "b", - collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } } + collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } }, + deployments: [ "Production", "Staging" ] }]); } diff --git a/definitions/rest-definitions.d.ts b/definitions/rest-definitions.d.ts index 853970e5..db373797 100644 --- a/definitions/rest-definitions.d.ts +++ b/definitions/rest-definitions.d.ts @@ -104,6 +104,7 @@ declare module "rest-definitions" { export interface App { /*generated*/ collaborators?: CollaboratorMap; /*key*/ name: string; + /* generated */ deployments?: string[]; } /*in*/