-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: DVC-9059 pull out EnvironmentConfigManager to its own library, …
…change nodejs build to define external pacakges (#564)
- Loading branch information
1 parent
083a5e3
commit 94334bd
Showing
24 changed files
with
282 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
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,12 @@ | ||
# config-manager | ||
|
||
This library extracts the `EnvironmentConfigManager` Server SDK logic to be used across the NodeJS SDK | ||
and Edge Worker SDKs. | ||
|
||
## Building | ||
|
||
Run `nx build config-manager` to build the library. | ||
|
||
## Running unit tests | ||
|
||
Run `nx test config-manager` to execute the unit tests via [Jest](https://jestjs.io). |
File renamed without changes.
File renamed without changes.
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
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,13 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'config-manager', | ||
preset: '../../../jest.preset.js', | ||
transform: { | ||
'^.+\\.[tj]s$': [ | ||
'ts-jest', | ||
{ tsconfig: '<rootDir>/tsconfig.spec.json' }, | ||
], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../../coverage/lib/shared/config-manager', | ||
} |
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 @@ | ||
{ | ||
"name": "@devcycle/config-manager", | ||
"private": true, | ||
"version": "1.0.0", | ||
"type": "commonjs", | ||
"dependencies": { | ||
"@devcycle/js-cloud-server-sdk": "^1.0.0", | ||
"@devcycle/types": "^1.1.15" | ||
} | ||
} |
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,41 @@ | ||
{ | ||
"name": "config-manager", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "lib/shared/config-manager/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/js:tsc", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/lib/shared/config-manager", | ||
"main": "lib/shared/config-manager/src/index.ts", | ||
"tsConfig": "lib/shared/config-manager/tsconfig.lib.json", | ||
"assets": ["lib/shared/config-manager/*.md"], | ||
"external": ["shared-types", "js-cloud-server-sdk"] | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["lib/shared/config-manager/**/*.ts"] | ||
} | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "lib/shared/config-manager/jest.config.ts", | ||
"passWithNoTests": true | ||
}, | ||
"configurations": { | ||
"ci": { | ||
"ci": true, | ||
"codeCoverage": true | ||
} | ||
} | ||
} | ||
}, | ||
"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
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,38 @@ | ||
import { RequestInitWithRetry } from 'fetch-retry' | ||
import { get } from '@devcycle/js-cloud-server-sdk' | ||
|
||
export async function getEnvironmentConfig( | ||
url: string, | ||
requestTimeout: number, | ||
etag?: string, | ||
): Promise<Response> { | ||
const headers: Record<string, string> = etag | ||
? { 'If-None-Match': etag } | ||
: {} | ||
|
||
return await getWithTimeout( | ||
url, | ||
{ | ||
headers: headers, | ||
retries: 1, | ||
}, | ||
requestTimeout, | ||
) | ||
} | ||
|
||
async function getWithTimeout( | ||
url: string, | ||
requestConfig: RequestInit | RequestInitWithRetry, | ||
timeout: number, | ||
): Promise<Response> { | ||
const controller = new AbortController() | ||
const id = setTimeout(() => { | ||
controller.abort() | ||
}, timeout) | ||
const response = await get(url, { | ||
...requestConfig, | ||
signal: controller.signal, | ||
}) | ||
clearTimeout(id) | ||
return response | ||
} |
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,13 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
Oops, something went wrong.
94334bd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
js-sdks-with-provider – ./
js-sdks-with-provider-devcyclehq.vercel.app
js-sdks-with-provider-git-main-devcyclehq.vercel.app
dvc-with-provider.vercel.app
94334bd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
js-sdks-web-elements – ./
js-sdks-web-elements-git-main-devcyclehq.vercel.app
js-sdks-web-elements-devcyclehq.vercel.app
js-sdks-web-elements.vercel.app