# 📖 项目脚本使用说明 本项目在 `package.json` 中定义了一系列常用脚本,用于本地开发、构建、发布和部署。 以下是每个脚本的功能及使用方法。 --- ## 🎯 彩色命令速查表 | 环境 | 命令 | 端口 / 说明 | |------|------|------------| | 🟢 开发环境 | `npm run dev` | 3000 | | 🟡 测试环境 | `npm run dev:test` | 4000 | | 🔴 生产环境(本地调试) | `npm run dev:pro` | 5000 | | 📦 构建开发环境 | `npm run build:dev` | - | | 📦 构建测试环境 | `npm run build:test` | - | | 📦 构建生产环境 | `npm run build` | - | | 🚀 发布版本 | `npm run release` | 自动推送代码 + tags | | 📤 部署测试环境 | `npm run deploy:test` | 打包 + 部署 | | 🔍 类型检查 | `npm run type-check` | TypeScript 检查 | | 🧹 代码修复 | `npm run lint` | ESLint 自动修复 | | 🎨 格式化代码 | `npm run format` | Prettier 格式化 | --- ## 📦 开发相关 | 命令 | 说明 | 运行示例 | |------|------|----------| | `npm run dev` | 启动开发环境(development),端口 3000 | `npm run dev` | | `npm run dev:test` | 启动测试环境(test),端口 4000 | `npm run dev:test` | | `npm run dev:pro` | 启动生产环境(production)本地调试,端口 5000 | `npm run dev:pro` | --- ## 🏗 构建相关 | 命令 | 说明 | 运行示例 | |------|------|----------| | `npm run build:dev` | 打包 **开发环境** 构建产物 | `npm run build:dev` | | `npm run build:test` | 打包 **测试环境** 构建产物 | `npm run build:test` | | `npm run build` | 打包 **生产环境** 构建产物 | `npm run build` | --- ## 🚀 发布相关 | 命令 | 说明 | 运行示例 | |------|------|----------| | `npm run bump` | 自动更新版本号(patch 增量),并生成 Git 提交信息 | `npm run bump` | | `npm run release` | 更新版本号 → 推送代码 → 推送 tags → 生成发布日志 | `npm run release` | > 💡 `npm run release` 会执行: > 1. `npm run bump` > 2. `git push`(推送代码) > 3. `git push --tags`(推送版本标签) > 4. `node scripts/release-message.js`(生成发布信息) --- ## 📤 部署相关 | 命令 | 说明 | 运行示例 | |------|------|----------| | `npm run deploy:test` | **打包测试环境** 并执行部署脚本 | `npm run deploy:test` | | `npm run run:deploy` | 直接执行部署脚本(不打包) | `npm run run:deploy` | > ⚠ `run:deploy` 会调用 `scripts/deploy.ps1`(PowerShell 脚本),需确保本地已安装 PowerShell 且允许执行脚本。 --- ## 👀 预览构建产物 | 命令 | 说明 | 运行示例 | |------|------|----------| | `npm run preview` | 本地预览已构建的生产环境包(默认端口 4173) | `npm run preview` | --- ## 🔍 代码检查与格式化 | 命令 | 说明 | 运行示例 | |------|------|----------| | `npm run type-check` | TypeScript 类型检查 | `npm run type-check` | | `npm run lint` | ESLint 代码规范检查并自动修复问题 | `npm run lint` | | `npm run format` | 使用 Prettier 格式化 `src/` 目录下的代码 | `npm run format` | --- ## 📝 常用工作流示例 **本地开发** ```bash npm install npm run dev ``` **打包并部署测试环境** ```bash npm run deploy:test ``` **发布新版本到远程仓库** ```bash npm run release ``` **代码检查与格式化** ```bash npm run type-check npm run lint npm run format ```