diff --git a/packages/canyon-backend/src/apps/project/project.resolver.ts b/packages/canyon-backend/src/apps/project/project.resolver.ts index a97f0184..8453a31a 100755 --- a/packages/canyon-backend/src/apps/project/project.resolver.ts +++ b/packages/canyon-backend/src/apps/project/project.resolver.ts @@ -1,6 +1,7 @@ import {Query, Resolver} from "@nestjs/graphql"; import {BuOption} from "./project.model"; import {ProjectService} from "./services/project.service"; +import {GetCoverageLogResponseModel} from "./services/get-coverage-log.response.model"; @Resolver(() => "Project") export class ProjectResolver { @@ -15,6 +16,30 @@ export class ProjectResolver { async getProjectsBuOptions(): Promise { const a = await this.projectService.getProjectsBuOptions() console.log(a) - return [] + return [{ + bu: "a", + count: 1, + }] + } + + + + @Query(() => [GetCoverageLogResponseModel], { + description: "获取CoverageLog列表", + }) + async getCoverageLog(): Promise { + const a = await this.projectService.getCoverageLog() + // console.log(a) + return a.map((item) => { + return { + id: item.id, + projectID: item.projectID, + sha: item.sha, + size: item.size, + timing: item.timing, + updatedAt: item.updatedAt, + createdAt: item.createdAt, + } + }) } } diff --git a/packages/canyon-backend/src/apps/project/services/get-coverage-log.response.model.ts b/packages/canyon-backend/src/apps/project/services/get-coverage-log.response.model.ts new file mode 100644 index 00000000..d0521147 --- /dev/null +++ b/packages/canyon-backend/src/apps/project/services/get-coverage-log.response.model.ts @@ -0,0 +1,26 @@ +import { Field, ID, ObjectType } from "@nestjs/graphql"; + +@ObjectType() +export class GetCoverageLogResponseModel { + @Field(() => String) + id: string; + + @Field(() => String) + projectID: string; + + @Field(() => String) + sha: string; + + @Field(() => Number) + size: number; + + @Field(() => String) + timing: string; + +// 创建、更新时间 + @Field(() => Date) + createdAt: Date; + + @Field(() => Date) + updatedAt: Date; +} diff --git a/packages/canyon-backend/src/apps/project/services/project.service.ts b/packages/canyon-backend/src/apps/project/services/project.service.ts index 054e23fc..0dabd82c 100755 --- a/packages/canyon-backend/src/apps/project/services/project.service.ts +++ b/packages/canyon-backend/src/apps/project/services/project.service.ts @@ -8,4 +8,9 @@ export class ProjectService { async getProjectsBuOptions() { return {} } + async getCoverageLog() { + return this.prisma.coverageLog.findMany({ + where:{} + }) + } } diff --git a/packages/canyon-backend/src/main.ts b/packages/canyon-backend/src/main.ts index 4c10a1d4..04ff8cb0 100644 --- a/packages/canyon-backend/src/main.ts +++ b/packages/canyon-backend/src/main.ts @@ -3,7 +3,7 @@ import { json } from 'express'; import dotenv from "dotenv"; import path from 'node:path'; import fs from 'node:fs'; -console.log(fs); +console.log(fs.chmod); import {ValidationPipe} from "@nestjs/common"; dotenv.config({ path: path.resolve(__dirname, "../../../.env"), diff --git a/packages/canyon-platform/.gitignore b/packages/canyon-platform/.gitignore old mode 100644 new mode 100755 index a547bf36..e1474998 --- a/packages/canyon-platform/.gitignore +++ b/packages/canyon-platform/.gitignore @@ -1,5 +1,3 @@ -# Logs -logs *.log npm-debug.log* yarn-debug.log* @@ -22,3 +20,10 @@ dist-ssr *.njsproj *.sln *.sw? + +pnpm-lock.yaml + +src/helpers/backend/gen + + +.canyon_output diff --git a/packages/canyon-platform/codegen.ts b/packages/canyon-platform/codegen.ts new file mode 100755 index 00000000..5f9e59a2 --- /dev/null +++ b/packages/canyon-platform/codegen.ts @@ -0,0 +1,16 @@ +import { type CodegenConfig } from "@graphql-codegen/cli"; + +const config: CodegenConfig = { + schema: "../../packages/canyon-backend/*.gql", + documents: ["src/**/*.graphql"], + generates: { + "./src/helpers/backend/gen/": { + preset: "client", + presetConfig: { + persistedDocuments: "string", + }, + }, + }, +}; + +export default config; diff --git a/packages/canyon-platform/index.html b/packages/canyon-platform/index.html index e4b78eae..c5d0c2eb 100644 --- a/packages/canyon-platform/index.html +++ b/packages/canyon-platform/index.html @@ -2,9 +2,14 @@ - + - Vite + React + TS + + Canyon
diff --git a/packages/canyon-platform/package.json b/packages/canyon-platform/package.json index 7b3976f1..2365e1c3 100644 --- a/packages/canyon-platform/package.json +++ b/packages/canyon-platform/package.json @@ -1,63 +1,75 @@ { - "name": "vite-project", + "name": "canyon-platform", "private": true, "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite", - "do-build": "tsc -b && vite build", - "lint": "eslint .", - "preview": "vite preview" + "dev-platform": "vite", + "do-build": "node --max_old_space_size=16384 ./node_modules/vite/bin/vite.js build", + "postinstall": "npm run codegen", + "codegen": "graphql-codegen --config codegen.ts", + "format": "prettier --write ." }, "dependencies": { - "react": "^18.3.1", - "react-dom": "^18.3.1", + "@ant-design/colors": "^7.1.0", "@ant-design/icons": "^5.5.1", + "@apollo/client": "^3.11.8", + "@graphql-typed-document-node/core": "^3.2.0", "@monaco-editor/react": "^4.6.0", + "ahooks": "^3.8.1", "antd": "^5.21.6", "axios": "^1.7.7", + "canyon-data": "^0.1.1-alpha.16", "clsx": "^2.1.1", + "copy-to-clipboard": "^3.3.3", "dayjs": "^1.11.13", "echarts": "^5.5.1", "echarts-for-react": "^3.0.2", + "graphql": "^16.9.0", "i18next": "^23.16.4", "i18next-browser-languagedetector": "^8.0.0", "monaco-editor": "^0.52.0", + "query-string": "^9.1.1", + "react": "^18.3.1", + "react-copy-to-clipboard": "^5.1.0", + "react-dom": "^18.3.1", "react-error-boundary": "^4.1.2", + "react-highlight-words": "^0.20.0", "react-i18next": "^15.1.0", "react-router-dom": "^6.27.0", - "shiki": "^1.22.2" + "shiki": "^1.22.2", + "tailwind-merge": "^2.5.4" }, "devDependencies": { - "@eslint/js": "^9.13.0", - "@types/react": "^18.3.12", - "@types/react-dom": "^18.3.1", - "@vitejs/plugin-react-swc": "^3.5.0", - "eslint": "^9.13.0", - "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.14", - "globals": "^15.11.0", - "typescript": "~5.6.2", - "typescript-eslint": "^8.11.0", - "vite": "^5.4.10", + "@eslint/js": "^9.14.0", "@graphql-codegen/cli": "^5.0.3", "@graphql-codegen/client-preset": "^4.5.0", - "@typescript-eslint/eslint-plugin": "^8.12.2", - "@typescript-eslint/parser": "^8.12.2", + "@types/react": "^18.3.12", + "@types/react-dom": "^18.3.1", + "@typescript-eslint/eslint-plugin": "^8.13.0", + "@typescript-eslint/parser": "^8.13.0", + "@vitejs/plugin-react-swc": "^3.7.1", "autoprefixer": "^10.4.20", + "eslint": "^9.14.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-jsx-a11y": "^6.10.2", "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-react": "^7.37.2", + "eslint-plugin-react-hooks": "^5.0.0", + "eslint-plugin-react-refresh": "^0.4.14", "eslint-plugin-simple-import-sort": "^12.1.1", + "globals": "^15.12.0", "postcss": "^8.4.47", "prettier": "^3.3.3", "swc-plugin-canyon": "0.0.2-alpha.25", "swc-plugin-coverage-instrument": "^0.0.25", + "@swc/core": "1.7.40", "tailwindcss": "^3.4.14", + "typescript": "^5.6.3", "unplugin-auto-import": "^0.18.3", "unplugin-auto-import-antd": "^0.0.2", + "vite": "^5.4.10", "vite-plugin-pages": "^0.32.3" } -} +} \ No newline at end of file diff --git a/packages/canyon-platform/postcss.config.mjs b/packages/canyon-platform/postcss.config.mjs new file mode 100644 index 00000000..1a69fd2a --- /dev/null +++ b/packages/canyon-platform/postcss.config.mjs @@ -0,0 +1,8 @@ +/** @type {import('postcss-load-config').Config} */ +const config = { + plugins: { + tailwindcss: {}, + }, +}; + +export default config; diff --git a/packages/canyon-platform/src/App.tsx b/packages/canyon-platform/src/App.tsx index 3d7ded3f..b4b53c4f 100644 --- a/packages/canyon-platform/src/App.tsx +++ b/packages/canyon-platform/src/App.tsx @@ -1,35 +1,45 @@ -import { useState } from 'react' -import reactLogo from './assets/react.svg' -import viteLogo from '/vite.svg' -import './App.css' +import enUS from "antd/es/locale/en_US"; +import jaJP from "antd/es/locale/ja_JP"; +import zhCN from "antd/es/locale/zh_CN"; +import { useRoutes } from "react-router-dom"; -function App() { - const [count, setCount] = useState(0) +import routes from "~react-pages"; +// import Sha from "@/pages/index/projects/[id]/commits/[sha].tsx"; +// routes.push({ +// element: , +// path: "/open-projects/:id/commits/:sha", +// }); + +const languages = { + cn: zhCN, + en: enUS, + ja: jaJP, +}; + +const lng = (localStorage.getItem("language") || + "cn") as keyof typeof languages; + +const { darkAlgorithm } = theme; +const App = () => { + const isDark = localStorage.getItem("theme") + ? localStorage.getItem("theme") === "dark" + : false; return ( - <> -
- - Vite logo - - - React logo - -
-

Vite + React

-
- -

- Edit src/App.tsx and save to test HMR -

-
-

- Click on the Vite and React logos to learn more -

- - ) -} +
+ + {useRoutes(routes)} + +
+ ); +}; -export default App +export default App; diff --git a/packages/canyon-platform/src/auto-imports.d.ts b/packages/canyon-platform/src/auto-imports.d.ts new file mode 100644 index 00000000..bc7ec6a0 --- /dev/null +++ b/packages/canyon-platform/src/auto-imports.d.ts @@ -0,0 +1,51 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// noinspection JSUnusedGlobalSymbols +// Generated by unplugin-auto-import +// biome-ignore lint: disable +export {} +declare global { + const ConfigProvider: typeof import('antd')['ConfigProvider'] + const Link: typeof import('react-router-dom')['Link'] + const NavLink: typeof import('react-router-dom')['NavLink'] + const Navigate: typeof import('react-router-dom')['Navigate'] + const Outlet: typeof import('react-router-dom')['Outlet'] + const Route: typeof import('react-router-dom')['Route'] + const Routes: typeof import('react-router-dom')['Routes'] + const createRef: typeof import('react')['createRef'] + const forwardRef: typeof import('react')['forwardRef'] + const lazy: typeof import('react')['lazy'] + const memo: typeof import('react')['memo'] + const message: typeof import('antd')['message'] + const startTransition: typeof import('react')['startTransition'] + const theme: typeof import('antd')['theme'] + const useCallback: typeof import('react')['useCallback'] + const useContext: typeof import('react')['useContext'] + const useDebugValue: typeof import('react')['useDebugValue'] + const useDeferredValue: typeof import('react')['useDeferredValue'] + const useEffect: typeof import('react')['useEffect'] + const useHref: typeof import('react-router-dom')['useHref'] + const useId: typeof import('react')['useId'] + const useImperativeHandle: typeof import('react')['useImperativeHandle'] + const useInRouterContext: typeof import('react-router-dom')['useInRouterContext'] + const useInsertionEffect: typeof import('react')['useInsertionEffect'] + const useLayoutEffect: typeof import('react')['useLayoutEffect'] + const useLinkClickHandler: typeof import('react-router-dom')['useLinkClickHandler'] + const useLocation: typeof import('react-router-dom')['useLocation'] + const useMemo: typeof import('react')['useMemo'] + const useNavigate: typeof import('react-router-dom')['useNavigate'] + const useNavigationType: typeof import('react-router-dom')['useNavigationType'] + const useOutlet: typeof import('react-router-dom')['useOutlet'] + const useOutletContext: typeof import('react-router-dom')['useOutletContext'] + const useParams: typeof import('react-router-dom')['useParams'] + const useReducer: typeof import('react')['useReducer'] + const useRef: typeof import('react')['useRef'] + const useResolvedPath: typeof import('react-router-dom')['useResolvedPath'] + const useRoutes: typeof import('react-router-dom')['useRoutes'] + const useSearchParams: typeof import('react-router-dom')['useSearchParams'] + const useState: typeof import('react')['useState'] + const useSyncExternalStore: typeof import('react')['useSyncExternalStore'] + const useTransition: typeof import('react')['useTransition'] + const useTranslation: typeof import('react-i18next')['useTranslation'] +} diff --git a/packages/canyon-platform/src/helpers/backend/gql/queries/GetCoverageLog.graphql b/packages/canyon-platform/src/helpers/backend/gql/queries/GetCoverageLog.graphql new file mode 100644 index 00000000..8aa7a475 --- /dev/null +++ b/packages/canyon-platform/src/helpers/backend/gql/queries/GetCoverageLog.graphql @@ -0,0 +1,11 @@ +query GetCoverageLog { + getCoverageLog { + id + projectID + size + sha + createdAt + updatedAt + timing + } +} diff --git a/packages/canyon-platform/src/helpers/backend/gql/queries/GetProjectsBuOptions.graphql b/packages/canyon-platform/src/helpers/backend/gql/queries/GetProjectsBuOptions.graphql new file mode 100644 index 00000000..8e353f63 --- /dev/null +++ b/packages/canyon-platform/src/helpers/backend/gql/queries/GetProjectsBuOptions.graphql @@ -0,0 +1,6 @@ +query GetProjectsBuOptions { + getProjectsBuOptions { + bu + count + } +} diff --git a/packages/canyon-platform/src/index.css b/packages/canyon-platform/src/index.css index 6119ad9a..7275a9af 100644 --- a/packages/canyon-platform/src/index.css +++ b/packages/canyon-platform/src/index.css @@ -1,68 +1,12 @@ -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} +@tailwind base; +@tailwind components; +@tailwind utilities; a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; + color: #0071c2; } a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } + color: #0071c2; + opacity: 0.8; + text-decoration: underline; } diff --git a/packages/canyon-platform/src/main.tsx b/packages/canyon-platform/src/main.tsx index bef5202a..d77460eb 100644 --- a/packages/canyon-platform/src/main.tsx +++ b/packages/canyon-platform/src/main.tsx @@ -1,10 +1,72 @@ -import { StrictMode } from 'react' -import { createRoot } from 'react-dom/client' -import './index.css' -import App from './App.tsx' - -createRoot(document.getElementById('root')!).render( - - - , -) +import "dayjs/locale/zh-cn.js"; +import "./useWorker.ts"; +// import "./i18n.ts"; +import "antd/dist/reset.css"; +import "./index.css"; +// import "./collect.js"; + +import { + ApolloClient, + ApolloProvider, + createHttpLink, + InMemoryCache, +} from "@apollo/client"; +import { onError } from "@apollo/client/link/error"; +import ReactDOM from "react-dom/client"; +import { BrowserRouter } from "react-router-dom"; + +import App from "./App.tsx"; + +// 创建一个error link来处理错误 +const errorLink = onError(({ graphQLErrors, networkError }) => { + if (graphQLErrors) { + graphQLErrors.forEach(({ message: msg, locations, path }) => { + console.error( + `[GraphQL error]: msg: ${msg}, Location: ${locations}, Path: ${path}`, + ); + message.error(`[GraphQL error]: msg: ${msg}, Path: ${path}`); + if ( + msg === "Unauthorized" && + window.location.pathname !== "/oauth" && + window.location.pathname !== "/login" + ) { + localStorage.clear(); + window.location.href = "/login"; + } + // 在这里你可以执行自定义的操作,比如显示错误提示 + }); + } + if (networkError) { + console.error(`[Network error]: ${networkError}`); + // 在这里你可以执行自定义的操作,比如显示网络错误提示 + } +}); + +// 创建一个http link来发送GraphQL请求 +const httpLink = createHttpLink({ + uri: "/graphql", // 你的GraphQL API的URL + + headers: { + Authorization: `Bearer ` + (localStorage.getItem("token") || ""), + }, +}); + +// 创建Apollo Client实例 +const client = new ApolloClient({ + link: errorLink.concat(httpLink), // 将error link和http link组合起来 + cache: new InMemoryCache(), +}); + +if (localStorage.getItem("theme") === "dark") { + document.documentElement.classList.add("dark"); +} else { + document.documentElement.classList.remove("dark"); +} + +ReactDOM.createRoot(document.getElementById("root")!).render( + + + + + , +); diff --git a/packages/canyon-platform/src/pages/index.tsx b/packages/canyon-platform/src/pages/index.tsx new file mode 100644 index 00000000..16e00c8f --- /dev/null +++ b/packages/canyon-platform/src/pages/index.tsx @@ -0,0 +1,9 @@ +import {Outlet} from "react-router-dom"; + +const IndexPage = () => { + return
+ +
+} + +export default IndexPage diff --git a/packages/canyon-platform/src/pages/index/home.tsx b/packages/canyon-platform/src/pages/index/home.tsx new file mode 100644 index 00000000..d3a45d92 --- /dev/null +++ b/packages/canyon-platform/src/pages/index/home.tsx @@ -0,0 +1,50 @@ +// import React, { useState, useEffect } from 'react'; +import { Table } from 'antd'; +import {useQuery} from "@apollo/client"; +import {GetCoverageLogDocument} from "@/helpers/backend/gen/graphql.ts"; + +const columns = [ + { + title: 'ID', + dataIndex: 'id', + }, + { + title: '项目 ID', + dataIndex: 'projectID', + }, + { + title: 'SHA', + dataIndex: 'sha', + }, + { + title: '大小', + dataIndex: 'size', + }, + { + title: '时间', + dataIndex: 'timing', + }, + // { + // title: '命中', + // dataIndex: 'hit', + // }, + { + title: '创建时间', + dataIndex: 'createdAt', + render: (createdAt) => (new Date(createdAt)).toLocaleString(), + }, + { + title: '更新时间', + dataIndex: 'updatedAt', + render: (updatedAt) => (new Date(updatedAt)).toLocaleString(), + }, +]; + +const CoverageLogTable = () => { + + const {data} = useQuery(GetCoverageLogDocument) + + return ; +}; + +export default CoverageLogTable; diff --git a/packages/canyon-platform/src/useWorker.ts b/packages/canyon-platform/src/useWorker.ts new file mode 100644 index 00000000..c31f2663 --- /dev/null +++ b/packages/canyon-platform/src/useWorker.ts @@ -0,0 +1,5 @@ +import { loader } from "@monaco-editor/react"; +import * as monaco from "monaco-editor"; +loader.config({ + monaco: monaco, +}); diff --git a/packages/canyon-platform/src/vite-env.d.ts b/packages/canyon-platform/src/vite-env.d.ts index 11f02fe2..f627ca46 100644 --- a/packages/canyon-platform/src/vite-env.d.ts +++ b/packages/canyon-platform/src/vite-env.d.ts @@ -1 +1,3 @@ /// +// vite-env.d.ts +/// diff --git a/packages/canyon-platform/tailwind.config.ts b/packages/canyon-platform/tailwind.config.ts new file mode 100755 index 00000000..1068d64f --- /dev/null +++ b/packages/canyon-platform/tailwind.config.ts @@ -0,0 +1,19 @@ +import type { Config } from "tailwindcss"; + +const config = { + darkMode: "class", + content: [ + "./index.html", + "./src/**/*.{js,ts,jsx,tsx}", + // "../canyon-report/src/**/*.{js,ts,jsx,tsx}", + ], + theme: { + extend: {}, + }, + plugins: [], + corePlugins: { + preflight: false, + }, +} satisfies Config; + +export default config; diff --git a/packages/canyon-platform/tsconfig.app.json b/packages/canyon-platform/tsconfig.app.json index f867de0d..ab207918 100644 --- a/packages/canyon-platform/tsconfig.app.json +++ b/packages/canyon-platform/tsconfig.app.json @@ -1,26 +1,27 @@ { "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + }, + "composite": true, "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "ES2020", "useDefineForClassFields": true, "lib": ["ES2020", "DOM", "DOM.Iterable"], "module": "ESNext", "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "Bundler", + "moduleResolution": "bundler", "allowImportingTsExtensions": true, + "resolveJsonModule": true, "isolatedModules": true, "moduleDetection": "force", "noEmit": true, "jsx": "react-jsx", - - /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true + "noFallthroughCasesInSwitch": true }, "include": ["src"] } diff --git a/packages/canyon-platform/tsconfig.json b/packages/canyon-platform/tsconfig.json index 1ffef600..1e173931 100644 --- a/packages/canyon-platform/tsconfig.json +++ b/packages/canyon-platform/tsconfig.json @@ -1,7 +1,17 @@ { "files": [], "references": [ - { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" } - ] + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.node.json" + } + ], + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + } + } } diff --git a/packages/canyon-platform/tsconfig.node.json b/packages/canyon-platform/tsconfig.node.json index abcd7f0d..3afdd6e3 100644 --- a/packages/canyon-platform/tsconfig.node.json +++ b/packages/canyon-platform/tsconfig.node.json @@ -1,24 +1,13 @@ { "compilerOptions": { + "composite": true, "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 */ + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true + "noEmit": true }, "include": ["vite.config.ts"] } diff --git a/packages/canyon-platform/vite.config.ts b/packages/canyon-platform/vite.config.ts index 2328e170..44a7cbc7 100644 --- a/packages/canyon-platform/vite.config.ts +++ b/packages/canyon-platform/vite.config.ts @@ -1,7 +1,58 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react-swc' +import react from "@vitejs/plugin-react-swc"; +import * as path from "path"; +import AutoImport from "unplugin-auto-import/vite"; +import AntdResolver from "unplugin-auto-import-antd"; +import { defineConfig } from "vite"; +import Pages from "vite-plugin-pages"; -// https://vite.dev/config/ export default defineConfig({ - plugins: [react()], -}) + plugins: [ + react({ + plugins: + process.env.NODE_ENV === "development" + ? [] + : [ + ["swc-plugin-coverage-instrument", {}], + [ + "swc-plugin-canyon", + { + projectID: process.env.CI_PROJECT_ID, + sha: process.env.CI_COMMIT_SHA, + dsn: process.env.DSN, + reporter: process.env.REPORTER, + branch: process.env.CI_COMMIT_BRANCH, + instrumentCwd: path.resolve(__dirname, "../.."), + }, + ], + ], + }), + AutoImport({ + imports: ["react", "react-i18next", "react-router-dom"], + dts: "./src/auto-imports.d.ts", + resolvers: [AntdResolver()], + }), + Pages({ + exclude: ["**/helper/**", "**/components/**"], + }), + ], + resolve: { + alias: { + "@": path.resolve(__dirname, "./src"), + // "canyon-report": path.resolve(__dirname, "../canyon-report"), + // "canyon-data": path.resolve(__dirname, "../canyon-data/src"), + }, + }, + build: { + sourcemap: true, + }, + server: { + port: 8000, + host: "0.0.0.0", + proxy: { + "^/graphql|^/api": { + target: "http://127.0.0.1:8080", + changeOrigin: true, + }, + }, + }, +});