pack.cmd 2.0 KB

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