Преглед на файлове

chore(custom): 构建体系搭建

linyuanjie преди 3 месеца
родител
ревизия
a3d9c3cb26
променени са 9 файла, в които са добавени 539 реда и са изтрити 125 реда
  1. 26 0
      .cz-config.cjs
  2. 1 1
      .env.production
  3. 0 24
      Dockerfile
  4. 43 0
      commitlint.config.cjs
  5. 0 7
      docker-compose.yaml
  6. 0 26
      lefthook1.yml
  7. 41 7
      package.json
  8. 427 59
      pnpm-lock.yaml
  9. 1 1
      src/vite-env.d.ts

+ 26 - 0
.cz-config.cjs

@@ -0,0 +1,26 @@
+module.exports = {
+  types: [
+    { value: 'feature', name: 'feature:  增加新功能' },
+    { value: 'bug', name: 'bug:      测试反馈bug列表中的bug号' },
+    { value: 'fix', name: 'fix:      修复bug' },
+    { value: 'ui', name: 'ui:       更新UI' },
+    { value: 'docs', name: 'docs:     文档变更' },
+    { value: 'style', name: 'style:    代码格式(不影响代码运行的变动)' },
+    { value: 'perf', name: 'perf:     性能优化' },
+    { value: 'refactor', name: 'refactor: 重构(既不是增加feature,也不是修复bug)' },
+    { value: 'release', name: 'release:  发布' },
+    { value: 'deploy', name: 'deploy:   部署' },
+    { value: 'test', name: 'test:     增加测试' },
+    { value: 'chore', name: 'chore:    构建过程或辅助工具的变动(更改配置文件)' },
+    { value: 'revert', name: 'revert:   回退' },
+    { value: 'build', name: 'build:    打包' }
+  ],
+  // override the messages, defaults are as follows
+  messages: {
+    type: '请选择提交类型:',
+    subject: '请简要描述提交 message (必填):',
+    confirmCommit: '确认使用以上信息提交?(y/n/e/h)'
+  },
+  skipQuestions: ['body', 'footer'],
+  subjectLimit: 72
+}

+ 1 - 1
.env.production

@@ -1,4 +1,4 @@
-VITE_APP_ENV = production
+VITE_APP_ENV = prod
 VITE_APP_URL = https://backend.yaoeasier.com/
 VITE_APP_TITLE = 要易业务管理系统
 VITE_APP_HOMEPAGE = /dashboard/index

+ 0 - 24
Dockerfile

@@ -1,24 +0,0 @@
-# Stage 1: build stage
-FROM node:22-alpine as build-stage
-# make the 'app' folder the current working directory
-WORKDIR /app
-# config node options
-ENV NODE_OPTIONS=--max_old_space_size=8192
-# config pnpm, install dependencies
-COPY package.json pnpm-lock.yaml* ./
-RUN npm install pnpm@9.x -g && \
-    pnpm install --frozen-lockfile
-# copy project files and folders to the current working directory (i.e. 'app' folder)
-COPY . ./
-# build the project
-RUN pnpm build
-RUN echo "build successful  🎉 🎉 🎉"
-
-
-# Stage 2: production stage
-FROM nginx:latest as production-stage
-COPY --from=build-stage /app/dist /usr/share/nginx/html
-EXPOSE 80
-CMD ["nginx", "-g", "daemon off;"]
-RUN echo "deploy to nginx successful  🎉 🎉 🎉"
-

+ 43 - 0
commitlint.config.cjs

@@ -0,0 +1,43 @@
+module.exports = {
+  extends: ['@commitlint/config-conventional'],
+  rules: {
+    'type-enum': [
+      2,
+      'always',
+      [
+        'feature', // 新功能(feature)
+        'bug', // 此项特别针对bug号,用于向测试反馈bug列表的bug修改情况
+        'fix', // 修补bug
+        'ui', // 更新 ui
+        'docs', // 文档(documentation)
+        'style', // 格式(不影响代码运行的变动)
+        'perf', // 性能优化
+        'release', // 发布
+        'deploy', // 部署
+        'refactor', // 重构(即不是新增功能,也不是修改bug的代码变动)
+        'test', // 增加测试
+        'chore', // 构建过程或辅助工具的变动
+        'revert', // feat(pencil): add ‘graphiteWidth’ option (撤销之前的commit)
+        'merge', // 合并分支, 例如: merge(前端页面): feature-xxxx修改线程地址
+        'build' // 编译相关修改,例如发布版本、项目构建或者依赖的改动
+      ]
+    ],
+    // <type> 格式 小写
+    'type-case': [2, 'always', 'lower-case'],
+    // <type> 不能为空
+    'type-empty': [2, 'never'],
+    // <scope> 范围不能为空
+    'scope-empty': [2, 'never'],
+    // <scope> 范围格式
+    'scope-case': [0],
+    // <subject> 主要 message 不能为空
+    'subject-empty': [2, 'never'],
+    // <subject> 以什么为结束标志,禁用
+    'subject-full-stop': [0, 'never'],
+    // <subject> 格式,禁用
+    'subject-case': [0, 'never'],
+    // <body> 以空行开头
+    'body-leading-blank': [1, 'always'],
+    'header-max-length': [0, 'always', 72]
+  }
+}

+ 0 - 7
docker-compose.yaml

@@ -1,7 +0,0 @@
-services:
-  slash:
-    build:
-      context: .
-    ports:
-      - "3001:80"
-    restart: always

+ 0 - 26
lefthook1.yml

@@ -1,26 +0,0 @@
-# SKIP CI in commit message to skip hooks
-skip_output:
-  - meta
-  - success
-  - summary
-
-pre-commit:
-  parallel: true
-  commands:
-    # format:
-    #   glob: "*.{js,jsx,ts,tsx,json,md}"
-    #   run: npx @biomejs/biome format --write --no-errors-on-unmatched {staged_files}
-    #   stage_fixed: true
-    # lint:
-    #   glob: "*.{js,jsx,ts,tsx}"
-    #   run: npx @biomejs/biome lint --no-errors-on-unmatched {staged_files}
-    # check-types:
-    #   glob: "*.{ts,tsx}"
-    #   run: npx tsc --noEmit
-
-commit-msg:
-  commands:
-    commitlint:
-      run: npx commitlint --edit {1}
-      # 允许空提交信息
-      skip: merge|rebase

+ 41 - 7
package.json

@@ -1,15 +1,44 @@
 {
-  "name": "slash-admin",
+  "name": "zsy3-admin",
   "private": true,
   "version": "0.0.0",
   "type": "module",
-  "homepage": "https://github.com/d3george/slash-admin",
   "scripts": {
     "dev": "vite",
     "build": "tsc && vite build",
     "preview": "vite preview",
-    "preinstall": "lefthook install",
-    "format": "prettier --write \"./**/*.{html,jsx,tsx,ts,js,json,md}\""
+    "format": "prettier --write \"./**/*.{html,jsx,tsx,ts,js,json,md}\"",
+    "prepare": "husky install",
+    "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
+    "lint:lint-staged": "lint-staged",
+    "tsc": "tsc --noEmit --skipLibCheck",
+    "commit": "git-cz"
+  },
+  "config": {
+    "commitizen": {
+      "path": "node_modules/cz-customizable"
+    },
+    "cz-customizable": {
+      "config": ".cz-config.cjs"
+    }
+  },
+  "lint-staged": {
+    "*.{js,jsx,ts,tsx}": [
+      "pnpm run lint --fix",
+      "npx prettier --write"
+    ],
+    "{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": [
+      "npx prettier --write--parser json"
+    ],
+    "package.json": [
+      "npx prettier --write"
+    ],
+    "*.{scss,less,styl,html}": [
+      "npx prettier --write"
+    ],
+    "*.md": [
+      "npx prettier --write"
+    ]
   },
   "dependencies": {
     "@ant-design/cssinjs": "^1.17.2",
@@ -79,8 +108,8 @@
     "zustand": "^4.4.3"
   },
   "devDependencies": {
-    "@commitlint/cli": "^17.7.2",
-    "@commitlint/config-conventional": "^17.7.0",
+    "@commitlint/cli": "^17.8.1",
+    "@commitlint/config-conventional": "^17.8.1",
     "@faker-js/faker": "^8.1.0",
     "@trivago/prettier-plugin-sort-imports": "^4.2.0",
     "@types/autosuggest-highlight": "^3.2.0",
@@ -97,12 +126,17 @@
     "@typescript-eslint/parser": "^8.23.0",
     "autoprefixer": "^10.4.16",
     "babel-eslint": "^10.1.0",
+    "commitizen": "^4.3.1",
+    "commitlint-config-cz": "^0.13.3",
+    "cz-conventional-changelog": "^3.3.0",
+    "cz-customizable": "^7.4.0",
     "eslint": "^8.57.1",
     "eslint-config-prettier": "^10.0.1",
     "eslint-plugin-import": "^2.31.0",
     "eslint-plugin-prettier": "^5.2.3",
     "eslint-plugin-react": "^7.37.4",
-    "lefthook": "^1.8.2",
+    "husky": "^9.1.7",
+    "lint-staged": "^15.5.0",
     "msw": "^2.4.9",
     "postcss": "^8.4.31",
     "postcss-import": "^15.1.0",

Файловите разлики са ограничени, защото са твърде много
+ 427 - 59
pnpm-lock.yaml


+ 1 - 1
src/vite-env.d.ts

@@ -1,7 +1,7 @@
 /// <reference types="vite/client" />
 
 interface ImportMetaEnv {
-  readonly VITE_APP_ENV: 'dev' | 'production'
+  readonly VITE_APP_ENV: 'dev' | 'prod'
   readonly VITE_APP_URL: string
   readonly VITE_APP_TITLE: string
   readonly VITE_APP_HOMEPAGE: string

Някои файлове не бяха показани, защото твърде много файлове са промени