Files
weixin-plugin-test/scripts/build-weixin-plugin.sh
zyh 77019ec050 feat: 初始化微信插件独立测试环境
添加完整的微信插件测试框架,包含:
- 微信插件源码(weixin-plugin/)
- TypeScript 类型定义(types.ts)
- 插件编译脚本(scripts/build-weixin-plugin.sh)
- 简化测试脚本(scripts/test-weixin-simple.js)
- 完整测试脚本(scripts/test-weixin-plugin.js)
- 项目配置和依赖管理(package.json)
- 使用说明文档(README.md)

主要功能:
- 支持二维码登录认证
- HTTP 长轮询消息接收
- 文本、图片、视频、文件消息收发
- 自动回复测试
- 运行状态统计

Generated with [Claude Code](https://claude.com/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-30 07:14:00 +00:00

102 lines
2.0 KiB
Bash
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.

#!/bin/bash
# 微信插件 TypeScript 编译脚本
# 用于快速编译 weixin-plugin 目录下的 TypeScript 文件
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
WEIXIN_PLUGIN_DIR="$PROJECT_ROOT/weixin-plugin"
echo "微信插件编译脚本"
echo "================"
echo ""
# 检查依赖
echo "1. 检查依赖..."
if ! command -v npx &> /dev/null; then
echo " ✗ npx 未找到"
echo " 请确保 Node.js 和 npm 已正确安装"
exit 1
fi
echo " ✓ npx 已找到"
# 检查是否安装了 typescript
if ! npm list typescript &> /dev/null; then
echo " 正在安装 typescript..."
npm install
fi
echo " ✓ typescript 已准备就绪"
echo ""
# 创建临时 tsconfig
echo "2. 创建编译配置..."
cat > "$WEIXIN_PLUGIN_DIR/tsconfig.json" << 'EOF'
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"lib": ["ES2020"],
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true,
"strict": false,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist",
"rootDir": ".",
"declaration": false,
"sourceMap": false
},
"include": [
"**/*.ts"
],
"exclude": [
"node_modules",
"dist"
]
}
EOF
echo " ✓ tsconfig.json 已创建"
echo ""
# 编译
echo "3. 开始编译..."
echo ""
cd "$WEIXIN_PLUGIN_DIR"
# 使用 tsc 编译
npx tsc
echo ""
echo " ✓ 编译完成"
echo ""
# 检查输出
echo "4. 检查输出文件..."
JS_COUNT=$(find dist -name "*.js" -type f 2>/dev/null | wc -l)
echo " 生成了 $JS_COUNT 个 JavaScript 文件"
if [ "$JS_COUNT" -eq 0 ]; then
echo " ✗ 编译可能失败dist 目录为空"
exit 1
fi
echo ""
echo "================"
echo "编译成功!"
echo ""
echo "编译后的文件位于: $WEIXIN_PLUGIN_DIR/dist/"
echo ""
echo "你现在可以运行测试脚本了:"
echo " npm run test:simple"