Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Dec 22, 2024
1 parent 5a51b1e commit 727eac3
Show file tree
Hide file tree
Showing 22 changed files with 329 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/canyon-ut/.gitignore
Original file line number Diff line number Diff line change
@@ -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?
6 changes: 6 additions & 0 deletions packages/canyon-ut/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Canyon UT

## 功能
1. 需要有上报接口,用于接收数据
2. 前端展示
3. docker容易部署
28 changes: 28 additions & 0 deletions packages/canyon-ut/eslint.config.js
Original file line number Diff line number Diff line change
@@ -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 },
],
},
},
)
13 changes: 13 additions & 0 deletions packages/canyon-ut/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
8 changes: 8 additions & 0 deletions packages/canyon-ut/lib/prisma.js
Original file line number Diff line number Diff line change
@@ -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;
35 changes: 35 additions & 0 deletions packages/canyon-ut/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
99 changes: 99 additions & 0 deletions packages/canyon-ut/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -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")
}
1 change: 1 addition & 0 deletions packages/canyon-ut/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions packages/canyon-ut/server.js
Original file line number Diff line number Diff line change
@@ -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');
});
Empty file added packages/canyon-ut/src/App.css
Empty file.
17 changes: 17 additions & 0 deletions packages/canyon-ut/src/App.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div>
<Button type={'primary'}>你好</Button>
</div>
)
}

export default App
1 change: 1 addition & 0 deletions packages/canyon-ut/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
10 changes: 10 additions & 0 deletions packages/canyon-ut/src/main.tsx
Original file line number Diff line number Diff line change
@@ -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(
<StrictMode>
<App />
</StrictMode>,
)
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions packages/canyon-ut/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
26 changes: 26 additions & 0 deletions packages/canyon-ut/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -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"]
}
7 changes: 7 additions & 0 deletions packages/canyon-ut/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
24 changes: 24 additions & 0 deletions packages/canyon-ut/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -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"]
}
7 changes: 7 additions & 0 deletions packages/canyon-ut/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
})

0 comments on commit 727eac3

Please sign in to comment.