* Added basic http facade
* Updated build rules
This commit is contained in:
Chris 2022-01-06 17:20:40 +01:00
parent 63aae2a504
commit 7c4ca953f6
4 changed files with 31 additions and 7 deletions

View File

@ -19,6 +19,8 @@ if [ ! -z "$FLAVOR" ]; then
fi
PATH="$PWD/tools:$PATH"
PLUGINS="plugins/com.noccy.apiclient plugins/com.noccy.pdo plugins/com.noccy.todo plugins/com.noccy.pdo.shell plugins/com.noccy.watcher"
if [ -z $DESTINATION ]; then
DESTINATION="release/$VERSION"
@ -34,15 +36,15 @@ cp README.md $DESTINATION/README.md
cp VERSIONS.md $DESTINATION/VERSIONS.md
echo "* Building dist and source archives"
7z a -tzip "$DESTINATION/spark-$VERSION-dist.zip" spark.phar plugins README.md VERSIONS.md >/dev/null
tar cfz "$DESTINATION/spark-$VERSION-dist.tgz" spark.phar plugins README.md VERSIONS.md
7z a -tzip "$DESTINATION/spark-$VERSION-src.zip" bin src runtime plugins composer.json README.md VERSIONS.md >/dev/null
tar cfz "$DESTINATION/spark-$VERSION-src.tgz" bin src runtime plugins composer.json README.md VERSIONS.md
7z a -tzip "$DESTINATION/spark-$VERSION-dist.zip" spark.phar $PLUGINS README.md VERSIONS.md >/dev/null
tar cfz "$DESTINATION/spark-$VERSION-dist.tgz" spark.phar $PLUGINS README.md VERSIONS.md
7z a -tzip "$DESTINATION/spark-$VERSION-src.zip" bin src runtime $PLUGINS composer.json README.md VERSIONS.md >/dev/null
tar cfz "$DESTINATION/spark-$VERSION-src.tgz" bin src runtime $PLUGINS composer.json README.md VERSIONS.md
echo "* Creating makeself installer"
test -d release/tmp && rm -rf release/tmp
mkdir release/tmp
cp -R spark.phar plugins README.md VERSIONS.md release/tmp/
cp -R spark.phar $PLUGINS README.md VERSIONS.md release/tmp/
pushd release/tmp &>/dev/null
makeself . ../../$DESTINATION/spark-$VERSION-dist.run "Spark $VERSION" ./spark.phar install &>/dev/null
popd &>/dev/null

View File

@ -11,5 +11,8 @@
- Rewritten script runner with proper variable substitution.
- Added utility libraries for HTTP requests (Guzzle), templating (Twig) and dotenv
support (symfony/dotenv, activates with environment).
- PHP REPL; execute PHP code interactively.
- Development mode; script the startup and shutdown of your projects development
environment, and have it start and stop with the dedicated project shell.
- Plugins in beta: com.noccy.pdo, com.noccy.pdo.shell, com.noccy.watcher.
- Plugins in alpha: com.noccy.apiclient.
- Plugins in alpha: com.noccy.apiclient, com.noccy.todo.

View File

@ -122,4 +122,6 @@ function get_filter(string $name, array $args=[]): null|FilterInterface|callable
$filter->setArguments($args);
}
return $filter;
}
}
require_once __DIR__."/http.php";

17
runtime/http.php Normal file
View File

@ -0,0 +1,17 @@
<?php
function fetch(string $url, array $options=[], bool $returnResponse=false) {
$client = new GuzzleHttp\Client();
$method = $options['method'] ?? 'GET';
$response = $client->request($method, $url, $options);
if ($returnResponse) {
return $response;
}
return (string)$response->getBody();
}