Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v1.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyshaw committed Nov 3, 2015
2 parents c58d8fe + b19c276 commit aaeb9d1
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 82 deletions.
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Working on Magento client sites typically requires a fresh copy of the productio
Download the phar.

```
wget https://github.com/meanbee/magedbm/releases/download/v.1.3.0/magedbm.phar
wget https://s3-eu-west-1.amazonaws.com/magedbm-releases/magedbm.phar
```

Make sure it's executable
Expand Down
12 changes: 8 additions & 4 deletions src/Meanbee/Magedbm/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
use Meanbee\Magedbm\Command\ListCommand;
use Meanbee\Magedbm\Command\PutCommand;

class Application extends \Symfony\Component\Console\Application {
class Application extends \Symfony\Component\Console\Application
{

const APP_NAME = "Magedbm";
const APP_VERSION = "1.0.0";

protected $autoloader;

public function __construct($autoloader = null) {
public function __construct($autoloader = null)
{
parent::__construct(self::APP_NAME, self::APP_VERSION);

if ($autoloader !== null) {
Expand All @@ -28,11 +30,13 @@ public function __construct($autoloader = null) {
$this->add(new PutCommand());
}

public function getAutoloader() {
public function getAutoloader()
{
return $this->autoloader;
}

public function setAutoloader($autoloader) {
public function setAutoloader($autoloader)
{
$this->autoloader = $autoloader;

return $this;
Expand Down
39 changes: 23 additions & 16 deletions src/Meanbee/Magedbm/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class BaseCommand extends Command {
class BaseCommand extends Command
{

const AWS_DIR_PATH = '/.aws';
const AWS_CREDENTIALS_PATH = '/.aws/credentials';
const AWS_CONFIG_PATH = '/.aws/config';
const APP_DIR_PATH = '/.magedbm';
const APP_CONFIG_PATH = '/.magedbm/config';
const TMP_PATH = '/tmp/magedbm';
const AWS_DIR_PATH = '/.aws';
const AWS_CREDENTIALS_PATH = '/.aws/credentials';
const AWS_CONFIG_PATH = '/.aws/config';
const APP_DIR_PATH = '/.magedbm';
const APP_CONFIG_PATH = '/.magedbm/config';
const TMP_PATH = '/tmp/magedbm';

/** @var InputInterface $input */
protected $input;
Expand All @@ -38,7 +39,8 @@ class BaseCommand extends Command {
*
* @return $this
*/
public function setInput(InputInterface $input) {
public function setInput(InputInterface $input)
{
$this->input = $input;

return $this;
Expand All @@ -49,7 +51,8 @@ public function setInput(InputInterface $input) {
*
* @return InputInterface
*/
public function getInput() {
public function getInput()
{
return $this->input;
}

Expand All @@ -60,7 +63,8 @@ public function getInput() {
*
* @return $this
*/
public function setOutput(OutputInterface $output) {
public function setOutput(OutputInterface $output)
{
$this->output = $output;

return $this;
Expand All @@ -71,7 +75,8 @@ public function setOutput(OutputInterface $output) {
*
* @return OutputInterface
*/
public function getOutput() {
public function getOutput()
{
return $this->output;
}

Expand Down Expand Up @@ -114,7 +119,7 @@ public function getS3Client($region = null)
try {
// Upload to S3.
$this->s3Client = S3Client::factory(array(
'region' => $region
'region' => $region
));
} catch (CredentialsException $e) {
$this->getOutput()->writeln('<error>AWS credentials failed</error>');
Expand All @@ -137,7 +142,7 @@ public function getConfig(InputInterface $input)
$config = $iniReader->readFile($this->getAppConfigPath());
$this->config = $config['default'];

foreach($input->getOptions() as $option => $value) {
foreach ($input->getOptions() as $option => $value) {
if ($value) {
$this->config[$option] = $value;
}
Expand All @@ -152,10 +157,11 @@ public function getConfig(InputInterface $input)
}

/**
* @param InputInterface $input
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function initialize(InputInterface $input, OutputInterface $output) {
protected function initialize(InputInterface $input, OutputInterface $output)
{
parent::initialize($input, $output);

$this->setInput($input);
Expand Down Expand Up @@ -201,7 +207,8 @@ protected function getAwsConfigPath()
/**
* Check for AWS Credentials
*/
protected function validateConfiguration() {
protected function validateConfiguration()
{
if ($this instanceof ConfigureCommand) {
return true;
}
Expand Down
11 changes: 6 additions & 5 deletions src/Meanbee/Magedbm/Command/ConfigureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function configure()
/**
* Execute the command.
*
* @param InputInterface $input
* @param InputInterface $input
* @param OutputInterface $output
*
* @throws \Exception
Expand All @@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
mkdir($this->getAwsDirPath());
}

if(!is_writeable($this->getAwsDirPath())) {
if (!is_writeable($this->getAwsDirPath())) {
$this->getOutput()->writeln('<error>Unable to write AWS credentials. Please manually add to ~/.aws/credentials');
exit;
}
Expand All @@ -90,7 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($input->getOption('key') && $input->getOption('secret')) {
$credentials = array(
'default' => array(
'aws_access_key_id' => $input->getOption('key'),
'aws_access_key_id' => $input->getOption('key'),
'aws_secret_access_key' => $input->getOption('secret')
)
);
Expand Down Expand Up @@ -136,8 +136,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
public function isConfigured()
{
if (file_exists($this->getAwsCredentialsPath()) && file_exists($this->getAwsConfigPath()) &&
file_exists($this->getAppConfigPath())) {
return true;
file_exists($this->getAppConfigPath())
) {
return true;
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Meanbee/Magedbm/Command/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function configure()
/**
* Execute the command.
*
* @param InputInterface $input
* @param InputInterface $input
* @param OutputInterface $output
*
* @throws \Exception
Expand Down
11 changes: 6 additions & 5 deletions src/Meanbee/Magedbm/Command/GetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function configure()
/**
* Execute the command.
*
* @param InputInterface $input
* @param InputInterface $input
* @param OutputInterface $output
*
* @throws \Exception
Expand All @@ -78,7 +78,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output,
'<question>Are you sure you wish to overwrite local database [y/n]?</question>',
false
)) {
)
) {
return;
}
}
Expand Down Expand Up @@ -151,7 +152,7 @@ protected function downloadBackup($file, $s3, $config, $input)
try {
$s3->getObject(array(
'Bucket' => $config['bucket'],
'Key' => $input->getArgument('name') . '/' . $file,
'Key' => $input->getArgument('name') . '/' . $file,
'SaveAs' => $this->getFilePath($file)
));
} catch (NoSuchKeyException $e) {
Expand Down Expand Up @@ -183,8 +184,8 @@ protected function backupImport($file, $input)
}

$params = array(
'filename' => $this->getFilePath($file),
'--compression' => 'gzip',
'filename' => $this->getFilePath($file),
'--compression' => 'gzip',
);

if ($input->getOption('drop-tables')) {
Expand Down
4 changes: 2 additions & 2 deletions src/Meanbee/Magedbm/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function configure()
/**
* Execute the command.
*
* @param InputInterface $input
* @param InputInterface $input
* @param OutputInterface $output
*
* @throws \Exception
Expand All @@ -61,7 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

foreach ($results as $item) {
$itemKeyChunks = explode('/', $item['Key']);
$this->getOutput()->writeln(sprintf('%s %dMB', array_pop($itemKeyChunks) , $item['Size'] / 1024 / 1024));
$this->getOutput()->writeln(sprintf('%s %dMB', array_pop($itemKeyChunks), $item['Size'] / 1024 / 1024));
}

if (!$results->count()) {
Expand Down
Loading

0 comments on commit aaeb9d1

Please sign in to comment.