From 84809ac3b8f11079324776c612138b7b764463d9 Mon Sep 17 00:00:00 2001 From: The DevOpser Date: Sun, 19 Jan 2025 14:46:28 +0100 Subject: [PATCH 1/8] Create manifest.json --- thedevopser/castor-symfony/manifest.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 thedevopser/castor-symfony/manifest.json diff --git a/thedevopser/castor-symfony/manifest.json b/thedevopser/castor-symfony/manifest.json new file mode 100644 index 000000000..61a034e2e --- /dev/null +++ b/thedevopser/castor-symfony/manifest.json @@ -0,0 +1,12 @@ +{ + "manifests": { + "thedevopser/castor-symfony": { + "manifest": { + "bundles": {}, + "copy-from-recipe": { + "castor.php": "%PROJECT_DIR%/castor.php" + } + } + } + } +} From 29e759491c1c45b54e784283565aa8df634cfbf3 Mon Sep 17 00:00:00 2001 From: The DevOpser Date: Sun, 19 Jan 2025 14:46:55 +0100 Subject: [PATCH 2/8] Create castor.php --- thedevopser/castor-symfony/castor.php | 165 ++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 thedevopser/castor-symfony/castor.php diff --git a/thedevopser/castor-symfony/castor.php b/thedevopser/castor-symfony/castor.php new file mode 100644 index 000000000..ca0d1dc92 --- /dev/null +++ b/thedevopser/castor-symfony/castor.php @@ -0,0 +1,165 @@ +title('Initialisation du projet Symfony'); + + $nodePacketManager = io()->ask('Quel packet manager utilisez-vous ? (yarn/npm)'); + + io()->info('Installation des vendors'); + run('composer install'); + + if ($node) { + io()->info('Installation node_modules'); + run($nodePacketManager . ' install'); + } + + io()->info('Copie du .env'); + run('cp .env .env.local'); + + io()->info('Mise en place des variables environnement'); + $dbUser = io()->ask('DatabaseUser:'); + $dbPassword = io()->askHidden('DatabasePassword:'); + $dbName = io()->ask('DatabaseName:'); + $dbHost = io()->ask('DatabaseHost:'); + $dbPort = io()->ask('DatabasePort:'); + + $dbUrl = "DATABASE_URL=\"postgresql://$dbUser:$dbPassword@$dbHost:$dbPort/$dbName\""; + run("sed -i 's|^DATABASE_URL=.*|$dbUrl|' .env.local"); + + $smtpHost = io()->ask('SMTP Host:'); + $smtpPort = io()->ask('SMTP Port:'); + + $mailerDsn = "MAILER_DSN=\"$smtpHost:$smtpPort\""; + run("sed -i 's|^MAILER_DSN=.*|$mailerDsn|' .env.local"); + + io()->info('Création de la BDD'); + run('bin/console d:d:c --if-not-exists'); + + if ($migrate) { + io()->info('Migration de la BDD'); + run('bin/console d:m:m -n'); + } +} + +#[AsTask(description: 'Installe les paquets')] +function install_packages(): void +{ + io()->title('Installation du projet'); + $nodePacketManager = io()->ask('Quel packet manager utilisez-vous ? (yarn/npm)'); + + run('composer install'); + run($nodePacketManager . ' install'); +} + +/** + * Base de données + */ +#[AsTask(description: 'Création de la BDD')] +function create_db(): void +{ + io()->title('Creation de la BDD'); + run('php bin/console d:d:c --if-not-exists'); +} + +#[AsTask(description: 'Création des migrations')] +function create_migration(): void +{ + io()->title('Creation des migrations'); + run('php bin/console make:migration'); +} + +#[AsTask(description: 'Migration de la base de données')] +function migrate(): void +{ + io()->title('Migration de la BDD'); + run('php bin/console d:m:m -n'); +} + +/** + * Qualité de code + */ +#[AsTask(description: 'Applique la qualité au level max sur le projet')] +function phpstan(): void +{ + $projectPath = getcwd(); + io()->info('Analyse du projet avec PHPStan'); + run('docker run --rm -v ' . $projectPath . ':/app -w /app jakzal/phpqa:latest phpstan analyse -c ./quality/phpstan.neon'); +} + +#[AsTask(description: 'Check la validation en PSR12')] +function phpcsfixer(): void +{ + $projectPath = getcwd(); + io()->info('Analyse du projet avec PHPCsFixer'); + run('docker run --rm -v ' . $projectPath . ':/app -w /app jakzal/phpqa:latest php-cs-fixer --config=./quality/.php-cs-fixer.dist.php fix ./src'); +} + +#[AsTask(description: 'Fix les erreurs PSR12')] +function phpcbf(): void +{ + $projectPath = getcwd(); + io()->info('Analyse du projet avec PHPCbf'); + run('docker run --rm -v ' . $projectPath . ':/app -w /app jakzal/phpqa:latest phpcbf --standard=PSR12 --colors src tests || true'); +} + +/** + * Gestion Git + */ +#[AsTask(description: 'Récupère la dernière version de la branche principale')] +function pull_main(bool $migrate = false): void +{ + run('git checkout main'); + run('git pull origin main'); + run('castor install-packages'); + if ($migrate) { + run('castor migrate'); + } + run('castor clean'); +} + +#[AsTask(description: 'Rebase la branche actuelle avec master')] +function rebase(string $branch): void +{ + run('castor pull-main'); + run(sprintf('git checkout %s', escapeshellarg($branch))); + run('git rebase main'); +} + +/** + * Maintenance + */ +#[AsTask(description: 'Nettoie le projet')] +function clean(string $env = 'dev'): void +{ + run(sprintf('bin/console c:c --env=%s', escapeshellarg($env))); +} + +/** + * Docker + */ + +#[AsTask(description: 'Démarrage des containers Docker')] +function docker_up(): void +{ + io()->title('Démarrage des containers Docker'); + run('docker-compose up -d'); +} + +#[AsTask(description: 'Arrêt des containers Docker')] +function docker_down():void +{ + io()->title('Arrêt des containers Docker'); + run('docker-compose down'); +} From d2192a5542a4c392d71469e5ad048e195a3749f8 Mon Sep 17 00:00:00 2001 From: The DevOpser Date: Sun, 19 Jan 2025 14:59:07 +0100 Subject: [PATCH 3/8] Create a --- thedevopser/castor-symfony/1.0/a | 1 + 1 file changed, 1 insertion(+) create mode 100644 thedevopser/castor-symfony/1.0/a diff --git a/thedevopser/castor-symfony/1.0/a b/thedevopser/castor-symfony/1.0/a new file mode 100644 index 000000000..789819226 --- /dev/null +++ b/thedevopser/castor-symfony/1.0/a @@ -0,0 +1 @@ +a From 423f5cd2a3c8cf249ee66cbb22243c06d4715c1c Mon Sep 17 00:00:00 2001 From: TheDevOpser Date: Sun, 19 Jan 2025 15:02:22 +0100 Subject: [PATCH 4/8] Fix version --- .idea/.gitignore | 8 ++++++++ .idea/vcs.xml | 4 ++++ thedevopser/castor-symfony/1.0/a | 1 - thedevopser/castor-symfony/{ => 1.0}/castor.php | 0 thedevopser/castor-symfony/{ => 1.0}/manifest.json | 0 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/vcs.xml delete mode 100644 thedevopser/castor-symfony/1.0/a rename thedevopser/castor-symfony/{ => 1.0}/castor.php (100%) rename thedevopser/castor-symfony/{ => 1.0}/manifest.json (100%) diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 000000000..13566b81b --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..d843f340d --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/thedevopser/castor-symfony/1.0/a b/thedevopser/castor-symfony/1.0/a deleted file mode 100644 index 789819226..000000000 --- a/thedevopser/castor-symfony/1.0/a +++ /dev/null @@ -1 +0,0 @@ -a diff --git a/thedevopser/castor-symfony/castor.php b/thedevopser/castor-symfony/1.0/castor.php similarity index 100% rename from thedevopser/castor-symfony/castor.php rename to thedevopser/castor-symfony/1.0/castor.php diff --git a/thedevopser/castor-symfony/manifest.json b/thedevopser/castor-symfony/1.0/manifest.json similarity index 100% rename from thedevopser/castor-symfony/manifest.json rename to thedevopser/castor-symfony/1.0/manifest.json From e71527bd82d0be7892f14801af0fe32d22cbbaea Mon Sep 17 00:00:00 2001 From: TheDevOpser Date: Sun, 19 Jan 2025 15:05:09 +0100 Subject: [PATCH 5/8] Fix Identation --- .idea/modules.xml | 8 +++++ .idea/php.xml | 22 ++++++++++++ .idea/recipes-contrib.iml | 36 ++++++++++++++++++++ .idea/vcs.xml | 4 ++- thedevopser/castor-symfony/1.0/manifest.json | 18 +++++----- 5 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/recipes-contrib.iml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..3174879f3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 000000000..29059d00f --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/recipes-contrib.iml b/.idea/recipes-contrib.iml new file mode 100644 index 000000000..eb5572db4 --- /dev/null +++ b/.idea/recipes-contrib.iml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index d843f340d..35eb1ddfb 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,4 +1,6 @@ - + + + \ No newline at end of file diff --git a/thedevopser/castor-symfony/1.0/manifest.json b/thedevopser/castor-symfony/1.0/manifest.json index 61a034e2e..eba0456dd 100644 --- a/thedevopser/castor-symfony/1.0/manifest.json +++ b/thedevopser/castor-symfony/1.0/manifest.json @@ -1,12 +1,12 @@ { - "manifests": { - "thedevopser/castor-symfony": { - "manifest": { - "bundles": {}, - "copy-from-recipe": { - "castor.php": "%PROJECT_DIR%/castor.php" + "manifests": { + "thedevopser/castor-symfony": { + "manifest": { + "bundles": {}, + "copy-from-recipe": { + "castor.php": "%PROJECT_DIR%/castor.php" + } + } } - } } - } -} +} \ No newline at end of file From 6f35e0df188146114187682c7e398f08e070450b Mon Sep 17 00:00:00 2001 From: TheDevOpser Date: Sun, 19 Jan 2025 15:08:17 +0100 Subject: [PATCH 6/8] Fix manifest --- thedevopser/castor-symfony/1.0/manifest.json | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/thedevopser/castor-symfony/1.0/manifest.json b/thedevopser/castor-symfony/1.0/manifest.json index eba0456dd..2d7196daf 100644 --- a/thedevopser/castor-symfony/1.0/manifest.json +++ b/thedevopser/castor-symfony/1.0/manifest.json @@ -1,12 +1,5 @@ { - "manifests": { - "thedevopser/castor-symfony": { - "manifest": { - "bundles": {}, - "copy-from-recipe": { - "castor.php": "%PROJECT_DIR%/castor.php" - } - } - } + "copy-from-recipe": { + "castor.php": "%ROOT_DIR%/castor.php" } -} \ No newline at end of file +} From 7a1e1e460576990e3865fb1b59cc99ff1d6d7a86 Mon Sep 17 00:00:00 2001 From: TheDevOpser Date: Sun, 19 Jan 2025 15:11:41 +0100 Subject: [PATCH 7/8] Redmove .idea --- .idea/.gitignore | 8 -------- .idea/modules.xml | 8 -------- .idea/php.xml | 22 ---------------------- .idea/recipes-contrib.iml | 36 ------------------------------------ .idea/vcs.xml | 6 ------ 5 files changed, 80 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/modules.xml delete mode 100644 .idea/php.xml delete mode 100644 .idea/recipes-contrib.iml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b81b..000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 3174879f3..000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index 29059d00f..000000000 --- a/.idea/php.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/recipes-contrib.iml b/.idea/recipes-contrib.iml deleted file mode 100644 index eb5572db4..000000000 --- a/.idea/recipes-contrib.iml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddfb..000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 597afd5d1893fb064413e6ecc53ea72e181e5827 Mon Sep 17 00:00:00 2001 From: TheDevOpser Date: Sun, 19 Jan 2025 17:30:45 +0100 Subject: [PATCH 8/8] Fix copy from recipe --- thedevopser/castor-symfony/1.0/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thedevopser/castor-symfony/1.0/manifest.json b/thedevopser/castor-symfony/1.0/manifest.json index 2d7196daf..bc85b215a 100644 --- a/thedevopser/castor-symfony/1.0/manifest.json +++ b/thedevopser/castor-symfony/1.0/manifest.json @@ -1,5 +1,5 @@ { "copy-from-recipe": { - "castor.php": "%ROOT_DIR%/castor.php" + "castor.php": "castor.php" } }