<?php
/********************************************************************************
 * (c)1337 aheadware.com - All rights reserved
 ********************************************************************************/
include_once 'build_inc-new.php';

function task_homeDeployDependenciesToTest() {

    $server = new Server();
    $local = new Local();

    $lTempDir = Local::TEMP_DIR . '/new-dependencies';
    $lSrcDir = Local::PROJECT_ROOT . '/dependencies';
    $remoteRootDir = Server::ROOT_DIR . '/projects/teambuddy/dependencies';

    print( "Reset local temp dirs...\n" );
    $local->rmDir( $lTempDir );
    $local->mkDir( $lTempDir );
    $local->mkDir( $lTempDir . '/Francis' );

    print( "Copy dependencies to temp folder...\n" );
    $local->rCopy( $lSrcDir, $lTempDir );

    $local->zipFolder( $lTempDir, $lTempDir . '/../new-dependencies.zip' );

    print( "Uploading compressed new server...\n" );
    $server->upload( $lTempDir . '/../new-dependencies.zip',  Server::TEMP_DIR . '/new-dependencies.zip' );

    print( "Copy new server files to remote dest dir..." );
    $server->exec( "cd " . Server::TEMP_DIR . ";unzip -o new-dependencies.zip -d $remoteRootDir" );

    print( "Cleanup remote zip file...\n" );
    $server->exec( "cd " . Server::TEMP_DIR . ";rm new-dependencies.zip;" );
}

task_homeDeployDependenciesToTest();