Skip to content

Commit

Permalink
Merge branch 'v1.0.3' into 'main'
Browse files Browse the repository at this point in the history
1-1-0

See merge request fluxlabs/flux-eco/source-downloader!10
  • Loading branch information
mstuder committed Apr 3, 2022
2 parents c32da3b + 8625fbb commit ebb473b
Show file tree
Hide file tree
Showing 19 changed files with 189 additions and 89 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## [1.1.0]
- change: added additional functional usage

## [1.0.8]
- fix: git - directory check for deletion

Expand Down
18 changes: 0 additions & 18 deletions bin/downloadSources.php

This file was deleted.

12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "flux-eco/source-downloader",
"description": "Component for flux-capacitor apps developed by fluxlabs",
"version": "1.0.8",
"version": "1.1.0",
"type": "flux-eco",
"keywords": [
"flux-eco",
Expand All @@ -23,15 +23,25 @@
},
"require": {
"flux-eco/shell-executor": ">=0.0.1",
"flux-eco/dot-env": ">=0.0.1",
"php": ">=7.4",
"ext-curl": "*",
"ext-json": "*",
"ext-yaml": "*"
},
"autoload": {
"files": [
"fn/downloadSources.php",
"fn/getEnvSourceDownloaderGitFullClone.php",
"fn/getEnvSourceDownloaderSourceListFilePath.php",
"fn/getEnvSourceDownloaderVolumePath.php"
],
"psr-4": {
"FluxEco\\SourceDownloader\\": [
"src/"
],
"fluxy\\": [
"fn/"
]
}
},
Expand Down
82 changes: 68 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions examples/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SOURCE_DOWNLOADER_SOURCE_LIST_FILE_PATH=sourceList.yaml
SOURCE_DOWNLOADER_VOLUME_PATH=/tmp
SOURCE_DOWNLOADER_GIT_FULL_CLONE=0
15 changes: 15 additions & 0 deletions examples/downloadSources.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';

use FluxEco\SourceDownloader;
use FluxEco\DotEnv;

DotEnv\Api::new()->load(__DIR__);

$sourceListFile = getenv(SourceDownloader\Env::SOURCE_LIST_FILE_PATH);
$volumePath = getenv(SourceDownloader\Env::VOLUME_PATH);
$gitGetFullClone = getenv(SourceDownloader\Env::GIT_FULL_CLONE);

$api = SourceDownloader\Api::new($gitGetFullClone);
$api->downloadSources($sourceListFile, $volumePath);
11 changes: 11 additions & 0 deletions examples/downloadSourcesFunctional.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';

fluxy\loadDotEnv(__DIR__);

fluxy\downloadSources(
fluxy\getEnvSourceDownloaderSourceListFilePath(),
fluxy\getEnvSourceDownloaderVolumePath(),
fluxy\getEnvSourceDownloaderGitFullClone()
);
1 change: 0 additions & 1 deletion examples/ilias/run.sh

This file was deleted.

File renamed without changes.
11 changes: 11 additions & 0 deletions fn/downloadSources.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace fluxy;

use FluxEco\SourceDownloader\Api;

function downloadSources(string $sourceListFile = null, ?string $volumePath = null, bool $gitGetFullClone = true)
{
$api = Api::new($gitGetFullClone);
$api->downloadSources($sourceListFile, $volumePath);
}
10 changes: 10 additions & 0 deletions fn/getEnvSourceDownloaderGitFullClone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace fluxy;

use FluxEco\SourceDownloader;

function getEnvSourceDownloaderGitFullClone() : bool
{
return (bool) getenv(SourceDownloader\Env::GIT_FULL_CLONE);
}
10 changes: 10 additions & 0 deletions fn/getEnvSourceDownloaderSourceListFilePath.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace fluxy;

use FluxEco\SourceDownloader;

function getEnvSourceDownloaderSourceListFilePath()
{
return getenv(SourceDownloader\Env::SOURCE_LIST_FILE_PATH);
}
10 changes: 10 additions & 0 deletions fn/getEnvSourceDownloaderVolumePath.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace fluxy;

use FluxEco\SourceDownloader;

function getEnvSourceDownloaderVolumePath(): string
{
return getenv(SourceDownloader\Env::VOLUME_PATH);
}
25 changes: 0 additions & 25 deletions src/Adapters/Api/SourceDownloaderApi.php

This file was deleted.

30 changes: 6 additions & 24 deletions src/Adapters/Configs/Outbounds.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,15 @@

class Outbounds implements Ports\Configs\Outbounds
{
private string $sourceListFile;
private string $volumePath;
private bool $gitGetFullClone;

private function __construct(string $sourceListFile, string $volumePath, bool $gitGetFullClone)
private function __construct(bool $gitGetFullClone)
{
$this->sourceListFile = $sourceListFile;
$this->volumePath = $volumePath;
$this->gitGetFullClone = $gitGetFullClone;
}

public static function new(
?string $sourceListFile = null,
?string $volumePath = null,
?bool $gitGetFullClone = null
) : self {
if (is_null($sourceListFile) === true) {
$sourceListFile = getenv(Env::SOURCE_LIST_FILE);
}
if (is_null($volumePath) === true) {
$volumePath = getenv(Env::VOLUME_PATH);
}
if (is_null($gitGetFullClone) === true) {
$gitGetFullClone = getenv(Env::GIT_FULL_CLONE);
}

return new self($sourceListFile, $volumePath, $gitGetFullClone);
public static function new(bool $gitGetFullClone) : self {
return new self($gitGetFullClone);
}

public function getShellExecutorClient() : Ports\ShellExecutor\ShellExecutorClient
Expand All @@ -45,12 +27,12 @@ public function getGitFullClone() : bool
return $this->gitGetFullClone;
}

public function getSourceList() : array
public function getSourceList(string $sourceListFile, ?string $volumePath = null) : array
{
$sources = yaml_parse(file_get_contents($this->sourceListFile));
$sources = yaml_parse(file_get_contents($sourceListFile));
$transformedSources = [];
foreach ($sources as $source) {
$source['directoryPath'] = $this->volumePath . $source['directoryPath'];
$source['directoryPath'] = $volumePath . $source['directoryPath'];
$transformedSources[] = $source;
}
return $transformedSources;
Expand Down
25 changes: 25 additions & 0 deletions src/Api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace FluxEco\SourceDownloader;

use FluxEco\SourceDownloader\{Adapters, Core\Ports};

class Api
{
private Ports\Service $service;

private function __construct(Ports\Service $service)
{
$this->service = $service;
}

public static function new(bool $gitGetFullClone = true) : self
{
$apiGatewayService = Ports\Service::new(Adapters\Configs\Outbounds::new($gitGetFullClone));
return new self($apiGatewayService);
}

public function downloadSources(string $sourceListFile = null, ?string $volumePath = null) {
$this->service->downloadSources($sourceListFile, $volumePath);
}
}
2 changes: 1 addition & 1 deletion src/Core/Ports/Configs/Outbounds.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ interface Outbounds
{
public function getShellExecutorClient() : Ports\ShellExecutor\ShellExecutorClient;
public function getGitFullClone() : bool;
public function getSourceList() : array;
public function getSourceList(string $sourceListFile, ?string $volumePath = null) : array;
}
4 changes: 2 additions & 2 deletions src/Core/Ports/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static function new(Configs\Outbounds $outbounds) : self
return new self($outbounds);
}

public function downloadSources()
public function downloadSources(string $sourceListFile = null, ?string $volumePath = null)
{
$sourceList = $this->outbounds->getSourceList();
$sourceList = $this->outbounds->getSourceList($sourceListFile, $volumePath);

foreach ($sourceList as $source) {
$process = Processes\DownloadProcess::new($this->outbounds);
Expand Down
Loading

0 comments on commit ebb473b

Please sign in to comment.