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

function task_deployDependenciesToTest() {

    global $local_temp_dir,
           $local_source_dir,
           $remote_temp_dir,
           $remote_dest_dir_dependencies;

    $lTempDir = $local_temp_dir . '/new-dependencies';
    $lSrcDir = $local_source_dir . '/dependencies';

    debug( "Remove old directory if exists...\n" );
    windowsRemoveDir( $lTempDir );
    localMkdir( $lTempDir );
    localMkDir( $lTempDir . '/Francis' );

    debug( "Copy dependencies to temp folder..." );
    localRCopy( $lSrcDir,  $lTempDir );

    localZipFolder( $lTempDir, $lTempDir . '/../new-dependencies.zip' );

    debug( "Uploading compressed new server..." );
    sshConnect();
    sshFileCopy( $lTempDir . '/../new-dependencies.zip',  $remote_temp_dir . '/new-dependencies.zip' );

    debug( "Copy new server files to remote dest dir..." );
    sshExec( "cd $remote_temp_dir;unzip -o new-dependencies.zip -d $remote_dest_dir_dependencies" );

    debug( "Cleanup remote zip file..." );
    sshExec( "cd $remote_temp_dir;rm new-dependencies.zip;" );
}

task_deployDependenciesToTest();