Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions cli/script/command-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,24 +152,8 @@ function appList(command: cli.IAppListCommand): Promise<void> {
throwForInvalidOutputFormat(command.format);
var apps: App[];
return sdk.getApps()
.then((retrievedApps: App[]): Promise<string[][]> => {
apps = retrievedApps;
var deploymentListPromises: Promise<string[]>[] = 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);
});
}

Expand Down Expand Up @@ -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);
});
});
Expand Down
6 changes: 4 additions & 2 deletions cli/test/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ export class SdkStub {
public getApps(): Promise<codePush.App[]> {
return Q([<codePush.App>{
name: "a",
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } }
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } },
deployments: [ "Production", "Staging" ]
}, <codePush.App>{
name: "b",
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } }
collaborators: { "a@a.com": { permission: "Owner", isCurrentAccount: true } },
deployments: [ "Production", "Staging" ]
}]);
}

Expand Down
1 change: 1 addition & 0 deletions definitions/rest-definitions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ declare module "rest-definitions" {
export interface App {
/*generated*/ collaborators?: CollaboratorMap;
/*key*/ name: string;
/* generated */ deployments?: string[];
}

/*in*/
Expand Down