From 5c00db7366a43728e00c6909f11172d3d275c1a6 Mon Sep 17 00:00:00 2001 From: Alan Isaacson Date: Tue, 30 Mar 2021 16:11:15 +0100 Subject: [PATCH 1/7] Add check for local deployer --- all.php | 1 + docs/build-summary.md | 2 +- docs/check-deployer.md | 33 +++++++++++++++++++++++++++++++++ examples/deploy.php | 4 ++++ src/check-deployer.php | 19 +++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 docs/check-deployer.md create mode 100644 src/check-deployer.php diff --git a/all.php b/all.php index ee2533c..9b4781a 100644 --- a/all.php +++ b/all.php @@ -9,3 +9,4 @@ require_once __DIR__ . '/src/display-disk-space.php'; require_once __DIR__ . '/src/vendors-subpath.php'; require_once __DIR__ . '/src/notify-slack.php'; +require_once __DIR__ . '/src/check-deployer.php'; diff --git a/docs/build-summary.md b/docs/build-summary.md index 1de3f60..cff179c 100644 --- a/docs/build-summary.md +++ b/docs/build-summary.md @@ -15,7 +15,7 @@ No configuration is required. ## Tasks -- `studio24:build-summary` – retrieves current deployment info and creates a `_build_summary.json` file in the web root +- `s24:build-summary` – retrieves current deployment info and creates a `_build_summary.json` file in the web root ## Usage diff --git a/docs/check-deployer.md b/docs/check-deployer.md new file mode 100644 index 0000000..4ae9ba5 --- /dev/null +++ b/docs/check-deployer.md @@ -0,0 +1,33 @@ +# Build summary recipe + +Checks that deployment is running via the local deploy +## Usage + +Either [install all Studio 24 tasks](../README.md#installation) or install this individual task by adding to your `deploy.php`: + +```php +require 'vendor/studio24/deployer-recipes/src/check-deployer.php'; +``` + +## Configuration +No configuration is required. + +## Tasks + +- `s24:check-deployer` – checks whether you are running local deployer, if not it stops the deployment + +## Usage + +Add task to the start of your `deploy.php` script: + +``` +task('deploy', [ + ... + // Add before deploy:info + 's24:check-deployer', + + // Run initial checks + 'deploy:info', + ... +]); +``` diff --git a/examples/deploy.php b/examples/deploy.php index 11f0865..55b2356 100644 --- a/examples/deploy.php +++ b/examples/deploy.php @@ -100,6 +100,10 @@ desc('Deploy ' . get('application')); task('deploy', [ + + // Check that we are using local deployer + 's24:check-deployer', + // Run initial checks 'deploy:info', 's24:check-branch', diff --git a/src/check-deployer.php b/src/check-deployer.php new file mode 100644 index 0000000..e275065 --- /dev/null +++ b/src/check-deployer.php @@ -0,0 +1,19 @@ +Pleaae run using local deployer with '); + writeln('./vendor/bin/dep'); + writeln(''); + throw new \RuntimeException("Deployment abandoned"); + } +}); From 5f1671ec7dca97722205e7c4b0653840ea76e040 Mon Sep 17 00:00:00 2001 From: Alan Isaacson Date: Wed, 31 Mar 2021 09:44:33 +0100 Subject: [PATCH 2/7] Update recipe name and adjust code --- all.php | 2 +- ...ck-deployer.md => check-local-deployer.md} | 2 +- examples/deploy.php | 2 +- src/check-deployer.php | 19 ------------------- src/check-local-deployer.php | 15 +++++++++++++++ 5 files changed, 18 insertions(+), 22 deletions(-) rename docs/{check-deployer.md => check-local-deployer.md} (95%) delete mode 100644 src/check-deployer.php create mode 100644 src/check-local-deployer.php diff --git a/all.php b/all.php index 9b4781a..b591291 100644 --- a/all.php +++ b/all.php @@ -9,4 +9,4 @@ require_once __DIR__ . '/src/display-disk-space.php'; require_once __DIR__ . '/src/vendors-subpath.php'; require_once __DIR__ . '/src/notify-slack.php'; -require_once __DIR__ . '/src/check-deployer.php'; +require_once __DIR__ . '/src/check-local-deployer.php'; diff --git a/docs/check-deployer.md b/docs/check-local-deployer.md similarity index 95% rename from docs/check-deployer.md rename to docs/check-local-deployer.md index 4ae9ba5..a84cd0a 100644 --- a/docs/check-deployer.md +++ b/docs/check-local-deployer.md @@ -24,7 +24,7 @@ Add task to the start of your `deploy.php` script: task('deploy', [ ... // Add before deploy:info - 's24:check-deployer', + 's24:check-local-deployer', // Run initial checks 'deploy:info', diff --git a/examples/deploy.php b/examples/deploy.php index 55b2356..804920b 100644 --- a/examples/deploy.php +++ b/examples/deploy.php @@ -102,7 +102,7 @@ task('deploy', [ // Check that we are using local deployer - 's24:check-deployer', + 's24:check-local-deployer', // Run initial checks 'deploy:info', diff --git a/src/check-deployer.php b/src/check-deployer.php deleted file mode 100644 index e275065..0000000 --- a/src/check-deployer.php +++ /dev/null @@ -1,19 +0,0 @@ -Pleaae run using local deployer with '); - writeln('./vendor/bin/dep'); - writeln(''); - throw new \RuntimeException("Deployment abandoned"); - } -}); diff --git a/src/check-local-deployer.php b/src/check-local-deployer.php new file mode 100644 index 0000000..5d59c82 --- /dev/null +++ b/src/check-local-deployer.php @@ -0,0 +1,15 @@ + Date: Wed, 31 Mar 2021 09:46:59 +0100 Subject: [PATCH 3/7] Remove redundant check in if statement --- src/check-local-deployer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/check-local-deployer.php b/src/check-local-deployer.php index 5d59c82..e96ef1f 100644 --- a/src/check-local-deployer.php +++ b/src/check-local-deployer.php @@ -7,9 +7,7 @@ $scriptPath = get_included_files()[0]; - if (strpos($scriptPath, __DIR__.'/vendor/deployer/deployer/bin/dep') !== false) { - writeln(' '); - } else { + if (strpos($scriptPath, __DIR__.'/vendor/deployer/deployer/bin/dep') !== true) { throw new \RuntimeException("Pleaae run using local deployer with ./vendor/bin/dep"); } }); From bff39c304d41f2a44abac7d9282c1d45138a1b9c Mon Sep 17 00:00:00 2001 From: Alan Isaacson Date: Wed, 31 Mar 2021 10:04:29 +0100 Subject: [PATCH 4/7] Update docs --- docs/check-local-deployer.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/check-local-deployer.md b/docs/check-local-deployer.md index a84cd0a..4c26aa1 100644 --- a/docs/check-local-deployer.md +++ b/docs/check-local-deployer.md @@ -1,6 +1,6 @@ -# Build summary recipe +# Check local deployer recipe -Checks that deployment is running via the local deploy +Checks that deployment is running via the local Deployer install. ## Usage Either [install all Studio 24 tasks](../README.md#installation) or install this individual task by adding to your `deploy.php`: @@ -10,7 +10,10 @@ require 'vendor/studio24/deployer-recipes/src/check-deployer.php'; ``` ## Configuration -No configuration is required. +The recipe detects the first item in the array of file paths only +```` +$scriptPath = get_included_files()[0]; +```` ## Tasks From 35f4b9ab8185dd72846c135fc737ef6cba9245ad Mon Sep 17 00:00:00 2001 From: Alan Isaacson Date: Wed, 31 Mar 2021 10:08:34 +0100 Subject: [PATCH 5/7] Update docs --- docs/check-local-deployer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/check-local-deployer.md b/docs/check-local-deployer.md index 4c26aa1..733a49c 100644 --- a/docs/check-local-deployer.md +++ b/docs/check-local-deployer.md @@ -17,7 +17,7 @@ $scriptPath = get_included_files()[0]; ## Tasks -- `s24:check-deployer` – checks whether you are running local deployer, if not it stops the deployment +- `s24:check-local-deployer` – checks whether you are running local deployer, if not it stops the deployment ## Usage From 1ddc1014ad733f10f506ec4d646e7b5d5a397cd7 Mon Sep 17 00:00:00 2001 From: Alan Isaacson Date: Wed, 31 Mar 2021 10:09:31 +0100 Subject: [PATCH 6/7] Update recipe for clarity --- src/check-local-deployer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/check-local-deployer.php b/src/check-local-deployer.php index e96ef1f..6e1b73b 100644 --- a/src/check-local-deployer.php +++ b/src/check-local-deployer.php @@ -8,6 +8,6 @@ $scriptPath = get_included_files()[0]; if (strpos($scriptPath, __DIR__.'/vendor/deployer/deployer/bin/dep') !== true) { - throw new \RuntimeException("Pleaae run using local deployer with ./vendor/bin/dep"); + throw new \RuntimeException("Pleaae run using local Deployer with ./vendor/bin/dep"); } }); From 976a05742583c1a34e9b8d211a1e093aca1af810 Mon Sep 17 00:00:00 2001 From: Alan Isaacson Date: Wed, 31 Mar 2021 10:31:39 +0100 Subject: [PATCH 7/7] Update docs --- docs/check-local-deployer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/check-local-deployer.md b/docs/check-local-deployer.md index 733a49c..2ad9a4c 100644 --- a/docs/check-local-deployer.md +++ b/docs/check-local-deployer.md @@ -6,7 +6,7 @@ Checks that deployment is running via the local Deployer install. Either [install all Studio 24 tasks](../README.md#installation) or install this individual task by adding to your `deploy.php`: ```php -require 'vendor/studio24/deployer-recipes/src/check-deployer.php'; +require 'vendor/studio24/deployer-recipes/src/check-local-deployer.php'; ``` ## Configuration