Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When creating the sut, also create aliases @sut.dev and @sut.stage. #3065

Merged
merged 2 commits into from
Oct 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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