diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0a4e824fb24..134fec1f01e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -98,6 +98,7 @@ libs/messaging @bitwarden/team-platform-dev libs/messaging-internal @bitwarden/team-platform-dev libs/serialization @bitwarden/team-platform-dev libs/guid @bitwarden/team-platform-dev +libs/client-type @bitwarden/team-platform-dev # Web utils used across app and connectors apps/web/src/utils/ @bitwarden/team-platform-dev # Web core and shared files diff --git a/libs/client-type/README.md b/libs/client-type/README.md new file mode 100644 index 00000000000..3a29bea584f --- /dev/null +++ b/libs/client-type/README.md @@ -0,0 +1,5 @@ +# client-type + +Owned by: platform + +Exports the ClientType enum diff --git a/libs/client-type/eslint.config.mjs b/libs/client-type/eslint.config.mjs new file mode 100644 index 00000000000..9c37d10e3ff --- /dev/null +++ b/libs/client-type/eslint.config.mjs @@ -0,0 +1,3 @@ +import baseConfig from "../../eslint.config.mjs"; + +export default [...baseConfig]; diff --git a/libs/client-type/jest.config.js b/libs/client-type/jest.config.js new file mode 100644 index 00000000000..f54ab83aa31 --- /dev/null +++ b/libs/client-type/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + displayName: "client-type", + preset: "../../jest.preset.js", + testEnvironment: "node", + transform: { + "^.+\\.[tj]s$": ["ts-jest", { tsconfig: "/tsconfig.spec.json" }], + }, + moduleFileExtensions: ["ts", "js", "html"], + coverageDirectory: "../../coverage/libs/client-type", +}; diff --git a/libs/client-type/package.json b/libs/client-type/package.json new file mode 100644 index 00000000000..1db72603bf9 --- /dev/null +++ b/libs/client-type/package.json @@ -0,0 +1,11 @@ +{ + "name": "@bitwarden/client-type", + "version": "0.0.1", + "description": "Exports the ClientType enum", + "private": true, + "type": "commonjs", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "license": "GPL-3.0", + "author": "platform" +} diff --git a/libs/client-type/project.json b/libs/client-type/project.json new file mode 100644 index 00000000000..8231e6634e4 --- /dev/null +++ b/libs/client-type/project.json @@ -0,0 +1,33 @@ +{ + "name": "client-type", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/client-type/src", + "projectType": "library", + "tags": [], + "targets": { + "build": { + "executor": "@nx/js:tsc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/libs/client-type", + "main": "libs/client-type/src/index.ts", + "tsConfig": "libs/client-type/tsconfig.lib.json", + "assets": ["libs/client-type/*.md"] + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/client-type/**/*.ts"] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/client-type/jest.config.js" + } + } + } +} diff --git a/libs/client-type/src/client-type.spec.ts b/libs/client-type/src/client-type.spec.ts new file mode 100644 index 00000000000..a178bba394b --- /dev/null +++ b/libs/client-type/src/client-type.spec.ts @@ -0,0 +1,8 @@ +import * as lib from "./index"; + +describe("client-type", () => { + // This test will fail until something is exported from index.ts + it("should work", () => { + expect(lib).toBeDefined(); + }); +}); diff --git a/libs/client-type/src/index.ts b/libs/client-type/src/index.ts new file mode 100644 index 00000000000..25e9d6f3371 --- /dev/null +++ b/libs/client-type/src/index.ts @@ -0,0 +1,10 @@ +// FIXME: update to use a const object instead of a typescript enum +// eslint-disable-next-line @bitwarden/platform/no-enums +export enum ClientType { + Web = "web", + Browser = "browser", + Desktop = "desktop", + // Mobile = "mobile", + Cli = "cli", + // DirectoryConnector = "connector", +} diff --git a/libs/client-type/tsconfig.eslint.json b/libs/client-type/tsconfig.eslint.json new file mode 100644 index 00000000000..3daf120441a --- /dev/null +++ b/libs/client-type/tsconfig.eslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["**/build", "**/dist"] +} diff --git a/libs/client-type/tsconfig.json b/libs/client-type/tsconfig.json new file mode 100644 index 00000000000..62ebbd94647 --- /dev/null +++ b/libs/client-type/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/client-type/tsconfig.lib.json b/libs/client-type/tsconfig.lib.json new file mode 100644 index 00000000000..9cbf6736007 --- /dev/null +++ b/libs/client-type/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.js", "src/**/*.spec.ts"] +} diff --git a/libs/client-type/tsconfig.spec.json b/libs/client-type/tsconfig.spec.json new file mode 100644 index 00000000000..1275f148a18 --- /dev/null +++ b/libs/client-type/tsconfig.spec.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "moduleResolution": "node10", + "types": ["jest", "node"] + }, + "include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"] +} diff --git a/libs/common/src/enums/client-type.enum.ts b/libs/common/src/enums/client-type.enum.ts index 25e9d6f3371..466e67ecd52 100644 --- a/libs/common/src/enums/client-type.enum.ts +++ b/libs/common/src/enums/client-type.enum.ts @@ -1,10 +1 @@ -// FIXME: update to use a const object instead of a typescript enum -// eslint-disable-next-line @bitwarden/platform/no-enums -export enum ClientType { - Web = "web", - Browser = "browser", - Desktop = "desktop", - // Mobile = "mobile", - Cli = "cli", - // DirectoryConnector = "connector", -} +export { ClientType } from "@bitwarden/client-type"; diff --git a/package-lock.json b/package-lock.json index 34fd77c1a7f..abab3a4c70a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -318,6 +318,11 @@ "version": "0.0.0", "license": "GPL-3.0" }, + "libs/client-type": { + "name": "@bitwarden/client-type", + "version": "0.0.1", + "license": "GPL-3.0" + }, "libs/common": { "name": "@bitwarden/common", "version": "0.0.0", @@ -4555,6 +4560,10 @@ "resolved": "apps/cli", "link": true }, + "node_modules/@bitwarden/client-type": { + "resolved": "libs/client-type", + "link": true + }, "node_modules/@bitwarden/common": { "resolved": "libs/common", "link": true diff --git a/tsconfig.base.json b/tsconfig.base.json index aa094ab8e41..a1ad39aca50 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -25,6 +25,7 @@ "@bitwarden/billing": ["./libs/billing/src"], "@bitwarden/bit-common/*": ["./bitwarden_license/bit-common/src/*"], "@bitwarden/cli/*": ["./apps/cli/src/*"], + "@bitwarden/client-type": ["libs/client-type/src/index.ts"], "@bitwarden/common/*": ["./libs/common/src/*"], "@bitwarden/components": ["./libs/components/src"], "@bitwarden/dirt-card": ["./libs/dirt/card/src"],