diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d1266a174e4..f0d1e0821dd 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -110,6 +110,7 @@ libs/core-test-utils @bitwarden/team-platform-dev libs/state @bitwarden/team-platform-dev libs/state-internal @bitwarden/team-platform-dev libs/state-test-utils @bitwarden/team-platform-dev +libs/flight-recorder @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/jest.config.js b/jest.config.js index bfe447f7a53..af5e36dca8f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -61,6 +61,7 @@ module.exports = { "/libs/vault/jest.config.js", "/libs/auto-confirm/jest.config.js", "/libs/subscription/jest.config.js", + "/libs/flight-recorder/jest.config.js", ], // Workaround for a memory leak that crashes tests in CI: diff --git a/libs/flight-recorder/README.md b/libs/flight-recorder/README.md new file mode 100644 index 00000000000..c41c2f32304 --- /dev/null +++ b/libs/flight-recorder/README.md @@ -0,0 +1,5 @@ +# flight-recorder + +Owned by: platform + +SDK Flight Recorder integration for capturing and exporting diagnostic logs diff --git a/libs/flight-recorder/eslint.config.mjs b/libs/flight-recorder/eslint.config.mjs new file mode 100644 index 00000000000..9c37d10e3ff --- /dev/null +++ b/libs/flight-recorder/eslint.config.mjs @@ -0,0 +1,3 @@ +import baseConfig from "../../eslint.config.mjs"; + +export default [...baseConfig]; diff --git a/libs/flight-recorder/jest.config.js b/libs/flight-recorder/jest.config.js new file mode 100644 index 00000000000..376c8deebe6 --- /dev/null +++ b/libs/flight-recorder/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + displayName: "flight-recorder", + preset: "../../jest.preset.js", + testEnvironment: "node", + transform: { + "^.+\\.[tj]s$": ["ts-jest", { tsconfig: "/tsconfig.spec.json" }], + }, + moduleFileExtensions: ["ts", "js", "html"], + coverageDirectory: "../../coverage/libs/flight-recorder", +}; diff --git a/libs/flight-recorder/package.json b/libs/flight-recorder/package.json new file mode 100644 index 00000000000..d250f962580 --- /dev/null +++ b/libs/flight-recorder/package.json @@ -0,0 +1,11 @@ +{ + "name": "@bitwarden/flight-recorder", + "version": "0.0.1", + "description": "SDK Flight Recorder integration for capturing and exporting diagnostic logs", + "private": true, + "type": "commonjs", + "main": "index.js", + "types": "index.d.ts", + "license": "GPL-3.0", + "author": "platform" +} diff --git a/libs/flight-recorder/project.json b/libs/flight-recorder/project.json new file mode 100644 index 00000000000..9ee496165e3 --- /dev/null +++ b/libs/flight-recorder/project.json @@ -0,0 +1,34 @@ +{ + "name": "flight-recorder", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/flight-recorder/src", + "projectType": "library", + "tags": [], + "targets": { + "build": { + "executor": "@nx/js:tsc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/libs/flight-recorder", + "main": "libs/flight-recorder/src/index.ts", + "tsConfig": "libs/flight-recorder/tsconfig.lib.json", + "assets": ["libs/flight-recorder/*.md"], + "rootDir": "libs/flight-recorder/src" + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/flight-recorder/**/*.ts"] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/flight-recorder/jest.config.js" + } + } + } +} diff --git a/libs/flight-recorder/src/flight-recorder.spec.ts b/libs/flight-recorder/src/flight-recorder.spec.ts new file mode 100644 index 00000000000..6264ead3f76 --- /dev/null +++ b/libs/flight-recorder/src/flight-recorder.spec.ts @@ -0,0 +1,8 @@ +import * as lib from "./index"; + +describe("flight-recorder", () => { + // This test will fail until something is exported from index.ts + it("should work", () => { + expect(lib).toBeDefined(); + }); +}); diff --git a/libs/flight-recorder/src/index.ts b/libs/flight-recorder/src/index.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libs/flight-recorder/tsconfig.eslint.json b/libs/flight-recorder/tsconfig.eslint.json new file mode 100644 index 00000000000..3daf120441a --- /dev/null +++ b/libs/flight-recorder/tsconfig.eslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": ["src/**/*.ts", "src/**/*.js"], + "exclude": ["**/build", "**/dist"] +} diff --git a/libs/flight-recorder/tsconfig.json b/libs/flight-recorder/tsconfig.json new file mode 100644 index 00000000000..62ebbd94647 --- /dev/null +++ b/libs/flight-recorder/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/flight-recorder/tsconfig.lib.json b/libs/flight-recorder/tsconfig.lib.json new file mode 100644 index 00000000000..9cbf6736007 --- /dev/null +++ b/libs/flight-recorder/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/flight-recorder/tsconfig.spec.json b/libs/flight-recorder/tsconfig.spec.json new file mode 100644 index 00000000000..1275f148a18 --- /dev/null +++ b/libs/flight-recorder/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/package-lock.json b/package-lock.json index 95842c6b409..10814ed2094 100644 --- a/package-lock.json +++ b/package-lock.json @@ -547,6 +547,11 @@ "version": "0.0.0", "license": "GPL-3.0" }, + "libs/flight-recorder": { + "name": "@bitwarden/flight-recorder", + "version": "0.0.1", + "license": "GPL-3.0" + }, "libs/guid": { "name": "@bitwarden/guid", "version": "0.0.1", @@ -5026,6 +5031,10 @@ "resolved": "libs/dirt/card", "link": true }, + "node_modules/@bitwarden/flight-recorder": { + "resolved": "libs/flight-recorder", + "link": true + }, "node_modules/@bitwarden/generator-components": { "resolved": "libs/tools/generator/components", "link": true diff --git a/tsconfig.base.json b/tsconfig.base.json index 68498cfae01..78030f00421 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -30,11 +30,12 @@ "@bitwarden/browser/*": ["./apps/browser/src/*"], "@bitwarden/cli/*": ["./apps/cli/src/*"], "@bitwarden/client-type": ["./libs/client-type/src/index.ts"], - "@bitwarden/common/spec": ["./libs/common/spec"], "@bitwarden/common/*": ["./libs/common/src/*"], + "@bitwarden/common/spec": ["./libs/common/spec"], "@bitwarden/components": ["./libs/components/src"], "@bitwarden/core-test-utils": ["./libs/core-test-utils/src/index.ts"], "@bitwarden/dirt-card": ["./libs/dirt/card/src"], + "@bitwarden/flight-recorder": ["./libs/flight-recorder/src/index.ts"], "@bitwarden/generator-components": ["./libs/tools/generator/components/src"], "@bitwarden/generator-core": ["./libs/tools/generator/core/src"], "@bitwarden/generator-history": ["./libs/tools/generator/extensions/history/src"],