diff --git a/autoload_runtime.template b/autoload_runtime.template new file mode 100644 index 0000000..1b47123 --- /dev/null +++ b/autoload_runtime.template @@ -0,0 +1,36 @@ +getResolver($app) + ->resolve(); + +$app = $app(...$args); + +exit( + $runtime + ->getRunner($app) + ->run() +); diff --git a/box.json.dist b/box.json.dist index 145033b..7ce6e04 100644 --- a/box.json.dist +++ b/box.json.dist @@ -1,13 +1,17 @@ { + "main": "bin/console", "output": "dist/versa", - "files": [ - "versa" - ], "directories": [ + "config", "src", "vendor" ], + "files": [ + ".env.local.php", + "autoload_runtime.template" + ], "check-requirements": true, "exclude-composer-files": false, + "force-autodiscovery": true, "compression": "GZ" } diff --git a/composer.json b/composer.json index 23c4614..e0374a1 100644 --- a/composer.json +++ b/composer.json @@ -47,13 +47,9 @@ }, "scripts": { "auto-scripts": { - "cache:clear": "symfony-cmd", - "assets:install %PUBLIC_DIR%": "symfony-cmd" + "cache:clear": "symfony-cmd" }, - "post-install-cmd": [ - "@auto-scripts" - ], - "post-update-cmd": [ + "post-autoload-dump": [ "@auto-scripts" ] }, @@ -61,6 +57,9 @@ "symfony/symfony": "*" }, "extra": { + "runtime": { + "autoload_template": "autoload_runtime.template" + }, "symfony": { "allow-contrib": false, "require": "7.0.*" diff --git a/config/packages/routing.yaml b/config/packages/routing.yaml deleted file mode 100644 index 8166181..0000000 --- a/config/packages/routing.yaml +++ /dev/null @@ -1,10 +0,0 @@ -framework: - router: - # Configure how to generate URLs in non-HTTP contexts, such as CLI commands. - # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands - #default_uri: http://localhost - -when@prod: - framework: - router: - strict_requirements: null diff --git a/config/routes.yaml b/config/routes.yaml deleted file mode 100644 index 41ef814..0000000 --- a/config/routes.yaml +++ /dev/null @@ -1,5 +0,0 @@ -controllers: - resource: - path: ../src/Controller/ - namespace: App\Controller - type: attribute diff --git a/config/routes/framework.yaml b/config/routes/framework.yaml deleted file mode 100644 index 0fc74bb..0000000 --- a/config/routes/framework.yaml +++ /dev/null @@ -1,4 +0,0 @@ -when@dev: - _errors: - resource: '@FrameworkBundle/Resources/config/routing/errors.xml' - prefix: /_error diff --git a/index.php b/index.php deleted file mode 100644 index fc769af..0000000 --- a/index.php +++ /dev/null @@ -1,3 +0,0 @@ -setDescription(static::$description); - $this->addOption( name: 'args', shortcut: 'a', diff --git a/src/Console/Command/BuildCommand.php b/src/Console/Command/BuildCommand.php index 046ba65..4107542 100644 --- a/src/Console/Command/BuildCommand.php +++ b/src/Console/Command/BuildCommand.php @@ -7,14 +7,19 @@ use App\Enum\ProjectLanguage; use App\Enum\ProjectType; use App\Process\Process; use RuntimeException; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; +#[AsCommand( + description: 'Install the project\'s dependencies', + name: 'build', +)] final class BuildCommand extends AbstractCommand { - public static string $description = 'Build the project'; + public static string $description = ''; public function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Console/Command/InstallCommand.php b/src/Console/Command/InstallCommand.php index f4413a7..f1878c1 100644 --- a/src/Console/Command/InstallCommand.php +++ b/src/Console/Command/InstallCommand.php @@ -8,15 +8,17 @@ use App\Enum\PackageManager; use App\Enum\ProjectLanguage; use App\Process\Process; use RuntimeException; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Filesystem\Filesystem; +#[AsCommand( + description: 'Install the project\'s dependencies', + name: 'install', +)] final class InstallCommand extends AbstractCommand { - public static string $description = 'Install the project\'s dependencies'; - public function execute(InputInterface $input, OutputInterface $output): int { $args = $input->getOption('args'); @@ -27,8 +29,6 @@ final class InstallCommand extends AbstractCommand workingDir: $workingDir, ))->getLanguage(); - $filesystem = new Filesystem(); - // TODO: Composer in Docker Compose? $process = Process::create( args: explode(separator: ' ', string: strval($args)), diff --git a/src/Console/Command/PackageInstallCommand.php b/src/Console/Command/PackageInstallCommand.php index ee0130b..7677f6b 100644 --- a/src/Console/Command/PackageInstallCommand.php +++ b/src/Console/Command/PackageInstallCommand.php @@ -7,15 +7,18 @@ use App\Action\DetermineProjectLanguage; use App\Enum\PackageManager; use App\Enum\ProjectLanguage; use App\Process\Process; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand( + description: 'Install a new package', + name: 'package-install', +)] final class PackageInstallCommand extends AbstractCommand { - public static string $description = 'Install a new package'; - public function configure(): void { parent::configure(); diff --git a/src/Console/Command/RunCommand.php b/src/Console/Command/RunCommand.php index 096b4db..0664da0 100644 --- a/src/Console/Command/RunCommand.php +++ b/src/Console/Command/RunCommand.php @@ -6,15 +6,18 @@ use App\Action\DetermineProjectLanguage; use App\Enum\ProjectLanguage; use App\Enum\ProjectType; use App\Process\Process; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; +#[AsCommand( + description: 'Run the project', + name: 'run', +)] final class RunCommand extends AbstractCommand { - public static string $description = 'Run the project'; - public function execute(InputInterface $input, OutputInterface $output): int { $projectType = null; diff --git a/src/Console/Command/TestCommand.php b/src/Console/Command/TestCommand.php index 139dfe3..dde362a 100644 --- a/src/Console/Command/TestCommand.php +++ b/src/Console/Command/TestCommand.php @@ -3,14 +3,17 @@ namespace App\Console\Command; use App\Process\Process; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand( + description: 'Run the project\'s tests', + name: 'test', +)] final class TestCommand extends AbstractCommand { - public static string $description = 'Run the project\'s tests'; - public function execute(InputInterface $input, OutputInterface $output): int { $args = $input->getOption('args'); diff --git a/src/Controller/.gitignore b/src/Controller/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/versa b/versa deleted file mode 100755 index 878b34a..0000000 --- a/versa +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env php - -addCommands([ - new BuildCommand(filesystem: $filesystem, name: 'build'), - new InstallCommand(filesystem: $filesystem, name: 'install'), - new PackageInstallCommand(filesystem: $filesystem, name: 'package-install'), - new RunCommand(filesystem: $filesystem, name: 'run'), - new TestCommand(filesystem: $filesystem, name: 'test'), -]); - -$application->run();