-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Initial GrowthBook OpenFeature provider (#896)
Signed-off-by: Michael Samper <[email protected]>
- Loading branch information
Showing
20 changed files
with
687 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"extends": ["../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.json"], | ||
"parser": "jsonc-eslint-parser", | ||
"rules": { | ||
"@nx/dependency-checks": "error" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# growthbook-client Provider | ||
|
||
## Installation | ||
|
||
``` | ||
$ npm install @openfeature/growthbook-client-provider | ||
``` | ||
|
||
## Example Setup | ||
|
||
```typescript | ||
import { GrowthBook, Context, InitOptions } from '@growthbook/growthbook'; | ||
import { GrowthbookClientProvider } from '@openfeature/growthbook-client-provider'; | ||
|
||
/* | ||
* Configure your GrowthBook instance with GrowthBook context | ||
* @see https://docs.growthbook.io/lib/js#step-1-configure-your-app | ||
*/ | ||
const gbContext: Context = { | ||
apiHost: 'https://cdn.growthbook.io', | ||
clientKey: 'sdk-abc123', | ||
// Only required if you have feature encryption enabled in GrowthBook | ||
decryptionKey: 'key_abc123', | ||
}; | ||
|
||
/* | ||
* optional init options | ||
* @see https://docs.growthbook.io/lib/js#switching-to-init | ||
*/ | ||
const initOptions: InitOptions = { | ||
timeout: 2000, | ||
streaming: true, | ||
}; | ||
|
||
OpenFeature.setProvider(new GrowthbookClientProvider(gbContext, initOptions)); | ||
``` | ||
|
||
## Building | ||
|
||
Run `nx package providers-growthbook-client` to build the library. | ||
|
||
## Running unit tests | ||
|
||
Run `nx test providers-growthbook-client` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["minify", { "builtIns": false }]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'providers-growthbook-client', | ||
preset: '../../../jest.preset.js', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../../coverage/libs/providers/growthbook-client', | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "@openfeature/growthbook-client-provider", | ||
"version": "0.1.0", | ||
"dependencies": { | ||
"tslib": "^2.3.0" | ||
}, | ||
"main": "./src/index.js", | ||
"typings": "./src/index.d.ts", | ||
"scripts": { | ||
"publish-if-not-exists": "cp $NPM_CONFIG_USERCONFIG .npmrc && if [ \"$(npm show $npm_package_name@$npm_package_version version)\" = \"$(npm run current-version -s)\" ]; then echo 'already published, skipping'; else npm publish --access public; fi", | ||
"current-version": "echo $npm_package_version" | ||
}, | ||
"peerDependencies": { | ||
"@growthbook/growthbook": "^1.0.0", | ||
"@openfeature/web-sdk": "^1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"name": "providers-growthbook-client", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/providers/growthbook-client/src", | ||
"projectType": "library", | ||
"targets": { | ||
"publish": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "npm run publish-if-not-exists", | ||
"cwd": "dist/libs/providers/growthbook-client" | ||
}, | ||
"dependsOn": [ | ||
{ | ||
"projects": "self", | ||
"target": "package" | ||
} | ||
] | ||
}, | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": [ | ||
"libs/providers/growthbook-client/**/*.ts", | ||
"libs/providers/growthbook-client/package.json" | ||
] | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "libs/providers/growthbook-client/jest.config.ts", | ||
"passWithNoTests": true | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"ci": true, | ||
"codeCoverage": true | ||
} | ||
} | ||
}, | ||
"package": { | ||
"executor": "@nx/rollup:rollup", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"project": "libs/providers/growthbook-client/package.json", | ||
"outputPath": "dist/libs/providers/growthbook-client", | ||
"entryFile": "libs/providers/growthbook-client/src/index.ts", | ||
"tsConfig": "libs/providers/growthbook-client/tsconfig.lib.json", | ||
"buildableProjectDepsInPackageJsonType": "dependencies", | ||
"compiler": "tsc", | ||
"generateExportsField": true, | ||
"umdName": "growthbook-client", | ||
"external": "all", | ||
"format": ["cjs", "esm"], | ||
"assets": [ | ||
{ | ||
"glob": "package.json", | ||
"input": "./assets", | ||
"output": "./src/" | ||
}, | ||
{ | ||
"glob": "LICENSE", | ||
"input": "./", | ||
"output": "./" | ||
}, | ||
{ | ||
"glob": "README.md", | ||
"input": "./libs/providers/growthbook-client", | ||
"output": "./" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './lib/growthbook-client-provider'; |
Oops, something went wrong.