Skip to content

Commit

Permalink
[ADD] Add version v1.10.0 and plugin v1.2.0. (#22)
Browse files Browse the repository at this point in the history
* Feature/diff command (#20)

* [ADD] Add diff command

- update AwsUpload handle diff / df agrs
- add DiffCommand

* [ADD] Add editor config file

* [ADD] Add RsyncCommands

- add interface to scope the const to define the available commands you can perform on rsync

* [MOD] Restructure Rsync to handle different commands

- update RsyncTest to test getExclude, upload and diff commands
- update DiffCommand to use  RsyncCommands
- update UploadCommand to use RsyncCommands

* [MOD] Update help message, add diff

* [MOD] Update CHANGELOG for diff command

* [MOD] Update phpdocs Rsync

* [MOD] Fix spacing

* [FIX] Fix no editor no sed (#21)

* [FIX] Fix case no $EDITOR variable present

- update SettingFile to get a default editor
- update tests for Envs and SettingFiles

* [FIX] Replace sed to activate aws-upload plugin

- change algorithm to activate plugin
- create test cases

* [REF] Extract getEditor from SettingFile to System

* [REF] Extract updatePluginLine from OhMyZsh::activate

* [FIX] Fix case * in diff

* [REF] Fix indetation issues

* WIP

* WIP

* [REF] Restructure OhMyZsh extract Zshrc

* WIP

* [MOD] Update CHANGELOG and and version in aws-upload

* WIP

* [FIX] Line ending unix

* [FIX] Line ending

* WIP

* WIP

* [MOD] Update autocomplete as well on selfupdate
  • Loading branch information
borracciaBlu authored Jun 19, 2018
1 parent 2403752 commit bedb47d
Show file tree
Hide file tree
Showing 37 changed files with 764 additions and 169 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
end_of_line = lf
trim_trailing_whitespace = true
22 changes: 16 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Change Log
All notable changes to this project will be documented in this file.

## 1.10.0
## Added
- Add new feature `aws-upload diff` to see files not yet in sync.
- Use `.editorconfig` to have clean files.

### Changed
- Refactor System\Rsync to handle multiple commands.
- Improve tests Rsync.
- Improve help section.

### Fixed
- Bug when no $EDITOR variable is defined.
- Bug sed error code m.

## 1.9.0 - 2017-09-05
### Added
Expand All @@ -17,9 +30,6 @@ All notable changes to this project will be documented in this file.
- Merge Check to SettingFile.
- Improve help section.

### Fixed
- namespace for tests

## 1.8.0 - 2017-07-27
### Added
- Add new feature `aws-upload autocomplete` to enable autocomplete in `aws-upload`.
Expand All @@ -32,7 +42,7 @@ All notable changes to this project will be documented in this file.
- Clean up the script section.

### Fixed
- namespace for tests
- Namespace for tests

## 1.7.2 - 2017-07-12
### Changed
Expand Down Expand Up @@ -144,7 +154,7 @@ All notable changes to this project will be documented in this file.
- Added `.travis.yml` `phpunit.xml.dist`.

## 0.0.2 - 2017-03-06
### Added
### Added
- Added LICENCE file for MIT.

### Changed
Expand All @@ -158,4 +168,4 @@ All notable changes to this project will be documented in this file.
- Added `composer.json`.
- Added Facilitator to print `help`, `banner`, `version`.
- Added Rsync to user `rsync`.
- Added SettingFolder to get `getHomeDir`, `getPath`.
- Added SettingFolder to get `getHomeDir`, `getPath`.
3 changes: 2 additions & 1 deletion aws-upload
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if (file_exists(__DIR__ . '/../../autoload.php')) {

use AwsUpload\AwsUpload;

$aws = new AwsUpload('1.9.0', '1.1.0');
$aws = new AwsUpload('1.10.0', '1.2.0');
$status = $aws->run();
exit($status);

5 changes: 3 additions & 2 deletions src/AwsUpload/AwsUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function __construct($version = 'test', $plugin = 'test')
'new' => array('new', 'n'),
'envs' => array('envs', 'e'),
'edit' => array('edit', 'E'),
'diff' => array('diff', 'df'),
'delete' => array('delete', 'rm'),
'copy' => array('copy', 'cp'),
'help' => array('help', 'h'),
Expand Down Expand Up @@ -121,7 +122,7 @@ public function run()
if ($this->args->verbose) {
$this->is_verbose = true;
}

if ($this->args->quiet) {
$this->is_quiet = true;
}
Expand Down Expand Up @@ -177,6 +178,7 @@ public function fetchArgsCmd()
'projs' => 'AwsUpload\Command\Projs',
'envs' => 'AwsUpload\Command\Envs',
'new' => 'AwsUpload\Command\New',
'diff' => 'AwsUpload\Command\Diff',
'edit' => 'AwsUpload\Command\Edit',
'copy' => 'AwsUpload\Command\Copy',
'delete' => 'AwsUpload\Command\Delete',
Expand All @@ -186,7 +188,6 @@ public function fetchArgsCmd()
'selfupdate' => 'AwsUpload\Command\SelfUpdate',
'autocomplete' => 'AwsUpload\Command\AutoComplete',
);

foreach ($cmdList as $arg => $cmdName) {
if ($this->args->{$arg} && empty($cmd)) {
$cmd = $cmdName;
Expand Down
34 changes: 18 additions & 16 deletions src/AwsUpload/Command/AutoCompleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ public function run()
$this->app->inline(' <b>•</b> Plugin already activated');
}


$this->app->inline("\nProcedure complete. Please reload the shell.");

system('zsh');

return Status::SUCCESS;
}

Expand Down Expand Up @@ -97,23 +99,23 @@ public function printSystemStatus()
$zsh = Zsh::isInstalled();
$omz = OhMyZsh::isInstalled();

$git_msg = " " .
CommonMessage::plot($git, $check) .
" Git \t" .
CommonMessage::plot($git, $labels);
$zsh_msg = " " .
CommonMessage::plot($zsh, $check) .
" Zsh \t" .
CommonMessage::plot($zsh, $labels);
$omz_msg = " " .
CommonMessage::plot($omz, $check) .
" Oh-my-zsh \t" .
CommonMessage::plot($omz, $labels);
$git_line = " " .
CommonMessage::plot($git, $check) .
" Git \t" .
CommonMessage::plot($git, $labels);
$zsh_line = " " .
CommonMessage::plot($zsh, $check) .
" Zsh \t" .
CommonMessage::plot($zsh, $labels);
$omz_line = " " .
CommonMessage::plot($omz, $check) .
" Oh-my-zsh \t" .
CommonMessage::plot($omz, $labels);

$this->app->inline("");
$this->app->inline($git_msg);
$this->app->inline($zsh_msg);
$this->app->inline($omz_msg);
$this->app->inline($git_line);
$this->app->inline($zsh_line);
$this->app->inline($omz_line);
$this->app->inline("");
}

Expand Down
2 changes: 1 addition & 1 deletion src/AwsUpload/Command/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getConfirmation()
{
$this->app->inline("<r>Are you sure you want delete " . $this->key . "?(y|n)</r>");

$handle = fopen("php://stdin","r");
$handle = fopen("php://stdin", "r");
$line = fgets($handle);
fclose($handle);

Expand Down
93 changes: 93 additions & 0 deletions src/AwsUpload/Command/DiffCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/**
* aws-upload - 🌈 A delicious CLI Tool for uploading files to ec2
*
* This source file is subject to the MIT license that is bundled
* with this package in the file LICENSE.
*
* @author Marco Buttini <[email protected]>
* @copyright 2017 Marco Buttini
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/

namespace AwsUpload\Command;

use AwsUpload\Model\Status;
use AwsUpload\System\Rsync;
use AwsUpload\Setting\SettingFile;
use AwsUpload\Message\RsyncMessage;
use AwsUpload\System\RsyncCommands;

class DiffCommand extends FileCommand
{
/**
* Property true if app is simulate.
*
* @var bool
*/
public $is_simulate;

/**
* Property true if app is verbose.
*
* @var bool
*/
public $is_verbose;

/**
* @var string
*/
public $key;

/**
* @var string
*/
public $proj;

/**
* @var string
*/
public $env;

public function init()
{
$this->key = $this->app->args->getFirst('diff');
$this->is_verbose = $this->app->args->verbose;
$this->is_simulate = $this->app->args->simulate;

list($proj, $env) = explode('.', $this->key);
$this->proj = $proj;
$this->env = $env;
}

/**
* Method to run the rsync cmd.
*
* @return mixed The status code.
*/
public function exec()
{
$settings = SettingFile::getObject($this->key);

$rsync = new Rsync($settings);
$rsync->setVerbose($this->is_verbose);
$rsync->setAction(RsyncCommands::DIFF);

$msg = RsyncMessage::banner($this->proj, $this->env, $rsync->cmd);
$this->app->inline($msg);

if ($this->is_simulate) {
$this->app->inline($rsync->getCmd());
return $this->simulate();
}

$rsync->run();
}

public function simulate()
{
$this->msg = 'Simulation mode' . "\n";

return $this->handleSuccess();
}
}
5 changes: 5 additions & 0 deletions src/AwsUpload/Command/SelfUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace AwsUpload\Command;

use AwsUpload\Model\Status;
use AwsUpload\System\OhMyZsh;

class SelfUpdateCommand extends BasicCommand
{
Expand All @@ -27,6 +28,10 @@ public function run()
system('composer -vvv global require aws-upload/aws-upload');
$this->app->inline("Self-update completed");

if (OhMyZsh::isPluginActive()) {
system('aws-upload autocomplete');
}

return Status::SUCCESS;
}
}
2 changes: 2 additions & 0 deletions src/AwsUpload/Command/UploadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use AwsUpload\System\Rsync;
use AwsUpload\Setting\SettingFile;
use AwsUpload\Message\RsyncMessage;
use AwsUpload\System\RsyncCommands;

class UploadCommand extends FileCommand
{
Expand Down Expand Up @@ -76,6 +77,7 @@ public function exec()

$rsync = new Rsync($settings);
$rsync->setVerbose($this->is_verbose);
$rsync->setAction(RsyncCommands::UPLOAD);

$msg = RsyncMessage::banner($this->proj, $this->env, $rsync->cmd);
$this->app->inline($msg);
Expand Down
36 changes: 18 additions & 18 deletions src/AwsUpload/Message/CheckMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,44 @@ public static function report($report)
$local_exists = CommonMessage::plot($report['local_exists'], $exist_labels);

// Json
$msg = "Checking...\n\n"
. " <b>File analysing:</b>\n"
. " <y>" . $report['path'] . "</y>" . "\n"
. " " . $check_json . " Json " . $is_valid_json . "\n"
. " " . $report['error_json'];
$text = "Checking...\n\n" .
" <b>File analysing:</b>\n" .
" <y>" . $report['path'] . "</y>" . "\n" .
" " . $check_json . " Json " . $is_valid_json . "\n" .
" " . $report['error_json'];

// Pem
$msg .= "\n"
. " <b>Pem File:</b>\n"
. " <y>" . $report['pem'] . "</y>\n"
. " " . $check_pem . " Pem " . $pem_exists . "\n";
$text .= "\n" .
" <b>Pem File:</b>\n" .
" <y>" . $report['pem'] . "</y>\n" .
" " . $check_pem . " Pem " . $pem_exists . "\n";

if ($report['pem_exists']) {
$msg .= " " . $check_400 . " Pem Perm " . $is_400_perms . "\n";
$text .= " " . $check_400 . " Pem Perm " . $is_400_perms . "\n";

if (!$report['is_400']) {
$msg .= ' Try to type: chmod 400 ' . $report['pem'] . "\n";
$text .= ' Try to type: chmod 400 ' . $report['pem'] . "\n";
}
}

// Local
$msg .= "\n"
. " <b>Local Folder:</b>\n"
. " <y>" . $report['local'] . "</y>" . "\n"
. " " . $check_loc . " Folder " . $local_exists . "\n";
$text .= "\n" .
" <b>Local Folder:</b>\n" .
" <y>" . $report['local'] . "</y>" . "\n" .
" " . $check_loc . " Folder " . $local_exists . "\n";

return $msg;
return $text;
}

public static function noArgs()
{
$msg = "It seems that you don't proper arguments for this command.\n\n" .
$text = "It seems that you don't proper arguments for this command.\n\n" .

"<y>How to use check:</y>\n\n" .
" <g>aws-upload check <key></g>\n" .
" <b>E.g.:</b> aws-upload check blog.dev\n\n" .
"\n";

return $msg;
return $text;
}
}
4 changes: 2 additions & 2 deletions src/AwsUpload/Message/CopyMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class CopyMessage implements ArgCommandMessage
{
public static function noArgs()
{
$msg = "It seems that you don't proper arguments for this command.\n\n" .
$text = "It seems that you don't proper arguments for this command.\n\n" .

"<y>How to use copy:</y>\n\n" .
" <g>aws-upload copy <src> <dest></g>\n" .
" <b>E.g.:</b> aws-upload copy blog.dev blog.prod\n\n" .
"\n";

return $msg;
return $text;
}
}
Loading

0 comments on commit bedb47d

Please sign in to comment.