mirror of
https://github.com/Silentely/eSIM-Tools.git
synced 2026-09-03 06:24:20 +08:00
feat: 重构部署流程并移除 Service Worker
- 新增部署工具脚本:添加 `build-static.js`、`deploy-prepare.js`、`deploy-analyze.js` 和 `test-deploy-config.js` 标准化构建部署流程 - 配置 Netlify 发布目录:修改 `netlify.toml` 将 `publish` 从根目录切换到 `dist` 目录以增强安全性 - 移除 Service Worker 相关代码:删除 `sw.js` 并清理相关注册逻辑,简化性能优化策略 - 增强服务器静态文件服务:重构静态资源中间件,增加环境检查和错误处理 - 改进 API 密钥处理逻辑:统一 Netlify Functions 的密钥验证流程,增加配置缺失提示 - 添加 Serena AI 配置文件:包含项目元数据、语言服务器设置和常用命令记忆 - 重构 HTML 页面路由:使用配置化的路由表替代硬编码路径,提高可维护性
This commit is contained in:
27
scripts/deploy-prepare.js
Executable file
27
scripts/deploy-prepare.js
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const projectRoot = path.join(__dirname, '..');
|
||||
const distDir = path.join(projectRoot, 'dist');
|
||||
|
||||
function ensureAccessKey() {
|
||||
const key = process.env.ACCESS_KEY || process.env.ESIM_ACCESS_KEY;
|
||||
if (!key) {
|
||||
throw new Error('ACCESS_KEY/ESIM_ACCESS_KEY 未配置,无法保护 Functions。');
|
||||
}
|
||||
}
|
||||
|
||||
function ensureDist() {
|
||||
const indexPath = path.join(distDir, 'index.html');
|
||||
if (!fs.existsSync(indexPath)) {
|
||||
throw new Error('dist 目录缺少 index.html,请先运行 npm run build。');
|
||||
}
|
||||
}
|
||||
|
||||
(function main() {
|
||||
console.log('🔧 检查部署前置条件...');
|
||||
ensureAccessKey();
|
||||
ensureDist();
|
||||
console.log('✅ 部署前检查通过,可继续执行部署流程');
|
||||
})();
|
||||
Reference in New Issue
Block a user