Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eas-cli] more branch map utility functions #2001

Merged
merged 3 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -26,13 +26,25 @@ import {
isConstrainedRolloutInfo,
isLegacyRolloutInfo,
isRolloutBranchMapping,
targetsRollout,
} from '../branch-mapping';
import {
rolloutBranchMapping,
rolloutBranchMappingLegacy,
standardBranchMapping,
} from './fixtures';

describe(targetsRollout, () => {
it('detects whether a runtime targets a constrained rollout', () => {
expect(targetsRollout(rolloutBranchMapping, '1.0.0')).toBe(true);
expect(targetsRollout(rolloutBranchMapping, '2.0.0')).toBe(false);
});
it('should always return true if the rollout is unconstrained', () => {
expect(targetsRollout(rolloutBranchMappingLegacy, '1.0.0')).toBe(true);
expect(targetsRollout(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 targetsRollout(
quinlanj marked this conversation as resolved.
Show resolved Hide resolved
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
Loading