pack.cmd 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. echo QDR Temporary Shared Storage Plugin Packager
  4. echo ===========================================
  5. echo.
  6. :: Set variables
  7. set PLUGIN_NAME=qdr-temporary-shared-storage
  8. set DEPLOY_DIR=D:\Deploy
  9. set CURRENT_DIR=%CD%
  10. set TARGET_ZIP=%DEPLOY_DIR%\%PLUGIN_NAME%.zip
  11. set SCRIPT_NAME=%~nx0
  12. :: Create deploy directory if it doesn't exist
  13. if not exist "%DEPLOY_DIR%" (
  14. echo Creating deploy directory %DEPLOY_DIR%...
  15. mkdir "%DEPLOY_DIR%"
  16. )
  17. :: Remove existing ZIP if it exists
  18. if exist "%TARGET_ZIP%" (
  19. echo Removing existing archive...
  20. del "%TARGET_ZIP%"
  21. )
  22. :: Create temporary directory for files to include
  23. set TEMP_DIR=%TEMP%\%PLUGIN_NAME%_package
  24. if exist "%TEMP_DIR%" rmdir /s /q "%TEMP_DIR%"
  25. mkdir "%TEMP_DIR%"
  26. echo Copying plugin files to temporary directory...
  27. :: Copy all files and directories except excluded ones
  28. for /d %%D in (*) do (
  29. if /i not "%%D"=="@documentation" (
  30. xcopy "%%D" "%TEMP_DIR%\%%D\" /E /I /H /Y >nul
  31. )
  32. )
  33. :: Copy individual files except the script itself
  34. for %%F in (*.*) do (
  35. if /i not "%%F"=="%SCRIPT_NAME%" (
  36. copy "%%F" "%TEMP_DIR%\" >nul
  37. )
  38. )
  39. echo Creating ZIP archive...
  40. :: Create ZIP file using PowerShell
  41. powershell -Command "Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::CreateFromDirectory('%TEMP_DIR%', '%TARGET_ZIP%')"
  42. :: Clean up temporary directory
  43. rmdir /s /q "%TEMP_DIR%"
  44. :: Verify creation and display result
  45. if exist "%TARGET_ZIP%" (
  46. echo.
  47. echo Package created successfully: %TARGET_ZIP%
  48. echo Size:
  49. for %%A in ("%TARGET_ZIP%") do echo %%~zA bytes
  50. ) else (
  51. echo.
  52. echo ERROR: Failed to create package!
  53. )
  54. echo.
  55. echo Process complete.
  56. endlocal