eas-cli 20.4.0 → 20.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -114
- package/build/build/utils/url.d.ts +1 -0
- package/build/build/utils/url.js +4 -0
- package/build/commands/integrations/posthog/connect.d.ts +3 -0
- package/build/commands/integrations/posthog/connect.js +66 -12
- package/build/commands/simulator/get.js +8 -10
- package/build/commands/simulator/list.js +7 -13
- package/build/commands/simulator/start.js +27 -27
- package/build/commands/simulator/stop.js +5 -5
- package/build/graphql/generated.d.ts +302 -4
- package/build/graphql/generated.js +40 -4
- package/build/graphql/mutations/PostHogMutation.d.ts +2 -2
- package/build/graphql/mutations/PostHogMutation.js +13 -7
- package/build/graphql/queries/AccountQuery.js +5 -0
- package/build/graphql/queries/PostHogQuery.d.ts +3 -1
- package/build/graphql/queries/PostHogQuery.js +5 -2
- package/build/graphql/types/PostHogConnection.d.ts +8 -0
- package/build/utils/usage/checkForOverages.d.ts +13 -3
- package/build/utils/usage/checkForOverages.js +72 -21
- package/oclif.manifest.json +2707 -2707
- package/package.json +2 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
|
2
2
|
import { PostHogOrganizationConnectionData, PostHogProjectData } from '../types/PostHogConnection';
|
|
3
3
|
export declare const PostHogQuery: {
|
|
4
|
-
getPostHogOrganizationConnectionByAccountIdAsync(graphqlClient: ExpoGraphqlClient, accountId: string
|
|
4
|
+
getPostHogOrganizationConnectionByAccountIdAsync(graphqlClient: ExpoGraphqlClient, accountId: string, { useCache }?: {
|
|
5
|
+
useCache?: boolean;
|
|
6
|
+
}): Promise<PostHogOrganizationConnectionData | null>;
|
|
5
7
|
getPostHogProjectByAppIdAsync(graphqlClient: ExpoGraphqlClient, appId: string): Promise<PostHogProjectData | null>;
|
|
6
8
|
};
|
|
@@ -7,7 +7,7 @@ const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
|
|
7
7
|
const client_1 = require("../client");
|
|
8
8
|
const PostHogConnection_1 = require("../types/PostHogConnection");
|
|
9
9
|
exports.PostHogQuery = {
|
|
10
|
-
async getPostHogOrganizationConnectionByAccountIdAsync(graphqlClient, accountId) {
|
|
10
|
+
async getPostHogOrganizationConnectionByAccountIdAsync(graphqlClient, accountId, { useCache = true } = {}) {
|
|
11
11
|
const data = await (0, client_1.withErrorHandlingAsync)(graphqlClient
|
|
12
12
|
.query((0, graphql_tag_1.default) `
|
|
13
13
|
query PostHogOrganizationConnectionByAccountId($accountId: String!) {
|
|
@@ -22,7 +22,10 @@ exports.PostHogQuery = {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
${(0, graphql_1.print)(PostHogConnection_1.PostHogOrganizationConnectionFragmentNode)}
|
|
25
|
-
`, { accountId }, {
|
|
25
|
+
`, { accountId }, {
|
|
26
|
+
additionalTypenames: ['PostHogOrganizationConnection'],
|
|
27
|
+
requestPolicy: useCache ? 'cache-first' : 'network-only',
|
|
28
|
+
})
|
|
26
29
|
.toPromise());
|
|
27
30
|
return data.account.byId.posthogOrganizationConnection ?? null;
|
|
28
31
|
},
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { PostHogOrganizationConnection, PostHogProject } from '../generated';
|
|
2
2
|
export type PostHogOrganizationConnectionData = Pick<PostHogOrganizationConnection, 'id' | 'posthogOrganizationIdentifier' | 'posthogOrganizationName' | 'posthogRegion' | 'createdAt' | 'updatedAt'>;
|
|
3
|
+
export type PostHogPendingConnectionData = {
|
|
4
|
+
url: string;
|
|
5
|
+
};
|
|
6
|
+
export type StartPostHogConnectionResult = ({
|
|
7
|
+
__typename: 'PostHogOrganizationConnection';
|
|
8
|
+
} & PostHogOrganizationConnectionData) | ({
|
|
9
|
+
__typename: 'PostHogPendingConnection';
|
|
10
|
+
} & PostHogPendingConnectionData);
|
|
3
11
|
export type PostHogProjectData = Pick<PostHogProject, 'id' | 'posthogProjectIdentifier' | 'posthogProjectName' | 'posthogProjectToken' | 'posthogHost' | 'createdAt' | 'updatedAt'> & {
|
|
4
12
|
posthogOrganizationConnection: PostHogOrganizationConnectionData;
|
|
5
13
|
};
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
|
2
|
+
export type UsageTier = 'approaching' | 'at' | 'over';
|
|
2
3
|
export declare function maybeWarnAboutUsageOveragesAsync({ graphqlClient, accountId, }: {
|
|
3
4
|
graphqlClient: ExpoGraphqlClient;
|
|
4
5
|
accountId: string;
|
|
5
6
|
}): Promise<void>;
|
|
7
|
+
export declare function classifyUsageTier({ planValue, limit, overageCount, }: {
|
|
8
|
+
planValue: number;
|
|
9
|
+
limit: number;
|
|
10
|
+
overageCount: number;
|
|
11
|
+
}): UsageTier | null;
|
|
6
12
|
export declare function calculatePercentUsed(value: number, limit: number): number;
|
|
7
13
|
export declare function createProgressBar(percentUsed: number, width?: number): string;
|
|
8
|
-
export declare function displayOverageWarning({
|
|
9
|
-
|
|
10
|
-
hasFreePlan: boolean;
|
|
14
|
+
export declare function displayOverageWarning({ tier, name, hasFreePlan, planValue, limit, overageCount, overageCostCents, }: {
|
|
15
|
+
tier: UsageTier;
|
|
11
16
|
name: string;
|
|
17
|
+
hasFreePlan: boolean;
|
|
18
|
+
planValue: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
overageCount: number;
|
|
21
|
+
overageCostCents: number;
|
|
12
22
|
}): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.maybeWarnAboutUsageOveragesAsync = maybeWarnAboutUsageOveragesAsync;
|
|
4
|
+
exports.classifyUsageTier = classifyUsageTier;
|
|
4
5
|
exports.calculatePercentUsed = calculatePercentUsed;
|
|
5
6
|
exports.createProgressBar = createProgressBar;
|
|
6
7
|
exports.displayOverageWarning = displayOverageWarning;
|
|
@@ -8,26 +9,59 @@ const tslib_1 = require("tslib");
|
|
|
8
9
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
9
10
|
const AccountQuery_1 = require("../../graphql/queries/AccountQuery");
|
|
10
11
|
const log_1 = tslib_1.__importStar(require("../../log"));
|
|
11
|
-
const
|
|
12
|
+
const APPROACHING_THRESHOLD_PERCENT = 80;
|
|
12
13
|
async function maybeWarnAboutUsageOveragesAsync({ graphqlClient, accountId, }) {
|
|
13
14
|
try {
|
|
14
15
|
const currentDate = new Date();
|
|
15
|
-
const
|
|
16
|
-
|
|
16
|
+
const account = await AccountQuery_1.AccountQuery.getUsageForOverageWarningAsync(graphqlClient, accountId, currentDate);
|
|
17
|
+
if (!account) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const { name, subscription, usageMetrics } = account;
|
|
21
|
+
const buildMetrics = usageMetrics.EAS_BUILD;
|
|
22
|
+
const planMetric = buildMetrics?.planMetrics?.[0];
|
|
17
23
|
if (!planMetric || !subscription) {
|
|
18
24
|
return;
|
|
19
25
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
const overageCount = buildMetrics.overageMetrics.reduce((sum, o) => sum + o.value, 0);
|
|
27
|
+
const overageCostCents = buildMetrics.totalCost;
|
|
28
|
+
const tier = classifyUsageTier({
|
|
29
|
+
planValue: planMetric.value,
|
|
30
|
+
limit: planMetric.limit,
|
|
31
|
+
overageCount,
|
|
32
|
+
});
|
|
33
|
+
if (!tier) {
|
|
34
|
+
return;
|
|
24
35
|
}
|
|
36
|
+
const hasFreePlan = subscription.name === 'Free';
|
|
37
|
+
displayOverageWarning({
|
|
38
|
+
tier,
|
|
39
|
+
name,
|
|
40
|
+
hasFreePlan,
|
|
41
|
+
planValue: planMetric.value,
|
|
42
|
+
limit: planMetric.limit,
|
|
43
|
+
overageCount,
|
|
44
|
+
overageCostCents,
|
|
45
|
+
});
|
|
25
46
|
}
|
|
26
47
|
catch (error) {
|
|
27
48
|
// Silently fail if we can't fetch usage data - we don't want to block the user's workflow
|
|
28
49
|
log_1.default.debug(`Failed to fetch usage data: ${error}`);
|
|
29
50
|
}
|
|
30
51
|
}
|
|
52
|
+
function classifyUsageTier({ planValue, limit, overageCount, }) {
|
|
53
|
+
if (overageCount > 0) {
|
|
54
|
+
return 'over';
|
|
55
|
+
}
|
|
56
|
+
if (limit > 0 && planValue >= limit) {
|
|
57
|
+
return 'at';
|
|
58
|
+
}
|
|
59
|
+
const percentUsed = calculatePercentUsed(planValue, limit);
|
|
60
|
+
if (percentUsed >= APPROACHING_THRESHOLD_PERCENT) {
|
|
61
|
+
return 'approaching';
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
31
65
|
function calculatePercentUsed(value, limit) {
|
|
32
66
|
if (limit === 0) {
|
|
33
67
|
return 0;
|
|
@@ -41,19 +75,36 @@ function createProgressBar(percentUsed, width = 30) {
|
|
|
41
75
|
const empty = '░'.repeat(emptyWidth);
|
|
42
76
|
return `${filled}${empty}`;
|
|
43
77
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
log_1.default.warn(message + progressBar);
|
|
78
|
+
function formatCents(cents) {
|
|
79
|
+
return `$${(cents / 100).toFixed(2)}`;
|
|
80
|
+
}
|
|
81
|
+
function displayOverageWarning({ tier, name, hasFreePlan, planValue, limit, overageCount, overageCostCents, }) {
|
|
49
82
|
const billingUrl = `https://expo.dev/accounts/${name}/settings/billing`;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
83
|
+
if (tier === 'approaching') {
|
|
84
|
+
const percentUsed = calculatePercentUsed(planValue, limit);
|
|
85
|
+
log_1.default.warn(chalk_1.default.bold(`You've used ${percentUsed}% of your included build credits this billing period.`) +
|
|
86
|
+
' ' +
|
|
87
|
+
createProgressBar(percentUsed));
|
|
88
|
+
log_1.default.warn(hasFreePlan
|
|
89
|
+
? "You won't be able to start new builds once you reach the limit. " +
|
|
90
|
+
(0, log_1.link)(billingUrl, { text: 'Upgrade your plan to continue service.', dim: false })
|
|
91
|
+
: 'Additional usage beyond your limit will be charged at pay-as-you-go rates. ' +
|
|
92
|
+
(0, log_1.link)(billingUrl, { text: 'See usage in billing.', dim: false }));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// Free users are blocked at the limit, so they can't reach an "over" state.
|
|
96
|
+
// If we ever see Free + over (data inconsistency, mid-flight plan change), treat it as "at".
|
|
97
|
+
if (tier === 'at' || (tier === 'over' && hasFreePlan)) {
|
|
98
|
+
log_1.default.warn(chalk_1.default.bold("You've reached your included build credits this billing period."));
|
|
99
|
+
log_1.default.warn(hasFreePlan
|
|
100
|
+
? 'New builds are blocked until your billing period resets. ' +
|
|
101
|
+
(0, log_1.link)(billingUrl, { text: 'Upgrade your plan to continue building.', dim: false })
|
|
102
|
+
: 'Additional builds will be charged at pay-as-you-go rates. ' +
|
|
103
|
+
(0, log_1.link)(billingUrl, { text: 'See usage in billing.', dim: false }));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// tier === 'over' && paid plan
|
|
107
|
+
log_1.default.warn(chalk_1.default.bold(`You've used ${overageCount} build${overageCount === 1 ? '' : 's'} beyond your included credits this billing period (${formatCents(overageCostCents)} in overages so far).`));
|
|
108
|
+
log_1.default.warn('Additional builds continue at pay-as-you-go rates. ' +
|
|
109
|
+
(0, log_1.link)(billingUrl, { text: 'See usage in billing.', dim: false }));
|
|
59
110
|
}
|