打包分发.bat 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. @echo off
  2. chcp 65001 >nul
  3. cd /d "%~dp0"
  4. set NAME=智慧运营中台-分发包
  5. set OUT=%CD%\dist\%NAME%
  6. set ZIP=%CD%\dist\%NAME%.zip
  7. if exist "%OUT%" rmdir /s /q "%OUT%"
  8. if exist "%ZIP%" del /q "%ZIP%"
  9. if not exist "dist" mkdir "dist"
  10. mkdir "%OUT%"
  11. rem 根目录代码:复制全部 *.js,新增模块不会漏
  12. for %%f in (*.js) do (
  13. copy /y "%%f" "%OUT%\" >nul
  14. )
  15. for %%f in (package.json package-lock.json config.example.json README.md 启动.bat 启动.command 启动.sh 打包分发.bat 打包分发.command) do (
  16. if exist "%%f" copy /y "%%f" "%OUT%\" >nul
  17. )
  18. robocopy public "%OUT%\public" /E /NFL /NDL /NJH /NJS >nul
  19. robocopy napos "%OUT%\napos" /E /NFL /NDL /NJH /NJS >nul
  20. robocopy server "%OUT%\server" /E /NFL /NDL /NJH /NJS >nul
  21. robocopy scripts "%OUT%\scripts" /E /NFL /NDL /NJH /NJS >nul
  22. robocopy node_modules "%OUT%\node_modules" /E /NFL /NDL /NJH /NJS >nul
  23. rem 敏感文件与数据默认不进包
  24. if exist "%OUT%\config.json" del /q "%OUT%\config.json"
  25. if exist "%OUT%\session.json" del /q "%OUT%\session.json"
  26. if exist "%OUT%\manual-shops.json" del /q "%OUT%\manual-shops.json"
  27. if exist "%OUT%\ops-export.json" del /q "%OUT%\ops-export.json"
  28. if exist "%OUT%\data" rmdir /s /q "%OUT%\data"
  29. if exist "%OUT%\workspace" rmdir /s /q "%OUT%\workspace"
  30. rem 可选:带上演示数据库(双击运行时默认不带;需要时在命令行执行 打包分发.bat --with-data)
  31. if /i "%~1"=="--with-data" (
  32. if exist "data\ops.db" (
  33. mkdir "%OUT%\data"
  34. copy /y "data\ops.db" "%OUT%\data\ops.db" >nul
  35. echo 已包含演示数据库 data\ops.db
  36. )
  37. )
  38. powershell -NoProfile -Command "Compress-Archive -LiteralPath '%OUT%' -DestinationPath '%ZIP%' -Force"
  39. if exist "%ZIP%" rmdir /s /q "%OUT%"
  40. echo 已生成分发包: %ZIP%
  41. echo 默认不含 config.json / data / workspace(密钥与数据只留在本机)。
  42. echo 对方解压后双击 启动.bat;首次启动自动生成配置与空数据库。
  43. echo 要求 Node.js 22.13 及以上。
  44. pause