Files
eSIM-Tools/scripts/deploy-prepare.js
Abner 4a0fcc94fe feat: 重构Netlify Functions架构并增强代码质量
- 新增统一的中间件模块,提供鉴权、CORS和错误处理功能
- 重构所有Functions使用withAuth中间件简化代码结构
- 添加安全存储模块替代localStorage,防御XSS攻击
- 引入HTML清理工具,自动转义特殊字符和验证URL安全性
- 创建代码质量检查脚本,验证语法、环境变量和依赖完整性
- 添加构建日志工具和重构脚本,统一替换console.log为Logger
- 引入ESLint配置,提升代码质量和一致性
- 重构Giffgaff相关API,统一错误处理和验证逻辑
- 优化构建脚本,添加压缩和图片优化功能
- 新增健康检查端点,用于服务监控和状态报告
2025-11-23 22:20:02 +08:00

29 lines
780 B
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
const BuildLogger = require('./logger.js');
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;
if (!key) {
throw new Error('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() {
BuildLogger.log('🔧 检查部署前置条件...');
ensureAccessKey();
ensureDist();
BuildLogger.success(' 部署前检查通过,可继续执行部署流程');
})();