Skip to content

Commit

Permalink
Merge branch 'Pingu501-ah/bugfix/use-guzzle-for-downloads'
Browse files Browse the repository at this point in the history
  • Loading branch information
hlubek committed Sep 28, 2022
2 parents a7884aa + 1bbdb50 commit 00f477f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 73 deletions.
56 changes: 0 additions & 56 deletions Classes/Command/PrunnerCommandController.php

This file was deleted.

14 changes: 8 additions & 6 deletions Classes/Composer/InstallerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Flowpack\Prunner\Composer;

use Composer\Script\Event;
use GuzzleHttp\Client;
use Neos\Utility\Files;
use PharData;

Expand Down Expand Up @@ -45,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'])) {
Expand All @@ -71,11 +72,12 @@ public static function postUpdateAndInstall(Event $event)
echo '> Version: ' . $version . $versionMessage . "\n";
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);
$downloadedFileContents = file_get_contents($downloadLink);

$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
Expand Down
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}

0 comments on commit 00f477f

Please sign in to comment.