Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a104799
feat: scopes wip
fahad19 Nov 29, 2025
4392015
failing test
fahad19 Nov 29, 2025
34c798f
example project using scopes
fahad19 Nov 29, 2025
1a8d4b1
wip
fahad19 Nov 29, 2025
e0be094
updates
fahad19 Nov 29, 2025
c03db89
extract into separate module
fahad19 Nov 29, 2025
c3a121d
linting fixes
fahad19 Nov 29, 2025
ec87346
tests
fahad19 Nov 29, 2025
870c3ad
tests updated
fahad19 Nov 29, 2025
503e05b
tests passing
fahad19 Nov 29, 2025
8cfa26b
tests for feature
fahad19 Dec 7, 2025
490168b
tests for scope
fahad19 Dec 7, 2025
ffd9eed
support linting for test specs with scope
fahad19 Dec 7, 2025
cb73704
test runner with scopes
fahad19 Dec 7, 2025
a0e6678
pick the scoped datafile when testing correctly
fahad19 Dec 15, 2025
8b4c0f3
todo for tag in feature assertion
fahad19 Dec 15, 2025
514c029
add two new features for testing
fahad19 Dec 15, 2025
fd384ca
allow scopes to target multiple tags
fahad19 Dec 17, 2025
96b8ceb
scope by multiple tags
fahad19 Dec 17, 2025
1b3ea48
tests updated
fahad19 Dec 17, 2025
51a14f9
allow printing datafile in CLI by tag and scope name
fahad19 Dec 18, 2025
87c254d
allow testing only against predefined scopes
fahad19 Dec 19, 2025
1bc093e
more examples for complex tests
fahad19 Dec 21, 2025
07c3788
build scoped conditions
fahad19 Dec 27, 2025
c9b55bd
TODOs
fahad19 Dec 27, 2025
9fb3da4
Merge branch 'main' into scopes-v2
fahad19 Dec 28, 2025
b976c54
version updated
fahad19 Dec 28, 2025
cd13365
and or not conditions
fahad19 Dec 31, 2025
826c475
todos
fahad19 Jan 3, 2026
f023fcb
update tests to be more granular
fahad19 Jan 4, 2026
96c8879
tests
fahad19 Jan 4, 2026
b8cfdcc
more tests
fahad19 Jan 4, 2026
cab52a5
tests for removing redundant conditions
fahad19 Jan 4, 2026
eefe138
add more tests
fahad19 Jan 4, 2026
bd53674
tests for buildScopedCondition
fahad19 Jan 4, 2026
63a8f09
tests for buildScopedConditions
fahad19 Jan 4, 2026
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
8 changes: 8 additions & 0 deletions examples/example-yml-scopes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
*.log
npm-debug.log*
.DS_Store

datafiles
out
src
46 changes: 46 additions & 0 deletions examples/example-yml-scopes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# example-yml-scopes

Example project showing how to use `scopes` in Featurevisor.

Visit [https://featurevisor.com](https://featurevisor.com) for more information.

## Initialize

```
$ mkdir my-featurevisor-project && cd my-featurevisor-project
$ npx @featurevisor/cli init --example example-yml-scopes
```

## Installation

```
$ npm install
```

## Usage

### Lint YAMLs

```
$ npm run lint
```

### Build datafiles

```
$ npm run build
```

### Test features

```
$ npm test
```

### Start local server

Generates and serves status site:

```
$ npm start
```
2 changes: 2 additions & 0 deletions examples/example-yml-scopes/attributes/country.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description: country code in lower case (two lettered)
type: string
2 changes: 2 additions & 0 deletions examples/example-yml-scopes/attributes/deviceId.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description: Device ID
type: string
2 changes: 2 additions & 0 deletions examples/example-yml-scopes/attributes/platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description: device platform (like web, iOS, android)
type: string
2 changes: 2 additions & 0 deletions examples/example-yml-scopes/attributes/userId.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description: User ID
type: string
17 changes: 17 additions & 0 deletions examples/example-yml-scopes/features/checkout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
description: Checkout feature
tags:
- all
- ios

bucketBy: userId

rules:
staging:
- key: everyone
segments: "*"
percentage: 100

production:
- key: everyone
segments: "*"
percentage: 0
35 changes: 35 additions & 0 deletions examples/example-yml-scopes/features/newRedesign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
description: New redesign feature
tags:
- all
- web

bucketBy: userId

rules:
staging:
- key: everyone
segments: "*"
percentage: 100

production:
- key: nl-web
segments:
- netherlands
- web
percentage: 100

- key: nl-ios
segments:
- netherlands
- ios
percentage: 100

- key: nl-android
segments:
- netherlands
- android
percentage: 100

- key: everyone
segments: "*"
percentage: 0
28 changes: 28 additions & 0 deletions examples/example-yml-scopes/features/showBanner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
description: Show banner feature
tags:
- all
- web
- ios
- android
- mobile

bucketBy: userId

rules:
staging:
- key: everyone
segments: "*"
percentage: 100

production:
- key: web
segments: web
percentage: 100

- key: ios
segments: ios
percentage: 50

- key: android
segments: android
percentage: 25
52 changes: 52 additions & 0 deletions examples/example-yml-scopes/featurevisor.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/** @type {import('@featurevisor/core').ProjectConfig} */
module.exports = {
environments: ["staging", "production"],
tags: ["all", "web", "ios", "android"],
scopes: [
{
name: "browsers",
tag: "web",
context: { platform: "web" },
},
{
name: "ios",
tag: "ios",
context: { platform: "ios" },
},
{
name: "android",
tag: "android",
context: { platform: "android" },
},

// multiple tags
{
name: "nl",
tags: ["web"],
context: { country: "nl" },
},
{
name: "web-or-mobile-simple",
tags: {
or: ["web", "ios"],
},
context: {},
},
{
name: "web-or-mobile-explicit",
tags: {
or: ["web", "ios"],
},
context: {},
},
{
name: "web-and-mobile",
tags: {
and: ["web", "ios"],
},
context: {},
},
],
prettyState: true,
prettyDatafile: true, // enabled for readability while developing
};
18 changes: 18 additions & 0 deletions examples/example-yml-scopes/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@featurevisor/example-yml-scopes",
"private": true,
"version": "2.3.3",
"description": "Featurevisor project with YAML definitions",
"scripts": {
"lint": "featurevisor lint",
"build": "featurevisor build",
"test": "featurevisor test",
"export": "featurevisor site export",
"start": "npm run export && featurevisor site serve",
"generate-code": "featurevisor generate-code --language typescript --out-dir ./src",
"find-duplicate-segments": "featurevisor find-duplicate-segments"
},
"dependencies": {
"@featurevisor/cli": "2.5.0"
}
}
5 changes: 5 additions & 0 deletions examples/example-yml-scopes/segments/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Target Android devices
conditions:
- attribute: platform
operator: equals
value: android
5 changes: 5 additions & 0 deletions examples/example-yml-scopes/segments/ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Target iOS devices
conditions:
- attribute: platform
operator: equals
value: ios
5 changes: 5 additions & 0 deletions examples/example-yml-scopes/segments/netherlands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: The Netherlands
conditions:
- attribute: country
operator: equals
value: nl
5 changes: 5 additions & 0 deletions examples/example-yml-scopes/segments/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Target browsers
conditions:
- attribute: platform
operator: equals
value: web
121 changes: 121 additions & 0 deletions examples/example-yml-scopes/tests/features/showBanner.spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
feature: showBanner
assertions:
##
# Enabled
#
- at: 10
environment: staging
context: {}
expectedToBeEnabled: true

- matrix:
at: [10, 20, 30]
platform: [web]
at: ${{ at }}
environment: production
description: "At ${{ at }}% in production, the feature should be enabled for web"
context:
platform: ${{ platform }}
expectedToBeEnabled: true

- matrix:
at: [10, 20, 30]
platform: [ios]
at: ${{ at }}
environment: production
description: "At ${{ at }}% in production, the feature should be enabled for ios"
context:
platform: ${{ platform }}
expectedToBeEnabled: true

- matrix:
at: [10, 20]
platform: [android]
at: ${{ at }}
environment: production
description: "At ${{ at }}% in production, the feature should be enabled for android"
context:
platform: ${{ platform }}
expectedToBeEnabled: true

##
# Disabled
#
- matrix:
at: [60, 80, 90]
platform: [ios]
at: ${{ at }}
environment: production
description: "At ${{ at }}% in production, the feature should be disabled for ios"
context:
platform: ${{ platform }}
expectedToBeEnabled: false

- matrix:
at: [40, 50, 60]
platform: [android]
at: ${{ at }}
environment: production
description: "At ${{ at }}% in production, the feature should be disabled for android"
context:
platform: ${{ platform }}
expectedToBeEnabled: false

##
# Enabled (with scope)
#
# No additional context is needed to be passed
#

# enabled
- at: 10
environment: staging
scope: browsers
context: {}
expectedToBeEnabled: true

- matrix:
at: [10, 20, 30, 40, 80, 100]
at: ${{ at }}
environment: production
scope: browsers
description: "At ${{ at }}% in production, the feature should be enabled for browsers scope"
context: {}
expectedToBeEnabled: true

- matrix:
at: [10, 20, 30, 40]
at: ${{ at }}
environment: production
scope: ios
description: "At ${{ at }}% in production, the feature should be enabled for ios scope"
context: {}
expectedToBeEnabled: true

- matrix:
at: [10, 20]
at: ${{ at }}
environment: production
scope: ios
description: "At ${{ at }}% in production, the feature should be enabled for android scope"
context: {}
expectedToBeEnabled: true

# disabled
- matrix:
at: [60, 80]
at: ${{ at }}
environment: production
scope: ios
description: "At ${{ at }}% in production, the feature should be disabled for ios scope"
context: {}
expectedToBeEnabled: false

- matrix:
at: [40, 80]
at: ${{ at }}
environment: production
scope: android
description: "At ${{ at }}% in production, the feature should be disabled for android scope"
context: {}
expectedToBeEnabled: false
14 changes: 14 additions & 0 deletions examples/example-yml-scopes/tests/segments/netherlands.spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
segment: netherlands
assertions:
- context:
country: nl
expectedToMatch: true

- context:
country: de
someOtherAttribute: someOtherValue
expectedToMatch: false

- context:
country: notNl
expectedToMatch: false
Loading