From dc9bbd3868efbde71fb8c9781b5b69f89c0d7bdd Mon Sep 17 00:00:00 2001 From: Alexander Hesse Date: Tue, 17 May 2022 16:17:14 +0200 Subject: [PATCH 1/5] BUGFIX: use Guzzle to download from GitHub --- Classes/Composer/InstallerScripts.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Classes/Composer/InstallerScripts.php b/Classes/Composer/InstallerScripts.php index c28ddfe..ff7169d 100644 --- a/Classes/Composer/InstallerScripts.php +++ b/Classes/Composer/InstallerScripts.php @@ -4,6 +4,7 @@ namespace Flowpack\Prunner\Composer; use Composer\Script\Event; +use GuzzleHttp\Client; use Neos\Utility\Files; use PharData; @@ -71,8 +72,10 @@ public static function postUpdateAndInstall(Event $event) echo '> Version: ' . $version . $versionMessage . "\n"; echo '> Platform: ' . $platform . "\n"; echo '> Architecture: ' . $architecture . "\n"; + + $httpClient = new Client(); $downloadLink = sprintf('https://github.com/Flowpack/prunner/releases/download/v%s/prunner_%s_%s_%s.tar.gz', $version, $version, $platform, $architecture); - $downloadedFileContents = file_get_contents($downloadLink); + $downloadedFileContents = $httpClient->get($downloadLink)->getBody()->getContents(); echo '> Download complete.' . "\n"; file_put_contents('Data/Temporary/prunner.tar.gz', $downloadedFileContents); From 60b7d8ffcd768837ff1d419e5d21705625d5dea2 Mon Sep 17 00:00:00 2001 From: Alexander Hesse Date: Fri, 20 May 2022 14:11:55 +0200 Subject: [PATCH 2/5] download directly to file --- Classes/Composer/InstallerScripts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Composer/InstallerScripts.php b/Classes/Composer/InstallerScripts.php index ff7169d..9269ca7 100644 --- a/Classes/Composer/InstallerScripts.php +++ b/Classes/Composer/InstallerScripts.php @@ -73,9 +73,9 @@ public static function postUpdateAndInstall(Event $event) echo '> Platform: ' . $platform . "\n"; echo '> Architecture: ' . $architecture . "\n"; - $httpClient = new Client(); $downloadLink = sprintf('https://github.com/Flowpack/prunner/releases/download/v%s/prunner_%s_%s_%s.tar.gz', $version, $version, $platform, $architecture); - $downloadedFileContents = $httpClient->get($downloadLink)->getBody()->getContents(); + $httpClient = new Client(); + $httpClient->get($downloadLink, ['sink' => 'Data/Temporary/prunner.tar.gz']); echo '> Download complete.' . "\n"; file_put_contents('Data/Temporary/prunner.tar.gz', $downloadedFileContents); From 2a5c43603a03dfe198c630e44c1f45d366c5ef05 Mon Sep 17 00:00:00 2001 From: batabana Date: Tue, 13 Sep 2022 14:35:45 +0200 Subject: [PATCH 3/5] TASK: Declare compatible with Neos 8 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 369c4c5..1459b4a 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "MIT", "require": { "neos/flow": "*", - "neos/neos": "^7", + "neos/neos": "^7.0 || ^8.0", "guzzlehttp/guzzle": "^7.3", "firebase/php-jwt": "^5.2" }, From 905c70f8be138d7b7020806283718ea21dacf3b4 Mon Sep 17 00:00:00 2001 From: Christopher Hlubek Date: Wed, 28 Sep 2022 10:23:19 +0200 Subject: [PATCH 4/5] Add improvements --- Classes/Composer/InstallerScripts.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Classes/Composer/InstallerScripts.php b/Classes/Composer/InstallerScripts.php index 9269ca7..221034c 100644 --- a/Classes/Composer/InstallerScripts.php +++ b/Classes/Composer/InstallerScripts.php @@ -73,12 +73,11 @@ public static function postUpdateAndInstall(Event $event) echo '> Platform: ' . $platform . "\n"; echo '> Architecture: ' . $architecture . "\n"; - $downloadLink = sprintf('https://github.com/Flowpack/prunner/releases/download/v%s/prunner_%s_%s_%s.tar.gz', $version, $version, $platform, $architecture); + $downloadLink = sprintf('https://github.com/Flowpack/prunner/releases/download/v%1$s/prunner_%1$s_%2$s_%3$s.tar.gz', $version, $platform, $architecture); $httpClient = new Client(); $httpClient->get($downloadLink, ['sink' => 'Data/Temporary/prunner.tar.gz']); echo '> Download complete.' . "\n"; - file_put_contents('Data/Temporary/prunner.tar.gz', $downloadedFileContents); Files::unlink('Data/Temporary/prunner.tar'); // decompress from gz From 1bbdb5068e85c585759c7d9a69ca1c2fb9661b72 Mon Sep 17 00:00:00 2001 From: Christopher Hlubek Date: Wed, 28 Sep 2022 10:48:05 +0200 Subject: [PATCH 5/5] Get rid of extra install step to patch main composer.json --- Classes/Command/PrunnerCommandController.php | 56 -------------------- Classes/Composer/InstallerScripts.php | 6 +-- README.md | 13 +---- composer.json | 4 ++ 4 files changed, 9 insertions(+), 70 deletions(-) delete mode 100644 Classes/Command/PrunnerCommandController.php diff --git a/Classes/Command/PrunnerCommandController.php b/Classes/Command/PrunnerCommandController.php deleted file mode 100644 index 5011ac8..0000000 --- a/Classes/Command/PrunnerCommandController.php +++ /dev/null @@ -1,56 +0,0 @@ -outputLine('adding post-install-script to root composer.json'); - - $composerJsonFile = file_get_contents(FLOW_PATH_ROOT . '/composer.json'); - $composerJson = json_decode($composerJsonFile, true); - if (!isset($composerJson['scripts'])) { - $composerJson['scripts'] = []; - } - - $postInstallCmd = []; - if (is_string($composerJson['scripts'][self::COMPOSER_INSTALL_CMD_KEY])) { - $postInstallCmd[] = $composerJson['scripts'][self::COMPOSER_INSTALL_CMD_KEY]; - } else { - $postInstallCmd = $composerJson['scripts'][self::COMPOSER_INSTALL_CMD_KEY]; - } - if (array_search($cmd, $postInstallCmd) === false) { - $postInstallCmd[] = $cmd; - } - $composerJson['scripts'][self::COMPOSER_INSTALL_CMD_KEY] = $postInstallCmd; - - $postUpdateCmd = []; - if (is_string($composerJson['scripts'][self::COMPOSER_UPDATE_CMD_KEY])) { - $postUpdateCmd[] = $composerJson['scripts'][self::COMPOSER_UPDATE_CMD_KEY]; - } else { - $postUpdateCmd = $composerJson['scripts'][self::COMPOSER_UPDATE_CMD_KEY]; - } - if (array_search($cmd, $postUpdateCmd) === false) { - $postUpdateCmd[] = $cmd; - } - $composerJson['scripts'][self::COMPOSER_UPDATE_CMD_KEY] = $postUpdateCmd; - - file_put_contents(FLOW_PATH_ROOT . '/composer.json', json_encode($composerJson, JSON_PRETTY_PRINT)); - - $this->outputLine('Updated root composer.json. You now need to run composer install'); - } -} diff --git a/Classes/Composer/InstallerScripts.php b/Classes/Composer/InstallerScripts.php index 221034c..4f1d83d 100644 --- a/Classes/Composer/InstallerScripts.php +++ b/Classes/Composer/InstallerScripts.php @@ -3,7 +3,6 @@ namespace Flowpack\Prunner\Composer; -use Composer\Script\Event; use GuzzleHttp\Client; use Neos\Utility\Files; use PharData; @@ -46,12 +45,13 @@ class InstallerScripts const DEFAULT_VERSION_TO_INSTALL = '0.8.1'; - public static function postUpdateAndInstall(Event $event) + public static function postUpdateAndInstall() { $platform = php_uname('s'); // stuff like Darwin etc $architecture = php_uname('m'); // x86_64 - $extra = $event->getComposer()->getPackage()->getExtra(); + $composerJson = json_decode(file_get_contents('composer.json'), true); + $extra = isset($composerJson['extra']) ? $composerJson['extra'] : []; $version = self::DEFAULT_VERSION_TO_INSTALL; $versionMessage = ''; if (isset($extra['prunner-version'])) { diff --git a/README.md b/README.md index 514f547..e721038 100644 --- a/README.md +++ b/README.md @@ -22,16 +22,7 @@ A Neos/Flow PHP package providing a backend module for the current pipeline stat ## Installation ```bash -# add the package composer require flowpack/prunner - -# patch main composer.json to add Flowpack\Prunner\Composer\InstallerScripts::postUpdateAndInstall to post-install-cmd and post-update-cmd -./flow prunner:setupProject - -# run composer install again, to download prunner. -composer install - -# prunner is now installed in your project root, as "prunner/prunner" ``` Now, start up prunner via the following command: @@ -40,7 +31,7 @@ Now, start up prunner via the following command: prunner/prunner --path Packages --data Data/Persistent/prunner ``` -This will parse all packages for `pipelines.yml` files. +This will parse all packages for `pipelines.yml` files. ## Overriding the Prunner Version @@ -65,7 +56,7 @@ Then, copy the `index.js` and `index.css` files to this package: ```bash export PRUNNERUI=/path/to/prunner-ui cp $PRUNNERUI/build/dist/index.js* Resources/Public/prunner-ui/ -cp $PRUNNERUI/build/index.css Resources/Public/prunner-ui/index.css +cp $PRUNNERUI/build/index.css Resources/Public/prunner-ui/index.css ``` ## License diff --git a/composer.json b/composer.json index 1459b4a..c805a12 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,10 @@ "extra": { "neos": { "package-key": "Flowpack.Prunner" + }, + "neos/flow": { + "post-install": "Flowpack\\Prunner\\Composer\\InstallerScripts::postUpdateAndInstall", + "post-update": "Flowpack\\Prunner\\Composer\\InstallerScripts::postUpdateAndInstall" } } }