diff --git a/packages/canyon-ut/.gitignore b/packages/canyon-ut/.gitignore new file mode 100644 index 00000000..a547bf36 --- /dev/null +++ b/packages/canyon-ut/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/packages/canyon-ut/README.md b/packages/canyon-ut/README.md new file mode 100644 index 00000000..a03b0f86 --- /dev/null +++ b/packages/canyon-ut/README.md @@ -0,0 +1,6 @@ +# Canyon UT + +## 功能 +1. 需要有上报接口,用于接收数据 +2. 前端展示 +3. docker容易部署 \ No newline at end of file diff --git a/packages/canyon-ut/eslint.config.js b/packages/canyon-ut/eslint.config.js new file mode 100644 index 00000000..092408a9 --- /dev/null +++ b/packages/canyon-ut/eslint.config.js @@ -0,0 +1,28 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import tseslint from 'typescript-eslint' + +export default tseslint.config( + { ignores: ['dist'] }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ['**/*.{ts,tsx}'], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, + }, +) diff --git a/packages/canyon-ut/index.html b/packages/canyon-ut/index.html new file mode 100644 index 00000000..e4b78eae --- /dev/null +++ b/packages/canyon-ut/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/packages/canyon-ut/lib/prisma.js b/packages/canyon-ut/lib/prisma.js new file mode 100644 index 00000000..594621cc --- /dev/null +++ b/packages/canyon-ut/lib/prisma.js @@ -0,0 +1,8 @@ +import { PrismaClient } from "@prisma/client"; + + +const prisma = global.prisma || new PrismaClient(); + +if (process.env.NODE_ENV === "development") global.prisma = prisma; + +export default prisma; diff --git a/packages/canyon-ut/package.json b/packages/canyon-ut/package.json new file mode 100644 index 00000000..cd116b42 --- /dev/null +++ b/packages/canyon-ut/package.json @@ -0,0 +1,35 @@ +{ + "name": "canyon-ut", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "lint": "eslint .", + "preview": "vite preview", + "serve": "node server.js", + "preinstall": "prisma generate" + }, + "dependencies": { + "@prisma/client": "5.16.1", + "antd": "^5.22.5", + "prisma": "5.16.1", + "react": "^18.3.1", + "react-dom": "^18.3.1" + }, + "devDependencies": { + "@eslint/js": "^9.17.0", + "@types/react": "^18.3.17", + "@types/react-dom": "^18.3.5", + "@vitejs/plugin-react": "^4.3.4", + "eslint": "^9.17.0", + "eslint-plugin-react-hooks": "^5.0.0", + "eslint-plugin-react-refresh": "^0.4.16", + "express": "^4.21.2", + "globals": "^15.13.0", + "typescript": "~5.6.3", + "typescript-eslint": "^8.18.1", + "vite": "^6.0.3" + } +} diff --git a/packages/canyon-ut/prisma/schema.prisma b/packages/canyon-ut/prisma/schema.prisma new file mode 100644 index 00000000..4daf288d --- /dev/null +++ b/packages/canyon-ut/prisma/schema.prisma @@ -0,0 +1,99 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") // uses connection pooling +} + +model User { + id String @id + username String + password String + nickname String + avatar String + refreshToken String @map("refresh_token") + accessToken String @map("access_token") + email String + favor String + createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3) + + @@map("canyon_v3_user") +} + +model Coverage { + id String @id @default(cuid()) + sha String + branch String + compareTarget String @map("compare_target") + provider String + buildProvider String @map("build_provider") // 通过侦测CI环境变量来判断 + buildID String @map("build_id") + projectID String @map("project_id") + reporter String + reportID String @map("report_id") // 未来聚合的一句,区分case + covType String @map("cov_type") // 普通类型,all、agg + // 代码覆盖率 + statementsTotal Int @map("statements_total") + statementsCovered Int @map("statements_covered") + summary Bytes + // 代码覆盖率详情 + hit Bytes + // 特殊逻辑,必须要有map数据,才能上报hit,并且存在cov_type上。 + map Bytes + instrumentCwd String @map("instrument_cwd") //是build时的路径,因为要与sourceMap对应 + // 通用 + createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3) + updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(3) + + @@map("canyon_v3_coverage") +} + +model SysSetting { + id String @id @default(cuid()) + key String + value String + + @@map("sys_setting") +} + +model GitProvider { + id String @id + url String + type String + name String + disabled Boolean + privateToken String @map("private_token") + + @@map("git_provider") +} + +model Distributedlock { + lockName String @id + isLocked Boolean @default(false) + lockTimestamp DateTime? + lockExpiration DateTime? + + @@map("canyon_v3_distributedlock") +} + +model Project { + id String @id + name String + pathWithNamespace String @map("path_with_namespace") + description String + bu String + tags Json + members Json + coverage String + language String + defaultBranch String @map("default_branch") + instrumentCwd String @map("instrument_cwd") + createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3) + + @@map("project") +} diff --git a/packages/canyon-ut/public/vite.svg b/packages/canyon-ut/public/vite.svg new file mode 100644 index 00000000..e7b8dfb1 --- /dev/null +++ b/packages/canyon-ut/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/canyon-ut/server.js b/packages/canyon-ut/server.js new file mode 100644 index 00000000..5f5c2c48 --- /dev/null +++ b/packages/canyon-ut/server.js @@ -0,0 +1,22 @@ +import express from 'express'; + +const app = express(); +import prisma from './lib/prisma'; + +app.post('/coverage/client', (req, res) => { + // prisma.coverage.findFirst + res.send('Hello World'); +}); + +app.get('/coverage/map', (req, res) => { + // prisma.coverage.findFirst + res.send('Hello World'); +}); + +app.get('/coverage/summary', (req, res) => { + +}); + +app.listen(8080, () => { + console.log('Server started on http://localhost:8080'); +}); \ No newline at end of file diff --git a/packages/canyon-ut/src/App.css b/packages/canyon-ut/src/App.css new file mode 100644 index 00000000..e69de29b diff --git a/packages/canyon-ut/src/App.tsx b/packages/canyon-ut/src/App.tsx new file mode 100644 index 00000000..ccfe373c --- /dev/null +++ b/packages/canyon-ut/src/App.tsx @@ -0,0 +1,17 @@ +import { useState } from 'react' +import reactLogo from './assets/react.svg' +import viteLogo from '/vite.svg' +import './App.css' +import {Button} from "antd"; + +function App() { + const [count, setCount] = useState(0) + + return ( +
+ +
+ ) +} + +export default App diff --git a/packages/canyon-ut/src/assets/react.svg b/packages/canyon-ut/src/assets/react.svg new file mode 100644 index 00000000..6c87de9b --- /dev/null +++ b/packages/canyon-ut/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/canyon-ut/src/index.css b/packages/canyon-ut/src/index.css new file mode 100644 index 00000000..e69de29b diff --git a/packages/canyon-ut/src/main.tsx b/packages/canyon-ut/src/main.tsx new file mode 100644 index 00000000..bef5202a --- /dev/null +++ b/packages/canyon-ut/src/main.tsx @@ -0,0 +1,10 @@ +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' +import './index.css' +import App from './App.tsx' + +createRoot(document.getElementById('root')!).render( + + + , +) diff --git a/packages/canyon-ut/src/pages/projects/[id]/commits/index.tsx b/packages/canyon-ut/src/pages/projects/[id]/commits/index.tsx new file mode 100644 index 00000000..e69de29b diff --git a/packages/canyon-ut/src/pages/projects/[id]/overview.tsx b/packages/canyon-ut/src/pages/projects/[id]/overview.tsx new file mode 100644 index 00000000..e69de29b diff --git a/packages/canyon-ut/src/pages/projects/index.tsx b/packages/canyon-ut/src/pages/projects/index.tsx new file mode 100644 index 00000000..e69de29b diff --git a/packages/canyon-ut/src/vite-env.d.ts b/packages/canyon-ut/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/packages/canyon-ut/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/packages/canyon-ut/tsconfig.app.json b/packages/canyon-ut/tsconfig.app.json new file mode 100644 index 00000000..358ca9ba --- /dev/null +++ b/packages/canyon-ut/tsconfig.app.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["src"] +} diff --git a/packages/canyon-ut/tsconfig.json b/packages/canyon-ut/tsconfig.json new file mode 100644 index 00000000..1ffef600 --- /dev/null +++ b/packages/canyon-ut/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" } + ] +} diff --git a/packages/canyon-ut/tsconfig.node.json b/packages/canyon-ut/tsconfig.node.json new file mode 100644 index 00000000..db0becc8 --- /dev/null +++ b/packages/canyon-ut/tsconfig.node.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "target": "ES2022", + "lib": ["ES2023"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/packages/canyon-ut/vite.config.ts b/packages/canyon-ut/vite.config.ts new file mode 100644 index 00000000..8b0f57b9 --- /dev/null +++ b/packages/canyon-ut/vite.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [react()], +})