Skip to content

Commit

Permalink
feat(sanity): use semver range for checking feature toggle Studio ver…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
juice49 committed Jun 19, 2024
1 parent 3c5cc31 commit 3c5efbe
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
1 change: 0 additions & 1 deletion packages/sanity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
"write:playwright-report-as-pr-comment": "node -r esbuild-register playwright-ct/scripts/parsePlaywrightReportJson.ts"
},
"dependencies": {
"compare-versions": "^6.1.0",
"@dnd-kit/core": "^6.0.5",
"@dnd-kit/modifiers": "^6.0.0",
"@dnd-kit/sortable": "^7.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@ describe('mapResponse', () => {
})

it.each([
['2', true],
['>= 2', true],
['>= 3', true],
['>= 4', false],

['2', false],
['3', true],
['3.0.0', false],
['4', false],

['2.13.13', true],
['3.13.13', true],
['4.13.13', false],
['>= 2.13.13', true],
['>= 3.13.13', true],
['>= 4.13.13', false],

['>= 3.46.9', true],
['>= 3.47.0', true],
['>= 3.47.1', false],

['3.46.9', true],
['3.47.0', true],
['3.47.1', false],
['< 2 || 3.47.0', true],
['< 2 || 3.45.0', false],
])(
'respects the version specified in the `minimumStudioVersion` property (%s)',
async (minimumStudioVersion, expected) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {type SanityClient} from '@sanity/client'
import {compare as compareVersions} from 'compare-versions'
import {map, type Observable, of, type OperatorFunction, ReplaySubject, timeout, timer} from 'rxjs'
import {catchError, concatMap, share} from 'rxjs/operators'
import {SANITY_VERSION} from 'sanity'
import semverSatisfies from 'semver/functions/satisfies'

export interface ActionsFeatureToggle {
minimumStudioVersion?: string
Expand Down Expand Up @@ -50,7 +50,7 @@ export function mapResponse(): OperatorFunction<ActionsFeatureToggle, boolean> {
return map<ActionsFeatureToggle, boolean>(
(res) =>
typeof res.minimumStudioVersion !== 'undefined' &&
compareVersions(SANITY_VERSION, res.minimumStudioVersion, '>='),
semverSatisfies(SANITY_VERSION, res.minimumStudioVersion),
)
}

Expand Down
7 changes: 0 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3c5efbe

Please sign in to comment.