eas-cli 3.17.1 → 3.18.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.
@@ -39,6 +39,7 @@ class BuildVersionGetView extends EasCommand_1.default {
39
39
  easJsonAccessor,
40
40
  platforms,
41
41
  profileName: (_b = flags.profile) !== null && _b !== void 0 ? _b : undefined,
42
+ projectDir,
42
43
  });
43
44
  const results = {};
44
45
  for (const { profile, platform } of buildProfiles) {
@@ -38,6 +38,7 @@ class BuildVersionSyncView extends EasCommand_1.default {
38
38
  easJsonAccessor,
39
39
  platforms,
40
40
  profileName: (_b = flags.profile) !== null && _b !== void 0 ? _b : undefined,
41
+ projectDir,
41
42
  });
42
43
  for (const profileInfo of buildProfiles) {
43
44
  const { exp, projectId } = await getDynamicPrivateProjectConfigAsync({
@@ -28,6 +28,7 @@ class MetadataLint extends EasCommand_1.default {
28
28
  easJsonAccessor: eas_json_1.EasJsonAccessor.fromProjectPath(projectDir),
29
29
  platforms: [eas_build_job_1.Platform.IOS],
30
30
  profileName: flags.profile,
31
+ projectDir,
31
32
  });
32
33
  if (submitProfiles.length !== 1) {
33
34
  throw new Error('Metadata only supports iOS and a single submit profile.');
@@ -28,6 +28,7 @@ class MetadataPull extends EasCommand_1.default {
28
28
  easJsonAccessor: eas_json_1.EasJsonAccessor.fromProjectPath(projectDir),
29
29
  platforms: [eas_build_job_1.Platform.IOS],
30
30
  profileName: flags.profile,
31
+ projectDir,
31
32
  });
32
33
  if (submitProfiles.length !== 1) {
33
34
  throw new Error('Metadata only supports iOS and a single submit profile.');
@@ -26,6 +26,7 @@ class MetadataPush extends EasCommand_1.default {
26
26
  easJsonAccessor: eas_json_1.EasJsonAccessor.fromProjectPath(projectDir),
27
27
  platforms: [eas_build_job_1.Platform.IOS],
28
28
  profileName: flags.profile,
29
+ projectDir,
29
30
  });
30
31
  if (submitProfiles.length !== 1) {
31
32
  throw new Error('Metadata only supports iOS and a single submit profile.');
@@ -30,6 +30,7 @@ class Submit extends EasCommand_1.default {
30
30
  easJsonAccessor: eas_json_1.EasJsonAccessor.fromProjectPath(projectDir),
31
31
  platforms,
32
32
  profileName: flagsWithPlatform.profile,
33
+ projectDir,
33
34
  });
34
35
  const submissions = [];
35
36
  for (const submissionProfile of submissionProfiles) {
@@ -0,0 +1,15 @@
1
+ import { ExpoConfig } from '@expo/config-types';
2
+ import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
3
+ export type EASUpdateContext = {
4
+ graphqlClient: ExpoGraphqlClient;
5
+ nonInteractive: boolean;
6
+ app: {
7
+ exp: ExpoConfig;
8
+ projectId: string;
9
+ };
10
+ };
11
+ export interface EASUpdateAction<T = any> {
12
+ runAsync(ctx: EASUpdateContext): Promise<T>;
13
+ }
14
+ export declare class NonInteractiveError extends Error {
15
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NonInteractiveError = void 0;
4
+ class NonInteractiveError extends Error {
5
+ }
6
+ exports.NonInteractiveError = NonInteractiveError;
@@ -9,7 +9,7 @@ interface ResolveTargetOptions {
9
9
  env?: Record<string, string>;
10
10
  xcodeBuildContext: XcodeBuildContext;
11
11
  }
12
- export declare function resolveMangedProjectTargetsAsync({ exp, projectDir, xcodeBuildContext, env, }: ResolveTargetOptions): Promise<Target[]>;
12
+ export declare function resolveManagedProjectTargetsAsync({ exp, projectDir, xcodeBuildContext, env, }: ResolveTargetOptions): Promise<Target[]>;
13
13
  export declare function resolveBareProjectTargetsAsync({ exp, projectDir, xcodeBuildContext, }: ResolveTargetOptions): Promise<Target[]>;
14
14
  export declare function resolveTargetsAsync(opts: ResolveTargetOptions): Promise<Target[]>;
15
15
  export declare function findApplicationTarget(targets: Target[]): Target;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getApplePlatformFromDeviceFamily = exports.getApplePlatformFromSdkRoot = exports.getApplePlatformFromTarget = exports.findTargetByName = exports.findApplicationTarget = exports.resolveTargetsAsync = exports.resolveBareProjectTargetsAsync = exports.resolveMangedProjectTargetsAsync = void 0;
3
+ exports.getApplePlatformFromDeviceFamily = exports.getApplePlatformFromSdkRoot = exports.getApplePlatformFromTarget = exports.findTargetByName = exports.findApplicationTarget = exports.resolveTargetsAsync = exports.resolveBareProjectTargetsAsync = exports.resolveManagedProjectTargetsAsync = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const config_plugins_1 = require("@expo/config-plugins");
6
6
  const eas_build_job_1 = require("@expo/eas-build-job");
@@ -15,7 +15,7 @@ const AppExtensionsConfigSchema = joi_1.default.array().items(joi_1.default.obje
15
15
  parentBundleIdentifier: joi_1.default.string(),
16
16
  entitlements: joi_1.default.object(),
17
17
  }));
18
- async function resolveMangedProjectTargetsAsync({ exp, projectDir, xcodeBuildContext, env, }) {
18
+ async function resolveManagedProjectTargetsAsync({ exp, projectDir, xcodeBuildContext, env, }) {
19
19
  var _a, _b, _c, _d, _e, _f;
20
20
  const { buildScheme, buildConfiguration } = xcodeBuildContext;
21
21
  const applicationTargetName = buildScheme;
@@ -52,7 +52,7 @@ async function resolveMangedProjectTargetsAsync({ exp, projectDir, xcodeBuildCon
52
52
  ...extensionsTargets,
53
53
  ];
54
54
  }
55
- exports.resolveMangedProjectTargetsAsync = resolveMangedProjectTargetsAsync;
55
+ exports.resolveManagedProjectTargetsAsync = resolveManagedProjectTargetsAsync;
56
56
  async function resolveBareProjectTargetsAsync({ exp, projectDir, xcodeBuildContext, }) {
57
57
  const { buildScheme, buildConfiguration } = xcodeBuildContext;
58
58
  const result = [];
@@ -93,7 +93,7 @@ async function resolveTargetsAsync(opts) {
93
93
  return await resolveBareProjectTargetsAsync(opts);
94
94
  }
95
95
  else if (workflow === eas_build_job_1.Workflow.MANAGED) {
96
- return await resolveMangedProjectTargetsAsync(opts);
96
+ return await resolveManagedProjectTargetsAsync(opts);
97
97
  }
98
98
  else {
99
99
  throw new Error(`Unknown workflow: ${workflow}`);
@@ -0,0 +1,8 @@
1
+ import { EASUpdateAction, EASUpdateContext } from '../../eas-update/utils';
2
+ import { UpdateChannelBasicInfoFragment } from '../../graphql/generated';
3
+ /**
4
+ * Select an existing rollout for the project.
5
+ */
6
+ export declare class SelectRollout implements EASUpdateAction<UpdateChannelBasicInfoFragment | null> {
7
+ runAsync(ctx: EASUpdateContext): Promise<UpdateChannelBasicInfoFragment | null>;
8
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SelectRollout = void 0;
4
+ const SelectChannel_1 = require("../../channel/actions/SelectChannel");
5
+ const branch_mapping_1 = require("../../channel/branch-mapping");
6
+ const branch_mapping_2 = require("../branch-mapping");
7
+ /**
8
+ * Select an existing rollout for the project.
9
+ */
10
+ class SelectRollout {
11
+ async runAsync(ctx) {
12
+ const rolloutFilterPredicate = (channelInfo) => {
13
+ const branchMapping = (0, branch_mapping_1.getBranchMapping)(channelInfo.branchMapping);
14
+ return (0, branch_mapping_2.isRollout)(branchMapping);
15
+ };
16
+ const selectChannel = new SelectChannel_1.SelectChannel({
17
+ printedType: 'rollout',
18
+ filterPredicate: rolloutFilterPredicate,
19
+ });
20
+ return await selectChannel.runAsync(ctx);
21
+ }
22
+ }
23
+ exports.SelectRollout = SelectRollout;
@@ -0,0 +1,80 @@
1
+ import { BranchMapping } from '../channel/branch-mapping';
2
+ import { UpdateChannelBasicInfoFragment } from '../graphql/generated';
3
+ import { UpdateBranchObject, UpdateChannelObject } from '../graphql/queries/ChannelQuery';
4
+ export type Rollout = LegacyRollout | ConstrainedRollout;
5
+ export type RolloutInfo = LegacyRolloutInfo | ConstrainedRolloutInfo;
6
+ type ConstrainedRollout = LegacyRollout & {
7
+ runtimeVersion: string;
8
+ };
9
+ type LegacyRollout = {
10
+ rolledOutBranch: UpdateBranchObject;
11
+ defaultBranch: UpdateBranchObject;
12
+ } & LegacyRolloutInfo;
13
+ type ConstrainedRolloutInfo = LegacyRolloutInfo & {
14
+ runtimeVersion: string;
15
+ };
16
+ type LegacyRolloutInfo = {
17
+ rolledOutBranchId: string;
18
+ percentRolledOut: number;
19
+ defaultBranchId: string;
20
+ };
21
+ export declare function isLegacyRolloutInfo(rollout: RolloutInfo): rollout is LegacyRolloutInfo;
22
+ export declare function isConstrainedRolloutInfo(rollout: RolloutInfo): rollout is ConstrainedRolloutInfo;
23
+ export declare function isConstrainedRollout(rollout: Rollout): rollout is ConstrainedRollout;
24
+ export declare function getRolloutInfo(basicChannelInfo: UpdateChannelBasicInfoFragment): RolloutInfo;
25
+ export declare function getRolloutInfoFromBranchMapping(branchMapping: BranchMapping): RolloutInfo;
26
+ export declare function getRollout(channel: UpdateChannelObject): Rollout;
27
+ /**
28
+ * Detect if a branch mapping is a rollout.
29
+ *
30
+ * Types of rollout:
31
+ * 1. Legacy unconstrained rollout:
32
+ * Maps to a rollout branch via a rollout token
33
+ * Falls back to a default branch
34
+ *
35
+ * Example:
36
+ * {
37
+ version: 0,
38
+ data: [
39
+ {
40
+ branchId: uuidv4(),
41
+ branchMappingLogic: {
42
+ operand: 10 / 100,
43
+ clientKey: 'rolloutToken',
44
+ branchMappingOperator: hashLtOperator(),
45
+ },
46
+ },
47
+ { branchId: uuidv4(), branchMappingLogic: alwaysTrue() },
48
+ ],
49
+ }
50
+ *
51
+ * 2. RTV constrained rollout:
52
+ * Maps to a rollout branch via a rollout token, constrained by runtime version
53
+ * Falls back to a default branch
54
+ *
55
+ * Example:
56
+ * {
57
+ version: 0,
58
+ data: [
59
+ {
60
+ branchId: uuidv4(),
61
+ branchMappingLogic: andStatement([
62
+ {
63
+ operand: '1.0.0',
64
+ clientKey: 'runtimeVersion',
65
+ branchMappingOperator: equalsOperator(),
66
+ },
67
+ {
68
+ operand: 10 / 100,
69
+ clientKey: 'rolloutToken',
70
+ branchMappingOperator: hashLtOperator(),
71
+ },
72
+ ]),
73
+ },
74
+ { branchId: uuidv4(), branchMappingLogic: alwaysTrue() },
75
+ ],
76
+ }
77
+ */
78
+ export declare function isRollout(branchMapping: BranchMapping): boolean;
79
+ export declare function editRolloutBranchMapping(branchMapping: BranchMapping, percent: number): BranchMapping;
80
+ export {};
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.editRolloutBranchMapping = exports.isRollout = exports.getRollout = exports.getRolloutInfoFromBranchMapping = exports.getRolloutInfo = exports.isConstrainedRollout = exports.isConstrainedRolloutInfo = exports.isLegacyRolloutInfo = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const assert_1 = tslib_1.__importDefault(require("assert"));
6
+ const branch_mapping_1 = require("../channel/branch-mapping");
7
+ const utils_1 = require("../channel/utils");
8
+ function isLegacyRolloutInfo(rollout) {
9
+ return !isConstrainedRolloutInfo(rollout);
10
+ }
11
+ exports.isLegacyRolloutInfo = isLegacyRolloutInfo;
12
+ function isConstrainedRolloutInfo(rollout) {
13
+ return 'runtimeVersion' in rollout;
14
+ }
15
+ exports.isConstrainedRolloutInfo = isConstrainedRolloutInfo;
16
+ function isConstrainedRollout(rollout) {
17
+ return isConstrainedRolloutInfo(rollout);
18
+ }
19
+ exports.isConstrainedRollout = isConstrainedRollout;
20
+ function getRolloutInfo(basicChannelInfo) {
21
+ const branchMapping = (0, branch_mapping_1.getBranchMapping)(basicChannelInfo.branchMapping);
22
+ assertRollout(branchMapping);
23
+ return getRolloutInfoFromBranchMapping(branchMapping);
24
+ }
25
+ exports.getRolloutInfo = getRolloutInfo;
26
+ function getRolloutInfoFromBranchMapping(branchMapping) {
27
+ assertRollout(branchMapping);
28
+ const rolledOutBranchId = branchMapping.data[0].branchId;
29
+ const defaultBranchId = branchMapping.data[1].branchId;
30
+ if (isRtvConstrainedRollout(branchMapping)) {
31
+ const statementNode = branchMapping.data[0].branchMappingLogic;
32
+ (0, branch_mapping_1.assertStatement)(statementNode);
33
+ const nodesFromStatement = (0, branch_mapping_1.getNodesFromStatement)(statementNode);
34
+ const runtimeVersionNode = nodesFromStatement.find(isRuntimeVersionNode);
35
+ (0, assert_1.default)(runtimeVersionNode, 'Runtime version node must be defined.');
36
+ (0, branch_mapping_1.assertNodeObject)(runtimeVersionNode);
37
+ const runtimeVersion = runtimeVersionNode.operand;
38
+ (0, branch_mapping_1.assertString)(runtimeVersion);
39
+ const rolloutNode = nodesFromStatement.find(isRolloutNode);
40
+ (0, assert_1.default)(rolloutNode, 'Rollout node must be defined.');
41
+ (0, branch_mapping_1.assertNodeObject)(rolloutNode);
42
+ const operand = rolloutNode.operand;
43
+ (0, branch_mapping_1.assertNumber)(operand);
44
+ return {
45
+ rolledOutBranchId,
46
+ percentRolledOut: operand * 100,
47
+ runtimeVersion,
48
+ defaultBranchId,
49
+ };
50
+ }
51
+ else {
52
+ const rolloutNode = branchMapping.data[0].branchMappingLogic;
53
+ (0, branch_mapping_1.assertNodeObject)(rolloutNode);
54
+ const operand = rolloutNode.operand;
55
+ (0, branch_mapping_1.assertNumber)(operand);
56
+ return {
57
+ rolledOutBranchId,
58
+ percentRolledOut: operand * 100,
59
+ defaultBranchId,
60
+ };
61
+ }
62
+ }
63
+ exports.getRolloutInfoFromBranchMapping = getRolloutInfoFromBranchMapping;
64
+ function getRollout(channel) {
65
+ const branchMapping = (0, branch_mapping_1.getBranchMapping)(channel.branchMapping);
66
+ assertRollout(branchMapping);
67
+ const rolledOutBranchId = branchMapping.data[0].branchId;
68
+ const rolledOutBranch = (0, utils_1.getUpdateBranch)(channel, rolledOutBranchId);
69
+ const defaultBranchId = branchMapping.data[1].branchId;
70
+ const defaultBranch = (0, utils_1.getUpdateBranch)(channel, defaultBranchId);
71
+ const rolloutInfo = getRolloutInfo(channel);
72
+ return {
73
+ ...rolloutInfo,
74
+ rolledOutBranch,
75
+ defaultBranch,
76
+ };
77
+ }
78
+ exports.getRollout = getRollout;
79
+ /**
80
+ * Detect if a branch mapping is a rollout.
81
+ *
82
+ * Types of rollout:
83
+ * 1. Legacy unconstrained rollout:
84
+ * Maps to a rollout branch via a rollout token
85
+ * Falls back to a default branch
86
+ *
87
+ * Example:
88
+ * {
89
+ version: 0,
90
+ data: [
91
+ {
92
+ branchId: uuidv4(),
93
+ branchMappingLogic: {
94
+ operand: 10 / 100,
95
+ clientKey: 'rolloutToken',
96
+ branchMappingOperator: hashLtOperator(),
97
+ },
98
+ },
99
+ { branchId: uuidv4(), branchMappingLogic: alwaysTrue() },
100
+ ],
101
+ }
102
+ *
103
+ * 2. RTV constrained rollout:
104
+ * Maps to a rollout branch via a rollout token, constrained by runtime version
105
+ * Falls back to a default branch
106
+ *
107
+ * Example:
108
+ * {
109
+ version: 0,
110
+ data: [
111
+ {
112
+ branchId: uuidv4(),
113
+ branchMappingLogic: andStatement([
114
+ {
115
+ operand: '1.0.0',
116
+ clientKey: 'runtimeVersion',
117
+ branchMappingOperator: equalsOperator(),
118
+ },
119
+ {
120
+ operand: 10 / 100,
121
+ clientKey: 'rolloutToken',
122
+ branchMappingOperator: hashLtOperator(),
123
+ },
124
+ ]),
125
+ },
126
+ { branchId: uuidv4(), branchMappingLogic: alwaysTrue() },
127
+ ],
128
+ }
129
+ */
130
+ function isRollout(branchMapping) {
131
+ return isUnconstrainedRollout(branchMapping) || isRtvConstrainedRollout(branchMapping);
132
+ }
133
+ exports.isRollout = isRollout;
134
+ function editRolloutBranchMapping(branchMapping, percent) {
135
+ (0, assert_1.default)(Number.isInteger(percent) && percent >= 0 && percent <= 100, 'The rollout percentage must be an integer between 0 and 100 inclusive.');
136
+ assertRollout(branchMapping);
137
+ if (isRtvConstrainedRollout(branchMapping)) {
138
+ return editRtvConstrainedRollout(branchMapping, percent);
139
+ }
140
+ else {
141
+ return editLegacyRollout(branchMapping, percent);
142
+ }
143
+ }
144
+ exports.editRolloutBranchMapping = editRolloutBranchMapping;
145
+ function editRtvConstrainedRollout(branchMapping, percent) {
146
+ const newBranchMapping = { ...branchMapping };
147
+ const statementNode = newBranchMapping.data[0].branchMappingLogic;
148
+ (0, branch_mapping_1.assertStatement)(statementNode);
149
+ const nodesFromStatement = (0, branch_mapping_1.getNodesFromStatement)(statementNode);
150
+ const rolloutNode = nodesFromStatement.find(isRolloutNode);
151
+ (0, assert_1.default)(rolloutNode, 'Rollout node must be defined.');
152
+ (0, branch_mapping_1.assertNodeObject)(rolloutNode);
153
+ rolloutNode.operand = percent / 100;
154
+ return newBranchMapping;
155
+ }
156
+ function editLegacyRollout(branchMapping, percent) {
157
+ const newBranchMapping = { ...branchMapping };
158
+ const rolloutNode = newBranchMapping.data[0].branchMappingLogic;
159
+ (0, branch_mapping_1.assertNodeObject)(rolloutNode);
160
+ rolloutNode.operand = percent / 100;
161
+ return newBranchMapping;
162
+ }
163
+ function assertRollout(branchMapping) {
164
+ (0, assert_1.default)(isRollout(branchMapping), 'Branch mapping node must be a rollout. Received: ' + JSON.stringify(branchMapping));
165
+ }
166
+ function isRtvConstrainedRollout(branchMapping) {
167
+ if (branchMapping.data.length !== 2) {
168
+ return false;
169
+ }
170
+ const hasRtvRolloutNode = isRtvConstrainedRolloutNode(branchMapping.data[0].branchMappingLogic);
171
+ const defaultsToAlwaysTrueNode = (0, branch_mapping_1.isAlwaysTrue)(branchMapping.data[1].branchMappingLogic);
172
+ return hasRtvRolloutNode && defaultsToAlwaysTrueNode;
173
+ }
174
+ function isRtvConstrainedRolloutNode(node) {
175
+ if (!(0, branch_mapping_1.isStatement)(node) || !(0, branch_mapping_1.isAndStatement)(node)) {
176
+ return false;
177
+ }
178
+ const statementNodes = (0, branch_mapping_1.getNodesFromStatement)(node);
179
+ if (statementNodes.length !== 2) {
180
+ return false;
181
+ }
182
+ const hasRuntimeVersionNode = statementNodes.some(isRuntimeVersionNode);
183
+ const hasRolloutNode = statementNodes.some(isRolloutNode);
184
+ return hasRuntimeVersionNode && hasRolloutNode;
185
+ }
186
+ function isUnconstrainedRollout(branchMapping) {
187
+ if (branchMapping.data.length !== 2) {
188
+ return false;
189
+ }
190
+ const hasRolloutNode = isRolloutNode(branchMapping.data[0].branchMappingLogic);
191
+ const defaultsToAlwaysTrueNode = (0, branch_mapping_1.isAlwaysTrue)(branchMapping.data[1].branchMappingLogic);
192
+ return hasRolloutNode && defaultsToAlwaysTrueNode;
193
+ }
194
+ function isRuntimeVersionNode(node) {
195
+ if (typeof node === 'string') {
196
+ return false;
197
+ }
198
+ if (Array.isArray(node)) {
199
+ return false;
200
+ }
201
+ return node.clientKey === 'runtimeVersion' && node.branchMappingOperator === '==';
202
+ }
203
+ function isRolloutNode(node) {
204
+ if (typeof node === 'string') {
205
+ return false;
206
+ }
207
+ if (Array.isArray(node)) {
208
+ return false;
209
+ }
210
+ return node.clientKey === 'rolloutToken' && node.branchMappingOperator === 'hash_lt';
211
+ }
@@ -1,53 +1,3 @@
1
- import { BranchMapping } from '../channel/branch-mapping';
2
- /**
3
- * Detect if a branch mapping is a rollout.
4
- *
5
- * Types of rollout:
6
- * 1. Legacy unconstrained rollout:
7
- * Maps to a rollout branch via a rollout token
8
- * Falls back to a default branch
9
- *
10
- * Example:
11
- * {
12
- version: 0,
13
- data: [
14
- {
15
- branchId: uuidv4(),
16
- branchMappingLogic: {
17
- operand: 10 / 100,
18
- clientKey: 'rolloutToken',
19
- branchMappingOperator: hashLtOperator(),
20
- },
21
- },
22
- { branchId: uuidv4(), branchMappingLogic: alwaysTrue() },
23
- ],
24
- }
25
- *
26
- * 2. RTV constrained rollout:
27
- * Maps to a rollout branch via a rollout token, constrained by runtime version
28
- * Falls back to a default branch
29
- *
30
- * Example:
31
- * {
32
- version: 0,
33
- data: [
34
- {
35
- branchId: uuidv4(),
36
- branchMappingLogic: andStatement([
37
- {
38
- operand: '1.0.0',
39
- clientKey: 'runtimeVersion',
40
- branchMappingOperator: equalsOperator(),
41
- },
42
- {
43
- operand: 10 / 100,
44
- clientKey: 'rolloutToken',
45
- branchMappingOperator: hashLtOperator(),
46
- },
47
- ]),
48
- },
49
- { branchId: uuidv4(), branchMappingLogic: alwaysTrue() },
50
- ],
51
- }
52
- */
53
- export declare function isRollout(branchMapping: BranchMapping): boolean;
1
+ import { UpdateChannelObject } from '../graphql/queries/ChannelQuery';
2
+ export declare function printRollout(channel: UpdateChannelObject): void;
3
+ export declare function printBranch(channel: UpdateChannelObject): void;
@@ -1,105 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRollout = void 0;
4
- const branch_mapping_1 = require("../channel/branch-mapping");
5
- /**
6
- * Detect if a branch mapping is a rollout.
7
- *
8
- * Types of rollout:
9
- * 1. Legacy unconstrained rollout:
10
- * Maps to a rollout branch via a rollout token
11
- * Falls back to a default branch
12
- *
13
- * Example:
14
- * {
15
- version: 0,
16
- data: [
17
- {
18
- branchId: uuidv4(),
19
- branchMappingLogic: {
20
- operand: 10 / 100,
21
- clientKey: 'rolloutToken',
22
- branchMappingOperator: hashLtOperator(),
3
+ exports.printBranch = exports.printRollout = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const log_1 = tslib_1.__importDefault(require("../log"));
7
+ const formatFields_1 = tslib_1.__importDefault(require("../utils/formatFields"));
8
+ const branch_mapping_1 = require("./branch-mapping");
9
+ function printRollout(channel) {
10
+ const rollout = (0, branch_mapping_1.getRollout)(channel);
11
+ const rolledOutPercent = rollout.percentRolledOut;
12
+ log_1.default.addNewLineIfNone();
13
+ log_1.default.log(chalk_1.default.bold('Rollout:'));
14
+ log_1.default.log((0, formatFields_1.default)([
15
+ { label: 'Channel', value: channel.name },
16
+ ...((0, branch_mapping_1.isConstrainedRollout)(rollout)
17
+ ? [{ label: 'Runtime Version', value: rollout.runtimeVersion }]
18
+ : []),
19
+ {
20
+ label: 'Branches',
21
+ value: `${rollout.rolledOutBranch.name} (${rolledOutPercent}%), ${rollout.defaultBranch.name} (${100 - rolledOutPercent}%)`,
23
22
  },
24
- },
25
- { branchId: uuidv4(), branchMappingLogic: alwaysTrue() },
26
- ],
27
- }
28
- *
29
- * 2. RTV constrained rollout:
30
- * Maps to a rollout branch via a rollout token, constrained by runtime version
31
- * Falls back to a default branch
32
- *
33
- * Example:
34
- * {
35
- version: 0,
36
- data: [
37
- {
38
- branchId: uuidv4(),
39
- branchMappingLogic: andStatement([
40
- {
41
- operand: '1.0.0',
42
- clientKey: 'runtimeVersion',
43
- branchMappingOperator: equalsOperator(),
44
- },
45
- {
46
- operand: 10 / 100,
47
- clientKey: 'rolloutToken',
48
- branchMappingOperator: hashLtOperator(),
49
- },
50
- ]),
51
- },
52
- { branchId: uuidv4(), branchMappingLogic: alwaysTrue() },
53
- ],
54
- }
55
- */
56
- function isRollout(branchMapping) {
57
- return isUnconstrainedRollout(branchMapping) || isRtvConstrainedRollout(branchMapping);
23
+ ]));
24
+ log_1.default.addNewLineIfNone();
58
25
  }
59
- exports.isRollout = isRollout;
60
- function isRtvConstrainedRollout(branchMapping) {
61
- if (branchMapping.data.length !== 2) {
62
- return false;
63
- }
64
- const hasRtvRolloutNode = isRtvConstrainedRolloutNode(branchMapping.data[0].branchMappingLogic);
65
- const defaultsToAlwaysTrueNode = (0, branch_mapping_1.isAlwaysTrue)(branchMapping.data[1].branchMappingLogic);
66
- return hasRtvRolloutNode && defaultsToAlwaysTrueNode;
67
- }
68
- function isRtvConstrainedRolloutNode(node) {
69
- if (!(0, branch_mapping_1.isStatement)(node) || !(0, branch_mapping_1.isAndStatement)(node)) {
70
- return false;
71
- }
72
- const statementNodes = (0, branch_mapping_1.getNodesFromStatement)(node);
73
- if (statementNodes.length !== 2) {
74
- return false;
75
- }
76
- const hasRuntimeVersionNode = statementNodes.some(isRuntimeVersionNode);
77
- const hasRolloutNode = statementNodes.some(isRolloutNode);
78
- return hasRuntimeVersionNode && hasRolloutNode;
79
- }
80
- function isUnconstrainedRollout(branchMapping) {
81
- if (branchMapping.data.length !== 2) {
82
- return false;
83
- }
84
- const hasRolloutNode = isRolloutNode(branchMapping.data[0].branchMappingLogic);
85
- const defaultsToAlwaysTrueNode = (0, branch_mapping_1.isAlwaysTrue)(branchMapping.data[1].branchMappingLogic);
86
- return hasRolloutNode && defaultsToAlwaysTrueNode;
87
- }
88
- function isRuntimeVersionNode(node) {
89
- if (typeof node === 'string') {
90
- return false;
91
- }
92
- if (Array.isArray(node)) {
93
- return false;
94
- }
95
- return node.clientKey === 'runtimeVersion' && node.branchMappingOperator === '==';
96
- }
97
- function isRolloutNode(node) {
98
- if (typeof node === 'string') {
99
- return false;
100
- }
101
- if (Array.isArray(node)) {
102
- return false;
103
- }
104
- return node.clientKey === 'rolloutToken' && node.branchMappingOperator === 'hash_lt';
26
+ exports.printRollout = printRollout;
27
+ function printBranch(channel) {
28
+ const rollout = (0, branch_mapping_1.getRollout)(channel);
29
+ const rolledOutPercent = rollout.percentRolledOut;
30
+ log_1.default.addNewLineIfNone();
31
+ log_1.default.log(chalk_1.default.bold('Rollout:'));
32
+ log_1.default.log((0, formatFields_1.default)([
33
+ { label: 'Channel', value: channel.name },
34
+ ...((0, branch_mapping_1.isConstrainedRollout)(rollout)
35
+ ? [{ label: 'Runtime Version', value: rollout.runtimeVersion }]
36
+ : []),
37
+ {
38
+ label: 'Branches',
39
+ value: `${rollout.rolledOutBranch.name} (${rolledOutPercent}%), ${rollout.defaultBranch.name} (${100 - rolledOutPercent}%)`,
40
+ },
41
+ ]));
42
+ log_1.default.addNewLineIfNone();
105
43
  }
44
+ exports.printBranch = printBranch;
@@ -6,10 +6,11 @@ export type ProfileData<T extends ProfileType> = {
6
6
  platform: Platform;
7
7
  profileName: string;
8
8
  };
9
- export declare function getProfilesAsync<T extends ProfileType>({ easJsonAccessor, platforms, profileName, type, }: {
9
+ export declare function getProfilesAsync<T extends ProfileType>({ easJsonAccessor, platforms, profileName, type, projectDir, }: {
10
10
  easJsonAccessor: EasJsonAccessor;
11
11
  platforms: Platform[];
12
12
  profileName?: string;
13
+ projectDir: string;
13
14
  type: T;
14
15
  }): Promise<ProfileData<T>[]>;
15
16
  /**