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

Commit 0d3be95

Browse files
author
scottbommarito
committed
deployment names are now stored in the app rest json
1 parent 0758d63 commit 0d3be95

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
@@ -152,24 +152,8 @@ function appList(command: cli.IAppListCommand): Promise<void> {
152152
throwForInvalidOutputFormat(command.format);
153153
var apps: App[];
154154
return sdk.getApps()
155-
.then((retrievedApps: App[]): Promise<string[][]> => {
156-
apps = retrievedApps;
157-
var deploymentListPromises: Promise<string[]>[] = apps.map((app: App) => {
158-
159-
return sdk.getDeployments(app.name)
160-
.then((deployments: Deployment[]) => {
161-
var deploymentList: string[] = deployments
162-
.map((deployment: Deployment) => deployment.name)
163-
.sort((first: string, second: string) => {
164-
return first.toLowerCase().localeCompare(second.toLowerCase());
165-
});
166-
return deploymentList;
167-
});
168-
});
169-
return Q.all(deploymentListPromises);
170-
})
171-
.then((deploymentLists: string[][]): void => {
172-
printAppList(command.format, apps, deploymentLists);
155+
.then((retrievedApps: App[]): void => {
156+
printAppList(command.format, retrievedApps);
173157
});
174158
}
175159

@@ -632,20 +616,14 @@ function formatDate(unixOffset: number): string {
632616
}
633617
}
634618

635-
function printAppList(format: string, apps: App[], deploymentLists: string[][]): void {
619+
function printAppList(format: string, apps: App[]): void {
636620
if (format === "json") {
637-
var dataSource: any[] = apps.map((app: App, index: number) => {
638-
var augmentedApp: any = app;
639-
augmentedApp.deployments = deploymentLists[index];
640-
return augmentedApp;
641-
});
642-
643-
printJson(dataSource);
621+
printJson(apps);
644622
} else if (format === "table") {
645623
var headers = ["Name", "Deployments"];
646624
printTable(headers, (dataSource: any[]): void => {
647625
apps.forEach((app: App, index: number): void => {
648-
var row = [app.name, wordwrap(50)(deploymentLists[index].join(", "))];
626+
var row = [app.name, wordwrap(50)(app.deployments.join(", "))];
649627
dataSource.push(row);
650628
});
651629
});

cli/test/cli.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ export class SdkStub {
7272
public getApps(): Promise<codePush.App[]> {
7373
return Q([<codePush.App>{
7474
name: "a",
75-
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } }
75+
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } },
76+
deployments: [ "Production", "Staging" ]
7677
}, <codePush.App>{
7778
name: "b",
78-
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } }
79+
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } },
80+
deployments: [ "Production", "Staging" ]
7981
}]);
8082
}
8183

definitions/rest-definitions.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ declare module "rest-definitions" {
104104
export interface App {
105105
/*generated*/ collaborators?: CollaboratorMap;
106106
/*key*/ name: string;
107+
/* generated */ deployments?: string[];
107108
}
108109

109110
/*in*/

0 commit comments

Comments
 (0)