build-win.bat 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. @echo off
  2. chcp 65001 >nul 2>&1
  3. :: ============================================
  4. :: Claude AI Installer Windows 构建脚本
  5. :: Build script for Windows (NSIS + Portable)
  6. :: 此脚本作为 scripts/build.js 的简单入口
  7. :: ============================================
  8. :: 切换到脚本所在目录
  9. cd /d "%~dp0"
  10. :: 检查是否请求帮助
  11. if /i "%~1"=="--help" goto :show_help
  12. if /i "%~1"=="-h" goto :show_help
  13. :: 检查 Node.js
  14. where node >nul 2>&1
  15. if errorlevel 1 (
  16. echo [91mx[0m 未找到 Node.js,请先安装 Node.js
  17. pause
  18. exit /b 1
  19. )
  20. :: 检查 node_modules
  21. if not exist "node_modules" (
  22. echo [93m![0m 未找到 node_modules,正在安装依赖...
  23. call npm install
  24. if errorlevel 1 (
  25. echo [91mx[0m 安装依赖失败
  26. pause
  27. exit /b 1
  28. )
  29. )
  30. :: 转换参数并调用 Node.js 脚本
  31. :: 将 bat 参数映射到 build.js 参数
  32. set "NODE_ARGS=-p win"
  33. :parse_args
  34. if "%~1"=="" goto :run_build
  35. if /i "%~1"=="--skip-build" set "NODE_ARGS=%NODE_ARGS% --skip-build" & shift & goto :parse_args
  36. if /i "%~1"=="-s" set "NODE_ARGS=%NODE_ARGS% --skip-build" & shift & goto :parse_args
  37. if /i "%~1"=="--skip-typecheck" set "NODE_ARGS=%NODE_ARGS% --skip-typecheck" & shift & goto :parse_args
  38. if /i "%~1"=="--arch" set "NODE_ARGS=%NODE_ARGS% --arch %~2" & shift & shift & goto :parse_args
  39. if /i "%~1"=="-a" set "NODE_ARGS=%NODE_ARGS% --arch %~2" & shift & shift & goto :parse_args
  40. shift
  41. goto :parse_args
  42. :run_build
  43. echo.
  44. echo [96m^> 调用 Node.js 构建脚本...[0m
  45. echo [94mi[0m 执行: node scripts/build.js %NODE_ARGS%
  46. echo.
  47. call node scripts/build.js %NODE_ARGS%
  48. if errorlevel 1 (
  49. echo.
  50. echo [91mx[0m 构建失败!
  51. echo.
  52. pause
  53. exit /b 1
  54. )
  55. echo.
  56. pause
  57. goto :eof
  58. :: ============================================
  59. :: 显示帮助信息
  60. :: ============================================
  61. :show_help
  62. echo.
  63. echo Claude AI Installer Windows 构建脚本
  64. echo.
  65. echo 用法:
  66. echo build-win.bat [参数]
  67. echo.
  68. echo 参数:
  69. echo --skip-build, -s 跳过前端构建,仅执行打包
  70. echo --skip-typecheck 跳过 TypeScript 类型检查
  71. echo --arch, -a ^<arch^> 目标架构: x64, arm64, all (默认: x64)
  72. echo --help, -h 显示此帮助信息
  73. echo.
  74. echo 示例:
  75. echo build-win.bat 完整构建
  76. echo build-win.bat -s 仅打包
  77. echo build-win.bat -a all 构建所有架构
  78. echo build-win.bat --skip-typecheck 跳过类型检查
  79. echo.
  80. echo 输出:
  81. echo release\Claude AI Installer-x.x.x-win-x64-nsis.exe (NSIS 安装程序)
  82. echo release\Claude AI Installer-x.x.x-win-x64-portable.exe (便携版)
  83. echo.
  84. echo 注意: 此脚本调用 scripts/build.js 执行实际构建
  85. echo.
  86. goto :eof