Skip to content

Commit

Permalink
Fix config key mismatch, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Tekill committed Aug 31, 2017
1 parent 3af1194 commit f336ae6
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 8 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

EnvDiff is tool to compare environment keys to find the difference between .env files and actualize them.

![Example cast](https://j.gifs.com/y8RGA6.gif)

# Installation

```
composer install tekill/env-diff
composer require tekill/env-diff
```

## Manual running
Expand Down Expand Up @@ -129,7 +131,7 @@ check_run() {
echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
}
# Aclualize env files if the `env.dist` file gets changed
# Actualize env files if the `env.dist` file gets changed
check_run env.dist "php ./vendor/bin/env-diff aclualize"
```

Expand Down
Empty file modified env-diff
100644 → 100755
Empty file.
4 changes: 3 additions & 1 deletion src/Composer/ScriptHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

class ScriptHandler
{
const CONFIG_KEY = 'lf-env-diff';

/**
* @param Event $event
*
Expand Down Expand Up @@ -54,7 +56,7 @@ private static function extractConfigs(Event $event)
{
$extras = $event->getComposer()->getPackage()->getExtra();

$configs = isset($extras['lf-diff-env']) ? $extras['lf-diff-env'] : [[]];
$configs = isset($extras[self::CONFIG_KEY]) ? $extras[self::CONFIG_KEY] : [[]];

if (!is_array($configs)) {
throw new InvalidArgumentException(
Expand Down
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Config
{
const DEFAULT_TARGET = '.env';
CONST DEFAULT_DIST = '.env.dist';
const DEFAULT_DIST = '.env.dist';

/** @var string */
private $dist;
Expand Down
5 changes: 4 additions & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
use LF\EnvDiff\Console\Command\ActualizeCommand;
use LF\EnvDiff\Console\Command\DiffCommand;
use Symfony\Component\Console\Application as BaseApplication;
use Symfony\Component\Console\Exception\LogicException;

class Application extends BaseApplication
{
/**
* {@inheritdoc}
*
* @throws LogicException
*/
public function __construct()
{
parent::__construct('Env diff', '1.0.2');
parent::__construct('Env diff', '1.0.3');

$this->setAutoExit(true);
$this->add(new DiffCommand('diff'));
Expand Down
5 changes: 5 additions & 0 deletions src/Console/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use LF\EnvDiff\IO\ConsoleIO;
use LF\EnvDiff\Processor;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -25,6 +26,8 @@ protected function configure()

/**
* {@inheritdoc}
*
* @throws InvalidArgumentException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Expand All @@ -40,6 +43,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
* @param InputInterface $input
*
* @return Config
*
* @throws InvalidArgumentException
*/
private function createConfig(InputInterface $input)
{
Expand Down
5 changes: 5 additions & 0 deletions src/Console/Command/ActualizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

namespace LF\EnvDiff\Console\Command;

use InvalidArgumentException;
use LF\EnvDiff\Config;
use LF\EnvDiff\Processor;
use RuntimeException;

class ActualizeCommand extends AbstractCommand
{
/**
* @param Processor $processor
* @param Config $config
*
* @throws RuntimeException
* @throws InvalidArgumentException
*/
protected function doExecute(Processor $processor, Config $config)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Console/Command/DiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LF\EnvDiff\Console\Command;

use InvalidArgumentException;
use LF\EnvDiff\Config;
use LF\EnvDiff\Processor;

Expand All @@ -10,6 +11,8 @@ class DiffCommand extends AbstractCommand
/**
* @param Processor $processor
* @param Config $config
*
* @throws InvalidArgumentException
*/
protected function doExecute(Processor $processor, Config $config)
{
Expand Down
3 changes: 3 additions & 0 deletions src/IO/ConsoleIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LF\EnvDiff\IO;

use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -52,6 +53,8 @@ public function isInteractive()

/**
* {@inheritdoc}
*
* @throws RuntimeException
*/
public function ask($question, $default = null)
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Composer/ScriptHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public function provideInvalidConfiguration()
{
return [
'invalid type' => [
['lf-diff-env' => 'not an array'],
['lf-env-diff' => 'not an array'],
'The extra.lf-env-diff setting must be an array or a configuration object',
],
'invalid type for multiple configs' => [
['lf-diff-env' => ['not an array']],
['lf-env-diff' => ['not an array']],
'The extra.lf-env-diff setting must be an array of configuration objects',
],
];
Expand Down Expand Up @@ -76,7 +76,7 @@ public function provideValidConfiguration()
return [
[
[
'lf-diff-env' => [
'lf-env-diff' => [
[
'dist' => 'fixtures/difference/valid/identical/.env.dist',
'target' => 'fixtures/difference/valid/identical/.env'
Expand Down

0 comments on commit f336ae6

Please sign in to comment.