diff --git a/.castor/docker.php b/.castor/docker.php
index d2b397e..f9e7121 100644
--- a/.castor/docker.php
+++ b/.castor/docker.php
@@ -23,7 +23,7 @@
#[AsTask(description: 'Displays some help and available urls for the current project', namespace: '')]
function about(): void
{
- io()->section('About this project');
+ io()->title('About this project');
io()->comment('Run castor to display all available commands.');
io()->comment('Run castor about to display this project help.');
@@ -53,9 +53,17 @@ function about(): void
io()->listing(array_map(fn ($url) => "https://{$url}", $urls));
}
+#[AsTask(description: 'Opens the project in your browser', namespace: '')]
+function open(): void
+{
+ run(['open', 'https://' . variable('root_domain')], quiet: true);
+}
+
#[AsTask(description: 'Builds the infrastructure', aliases: ['build'])]
function build(): void
{
+ io()->title('Building infrastructure');
+
$userId = variable('user_id');
$phpVersion = variable('php_version');
@@ -71,8 +79,10 @@ function build(): void
#[AsTask(description: 'Builds and starts the infrastructure', aliases: ['up'])]
function up(): void
{
+ io()->title('Starting infrastructure');
+
try {
- docker_compose(['up', '--remove-orphans', '--detach', '--no-build']);
+ docker_compose(['up', '--detach', '--no-build']);
} catch (ExceptionInterface $e) {
io()->error('An error occured while starting the infrastructure.');
io()->note('Did you forget to run "castor docker:build"?');
@@ -85,6 +95,8 @@ function up(): void
#[AsTask(description: 'Stops the infrastructure', aliases: ['stop'])]
function stop(): void
{
+ io()->title('Stopping infrastructure');
+
docker_compose(['stop']);
}
@@ -117,6 +129,8 @@ function destroy(
#[AsOption(description: 'Force the destruction without confirmation', shortcut: 'f')]
bool $force = false,
): void {
+ io()->title('Destroying infrastructure');
+
if (!$force) {
io()->warning('This will permanently remove all containers, volumes, networks... created for this project.');
io()->note('You can use the --force option to avoid this confirmation.');
@@ -136,7 +150,7 @@ function destroy(
fs()->remove($files);
}
-#[AsTask(description: 'Generates SSL certificates (with mkcert if available or self-signed if not)')]
+#[AsTask(description: 'Generates SSL certificates (with mkcert if available or self-signed if not)', namespace: '')]
function generate_certificates(
#[AsOption(description: 'Force the certificates re-generation without confirmation', shortcut: 'f')]
bool $force = false,
@@ -150,6 +164,8 @@ function generate_certificates(
return;
}
+ io()->title('Generating SSL certificates');
+
if ($force) {
if (file_exists($f = "{$sslDir}/cert.pem")) {
io()->comment('Removing existing certificates in infrastructure/docker/services/router/certs/*.pem.');
@@ -206,6 +222,8 @@ function generate_certificates(
#[AsTask(description: 'Starts the workers', namespace: 'docker:worker', name: 'start', aliases: ['start-workers'])]
function workers_start(): void
{
+ io()->title('Starting workers');
+
$workers = get_workers();
if (!$workers) {
@@ -229,6 +247,8 @@ function workers_start(): void
#[AsTask(description: 'Stops the workers', namespace: 'docker:worker', name: 'stop', aliases: ['stop-workers'])]
function workers_stop(): void
{
+ io()->title('Stopping workers');
+
$workers = get_workers();
if (!$workers) {
diff --git a/.castor/qa.php b/.castor/qa.php
index 992cdfc..32d5202 100644
--- a/.castor/qa.php
+++ b/.castor/qa.php
@@ -4,6 +4,7 @@
use Castor\Attribute\AsTask;
+use function Castor\io;
use function docker\docker_compose_run;
use function docker\docker_exit_code;
@@ -13,17 +14,26 @@ function all(): int
install();
$cs = cs();
$phpstan = phpstan();
+ // $phpunit = phpunit();
- return max($cs, $phpstan);
+ return max($cs, $phpstan/*, $phpunit*/);
}
#[AsTask(description: 'Installs tooling')]
function install(): void
{
+ io()->title('Installing QA tooling');
+
docker_compose_run('composer install -o', workDir: '/var/www/tools/php-cs-fixer');
docker_compose_run('composer install -o', workDir: '/var/www/tools/phpstan');
}
+// #[AsTask(description: 'Runs PHPUnit', aliases: ['phpunit'])]
+// function phpunit(): int
+// {
+// return docker_exit_code('phpunit');
+// }
+
#[AsTask(description: 'Runs PHPStan', aliases: ['phpstan'])]
function phpstan(): int
{
diff --git a/castor.php b/castor.php
index 35160c9..556e03f 100644
--- a/castor.php
+++ b/castor.php
@@ -37,6 +37,8 @@ function create_default_variables(): array
#[AsTask(description: 'Builds and starts the infrastructure, then install the application (composer, yarn, ...)')]
function start(): void
{
+ io()->title('Starting the stack');
+
workers_stop();
generate_certificates(force: false);
build();
@@ -55,17 +57,23 @@ function start(): void
#[AsTask(description: 'Installs the application (composer, yarn, ...)', namespace: 'app', aliases: ['install'])]
function install(): void
{
+ io()->title('Installing the application');
+
$basePath = sprintf('%s/application', variable('root_dir'));
if (is_file("{$basePath}/composer.json")) {
+ io()->section('Installing PHP dependencies');
docker_compose_run('composer install -n --prefer-dist --optimize-autoloader');
}
if (is_file("{$basePath}/yarn.lock")) {
+ io()->section('Installing Node.js dependencies');
docker_compose_run('yarn install --frozen-lockfile');
} elseif (is_file("{$basePath}/package.json")) {
+ io()->section('Installing Node.js dependencies');
docker_compose_run('npm ci');
}
if (is_file("{$basePath}/importmap.php")) {
+ io()->section('Installing importmap');
docker_compose_run('bin/console importmap:install');
}
@@ -75,12 +83,16 @@ function install(): void
#[AsTask(description: 'Clear the application cache', namespace: 'app', aliases: ['cache-clear'])]
function cache_clear(): void
{
+ // io()->title('Clearing the application cache');
+
// docker_compose_run('rm -rf var/cache/ && bin/console cache:warmup');
}
#[AsTask(description: 'Migrates database schema', namespace: 'app:db', aliases: ['migrate'])]
function migrate(): void
{
+ // io()->title('Migrating the database schema');
+
// docker_compose_run('bin/console doctrine:database:create --if-not-exists');
// docker_compose_run('bin/console doctrine:migration:migrate -n --allow-no-migration');
}