Skip to content

Commit

Permalink
Fixed index.html render to use flysystem
Browse files Browse the repository at this point in the history
Signed-off-by: Webysther Nunes <webysther@gmail.com>
  • Loading branch information
webysther committed Jun 10, 2018
1 parent bbd9c18 commit 1dcae96
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ coverage
vendor
legacy
/.env
cs_fixer*
2 changes: 1 addition & 1 deletion src/Command/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
*/
public function init(InputInterface $input, OutputInterface $output)
{
if(isset($this->input) && isset($this->output)){
if (isset($this->input) && isset($this->output)) {
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function bootstrap():void
*/
protected function flushProviders():Clean
{
if (!$this->filesystem->hasFile(self::MAIN)){
if (!$this->filesystem->hasFile(self::MAIN)) {
return $this;
}

Expand Down
13 changes: 9 additions & 4 deletions src/Command/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,17 @@ protected function generateHtml():Create
$maintainerLicense = getenv('MAINTAINER_LICENSE');
$tz = getenv('TZ');
$synced = getenv('SLEEP');
$exists = file_exists(getenv('PUBLIC_DIR').'/packages.json');
$lastModified = filemtime(getenv('PUBLIC_DIR').'/packages.json');
$file = $this->filesystem->getGzName('packages.json');
$exists = $this->filesystem->hasFile($file);

$lastModified = false;
if ($exists) {
$lastModified = $this->filesystem->getTimestamp($file);
}

$lastSync = null;
if ($exists && false !== $lastModified){
$moment = new \Moment\Moment('now', $tz);
if ($exists && false !== $lastModified) {
$moment = new \Moment\Moment($lastModified, $tz);
$momentJs = new \Moment\CustomFormats\MomentJs();
$format = $momentJs->format("dddd, MMMM Do YYYY HH:mm:ss ZZ");
$lastSync = $moment->format($format);
Expand Down
14 changes: 13 additions & 1 deletion src/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected function symlink(string $file):Filesystem
return $this;
}

if (strpos($link, 'vfs://') !== false){
if (strpos($link, 'vfs://') !== false) {
return $this;
}

Expand Down Expand Up @@ -281,6 +281,18 @@ public function delete(string $fileOrDirectory):Filesystem
return $this;
}

/**
* Return the timestamp of modification
*
* @param string $path
*
* @return int
*/
public function getTimestamp(string $path):int
{
return $this->filesystem->getTimestamp($path);
}

/**
* Calculates SHA256.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function getPackagesJson(stdClass $json, string $name = 'archived'):st
$newJson->{'provider-includes'} = new stdClass();

foreach ($json->{'provider-includes'} as $item => $value) {
if (strpos((string) $item, $name.'$') === false){
if (strpos((string) $item, $name.'$') === false) {
continue;
}

Expand Down
19 changes: 15 additions & 4 deletions tests/fixture/.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,28 @@ APP_NAME='Packagist Mirror'
# Application version
APP_VERSION='1.0.0'

# Language
APP_COUNTRY_NAME='Brazil'
APP_COUNTRY_CODE='br'

# Folder used to save the files
PUBLIC_DIR=public

# Maintainer information
MAINTAINER_MIRROR='Webysther'
MAINTAINER_PROFILE='https://github.com/Webysther'
MAINTAINER_REPO='https://github.com/Webysther/packagist-mirror'
MAINTAINER_LICENSE='MIT License'

# Main mirror used to get providers
MAIN_MIRROR=https://packagist.org

# Data mirror used to download repositories data
DATA_MIRROR=https://packagist.jp,https://packagist.com.br,https://packagist.phpcomposer.com

# URI of your mirror
URL=packagist.com.br
# Japan - https://packagist.jp
# Indonesia - https://packagist.phpindonesia.id
# Brazil - https://packagist.com.br
# China - https://packagist.phpcomposer.com (not fully compatible - too much broken packages)
DATA_MIRROR=https://packagist.jp,https://packagist.com.br,https://packagist.phpindonesia.id

# Max connections by mirror
MAX_CONNECTIONS=25

0 comments on commit 1dcae96

Please sign in to comment.