Skip to content

Commit e340214

Browse files
authored
Initial circleci additions. Updates to jest configuration and README for supported node versions. (#2)
1 parent bfc30ba commit e340214

File tree

9 files changed

+88
-14
lines changed

9 files changed

+88
-14
lines changed

.circleci/config.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: 2.1
2+
3+
orbs:
4+
win: circleci/[email protected]
5+
6+
workflows:
7+
build-and-test-all:
8+
jobs:
9+
# CircleCI's current generation of Node images, cimg/node, allow you to leave the
10+
# patch version unpinned, but require you to specify the minor version. The one
11+
# exception is cimg/node:current, which will always give us the latest release in
12+
# the latest major version-- and the latest major version is where it's most likely
13+
# that there would be a new minor version, anyway.
14+
- build-test-linux:
15+
name: latest Node version
16+
docker-image: cimg/node:current
17+
run-lint: true
18+
- build-test-linux:
19+
name: Node 16.14
20+
docker-image: cimg/node:16.14
21+
- build-test-linux:
22+
name: Node 14.19
23+
docker-image: cimg/node:14.19
24+
- build-test-windows:
25+
name: Windows
26+
27+
jobs:
28+
build-test-linux:
29+
parameters:
30+
run-lint:
31+
type: boolean
32+
default: false
33+
docker-image:
34+
type: string
35+
run-contract-tests:
36+
type: boolean
37+
default: true
38+
docker:
39+
- image: <<parameters.docker-image>>
40+
steps:
41+
- checkout
42+
- run: echo "Node version:" `node --version`
43+
- run: npm install
44+
- run:
45+
command: npm test
46+
environment:
47+
JEST_JUNIT_OUTPUT_FILE: "reports/junit/js-test-results.xml"
48+
- when:
49+
condition: <<parameters.run-lint>>
50+
steps:
51+
- run: npm run lint
52+
- store_test_results:
53+
path: reports/junit
54+
- store_artifacts:
55+
path: reports/junit
56+
57+
build-test-windows:
58+
executor:
59+
name: win/default
60+
shell: powershell.exe
61+
steps:
62+
- checkout
63+
- run: node --version
64+
- run: npm install
65+
- run: npm test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ package-lock.json
22
dist/
33
node_modules/
44
coverage/
5+
reports/

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# LaunchDarkly OpenFeature provider for the Server-Side SDK for Node.js
22

3-
This provider allows for using LaunchDarkly with the OpenFeature Node SDK.
3+
This provider allows for using LaunchDarkly with the OpenFeature JS SDK.
44

55
This provider is designed primarily for use in multi-user systems such as web servers and applications. It follows the server-side LaunchDarkly model for multi-user contexts. It is not intended for use in desktop and embedded systems applications.
66

@@ -12,21 +12,21 @@ This provider is designed primarily for use in multi-user systems such as web se
1212

1313
## Supported Node versions
1414

15-
This version of the LaunchDarkly OpenFeature provider is compatible with Node.js versions 16 and above.
15+
This version of the LaunchDarkly OpenFeature provider is compatible with Node.js versions 14 and above.
1616

1717
## Getting started
1818

1919
### Installation
2020

2121
```
22-
npm install @openfeature/nodejs-sdk
22+
npm install @openfeature/js-sdk
2323
npm install launchdarkly-node-server-sdk
2424
npm install @launchdarkly/open-feature-node
2525
```
2626

2727
### Usage
2828
```
29-
import { OpenFeature } from '@openfeature/nodejs-sdk';
29+
import { OpenFeature } from '@openfeature/js-sdk';
3030
import { init } from 'launchdarkly-node-server-sdk';
3131
import { LaunchDarklyProvider } from 'open-feature-node';
3232

__tests__/LaunchDarklyProvider.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OpenFeature, Client } from '@openfeature/nodejs-sdk';
1+
import { OpenFeature, Client } from '@openfeature/js-sdk';
22
import { LDClient } from 'launchdarkly-node-server-sdk';
33
import { LaunchDarklyProvider } from '../src';
44
import translateContext from '../src/translateContext';

jest.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
module.exports = {
2-
transform: {'^.+\\.ts?$': 'ts-jest'},
2+
transform: { '^.+\\.ts?$': 'ts-jest' },
33
testMatch: ["**/__tests__/**/*test.ts?(x)"],
44
testEnvironment: 'node',
55
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
66
collectCoverageFrom: [
77
"src/**/*.ts",
8+
],
9+
reporters: [
10+
"default",
11+
["jest-junit", { suiteName: "jest tests", outputFile: "reports/junit/js-test-results.xml" }]
812
]
913
};

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,22 @@
1919
],
2020
"license": "Apache-2.0",
2121
"peerDependencies": {
22-
"@openfeature/nodejs-sdk": "^0.3.2",
22+
"@openfeature/js-sdk": "0.4.0",
2323
"launchdarkly-node-server-sdk": "6.x"
2424
},
2525
"devDependencies": {
26-
"typescript": "^4.7.4",
26+
"@openfeature/js-sdk": "0.4.0",
27+
"@types/jest": "^27.4.1",
2728
"@typescript-eslint/eslint-plugin": "^5.22.0",
2829
"@typescript-eslint/parser": "^5.22.0",
2930
"eslint": "^8.14.0",
3031
"eslint-config-airbnb-base": "^15.0.0",
3132
"eslint-config-airbnb-typescript": "^17.0.0",
3233
"eslint-plugin-import": "^2.26.0",
33-
"@types/jest": "^27.4.1",
3434
"jest": "^27.5.1",
35-
"ts-jest": "^27.1.4"
35+
"jest-junit": "^14.0.1",
36+
"launchdarkly-node-server-sdk": "6.x",
37+
"ts-jest": "^27.1.4",
38+
"typescript": "^4.7.4"
3639
}
3740
}

src/LaunchDarklyProvider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {
22
EvaluationContext, FlagValue, Hook,
3+
JsonValue,
34
Provider, ProviderMetadata, ResolutionDetails,
4-
} from '@openfeature/nodejs-sdk';
5+
} from '@openfeature/js-sdk';
56
import { LDClient } from 'launchdarkly-node-server-sdk';
67
import translateContext from './translateContext';
78
import translateResult from './translateResult';
@@ -121,7 +122,7 @@ export default class LaunchDarklyProvider implements Provider {
121122
* register this context with LaunchDarkly if the context does not already exist.
122123
* @returns A promise which will resolve to an {@link EvaluationDetails}.
123124
*/
124-
async resolveObjectEvaluation<U extends object>(
125+
async resolveObjectEvaluation<U extends JsonValue>(
125126
flagKey: string,
126127
defaultValue: U,
127128
context: EvaluationContext,

src/translateContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EvaluationContext } from '@openfeature/nodejs-sdk';
1+
import { EvaluationContext } from '@openfeature/js-sdk';
22
import { LDUser } from 'launchdarkly-node-server-sdk';
33

44
const LDUserBuiltIns = {

src/translateResult.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ResolutionDetails } from '@openfeature/nodejs-sdk';
1+
import { ResolutionDetails } from '@openfeature/js-sdk';
22
import { LDEvaluationDetail } from 'launchdarkly-node-server-sdk';
33

44
/**

0 commit comments

Comments
 (0)