Remove SpinnerFilePath to fix for Unix (Windows will need work)
This commit is contained in:
parent
f3fb68af39
commit
3fe612cb36
9 changed files with 38 additions and 55 deletions
0
bin/spinner
Normal file → Executable file
0
bin/spinner
Normal file → Executable file
|
@ -6,7 +6,6 @@ namespace Loom\Spinner\Classes\Config;
|
|||
|
||||
use Loom\Spinner\Classes\Collection\FilePathCollection;
|
||||
use Loom\Spinner\Classes\File\Interface\DataPathInterface;
|
||||
use Loom\Spinner\Classes\File\SpinnerFilePath;
|
||||
use Loom\Utility\FilePath\FilePath;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
@ -152,19 +151,19 @@ class Config
|
|||
private function setFilePaths(): void
|
||||
{
|
||||
$this->filePaths = new FilePathCollection([
|
||||
'config' => new SpinnerFilePath('config'),
|
||||
'defaultSpinnerConfig' => new SpinnerFilePath('config/spinner.yaml'),
|
||||
'envTemplate' => new SpinnerFilePath('config/.template.env'),
|
||||
'data' => new SpinnerFilePath('data'),
|
||||
'phpYamlTemplate' => new SpinnerFilePath('config/php.yaml'),
|
||||
'nginxYamlTemplate' => new SpinnerFilePath('config/nginx.yaml'),
|
||||
'phpFpmDataDirectory' => new SpinnerFilePath('config/php-fpm'),
|
||||
DataPathInterface::CONFIG_PHP_FPM_DOCKERFILE => new SpinnerFilePath(DataPathInterface::CONFIG_PHP_FPM_DOCKERFILE),
|
||||
DataPathInterface::CONFIG_NGINX_DOCKERFILE => new SpinnerFilePath(DataPathInterface::CONFIG_NGINX_DOCKERFILE),
|
||||
'nodeDockerfileTemplate' => new SpinnerFilePath('config/php-fpm/Node.Dockerfile'),
|
||||
'xdebugIniTemplate' => new SpinnerFilePath('config/php-fpm/xdebug.ini'),
|
||||
'opcacheIniTemplate' => new SpinnerFilePath('config/php-fpm/opcache.ini'),
|
||||
'xdebugDockerfileTemplate' => new SpinnerFilePath('config/php-fpm/XDebug.Dockerfile'),
|
||||
'config' => new FilePath('config'),
|
||||
'defaultSpinnerConfig' => new FilePath('config/spinner.yaml'),
|
||||
'envTemplate' => new FilePath('config/.template.env'),
|
||||
'data' => new FilePath('data'),
|
||||
'phpYamlTemplate' => new FilePath('config/php.yaml'),
|
||||
'nginxYamlTemplate' => new FilePath('config/nginx.yaml'),
|
||||
'phpFpmDataDirectory' => new FilePath('config/php-fpm'),
|
||||
DataPathInterface::CONFIG_PHP_FPM_DOCKERFILE => new FilePath(DataPathInterface::CONFIG_PHP_FPM_DOCKERFILE),
|
||||
DataPathInterface::CONFIG_NGINX_DOCKERFILE => new FilePath(DataPathInterface::CONFIG_NGINX_DOCKERFILE),
|
||||
'nodeDockerfileTemplate' => new FilePath('config/php-fpm/Node.Dockerfile'),
|
||||
'xdebugIniTemplate' => new FilePath('config/php-fpm/xdebug.ini'),
|
||||
'opcacheIniTemplate' => new FilePath('config/php-fpm/opcache.ini'),
|
||||
'xdebugDockerfileTemplate' => new FilePath('config/php-fpm/XDebug.Dockerfile'),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -6,13 +6,14 @@ namespace Loom\Spinner\Classes\File;
|
|||
|
||||
use Loom\Spinner\Classes\Config\Config;
|
||||
use Loom\Spinner\Classes\File\Interface\FileBuilderInterface;
|
||||
use Loom\Utility\FilePath\FilePath;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
abstract class AbstractFileBuilder implements FileBuilderInterface
|
||||
{
|
||||
protected string $content;
|
||||
|
||||
public function __construct(protected SpinnerFilePath $path, protected Config $config)
|
||||
public function __construct(protected FilePath $path, protected Config $config)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Loom\Spinner\Classes\File;
|
||||
|
||||
use Loom\Spinner\Classes\Config\Config;
|
||||
use Loom\Utility\FilePath\FilePath;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
class DockerComposeFileBuilder extends AbstractFileBuilder
|
||||
|
@ -16,7 +17,7 @@ class DockerComposeFileBuilder extends AbstractFileBuilder
|
|||
{
|
||||
$projectDockerCompose = $config->getFilePaths()->get('projectDockerCompose');
|
||||
|
||||
if (!$projectDockerCompose instanceof SpinnerFilePath) {
|
||||
if (!$projectDockerCompose instanceof FilePath) {
|
||||
throw new \Exception('Project Docker Compose file path not found.');
|
||||
}
|
||||
|
||||
|
@ -54,14 +55,14 @@ class DockerComposeFileBuilder extends AbstractFileBuilder
|
|||
);
|
||||
$this->content = str_replace(
|
||||
'./nginx/conf.d',
|
||||
(new SpinnerFilePath('config/nginx/conf.d'))->getAbsolutePath(),
|
||||
(new FilePath('config/nginx/conf.d'))->getAbsolutePath(),
|
||||
$this->content
|
||||
);
|
||||
}
|
||||
|
||||
private function addSqliteDatabaseConfig(): void
|
||||
{
|
||||
$sqlLiteConfig = file_get_contents((new SpinnerFilePath('config/sqlite.yaml'))->getAbsolutePath());
|
||||
$sqlLiteConfig = file_get_contents((new FilePath('config/sqlite.yaml'))->getAbsolutePath());
|
||||
$sqlLiteConfig = str_replace('volumes:', '', $sqlLiteConfig);
|
||||
$this->content .= $sqlLiteConfig;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Loom\Spinner\Classes\File;
|
|||
|
||||
use Loom\Spinner\Classes\Config\Config;
|
||||
use Loom\Spinner\Classes\File\Interface\DataPathInterface;
|
||||
use Loom\Utility\FilePath\FilePath;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
class NginxDockerFileBuilder extends AbstractFileBuilder
|
||||
|
@ -17,7 +18,7 @@ class NginxDockerFileBuilder extends AbstractFileBuilder
|
|||
{
|
||||
$projectNginxDockerfilePath = $config->getFilePath('projectNginxDockerfile');
|
||||
|
||||
if (!$projectNginxDockerfilePath instanceof SpinnerFilePath) {
|
||||
if (!$projectNginxDockerfilePath instanceof FilePath) {
|
||||
throw new \Exception('Project PHP-FPM Dockerfile not found');
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Loom\Spinner\Classes\File;
|
|||
|
||||
use Loom\Spinner\Classes\Config\Config;
|
||||
use Loom\Spinner\Classes\File\Interface\DataPathInterface;
|
||||
use Loom\Utility\FilePath\FilePath;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
class PHPDockerFileBuilder extends AbstractFileBuilder
|
||||
|
@ -17,7 +18,7 @@ class PHPDockerFileBuilder extends AbstractFileBuilder
|
|||
{
|
||||
$projectPhpFpmDockerfile = $config->getFilePath('projectPhpFpmDockerfile');
|
||||
|
||||
if (!$projectPhpFpmDockerfile instanceof SpinnerFilePath) {
|
||||
if (!$projectPhpFpmDockerfile instanceof FilePath) {
|
||||
throw new \Exception('Project PHP-FPM Dockerfile not found');
|
||||
}
|
||||
|
||||
|
@ -34,13 +35,13 @@ class PHPDockerFileBuilder extends AbstractFileBuilder
|
|||
$this->content = str_replace('${PHP_VERSION}', (string) $this->config->getPhpVersion($input), $this->content);
|
||||
|
||||
file_put_contents(
|
||||
(new SpinnerFilePath(sprintf('data/environments/%s/php-fpm/opcache.ini', $input->getArgument('name'))))->getProvidedPath(),
|
||||
(new FilePath(sprintf('data/environments/%s/php-fpm/opcache.ini', $input->getArgument('name'))))->getProvidedPath(),
|
||||
file_get_contents($this->config->getFilePaths()->get('opcacheIniTemplate')->getAbsolutePath())
|
||||
);
|
||||
|
||||
if ($this->config->isDatabaseEnabled($input) && in_array($this->config->getDatabaseDriver($input), ['sqlite3', 'sqlite'])) {
|
||||
$this->addNewLine();
|
||||
$this->content .= file_get_contents((new SpinnerFilePath('config/php-fpm/Sqlite.Dockerfile'))->getAbsolutePath());
|
||||
$this->content .= file_get_contents((new FilePath('config/php-fpm/Sqlite.Dockerfile'))->getAbsolutePath());
|
||||
}
|
||||
|
||||
if ($this->config->isNodeEnabled($input)) {
|
||||
|
@ -53,7 +54,7 @@ class PHPDockerFileBuilder extends AbstractFileBuilder
|
|||
$this->addNewLine();
|
||||
$this->content .= file_get_contents($this->config->getFilePaths()->get('xdebugDockerfileTemplate')->getAbsolutePath());
|
||||
file_put_contents(
|
||||
(new SpinnerFilePath(sprintf('data/environments/%s/php-fpm/xdebug.ini', $input->getArgument('name'))))->getProvidedPath(),
|
||||
(new FilePath(sprintf('data/environments/%s/php-fpm/xdebug.ini', $input->getArgument('name'))))->getProvidedPath(),
|
||||
file_get_contents($this->config->getFilePaths()->get('xdebugIniTemplate')->getAbsolutePath())
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Loom\Spinner\Classes\File;
|
||||
|
||||
use Loom\Utility\FilePath\FilePath;
|
||||
|
||||
class SpinnerFilePath extends FilePath
|
||||
{
|
||||
public function __construct(string $path)
|
||||
{
|
||||
parent::__construct(sprintf('%s%s%s', dirname(__DIR__, 3), DIRECTORY_SEPARATOR, $path));
|
||||
}
|
||||
|
||||
public function getProvidedPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ namespace Loom\Spinner\Command;
|
|||
|
||||
use Loom\Spinner\Classes\Collection\FilePathCollection;
|
||||
use Loom\Spinner\Classes\Config\Config;
|
||||
use Loom\Spinner\Classes\File\SpinnerFilePath;
|
||||
use Loom\Spinner\Classes\OS\System;
|
||||
use Loom\Spinner\Command\Interface\ConsoleCommandInterface;
|
||||
use Loom\Utility\FilePath\FilePath;
|
||||
|
@ -54,7 +53,7 @@ class AbstractSpinnerCommand extends Command implements ConsoleCommandInterface
|
|||
protected function buildDockerComposeCommand(string $command, bool $daemon = true): string
|
||||
{
|
||||
return sprintf(
|
||||
'cd %s && docker-compose --env-file=%s %s%s',
|
||||
'cd %s && docker compose --env-file=%s %s%s',
|
||||
$this->config->getFilePaths()->get('projectData')->getAbsolutePath(),
|
||||
$this->config->getFilePaths()->get('projectEnv')->getAbsolutePath(),
|
||||
$command,
|
||||
|
@ -81,25 +80,26 @@ class AbstractSpinnerCommand extends Command implements ConsoleCommandInterface
|
|||
|
||||
private function validateNameArgument(InputInterface $input): void
|
||||
{
|
||||
var_dump('Validating name argument');
|
||||
if ($input->hasArgument('name')) {
|
||||
$this->config->addFilePath(
|
||||
new SpinnerFilePath(sprintf('data/environments/%s', $input->getArgument('name'))),
|
||||
new FilePath(sprintf('data/environments/%s', $input->getArgument('name'))),
|
||||
'projectData'
|
||||
);
|
||||
$this->config->addFilePath(
|
||||
new SpinnerFilePath(sprintf('data/environments/%s/.env', $input->getArgument('name'))),
|
||||
new FilePath(sprintf('data/environments/%s/.env', $input->getArgument('name'))),
|
||||
'projectEnv'
|
||||
);
|
||||
$this->config->addFilePath(
|
||||
new SpinnerFilePath(sprintf('data/environments/%s/docker-compose.yml', $input->getArgument('name'))),
|
||||
new FilePath(sprintf('data/environments/%s/docker-compose.yml', $input->getArgument('name'))),
|
||||
'projectDockerCompose'
|
||||
);
|
||||
$this->config->addFilePath(
|
||||
new SpinnerFilePath(sprintf('data/environments/%s/php-fpm/Dockerfile', $input->getArgument('name'))),
|
||||
new FilePath(sprintf('data/environments/%s/php-fpm/Dockerfile', $input->getArgument('name'))),
|
||||
'projectPhpFpmDockerfile'
|
||||
);
|
||||
$this->config->addFilePath(
|
||||
new SpinnerFilePath(sprintf('data/environments/%s/nginx/Dockerfile', $input->getArgument('name'))),
|
||||
new FilePath(sprintf('data/environments/%s/nginx/Dockerfile', $input->getArgument('name'))),
|
||||
'projectNginxDockerfile'
|
||||
);
|
||||
$this->config->addFilePath(
|
||||
|
|
|
@ -7,8 +7,8 @@ namespace Loom\Spinner\Command;
|
|||
use Loom\Spinner\Classes\File\DockerComposeFileBuilder;
|
||||
use Loom\Spinner\Classes\File\NginxDockerFileBuilder;
|
||||
use Loom\Spinner\Classes\File\PHPDockerFileBuilder;
|
||||
use Loom\Spinner\Classes\File\SpinnerFilePath;
|
||||
use Loom\Spinner\Classes\OS\PortGenerator;
|
||||
use Loom\Utility\FilePath\FilePath;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
@ -131,7 +131,7 @@ class SpinCommand extends AbstractSpinnerCommand
|
|||
{
|
||||
$projectData = $this->config->getFilePaths()->get('projectData');
|
||||
|
||||
if (!$projectData instanceof SpinnerFilePath) {
|
||||
if (!$projectData instanceof FilePath) {
|
||||
throw new \Exception('Invalid project data directory provided.');
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ class SpinCommand extends AbstractSpinnerCommand
|
|||
{
|
||||
$projectEnv = $this->config->getFilePaths()->get('projectEnv');
|
||||
|
||||
if (!$projectEnv instanceof SpinnerFilePath) {
|
||||
if (!$projectEnv instanceof FilePath) {
|
||||
throw new \Exception('Invalid project environment file provided.');
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ class SpinCommand extends AbstractSpinnerCommand
|
|||
{
|
||||
$projectData = $this->config->getFilePaths()->get('projectData');
|
||||
|
||||
if (!$projectData instanceof SpinnerFilePath) {
|
||||
if (!$projectData instanceof FilePath) {
|
||||
throw new \Exception('Invalid project data directory provided.');
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ class SpinCommand extends AbstractSpinnerCommand
|
|||
{
|
||||
$projectData = $this->config->getFilePaths()->get('projectData');
|
||||
|
||||
if (!$projectData instanceof SpinnerFilePath) {
|
||||
if (!$projectData instanceof FilePath) {
|
||||
throw new \Exception('Invalid project data directory provided.');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue