|
|
|
@ -19,52 +19,38 @@ task('composer_reset', function()
|
|
|
|
|
ensure_rm("$GAME_ROOT/composer/composer.last");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
task('composer', function($args) {
|
|
|
|
|
global $GAME_ROOT;
|
|
|
|
|
|
|
|
|
|
$composer_dir = $GAME_ROOT . '/composer/';
|
|
|
|
|
|
|
|
|
|
$files = glob($composer_dir . '/composer-*.phar');
|
|
|
|
|
$PHAR = basename($files[0]);
|
|
|
|
|
|
|
|
|
|
$cmd = "cd $composer_dir && ";
|
|
|
|
|
if(PHP_OS_FAMILY === 'Darwin')
|
|
|
|
|
{
|
|
|
|
|
$cmd .= "DYLD_LIBRARY_PATH='" . getenv("DYLD_LIBRARY_PATH") . "' " .
|
|
|
|
|
"PHP_INI_SCAN_DIR='" . getenv("PHP_INI_SCAN_DIR") . "' ";
|
|
|
|
|
$cmd .= PHP_BINARY . " -c '". getenv("PHP_INI") . "' ";
|
|
|
|
|
$ext_dir = realpath(ini_get('extension_dir'));
|
|
|
|
|
$cmd .= " -d extension_dir='$ext_dir' ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$cmd .= PHP_BINARY . ' ';
|
|
|
|
|
|
|
|
|
|
$cmd .= "$PHAR " . implode(' ', $args);
|
|
|
|
|
|
|
|
|
|
shell($cmd);
|
|
|
|
|
task('composer', function(array $args) {
|
|
|
|
|
composer_run($args);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
task('composer_vendor_push', function($args) {
|
|
|
|
|
task('composer_vendor_push', function(array $args) {
|
|
|
|
|
|
|
|
|
|
$usage = "Usage: ./gamectl composer_vendor_push <path/to/repo> <commit message> [^[^[^]]]\n";
|
|
|
|
|
|
|
|
|
|
$dry_run = arg_opt($args, '--dry-run', false);
|
|
|
|
|
arg_opt_check_no_trailing($args);
|
|
|
|
|
|
|
|
|
|
if(count($args) < 2)
|
|
|
|
|
throw new Exception($usage);
|
|
|
|
|
|
|
|
|
|
$force_new_tag = '';
|
|
|
|
|
$up_mode = 1;
|
|
|
|
|
if(count($args) > 2)
|
|
|
|
|
{
|
|
|
|
|
if($args[2] === '^')
|
|
|
|
|
$tmp_arg = array_pop($args);
|
|
|
|
|
|
|
|
|
|
if($tmp_arg === '^')
|
|
|
|
|
$up_mode = 1;
|
|
|
|
|
else if($args[2] === '^^')
|
|
|
|
|
else if($tmp_arg === '^^')
|
|
|
|
|
$up_mode = 2;
|
|
|
|
|
else if($args[2] === '^^^')
|
|
|
|
|
else if($tmp_arg === '^^^')
|
|
|
|
|
$up_mode = 3;
|
|
|
|
|
else
|
|
|
|
|
throw new Exception("Invalid up mode: {$args[2]} (supported ^, ^^ and ^^^)");
|
|
|
|
|
else
|
|
|
|
|
$force_new_tag = $tmp_arg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$relpath = $args[0];
|
|
|
|
|
$commit_msg = $args[1];
|
|
|
|
|
$relpath = array_shift($args);
|
|
|
|
|
$commit_msg = array_shift($args);
|
|
|
|
|
$repo = realpath("composer" .DIRECTORY_SEPARATOR. "vendor" .DIRECTORY_SEPARATOR. $relpath) ?: realpath($relpath);
|
|
|
|
|
|
|
|
|
|
if(!$repo)
|
|
|
|
@ -72,7 +58,7 @@ task('composer_vendor_push', function($args) {
|
|
|
|
|
|
|
|
|
|
echo "Detected folder: '$repo'\n";
|
|
|
|
|
|
|
|
|
|
if(!git_is_repo($repo))
|
|
|
|
|
if(!git_is_repo($repo, true))
|
|
|
|
|
throw new Exception("'$repo' is not a valid Git repo!\n");
|
|
|
|
|
|
|
|
|
|
echo "It's a valid Git repo\n";
|
|
|
|
@ -84,13 +70,63 @@ task('composer_vendor_push', function($args) {
|
|
|
|
|
echo "========\n";
|
|
|
|
|
|
|
|
|
|
$last_remote_tag = get_git_last_remote_tag($repo);
|
|
|
|
|
if($last_remote_tag === false)
|
|
|
|
|
throw new Exception("Could not retrieve last remote tag");
|
|
|
|
|
echo "The last remote Git tag: $last_remote_tag\n";
|
|
|
|
|
$last_remote_version = GitVersion::parse($last_remote_tag);
|
|
|
|
|
|
|
|
|
|
$last_remote_version->bump($up_mode);
|
|
|
|
|
echo "New version expected to be: {$last_remote_version->encode()}\n";
|
|
|
|
|
if(empty($force_new_tag))
|
|
|
|
|
{
|
|
|
|
|
$last_remote_version = GitVersion::parse($last_remote_tag);
|
|
|
|
|
$last_remote_version->bump($up_mode);
|
|
|
|
|
$new_tag = $last_remote_version->encode();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$new_tag = $force_new_tag;
|
|
|
|
|
|
|
|
|
|
are_you_sure();
|
|
|
|
|
echo "Commit message: {$commit_msg}\n";
|
|
|
|
|
echo "New version expected to be: {$new_tag}\n";
|
|
|
|
|
|
|
|
|
|
if($dry_run === false)
|
|
|
|
|
are_you_sure();
|
|
|
|
|
|
|
|
|
|
$is_upm = file_exists("$repo/package.json");
|
|
|
|
|
if($is_upm)
|
|
|
|
|
{
|
|
|
|
|
echo "This looks like an UPM package, let's update the package.json?\n";
|
|
|
|
|
if(are_you_sure_ask())
|
|
|
|
|
{
|
|
|
|
|
if(!function_exists('taskman\upm_get_package_info'))
|
|
|
|
|
{
|
|
|
|
|
echo "Can't proceed, composer 'bit/taskman_upm' package is missing\n";
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$upm_info = upm_get_package_info($repo);
|
|
|
|
|
if(!isset($upm_info['name']))
|
|
|
|
|
throw new Exception("'name' is not present in package.json");
|
|
|
|
|
if(!isset($upm_info['version']))
|
|
|
|
|
throw new Exception("'version' is not present in package.json");
|
|
|
|
|
$upm_version = $upm_info['version'];
|
|
|
|
|
|
|
|
|
|
echo "Current package.json version is: {$upm_version}\n";
|
|
|
|
|
$upm_new_version = ltrim($new_tag, 'v');
|
|
|
|
|
echo "New package.json expected to be: {$upm_new_version}\n";
|
|
|
|
|
|
|
|
|
|
if($dry_run === false)
|
|
|
|
|
{
|
|
|
|
|
are_you_sure();
|
|
|
|
|
|
|
|
|
|
$upm_info['version'] = $upm_new_version;
|
|
|
|
|
upm_set_package_info($repo, $upm_info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($dry_run !== false)
|
|
|
|
|
{
|
|
|
|
|
echo "Dry run is done.\n";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
git_do($repo, 'add .');
|
|
|
|
|
git_do($repo, "commit -am \"$commit_msg\"", $commit_output);
|
|
|
|
@ -116,9 +152,14 @@ task('composer_vendor_push', function($args) {
|
|
|
|
|
$last_tag = _get_last_version_tag($tags);
|
|
|
|
|
echo "Last tag: $last_tag\n";
|
|
|
|
|
|
|
|
|
|
$last_version = GitVersion::parse($last_tag);
|
|
|
|
|
$last_version->bump($up_mode);
|
|
|
|
|
$new_tag = $last_version->encode();
|
|
|
|
|
if(empty($force_new_tag))
|
|
|
|
|
{
|
|
|
|
|
$last_version = GitVersion::parse($last_tag);
|
|
|
|
|
$last_version->bump($up_mode);
|
|
|
|
|
$new_tag = $last_version->encode();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$new_tag = $force_new_tag;
|
|
|
|
|
|
|
|
|
|
echo "New tag: $new_tag\n";
|
|
|
|
|
|
|
|
|
@ -132,7 +173,13 @@ task('composer_vendor_push', function($args) {
|
|
|
|
|
git_do($repo, 'push --tags');
|
|
|
|
|
|
|
|
|
|
git_do($repo, 'rev-parse HEAD', $output);
|
|
|
|
|
composer_try_update_lock_entry($relpath, trim($output[0]), $new_tag);
|
|
|
|
|
if(composer_try_update_lock_entry($relpath, trim($output[0]), $new_tag))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
echo "composer.lock file was not updated, run 'composer update $relpath'?\n";
|
|
|
|
|
are_you_sure();
|
|
|
|
|
|
|
|
|
|
composer_run(['update', $relpath]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
task('composer_vendor_status', function(array $args) {
|
|
|
|
@ -160,7 +207,11 @@ task('composer_vendor_status', function(array $args) {
|
|
|
|
|
if($status)
|
|
|
|
|
{
|
|
|
|
|
$package = str_replace(normalize_path("$GAME_ROOT/composer/vendor/"), '', normalize_path($item));
|
|
|
|
|
echo "==== Vendor package '$package' changes:\n";
|
|
|
|
|
$last_remote_tag = get_git_last_remote_tag($item);
|
|
|
|
|
echo "==== Vendor package '$package'[$last_remote_tag] changes";
|
|
|
|
|
if(is_file($item . '/package.json'))
|
|
|
|
|
echo " (UPM package?)";
|
|
|
|
|
echo ":\n";
|
|
|
|
|
echo implode("\n", $status) . "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -210,12 +261,19 @@ function composer_try_update_lock_entry($package, $rev, $new_tag)
|
|
|
|
|
return $changed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//NOTE: COMPOSER_FORCE_UPDATE = true will make composer to update packages and
|
|
|
|
|
// a lock file
|
|
|
|
|
// COMPOSER_FORCE_UPDATE = false will make composer install dependencies
|
|
|
|
|
// listed in a lock file in case if it's present
|
|
|
|
|
function composer_update($COMPOSER_FORCE_UPDATE = false)
|
|
|
|
|
function composer_run(array $args)
|
|
|
|
|
{
|
|
|
|
|
global $GAME_ROOT;
|
|
|
|
|
putenv('COMPOSER_RUN='.implode(' ', $args));
|
|
|
|
|
include("$GAME_ROOT/composer/update.php");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//NOTE: keeping this function for BC
|
|
|
|
|
function composer_update($update = false)
|
|
|
|
|
{
|
|
|
|
|
if($update)
|
|
|
|
|
composer_run(['update']);
|
|
|
|
|
else
|
|
|
|
|
composer_run(['install']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|