Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sarfraznawaz2005 committed May 21, 2018
1 parent 54a83fc commit 4a631da
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 40 deletions.
Binary file modified dist/floyer.phar
Binary file not shown.
8 changes: 5 additions & 3 deletions src/Commands/Deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ protected function init()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$configFile = '';

$io = new SymfonyStyle($input, $output);

if (!trim($input->getArgument(static::CONFIG_FILE))) {
Expand All @@ -102,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

if (!file_exists($configFile)) {
$io->writeln("<fg=red>'$configFile' does not exists!</>");
$io->writeln("<fg=red>'$configFile' does not exist!</>");
exit;
}

Expand All @@ -126,9 +128,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$driver = new $driver;
$connector = new $connector;

$connector->connect();
$connector->connect($options);
$driver->setIO($io);
$driver->init($connector);
$driver->init($connector, $options);

$isSync = $input->getOption(static::SYNC);
$isRollback = $input->getOption(static::ROLLBACK);
Expand Down
21 changes: 9 additions & 12 deletions src/Connectors/FTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,22 @@
use League\Flysystem\Adapter\Ftp as FtpAdapter;
use League\Flysystem\Filesystem;
use Sarfraznawaz2005\Floyer\Contracts\ConnectorInterface;
use Sarfraznawaz2005\Floyer\Traits\Options;

class FTP implements ConnectorInterface
{
use Options;

protected $connector = null;

function connect()
public function connect(array $options)
{
try {
$this->connector = new Filesystem(new FtpAdapter($this->getOptions()));
$this->connector = new Filesystem(new FtpAdapter($options));
} catch (\Exception $e) {
echo "\r\nError: {$e->getMessage()}\r\n";
exit;
}
}

function upload($path, $destination, $overwrite = true)
public function upload($path, $destination, $overwrite = true)
{
$destination = $destination . '/' . basename($path);
$destination = str_replace('//', '/', $destination);
Expand All @@ -45,22 +42,22 @@ function upload($path, $destination, $overwrite = true)
return $result;
}

function exists($path)
public function exists($path)
{
return $this->connector->has(basename($path));
}

function existsAt($path)
public function existsAt($path)
{
return $this->connector->has($path);
}

function delete($path)
public function delete($path)
{
$this->deleteAt(basename($path));
}

function deleteAt($path)
public function deleteAt($path)
{
try {
if (!is_dir($path)) {
Expand All @@ -73,7 +70,7 @@ function deleteAt($path)
}
}

function write($path, $contents, $overwrite = true)
public function write($path, $contents, $overwrite = true)
{
if ($overwrite && $this->exists($path)) {
$this->delete($path);
Expand All @@ -82,7 +79,7 @@ function write($path, $contents, $overwrite = true)
return $this->connector->write(basename($path), $contents);
}

function read($path)
public function read($path)
{
return $this->connector->read(basename($path));
}
Expand Down
4 changes: 1 addition & 3 deletions src/Connectors/SFTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ class SFTP extends FTP
{
protected $connector = null;

function connect()
public function connect(array $options)
{
try {

$options = $this->getOptions();

// see if key file exists
if (!trim($options['key_file']) || !is_file($options['key_file'])) {
throw new \Exception("Private key file: {$options['key_file']} doesn't exists.");
Expand Down
12 changes: 6 additions & 6 deletions src/Contracts/ConnectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

interface ConnectorInterface
{
function connect();
public function connect(array $options);

function upload($path, $destination, $overwrite = true);
public function upload($path, $destination, $overwrite = true);

function exists($path);
public function exists($path);

function delete($path);
public function delete($path);

function write($path, $contents, $overwrite = true);
public function write($path, $contents, $overwrite = true);

function read($path);
public function read($path);
}
24 changes: 12 additions & 12 deletions src/Contracts/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,54 +17,54 @@ interface DriverInterface
* @param SymfonyStyle $io
* @return null
*/
function setIO(SymfonyStyle $io);
public function setIO(SymfonyStyle $io);

/**
* Initialize.
* @param ConnectorInterface $connector
* @return
* @param array $options
*/
function init(ConnectorInterface $connector);
public function init(ConnectorInterface $connector, array $options);

/**
* Starts deployment process
*/
function processDeployment();
public function processDeployment();

/**
* Synchronize last local commit id with remote revision file.
*/
function sync();
public function sync();

/**
* Rollback previous deployment.
*/
function rollback();
public function rollback();

/**
* List files deployed in previous deployment.
*/
function history();
public function history();

/**
* Gets last local commit ID.
*/
function lastCommitIdLocal();
public function lastCommitIdLocal();

/**
* Gets last remoate/revision file commit ID.
*/
function lastCommitIdRemote();
public function lastCommitIdRemote();

/**
* Lists file to upload.
*/
function filesToUpload();
public function filesToUpload();

/**
* Creates zip file of files to upload.
*/
function createZipOfChangedFiles();
public function createZipOfChangedFiles();

function checkDirty();
public function checkDirty();
}
6 changes: 2 additions & 4 deletions src/Drivers/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
use RecursiveIteratorIterator;
use Sarfraznawaz2005\Floyer\Contracts\ConnectorInterface;
use Sarfraznawaz2005\Floyer\Traits\IO;
use Sarfraznawaz2005\Floyer\Traits\Options;
use ZipArchive;

Abstract class Base
{
use IO;
use Options;

protected $lastCommitId = '';
protected $lastCommitIdRemote = '';
Expand All @@ -39,15 +37,15 @@
protected $filesChanged = [];
protected $filesToExclude = [];

public function init(ConnectorInterface $connector)
public function init(ConnectorInterface $connector, array $options)
{
$this->dir = getcwd() . DIRECTORY_SEPARATOR;

$this->connector = $connector;

$this->lastCommitId = $this->lastCommitIdLocal();

$this->options = $this->getOptions();
$this->options = $options;

$this->revFile = $this->options['revision_file_name'];

Expand Down

0 comments on commit 4a631da

Please sign in to comment.