From 8b18a0ff05982f350240d33114f3738bac2be4ed Mon Sep 17 00:00:00 2001 From: Katerina Pilatova Date: Thu, 1 Feb 2024 20:43:59 +0100 Subject: [PATCH] feat(plugin-coverage): set up plugin-coverage package --- packages/plugin-coverage/.eslintrc.json | 19 +++++++ packages/plugin-coverage/package.json | 10 ++++ packages/plugin-coverage/project.json | 55 +++++++++++++++++++ packages/plugin-coverage/tsconfig.json | 23 ++++++++ packages/plugin-coverage/tsconfig.lib.json | 16 ++++++ packages/plugin-coverage/tsconfig.test.json | 13 +++++ .../vite.config.integration.ts | 21 +++++++ packages/plugin-coverage/vite.config.unit.ts | 25 +++++++++ tsconfig.base.json | 1 + 9 files changed, 183 insertions(+) create mode 100644 packages/plugin-coverage/.eslintrc.json create mode 100644 packages/plugin-coverage/package.json create mode 100644 packages/plugin-coverage/project.json create mode 100644 packages/plugin-coverage/tsconfig.json create mode 100644 packages/plugin-coverage/tsconfig.lib.json create mode 100644 packages/plugin-coverage/tsconfig.test.json create mode 100644 packages/plugin-coverage/vite.config.integration.ts create mode 100644 packages/plugin-coverage/vite.config.unit.ts diff --git a/packages/plugin-coverage/.eslintrc.json b/packages/plugin-coverage/.eslintrc.json new file mode 100644 index 000000000..a8f1c89f5 --- /dev/null +++ b/packages/plugin-coverage/.eslintrc.json @@ -0,0 +1,19 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx"], + "parserOptions": { + "project": ["packages/plugin-coverage/tsconfig.*?.json"] + } + }, + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": ["error"] + } + } + ] +} diff --git a/packages/plugin-coverage/package.json b/packages/plugin-coverage/package.json new file mode 100644 index 000000000..96a53027b --- /dev/null +++ b/packages/plugin-coverage/package.json @@ -0,0 +1,10 @@ +{ + "name": "@code-pushup/coverage-plugin", + "version": "0.8.25", + "dependencies": { + "@code-pushup/models": "*", + "@code-pushup/utils": "*", + "parse-lcov": "^1.0.4", + "zod": "^3.22.4" + } +} diff --git a/packages/plugin-coverage/project.json b/packages/plugin-coverage/project.json new file mode 100644 index 000000000..2b325a66f --- /dev/null +++ b/packages/plugin-coverage/project.json @@ -0,0 +1,55 @@ +{ + "name": "plugin-coverage", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/plugin-coverage/src", + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/esbuild:esbuild", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/packages/plugin-coverage", + "main": "packages/plugin-coverage/src/index.ts", + "tsConfig": "packages/plugin-coverage/tsconfig.lib.json", + "assets": ["packages/plugin-coverage/*.md"], + "esbuildConfig": "esbuild.config.js" + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "packages/plugin-coverage/**/*.ts", + "packages/plugin-coverage/package.json" + ] + } + }, + "unit-test": { + "executor": "@nx/vite:test", + "outputs": ["{workspaceRoot}/coverage/packages/plugin-coverage"], + "options": { + "config": "packages/plugin-coverage/vite.config.unit.ts", + "reportsDirectory": "../../coverage/plugin-coverage/unit-tests" + } + }, + "integration-test": { + "executor": "@nx/vite:test", + "outputs": ["{workspaceRoot}/coverage/packages/plugin-coverage"], + "options": { + "config": "packages/plugin-coverage/vite.config.integration.ts", + "reportsDirectory": "../../coverage/plugin-coverage/integration-tests" + } + }, + "deploy": { + "options": { + "distFolderPath": "dist/packages/plugin-coverage" + } + }, + "publish": { + "command": "node tools/scripts/publish.mjs plugin-coverage {args.ver} {args.tag}", + "dependsOn": ["build"] + } + }, + "tags": ["scope:plugin", "type:feature"] +} diff --git a/packages/plugin-coverage/tsconfig.json b/packages/plugin-coverage/tsconfig.json new file mode 100644 index 000000000..893f9a925 --- /dev/null +++ b/packages/plugin-coverage/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "ESNext", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "types": ["vitest"] + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.test.json" + } + ] +} diff --git a/packages/plugin-coverage/tsconfig.lib.json b/packages/plugin-coverage/tsconfig.lib.json new file mode 100644 index 000000000..ef2f7e2b3 --- /dev/null +++ b/packages/plugin-coverage/tsconfig.lib.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": [ + "vite.config.unit.ts", + "vite.config.integration.ts", + "src/**/*.test.ts", + "src/**/*.mock.ts", + "mocks/**/*.ts" + ] +} diff --git a/packages/plugin-coverage/tsconfig.test.json b/packages/plugin-coverage/tsconfig.test.json new file mode 100644 index 000000000..9f29d6bb0 --- /dev/null +++ b/packages/plugin-coverage/tsconfig.test.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] + }, + "include": [ + "vite.config.unit.ts", + "vite.config.integration.ts", + "mocks/**/*.ts", + "src/**/*.test.ts" + ] +} diff --git a/packages/plugin-coverage/vite.config.integration.ts b/packages/plugin-coverage/vite.config.integration.ts new file mode 100644 index 000000000..92dda7e4a --- /dev/null +++ b/packages/plugin-coverage/vite.config.integration.ts @@ -0,0 +1,21 @@ +/// +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/plugin-coverage', + plugins: [nxViteTsPaths()], + test: { + globals: true, + cache: { + dir: '../../node_modules/.vitest', + }, + environment: 'node', + include: ['src/**/*.integration.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + globalSetup: ['global-setup.ts'], + setupFiles: [ + '../../testing-utils/src/lib/setup/console.mock.ts', + '../../testing-utils/src/lib/setup/reset.mocks.ts', + ], + }, +}); diff --git a/packages/plugin-coverage/vite.config.unit.ts b/packages/plugin-coverage/vite.config.unit.ts new file mode 100644 index 000000000..3d1991ab3 --- /dev/null +++ b/packages/plugin-coverage/vite.config.unit.ts @@ -0,0 +1,25 @@ +/// +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/plugin-coverage', + plugins: [nxViteTsPaths()], + test: { + globals: true, + cache: { + dir: '../../node_modules/.vitest', + }, + coverage: { + reporter: ['lcov'], + }, + environment: 'node', + include: ['src/**/*.unit.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + globalSetup: ['global-setup.ts'], + setupFiles: [ + '../../testing-utils/src/lib/setup/fs.mock.ts', + '../../testing-utils/src/lib/setup/console.mock.ts', + '../../testing-utils/src/lib/setup/reset.mocks.ts', + ], + }, +}); diff --git a/tsconfig.base.json b/tsconfig.base.json index 64759fdbf..5403a3fd1 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -25,6 +25,7 @@ "@code-pushup/lighthouse-plugin": [ "packages/plugin-lighthouse/src/index.ts" ], + "@code-pushup/coverage-plugin": ["packages/plugin-coverage/src/index.ts"], "@code-pushup/models": ["packages/models/src/index.ts"], "@code-pushup/nx-plugin": ["packages/nx-plugin/src/index.ts"], "@code-pushup/testing-utils": ["testing-utils/src/index.ts"],