Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit b2e8b51

Browse files
author
Richard Hua
authored
Merge pull request #250 from Microsoft/app-deployment-names
use the fact that deployment names are now stored in the rest app object
2 parents 391d8c4 + 0d3be95 commit b2e8b51

File tree

3 files changed

+10
-29
lines changed

3 files changed

+10
-29
lines changed

cli/script/command-executor.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,8 @@ function appList(command: cli.IAppListCommand): Promise<void> {
179179
throwForInvalidOutputFormat(command.format);
180180
var apps: App[];
181181
return sdk.getApps()
182-
.then((retrievedApps: App[]): Promise<string[][]> => {
183-
apps = retrievedApps;
184-
var deploymentListPromises: Promise<string[]>[] = apps.map((app: App) => {
185-
186-
return sdk.getDeployments(app.name)
187-
.then((deployments: Deployment[]) => {
188-
var deploymentList: string[] = deployments
189-
.map((deployment: Deployment) => deployment.name)
190-
.sort((first: string, second: string) => {
191-
return first.toLowerCase().localeCompare(second.toLowerCase());
192-
});
193-
return deploymentList;
194-
});
195-
});
196-
return Q.all(deploymentListPromises);
197-
})
198-
.then((deploymentLists: string[][]): void => {
199-
printAppList(command.format, apps, deploymentLists);
182+
.then((retrievedApps: App[]): void => {
183+
printAppList(command.format, retrievedApps);
200184
});
201185
}
202186

@@ -671,20 +655,14 @@ function formatDate(unixOffset: number): string {
671655
}
672656
}
673657

674-
function printAppList(format: string, apps: App[], deploymentLists: string[][]): void {
658+
function printAppList(format: string, apps: App[]): void {
675659
if (format === "json") {
676-
var dataSource: any[] = apps.map((app: App, index: number) => {
677-
var augmentedApp: any = app;
678-
augmentedApp.deployments = deploymentLists[index];
679-
return augmentedApp;
680-
});
681-
682-
printJson(dataSource);
660+
printJson(apps);
683661
} else if (format === "table") {
684662
var headers = ["Name", "Deployments"];
685663
printTable(headers, (dataSource: any[]): void => {
686664
apps.forEach((app: App, index: number): void => {
687-
var row = [app.name, wordwrap(50)(deploymentLists[index].join(", "))];
665+
var row = [app.name, wordwrap(50)(app.deployments.join(", "))];
688666
dataSource.push(row);
689667
});
690668
});

cli/test/cli.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ export class SdkStub {
9494
public getApps(): Promise<codePush.App[]> {
9595
return Q([<codePush.App>{
9696
name: "a",
97-
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } }
97+
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } },
98+
deployments: [ "Production", "Staging" ]
9899
}, <codePush.App>{
99100
name: "b",
100-
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } }
101+
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } },
102+
deployments: [ "Production", "Staging" ]
101103
}]);
102104
}
103105

definitions/rest-definitions.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ declare module "rest-definitions" {
115115
export interface App {
116116
/*generated*/ collaborators?: CollaboratorMap;
117117
/*key*/ name: string;
118+
/* generated */ deployments?: string[];
118119
}
119120

120121
/*in*/

0 commit comments

Comments
 (0)