-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathavailability.ts
More file actions
36 lines (33 loc) · 1.11 KB
/
availability.ts
File metadata and controls
36 lines (33 loc) · 1.11 KB
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
import { appDistributionOrigin } from "../../../api";
import { getPlatformsFromFolder, Platform } from "../../../appUtils";
import { check } from "../../../ensureApiEnabled";
import { timeoutFallback } from "../../../timeout";
import { McpContext } from "../../types";
/**
* Returns whether or not App Testing should be enabled
*/
export async function isAppTestingAvailable(ctx: McpContext): Promise<boolean> {
const host = ctx.host;
const projectDir = ctx.config.projectDir;
const platforms = await getPlatformsFromFolder(projectDir);
// If this is not a mobile app, then App Testing won't be enabled
if (
!platforms.includes(Platform.FLUTTER) &&
!platforms.includes(Platform.ANDROID) &&
!platforms.includes(Platform.IOS)
) {
host.log("debug", `Found no supported App Testing platforms.`);
return false;
}
// Checkf if App Distribution API is active
try {
return await timeoutFallback(
check(ctx.projectId, appDistributionOrigin(), "", true),
true,
3000,
);
} catch (e) {
// If there was a network error, default to enabling the feature
return true;
}
}