Skip to content

Commit

Permalink
When creating the sut, also create aliases @sut.dev and @sut.stage. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson authored Oct 14, 2017
1 parent 5f64eb5 commit 6b7c4a4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
16 changes: 11 additions & 5 deletions sut
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ $vendor = $sut . '/vendor';
$arguments = $GLOBALS['argv'];
// Shift off argv[0] which contains the name of this script.
array_shift($arguments);
// Add uri option
array_unshift($arguments, "--uri=dev");
// Add alias if not already specified
if (!empty($arguments) && ($arguments[0][0] != '@')) {
array_unshift($arguments, "@sut.dev");
}

// Make it easy to just call `/.sut si -y testing`
// Make it easy to just call `./sut si -y testing`, or `./sut @sut.stage -y testing`
if (in_array('si', $arguments) || in_array('site-install', $arguments)) {
$subdir = 'dev';
if (in_array('@sut.stage', $arguments)) {
$subdir = 'stage';
}
$db_url = getenv('UNISH_DB_URL') ?: 'mysql://root:@127.0.0.1';
$arguments[] = "--db-url=$db_url/unish_dev";
$arguments[] = '--sites-subdir=dev';
$arguments[] = "--db-url=$db_url/unish_$subdir";
$arguments[] = "--sites-subdir=$subdir";
}

/**
Expand Down
14 changes: 13 additions & 1 deletion unish.sut.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function unish_validate() {
*/
function unish_setup_sut($unish_sandbox) {
$working_dir = dirname($unish_sandbox) . DIRECTORY_SEPARATOR . 'build-drush-sut';
$target_dir = dirname($working_dir) . DIRECTORY_SEPARATOR . 'drush-sut';
drush_delete_dir($working_dir, TRUE);
$codebase = 'tests/resources/codebase';
drush_copy_dir($codebase, $working_dir);
Expand All @@ -41,6 +42,18 @@ function unish_setup_sut($unish_sandbox) {
}
}

$alias_contents = <<<EOT
dev:
root: $target_dir/web
uri: dev
stage:
root: $target_dir/web
uri: stage
EOT;
mkdir("$working_dir/drush");
mkdir("$working_dir/drush/site-aliases");
file_put_contents("$working_dir/drush/site-aliases/sut.alias.yml", $alias_contents);

$verbose = unishIsVerbose();
$cmd = "composer $verbose install --prefer-dist --no-progress --no-suggest --working-dir " . escapeshellarg($working_dir);
fwrite(STDERR, 'Executing: ' . $cmd . "\n");
Expand All @@ -54,7 +67,6 @@ function unish_setup_sut($unish_sandbox) {
}

// Move the sut into place
$target_dir = dirname($working_dir) . DIRECTORY_SEPARATOR . 'drush-sut';
drush_delete_dir($target_dir, TRUE);
rename($working_dir, $target_dir);

Expand Down

0 comments on commit 6b7c4a4

Please sign in to comment.