From e1fe9babc7d6360f03b0c52415b09b4c9718186b Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Thu, 3 Jul 2025 15:54:22 -0600 Subject: [PATCH 01/11] Base work and remove info from connection:info command. --- src/Models/Environment.php | 21 ++++++++++++++++++++- src/Models/Site.php | 27 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/Models/Environment.php b/src/Models/Environment.php index ff96d8113..e43b45e8b 100755 --- a/src/Models/Environment.php +++ b/src/Models/Environment.php @@ -258,7 +258,7 @@ public function connectionInfo() ); // Can only Use Git on dev/multidev environments - if (!in_array($this->id, ['test', 'live',])) { + if (!in_array($this->id, ['test', 'live',]) && !$this->isEvcsSite()) { $git_info = $this->gitConnectionInfo(); $info = array_merge( array_combine( @@ -271,6 +271,13 @@ public function connectionInfo() ); } + if (empty($info)) { + throw new TerminusException( + 'No connection information available for {env} environment for this site.', + ['env' => $this->id,] + ); + } + return $info; } @@ -281,6 +288,10 @@ public function connectionInfo() */ public function cacheserverConnectionInfo() { + if ($this->getSite()->isNodejs()) { + // No database for Node.js sites + return []; + } $env_vars = $this->fetchEnvironmentVars(); $port = $env_vars['CACHE_PORT'] ?? null; $password = $env_vars['CACHE_PASSWORD'] ?? null; @@ -327,6 +338,10 @@ public function fetchEnvironmentVars(): array */ public function databaseConnectionInfo() { + if ($this->getSite()->isNodejs()) { + // No database for Node.js sites + return []; + } $env_vars = $this->fetchEnvironmentVars(); $domain = "dbserver.{$this->id}.{$this->getSite()->id}.drush.in"; $port = $env_vars['DB_PORT'] ?? null; @@ -965,6 +980,10 @@ public function setHttpsCertificate($certificate = []) */ public function sftpConnectionInfo() { + if ($this->isEvcsSite()) { + // No SFTP for EVCS sites + return []; + } $site = $this->getSite(); if (!empty($ssh_host = $this->getConfig()->get('ssh_host'))) { $username = "appserver.{$this->id}.{$site->id}"; diff --git a/src/Models/Site.php b/src/Models/Site.php index 6843f0045..f6546cbab 100755 --- a/src/Models/Site.php +++ b/src/Models/Site.php @@ -589,4 +589,31 @@ public function getWorkflowLogs(): WorkflowLogsCollection ->addArgument($this); return $this->getContainer()->get($nickname)->fetch(); } + + /** + * @return bool + * @throws TerminusException + */ + public function isEvcs(): bool + { + // We are using a variable that we retrieve at environment level, + // so we need to retrieve dev environment first. + $env = $this->getEnvironments()->get('dev'); + if (empty($env)) { + throw new TerminusException( + 'Site {site} does not have a dev environment.', + ['site' => $this->getName()] + ); + } + return $env->isEvcsSite(); + } + + /** + * @return bool + * @throws TerminusException + */ + public function isNodejs(): bool + { + return $this->get('framework') === 'nodejs'; + } } From 2eeddf808c8ebd05870eb0f47dfc0f9b2643b6f9 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Thu, 3 Jul 2025 16:00:07 -0600 Subject: [PATCH 02/11] Modify EnvInfo command. --- src/Commands/Env/InfoCommand.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Commands/Env/InfoCommand.php b/src/Commands/Env/InfoCommand.php index 8848b34fd..bd9ee0c08 100644 --- a/src/Commands/Env/InfoCommand.php +++ b/src/Commands/Env/InfoCommand.php @@ -7,6 +7,7 @@ use Pantheon\Terminus\Commands\StructuredListTrait; use Pantheon\Terminus\Site\SiteAwareInterface; use Pantheon\Terminus\Site\SiteAwareTrait; +use Pantheon\Terminus\Models\TerminusModel; /** * Class InfoCommand. @@ -49,4 +50,24 @@ public function info($site_env) return $this->getPropertyList($this->getEnv($site_env)); } + + /** + * @param TerminusModel $model A model with data to extract + * @return PropertyList A PropertyList-type object with applied filters + */ + public function getPropertyList(TerminusModel $model) + { + $properties = $model->serialize(); + if ($model->isEvcsSite()) { + // Remove properties that are not applicable to EVCS sites + unset($properties['connection_mode']); + } + if ($model->getSite()->isNodejs()) { + // Remove properties that are not applicable to Node.js sites + unset($properties['drush_version']); + unset($properties['php_version']); + unset($properties['locked']); + } + return new PropertyList($properties); + } } From e541574105d9c64775a3ecd0ca45adca4d737882 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Thu, 3 Jul 2025 16:04:08 -0600 Subject: [PATCH 03/11] Modify localClone command. --- src/Commands/Local/CloneCommand.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Commands/Local/CloneCommand.php b/src/Commands/Local/CloneCommand.php index e116f4ff0..4cc1809bd 100644 --- a/src/Commands/Local/CloneCommand.php +++ b/src/Commands/Local/CloneCommand.php @@ -9,6 +9,7 @@ use Pantheon\Terminus\Site\SiteAwareInterface; use Pantheon\Terminus\Site\SiteAwareTrait; use Robo\Contract\ConfigAwareInterface; +use Pantheon\Terminus\Exceptions\TerminusException; /** * Class CloneCommand. @@ -47,6 +48,13 @@ public function clone( array $options = ['site_dir' => null, 'override' => null, 'branch' => 'master'] ): string { $site = $this->getSiteById($site_id); + + if ($site->isEvcs()) { + throw new TerminusException( + 'This command is not supported for sites in external version control. Please clone from your version control system.' + ); + } + $env = $site->getEnvironments()->get('dev'); $gitUrl = $env->connectionInfo()['git_url'] ?? null; From 3eb8007d95569932581b07a4ede094814d189133 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Thu, 3 Jul 2025 16:04:19 -0600 Subject: [PATCH 04/11] Modify localCommitAndPush command. --- src/Commands/Local/CommitAndPushCommand.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Commands/Local/CommitAndPushCommand.php b/src/Commands/Local/CommitAndPushCommand.php index 4b910e76b..074bef43d 100644 --- a/src/Commands/Local/CommitAndPushCommand.php +++ b/src/Commands/Local/CommitAndPushCommand.php @@ -54,6 +54,13 @@ public function commitAndPushCommand($site): string ); } } + + if ($siteData->isEvcs()) { + throw new TerminusException( + 'This command is not supported for sites in external version control. Please clone from your version control system.' + ); + } + $git = new \CzProject\GitPhp\Git(); $repo = $git->open($siteData->getLocalCopyDir()); $repo->addAllChanges(); From c1f634f8f8bb96666fdd545cb89b60b9d8df1349 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Thu, 3 Jul 2025 16:05:50 -0600 Subject: [PATCH 05/11] Modify multidevCreate command. --- src/Commands/Multidev/CreateCommand.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Commands/Multidev/CreateCommand.php b/src/Commands/Multidev/CreateCommand.php index ae3c3c61a..23e8c1880 100644 --- a/src/Commands/Multidev/CreateCommand.php +++ b/src/Commands/Multidev/CreateCommand.php @@ -56,6 +56,13 @@ public function create( ) { $this->requireSiteIsNotFrozen($site_env); $site = $this->getSiteById($site_env); + + if ($site->isEvcs()) { + throw new \Pantheon\Terminus\Exceptions\TerminusException( + 'Multidev environments should be created from your external repository for this site.' + ); + } + $env = $this->getEnv($site_env); if (strlen($multidev) > 11) { From 222cd929ff0167c3b3b20405c4b78df81a863a8f Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Thu, 3 Jul 2025 16:08:23 -0600 Subject: [PATCH 06/11] Modify multidevDelete command. --- src/Commands/Multidev/DeleteCommand.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Commands/Multidev/DeleteCommand.php b/src/Commands/Multidev/DeleteCommand.php index 9c67d7194..432dd62aa 100644 --- a/src/Commands/Multidev/DeleteCommand.php +++ b/src/Commands/Multidev/DeleteCommand.php @@ -48,6 +48,14 @@ public function deleteMultidev($site_env, $options = ['delete-branch' => false,] return; } + if ($options['delete-branch'] && $env->isEvcsSite()) { + $this->log()->warning( + 'Cannot delete the branch for {env} because it is an external version control site.', + ['env' => $env->getName()] + ); + $options['delete-branch'] = false; + } + $workflow = $env->delete(['delete_branch' => $options['delete-branch'] ?? false]); $this->processWorkflow($workflow); $this->log()->notice( From d0dfd33af602ff369cd16c56a0cd3b12b27cb28b Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Thu, 3 Jul 2025 16:10:01 -0600 Subject: [PATCH 07/11] Modify lockInfo command. --- src/Commands/Lock/InfoCommand.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Commands/Lock/InfoCommand.php b/src/Commands/Lock/InfoCommand.php index 53cc3ad53..68d62e361 100644 --- a/src/Commands/Lock/InfoCommand.php +++ b/src/Commands/Lock/InfoCommand.php @@ -7,6 +7,7 @@ use Pantheon\Terminus\Commands\StructuredListTrait; use Pantheon\Terminus\Site\SiteAwareInterface; use Pantheon\Terminus\Site\SiteAwareTrait; +use Pantheon\Terminus\Exceptions\TerminusException; /** * Class InfoCommand. @@ -40,6 +41,12 @@ class InfoCommand extends TerminusCommand implements SiteAwareInterface */ public function info($site_env) { - return $this->getPropertyList($this->getEnv($site_env)->getLock()); + $env = $this->getEnv($site_env); + if ($env->getSite()->isNodejs()) { + throw new TerminusException( + 'Locking is not supported for Node.js sites.' + ); + } + return $this->getPropertyList($env->getLock()); } } From 21e8e4d3f877707ab615c7f40310f630bf29ba52 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Thu, 3 Jul 2025 16:13:36 -0600 Subject: [PATCH 08/11] Modify sshBase commands. --- src/Commands/Remote/SSHBaseCommand.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Commands/Remote/SSHBaseCommand.php b/src/Commands/Remote/SSHBaseCommand.php index e5b6e8715..af9b58c35 100755 --- a/src/Commands/Remote/SSHBaseCommand.php +++ b/src/Commands/Remote/SSHBaseCommand.php @@ -51,6 +51,12 @@ protected function prepareEnvironment($site_env) { $this->site = $this->getSiteById($site_env); $this->environment = $this->getEnv($site_env); + + if ($this->site->isNodejs()) { + throw new TerminusProcessException( + 'This command is not supported for Node.js sites.' + ); + } } /** From 67400820ba512d0886adc444305d003d6d9a5f35 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Thu, 3 Jul 2025 16:17:14 -0600 Subject: [PATCH 09/11] Modify envWake command. --- src/Commands/Env/WakeCommand.php | 5 +++++ src/Models/Environment.php | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Commands/Env/WakeCommand.php b/src/Commands/Env/WakeCommand.php index b3b1ab256..591597844 100644 --- a/src/Commands/Env/WakeCommand.php +++ b/src/Commands/Env/WakeCommand.php @@ -51,6 +51,11 @@ public function wake($site_env, $options = [ ]); throw new TerminusException('Could not reach {target}', $wakeStatus); } + if ($env->getSite()->isNodejs()) { + // We do not expect a 'styx' header for Node.js sites so if we make it here, we assume success. + $this->log()->notice('OK >> {target} responded', $wakeStatus); + return; + } if (empty($wakeStatus['styx'])) { throw new TerminusException('Pantheon headers missing, which is not quite right.'); } diff --git a/src/Models/Environment.php b/src/Models/Environment.php index e43b45e8b..d21a5f1ca 100755 --- a/src/Models/Environment.php +++ b/src/Models/Environment.php @@ -1040,12 +1040,18 @@ function ($domain) { $success = false; $lastError = null; + $wakeUrl = "https://{$domain->id}/pantheon_healthcheck"; + if ($this->getSite()->isNodejs()) { + // For Node.js sites, we use the root path for the health check. + $wakeUrl = "https://{$domain->id}"; + } + while ($attempt < $maxRetries && !$success) { $lastError = null; $attempt++; try { $response = $this->request()->request( - "https://{$domain->id}/pantheon_healthcheck" + $wakeUrl, ); $success = ($response['status_code'] === 200); if ($success) { From accacafa8acb15916b1e38826d79143c9d7c891c Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Mon, 7 Jul 2025 07:44:40 -0600 Subject: [PATCH 10/11] Fix linting. --- src/Commands/Local/CloneCommand.php | 2 +- src/Commands/Local/CommitAndPushCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Local/CloneCommand.php b/src/Commands/Local/CloneCommand.php index 4cc1809bd..afd5b5a1e 100644 --- a/src/Commands/Local/CloneCommand.php +++ b/src/Commands/Local/CloneCommand.php @@ -51,7 +51,7 @@ public function clone( if ($site->isEvcs()) { throw new TerminusException( - 'This command is not supported for sites in external version control. Please clone from your version control system.' + 'This command is not supported for sites with external vcs. Please clone from your external repository.' ); } diff --git a/src/Commands/Local/CommitAndPushCommand.php b/src/Commands/Local/CommitAndPushCommand.php index 074bef43d..ef9a92586 100644 --- a/src/Commands/Local/CommitAndPushCommand.php +++ b/src/Commands/Local/CommitAndPushCommand.php @@ -57,7 +57,7 @@ public function commitAndPushCommand($site): string if ($siteData->isEvcs()) { throw new TerminusException( - 'This command is not supported for sites in external version control. Please clone from your version control system.' + 'This command is not supported for sites with external vcs. Please clone from your external repository.' ); } From 28c2b554abcfb865eb15d755016d1b88345986c5 Mon Sep 17 00:00:00 2001 From: Kevin Porras Date: Tue, 8 Jul 2025 12:55:53 -0600 Subject: [PATCH 11/11] Update src/Commands/Local/CommitAndPushCommand.php --- src/Commands/Local/CommitAndPushCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Local/CommitAndPushCommand.php b/src/Commands/Local/CommitAndPushCommand.php index ef9a92586..9dc122933 100644 --- a/src/Commands/Local/CommitAndPushCommand.php +++ b/src/Commands/Local/CommitAndPushCommand.php @@ -57,7 +57,7 @@ public function commitAndPushCommand($site): string if ($siteData->isEvcs()) { throw new TerminusException( - 'This command is not supported for sites with external vcs. Please clone from your external repository.' + 'This command is not supported for sites with external vcs. Please push to your external repository.' ); }