Initial Drupal 11 with DDEV setup

This commit is contained in:
gluebox
2025-10-08 11:39:17 -04:00
commit 89ef74b305
25344 changed files with 2599172 additions and 0 deletions

View File

@ -0,0 +1,113 @@
<?php
namespace Consolidation\SiteProcess\Transport;
use Consolidation\SiteProcess\SiteProcess;
use Consolidation\SiteAlias\SiteAliasInterface;
use Consolidation\SiteProcess\Util\Shell;
use Consolidation\Config\ConfigInterface;
/**
* DockerComposeTransport knows how to wrap a command such that it executes
* on a Docker Compose service.
*/
class DockerComposeTransport implements TransportInterface
{
protected $tty;
protected $siteAlias;
protected $cd_remote;
public function __construct(SiteAliasInterface $siteAlias)
{
$this->siteAlias = $siteAlias;
}
/**
* @inheritdoc
*/
public function configure(SiteProcess $process)
{
$this->tty = $process->isTty();
}
/**
* @inheritdoc
*/
public function wrap($args)
{
$transport = $this->getTransport();
$transportOptions = $this->getTransportOptions();
$commandToExecute = $this->getCommandToExecute($args);
return array_merge(
$transport,
$transportOptions,
$commandToExecute
);
}
/**
* @inheritdoc
*/
public function addChdir($cd, $args)
{
$this->cd_remote = $cd;
return $args;
}
/**
* getTransport returns the transport along with the docker-compose
* project in case it is defined.
*/
protected function getTransport()
{
$version = $this->siteAlias->get('docker.compose.version', '1');
if ($version == 2) {
$transport = ['docker', 'compose'];
} else {
$transport = ['docker-compose'];
}
$project = $this->siteAlias->get('docker.project', '');
$options = $this->siteAlias->get('docker.compose.options', '');
$command = $this->siteAlias->get('docker.compose.command', 'exec');
if ($project && (strpos($options, '-p') === false || strpos($options, '--project') === false)) {
$transport = array_merge($transport, ['-p', $project]);
}
if ($options) {
$transport[] = Shell::preEscaped($options);
}
return array_merge($transport, [$command]);
}
/**
* getTransportOptions returns the transport options for the tranport
* mechanism itself
*/
protected function getTransportOptions()
{
$transportOptions = [
$this->siteAlias->get('docker.service', ''),
];
if ($options = $this->siteAlias->get('docker.exec.options', '')) {
array_unshift($transportOptions, Shell::preEscaped($options));
}
if (!$this->tty) {
array_unshift($transportOptions, '-T');
}
if ($this->cd_remote) {
$transportOptions = array_merge(['--workdir', $this->cd_remote], $transportOptions);
}
return array_filter($transportOptions);
}
/**
* getCommandToExecute processes the arguments for the command to
* be executed such that they are appropriate for the transport mechanism.
*
* Nothing to do for this transport.
*/
protected function getCommandToExecute($args)
{
return $args;
}
}

View File

@ -0,0 +1,84 @@
<?php
namespace Consolidation\SiteProcess\Transport;
use Consolidation\SiteProcess\SiteProcess;
use Consolidation\SiteAlias\SiteAliasInterface;
use Consolidation\SiteProcess\Util\Shell;
/**
* KubectlTransport knows how to wrap a command such that it runs in a container
* on Kubernetes via kubectl.
*/
class KubectlTransport implements TransportInterface
{
/** @var bool */
protected $tty;
/** @var \Consolidation\SiteAlias\SiteAliasInterface */
protected $siteAlias;
public function __construct(SiteAliasInterface $siteAlias)
{
$this->siteAlias = $siteAlias;
}
/**
* @inheritdoc
*/
public function configure(SiteProcess $process)
{
$this->tty = $process->isTty();
}
/**
* inheritdoc
*/
public function wrap($args)
{
# TODO: How/where do we complain if a required argument is not available?
$namespace = $this->siteAlias->get('kubectl.namespace');
$tty = $this->tty && $this->siteAlias->get('kubectl.tty', false) ? "true" : "false";
$interactive = $this->tty && $this->siteAlias->get('kubectl.interactive', false) ? "true" : "false";
$resource = $this->siteAlias->get('kubectl.resource');
$container = $this->siteAlias->get('kubectl.container');
$kubeconfig = $this->siteAlias->get('kubectl.kubeconfig');
$entrypoint = $this->siteAlias->get('kubectl.entrypoint');
$transport = [
'kubectl',
"--namespace=$namespace",
'exec',
"--tty=$tty",
"--stdin=$interactive",
$resource,
];
if ($container) {
$transport[] = "--container=$container";
}
if ($kubeconfig) {
$transport[] = "--kubeconfig=$kubeconfig";
}
$transport[] = "--";
if ($entrypoint) {
$transport = is_array($entrypoint) ? [...$transport, ...$entrypoint] : [...$transport, $entrypoint];
}
return array_merge($transport, $args);
}
/**
* @inheritdoc
*/
public function addChdir($cd_remote, $args)
{
return array_merge(
[
'cd',
$cd_remote,
Shell::op('&&'),
],
$args
);
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace Consolidation\SiteProcess\Transport;
use Consolidation\SiteProcess\SiteProcess;
/**
* LocalTransport just runs the command on the local system.
*/
class LocalTransport implements TransportInterface
{
/**
* @inheritdoc
*/
public function configure(SiteProcess $process)
{
$process->setWorkingDirectoryLocal($process->getWorkingDirectory());
}
/**
* @inheritdoc
*/
public function wrap($args)
{
return $args;
}
/**
* @inheritdoc
*/
public function addChdir($cd, $args)
{
return $args;
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace Consolidation\SiteProcess\Transport;
use Consolidation\SiteProcess\SiteProcess;
use Consolidation\SiteAlias\SiteAliasInterface;
use Consolidation\SiteProcess\Util\Shell;
/**
* SkprTransport knows how to wrap a command to run on a site hosted
* on the Skpr platform.
*/
class SkprTransport implements TransportInterface
{
/** @var \Consolidation\SiteAlias\SiteAliasInterface */
protected $siteAlias;
public function __construct(SiteAliasInterface $siteAlias)
{
$this->siteAlias = $siteAlias;
}
/**
* @inheritdoc
*/
public function configure(SiteProcess $process)
{
$path = $this->siteAlias->getDefault('skpr.path', getcwd());
if ($path) {
$process->chdirToSiteRoot($path);
}
}
/**
* inheritdoc
*/
public function wrap($args)
{
$environment = $this->siteAlias->get('skpr.env');
$transport = [
'skpr',
'exec',
"$environment",
];
$transport[] = "--";
return array_merge($transport, $args);
}
/**
* @inheritdoc
*/
public function addChdir($cd_remote, $args)
{
return array_merge(
[
'cd',
$cd_remote,
Shell::op('&&'),
],
$args
);
}
}

View File

@ -0,0 +1,92 @@
<?php
namespace Consolidation\SiteProcess\Transport;
use Consolidation\SiteProcess\SiteProcess;
use Consolidation\SiteProcess\Util\Escape;
use Consolidation\SiteAlias\SiteAliasInterface;
use Consolidation\SiteProcess\Util\Shell;
use Consolidation\Config\ConfigInterface;
/**
* SshTransport knows how to wrap a command such that it runs on a remote
* system via the ssh cli.
*/
class SshTransport implements TransportInterface
{
protected $tty;
protected $siteAlias;
public function __construct(SiteAliasInterface $siteAlias)
{
$this->siteAlias = $siteAlias;
}
/**
* @inheritdoc
*/
public function configure(SiteProcess $process)
{
$this->tty = $process->isTty();
}
/**
* inheritdoc
*/
public function wrap($args)
{
$transport = ['ssh'];
$transportOptions = $this->getTransportOptions();
$commandToExecute = $this->getCommandToExecute($args);
return array_merge(
$transport,
$transportOptions,
$commandToExecute
);
}
/**
* @inheritdoc
*/
public function addChdir($cd_remote, $args)
{
return array_merge(
[
'cd',
$cd_remote,
Shell::op('&&'),
],
$args
);
}
/**
* getTransportOptions returns the transport options for the tranport
* mechanism itself
*/
protected function getTransportOptions()
{
$transportOptions = [
Shell::preEscaped($this->siteAlias->get('ssh.options', '-o PasswordAuthentication=no')),
$this->siteAlias->remoteHostWithUser(),
];
if ($this->tty) {
array_unshift($transportOptions, '-t');
}
return $transportOptions;
}
/**
* getCommandToExecute processes the arguments for the command to
* be executed such that they are appropriate for the transport mechanism.
*/
protected function getCommandToExecute($args)
{
// Escape each argument for the target system and then join
$args = Escape::argsForSite($this->siteAlias, $args);
$commandToExecute = implode(' ', $args);
return [$commandToExecute];
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace Consolidation\SiteProcess\Transport;
use Consolidation\SiteProcess\SiteProcess;
/**
* Transports know how to wrap a command such that it runs on a remote system
* via some other command.
*
* There is always a transport for every factory, and visa-versa.
*
* @see Consolidation\SiteProcess\Factory\TransportFactoryInterface
*/
interface TransportInterface
{
/**
* Configure ourselves based on the settings of the process object
* (e.g. isTty()).
*
* @param \Consolidation\SiteProcess\SiteProcess $process
*/
public function configure(SiteProcess $process);
/**
* wrapWithTransport examines the provided site alias; if it is a local
* alias, then the provided arguments are returned unmodified. If the
* alias points at a remote system, though, then the arguments are
* escaped and wrapped in an appropriate ssh command.
*
* @param array $args arguments provided by caller.
* @return array command and arguments to execute.
*/
public function wrap($args);
/**
* addChdir adds an appropriate 'chdir' / 'cd' command for the transport.
*/
public function addChdir($cd, $args);
}

View File

@ -0,0 +1,85 @@
<?php
namespace Consolidation\SiteProcess\Transport;
use Consolidation\SiteProcess\SiteProcess;
use Consolidation\SiteProcess\Util\Escape;
use Consolidation\SiteAlias\SiteAliasInterface;
use Consolidation\SiteProcess\Util\Shell;
/**
* VagrantTransport knows how to wrap a command such that it runs on a remote
* system via the vagrant cli.
*/
class VagrantTransport implements TransportInterface
{
protected $tty;
protected $siteAlias;
public function __construct(SiteAliasInterface $siteAlias)
{
$this->siteAlias = $siteAlias;
}
/**
* @inheritdoc
*/
public function configure(SiteProcess $process)
{
$this->tty = $process->isTty();
}
/**
* inheritdoc
*/
public function wrap($args)
{
$transport = ['vagrant', 'ssh'];
$transportOptions = $this->getTransportOptions();
$commandToExecute = $this->getCommandToExecute($args);
return array_merge(
$transport,
$transportOptions,
['-c'],
$commandToExecute
);
}
/**
* @inheritdoc
*/
public function addChdir($cd_remote, $args)
{
return array_merge(
[
'cd',
$cd_remote,
Shell::op('&&'),
],
$args
);
}
/**
* getTransportOptions returns the transport options for the tranport
* mechanism itself
*/
protected function getTransportOptions()
{
return $this->tty ? ['-t'] : [];
}
/**
* getCommandToExecute processes the arguments for the command to
* be executed such that they are appropriate for the transport mechanism.
*/
protected function getCommandToExecute($args)
{
// Escape each argument for the target system and then join
$args = Escape::argsForSite($this->siteAlias, $args);
$commandToExecute = implode(' ', $args);
return [$commandToExecute];
}
}