View unanswered posts | View active topics



Reply to topic  [ 1 post ] 
Flash Catalyst helper script 
Author Message
Member

Joined: Wed Aug 12, 2009 2:09 pm
Posts: 29
I made this little helper script for working with Flash Catalyst and FlashDevelop.

Flash Catalyst saves files in FXP format, which are regular ZIP files.

Point the variable FXP_NAME to your FXP file.

By default this script only syncs src/components/* and src/assets/images/*.
You can set your own catalogs in the variable FILE_LIST.

I added a simple backup as well, because you can't be safe enough when editing files from two directions. Wouldn't trust my life on it so keep those svn commits going!

REQUIREMENTS:
ZIP and UNZIP. I use and recommend UnxUtils, see UnxUtils http://sourceforge.net/projects/unxutils/.

Installation:
1. Copy the attached code.
2. Create the file Catalyst_Sync.bat in the root folder of your project.
3. Paste the code in the file.
4. Edit the variables FXP_NAME, FILE_LIST and ZIP_PATH
5. Save

Disclaimer:
This script is shared as is. It works for me and I can not be held responsible for whatever damage you might manage to do with it. You may use and modify it freely. You are kindly asked to not redistribute this script, but refer to this thread for the lastest version. If you share a modified version, the original credits plus information on your own additions must be included. You may not include this script in any kind of distribution without permission. Thanks.

Code:
@echo off

:: Catalyst_Sync.bat
::
:: Helper for syncing Flash Catalyst and FlashDevelop file structures
:: must have zip.exe and unzip.exe in path!
::
:: Version 0.21 by Mkn 2011-09-01
:: http://www.flashdevelop.org/community/viewtopic.php?f=20&t=8674

:INIT
:: File name of FXP file
set FXP_NAME=.

:: Space separated list of files to synchronize
set FILE_LIST=src\components\* src\assets\images\*

:: Set the path to ZIP and UNZIP here if needed
set ZIP_PATH=.

if %ZIP_PATH% NEQ . set PATH=%PATH%;%ZIP_PATH%

if %FXP_NAME% EQU . (
   echo FXP_NAME not set.
   pause
   exit
)

:MENU
echo.
echo FXP Helper
echo ==========
echo.
echo Synchronize:
echo (1) FXP to src
echo (2) src to FXP
echo (3) List contents of FXP
echo (4) Restore from backup copy
echo (5) Remove backups
echo (x) Exit
echo.
choice /C 12345x
echo.

set ACTION=%ERRORLEVEL%

if %ACTION% LEQ 2 goto BACKUP

:DO_ACTION
echo.
if %ACTION% EQU 1 goto UNZIP_FXP
if %ACTION% EQU 2 goto ZIP_FXP
if %ACTION% EQU 3 goto LIST_FXP
if %ACTION% EQU 4 goto RESTORE
if %ACTION% EQU 5 goto REMOVE_BUPS
goto QUIT

:ZIP_FXP
echo Updating files from src/ to FXP
echo ===============================
echo.
zip -r %FXP_NAME% %FILE_LIST%
if %ERRORLEVEL% EQU 0 goto QUIT
if %ERRORLEVEL% EQU 12 (
   echo No files added to FXP
   goto QUIT
)
goto ERROR

:UNZIP_FXP
echo Extracting files from FXP to src/
echo =================================
echo.
unzip -u %FXP_NAME% %FILE_LIST%
if %ERRORLEVEL% EQU 0 goto QUIT
if %ERRORLEVEL% EQU 11 (
   echo No files extracted from FXP
   goto QUIT
)
goto ERROR

:LIST_FXP
echo Listing contents of FXP
echo =======================
echo.
unzip -l %FXP_NAME%
if %ERRORLEVEL% EQU 0 goto QUIT
goto ERROR

:BACKUP
echo.
echo Back up current structure?
echo.
choice /c yn
echo.

if %ERRORLEVEL% EQU 1 (
   if %ACTION% EQU 1 (
      if exist src.zip del src.zip
      echo Copy src/ to src.zip
      zip -r src.zip src
   )
   if %ACTION% EQU 2 (
      if exist %FXP_NAME%.bup del %FXP_NAME%.bup
      echo Copy %FXP_NAME% to %FXP_NAME%.bup
      copy %FXP_NAME% %FXP_NAME%.bup
   )
)

goto DO_ACTION

:RESTORE
echo Restore from backup
echo ===================
echo.
echo (1) Copy FXP backup to FXP
echo (2) Copy files src.zip to src/
echo (x) Exit
echo.
choice /c 12x

if %ERRORLEVEL% EQU 1 (
   echo Are you sure you want to copy %FXP_NAME%.bup to %FXP_NAME%?
   choice /c yn
   if %ERRORLEVEL% EQU 2 goto QUIT
   
   if not exist %FXP_NAME%.bup goto ERROR
   
   echo Copying %FXP_NAME%.bup to %FXP_NAME%.
   del %FXP_NAME%
   copy %FXP_NAME%.bup %FXP_NAME%
)

if %ERRORLEVEL% EQU 2 (
   echo Are you sure you want to copy src.zip to src?
   choice /c ny
   if %ERRORLEVEL% EQU 1 goto QUIT
   
   if not exist src.zip goto ERROR
   
   echo Copying files from src.zip to src.
   rmdir /s /q src
   unzip src.zip
)

goto QUIT

:REMOVE_BUPS
if exist %FXP_NAME%.bup del %FXP_NAME%.bup
if exist src.zip del src.zip
goto QUIT

:ERROR
echo ERROR
echo =====
if %ACTION% LEQ 2 (
   if %ERRORLEVEL% EQU 9009 echo Do you have zip and unzip in PATH?
   if %ERRORLEVEL% NEQ 9009 echo Something went wrong.
)
if %ACTION% EQU 4 echo No back up to restore!
echo.
pause
exit

:QUIT
echo.
echo All done
echo ========
pause
exit



Thu Sep 01, 2011 3:18 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.