Skip to content

Commit

Permalink
[eas-cli] more branch map utility functions (#2001)
Browse files Browse the repository at this point in the history
* [eas-cli] more branch map utility functions

* update CHANGELOG.md

* feedback
  • Loading branch information
quinlanj committed Aug 11, 2023
1 parent 162d64b commit baf94a2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ This is the log of notable changes to EAS CLI and related packages.

### 🧹 Chores

- More branch map utility functions. ([#2001](https://github.com/expo/eas-cli/pull/2001) by [@quinlanj](https://github.com/quinlanj))

## [4.1.2](https://github.com/expo/eas-cli/releases/tag/v4.1.2) - 2023-08-10

### 🧹 Chores
Expand Down
12 changes: 12 additions & 0 deletions packages/eas-cli/src/rollout/__tests__/branch-mapping-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
assertRolloutBranchMapping,
composeRollout,
createRolloutBranchMapping,
doesTargetRollout,
editRolloutBranchMapping,
getRollout,
getRolloutInfo,
Expand All @@ -33,6 +34,17 @@ import {
standardBranchMapping,
} from './fixtures';

describe(doesTargetRollout, () => {
it('detects whether a runtime targets a constrained rollout', () => {
expect(doesTargetRollout(rolloutBranchMapping, '1.0.0')).toBe(true);
expect(doesTargetRollout(rolloutBranchMapping, '2.0.0')).toBe(false);
});
it('should always return true if the rollout is unconstrained', () => {
expect(doesTargetRollout(rolloutBranchMappingLegacy, '1.0.0')).toBe(true);
expect(doesTargetRollout(rolloutBranchMappingLegacy, '2.0.0')).toBe(true);
});
});

describe(composeRollout, () => {
it('composes a rollout', () => {
const rollout = getRollout(channelInfoWithBranches);
Expand Down
11 changes: 11 additions & 0 deletions packages/eas-cli/src/rollout/branch-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ export function isRollout(channelInfo: ChannelBasicInfo): boolean {
return isRolloutBranchMapping(branchMapping);
}

export function doesTargetRollout(
branchMapping: RolloutBranchMapping,
runtimeVersion: string
): boolean {
const rolloutInfo = getRolloutInfoFromBranchMapping(branchMapping);
if (!isConstrainedRolloutInfo(rolloutInfo)) {
return true;
}
return rolloutInfo.runtimeVersion === runtimeVersion;
}

export function createRolloutBranchMapping({
defaultBranchId,
rolloutBranchId,
Expand Down

0 comments on commit baf94a2

Please sign in to comment.