#!/usr/bin/env php
<?php /*! anamo/market-dummy-deployment v1.0.0 | © 2006-present Anamo Inc. MIT License | bitbucket.org/anamo/market-dummy-deployment */

error_reporting(E_ERROR | E_PARSE | E_USER_ERROR);

@include __DIR__.'/../../../../vendor/autoload.php';
@include __DIR__.'/../../../vendor/autoload.php';
@include __DIR__.'/../../vendor/autoload.php';
@include __DIR__.'/../vendor/autoload.php';
@include __DIR__.'/vendor/autoload.php';

if ('cli' !== PHP_SAPI) {
	trigger_error('This script runs only in CLI', E_USER_ERROR);
}

$options = getopt('', [
	'dist::',
	'scaffolding::',
	'cp::'
]); // $ php deploy [--dist=] [--scaffolding=] [--cp=]
$opt_dist = $options['dist'] ?? realpath(getcwd().'/dist-test/');
$opt_scaffolding = $options['scaffolding'] ?? realpath(__DIR__.'/../lib/webstore/');
$opt_cp = $options['cp'] ?? realpath(getcwd().'/cp/');

shell_exec(escapeshellcmd('rd /s /q '.escapeshellarg($opt_dist))); //TODO: LINUX

shell_exec(escapeshellcmd('xcopy '.escapeshellarg($opt_scaffolding).' '.escapeshellarg($opt_dist).' /E /K /I')); //TODO: LINUX

shell_exec(escapeshellcmd('xcopy '.escapeshellarg($opt_cp).' '.escapeshellarg($opt_dist).' /E /K /I /Y')); //TODO: LINUX

echo "done!\n";
