-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathappstore-list.ts
98 lines (87 loc) · 2.94 KB
/
appstore-list.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { createTable } from "../common/helpers";
import { StringCommandParameter } from "../common/command-params";
import { IProjectData } from "../definitions/project";
import { IPlatformValidationService, IOptions } from "../declarations";
import { ICommand, ICommandParameter } from "../common/definitions/commands";
import { IInjector } from "../common/definitions/yok";
import { injector } from "../common/yok";
import { IErrors } from "../common/declarations";
import {
IApplePortalApplicationService,
IApplePortalSessionService,
} from "../services/apple-portal/definitions";
export class ListiOSApps implements ICommand {
public allowedParameters: ICommandParameter[] = [
new StringCommandParameter(this.$injector),
new StringCommandParameter(this.$injector),
];
constructor(
private $injector: IInjector,
private $applePortalApplicationService: IApplePortalApplicationService,
private $applePortalSessionService: IApplePortalSessionService,
private $logger: ILogger,
private $projectData: IProjectData,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $platformValidationService: IPlatformValidationService,
private $errors: IErrors,
private $prompter: IPrompter,
private $options: IOptions
) {
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
if (
!this.$platformValidationService.isPlatformSupportedForOS(
this.$devicePlatformsConstants.iOS,
this.$projectData
)
) {
this.$errors.fail(
`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`
);
}
let username = args[0];
let password = args[1];
if (!username) {
username = await this.$prompter.getString("Apple ID", {
allowEmpty: false,
});
}
if (!password) {
password = await this.$prompter.getPassword("Apple ID password");
}
const user = await this.$applePortalSessionService.createUserSession(
{ username, password },
{
sessionBase64: this.$options.appleSessionBase64,
}
);
if (!user.areCredentialsValid) {
this.$errors.fail(
`Invalid username and password combination. Used '${username}' as the username.`
);
}
const applications = await this.$applePortalApplicationService.getApplications(
user
);
if (!applications || !applications.length) {
this.$logger.info("Seems you don't have any applications yet.");
} else {
const table: any = createTable(
["Application Name", "Bundle Identifier", "In Flight Version"],
applications.map((application) => {
const version =
(application &&
application.versionSets &&
application.versionSets.length &&
application.versionSets[0].inFlightVersion &&
application.versionSets[0].inFlightVersion.version) ||
"";
return [application.name, application.bundleId, version];
})
);
this.$logger.info(table.toString());
}
}
}
injector.registerCommand("appstore|*list", ListiOSApps);