Skip to content

Commit

Permalink
Update configuration and tokens (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmleroux authored Feb 18, 2020
1 parent 818d81b commit c916c07
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ bin/phpspec
bin
app/console
app/logs/
!config/example.yml
config/*
1 change: 1 addition & 0 deletions .php_cs.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
->in(__DIR__);

return PhpCsFixer\Config::create()
->setUsingCache(false)
->setRules([
'@PSR2' => true,
'linebreak_after_opening_tag' => true,
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ before_install:

install:
- composer install --prefer-dist --no-interaction
- curl http://get.sensiolabs.org/php-cs-fixer.phar -o php-cs-fixer

script:
- bin/phpspec run
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ An example of crontab to push new keys every friday and create pull requests eve
0 5 * * 1 cd /path/to/nelson/ && app/console nelson:push-translation-keys > /tmp/nelson_push.log 2>&1
```

## Testing

You can use the shipped docker container to develop and test.

Launch specs in the docker container:
```
docker-compose run --rm php bin/console phpspec run
```

Launch a command with XDebug:
```
PHP_XDEBUG_ENABLED=1 docker-compose run --rm php app/console nelson:refresh-packages --config_file=community-1.x-2.x.yml
```

Automatically fix your code style:
```
docker-compose run --rm php bin/php-cs-fixer fix --config=.php_cs.php
```

## Copyrights

Thanks to [Bouletmaton](http://www.zanorg.net/bouletmaton/) for the avatar ([bouletcorp.com](http://www.bouletcorp.com/), [zanorg.com](http://www.zanorg.com/))
Thanks to [Bouletmaton](http://www.zanorg.net/bouletmaton/) for the avatar ([bouletcorp.com](http://www.bouletcorp.com/),
[zanorg.com](http://www.zanorg.com/))
9 changes: 5 additions & 4 deletions app/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@ public function __construct($name = 'crowdin', $version = 'UNKNOWN')
$this->registerCommands();

$input = new ArgvInput();
$configFile = $input->getParameterOption(['--config_file', '-c'], getenv('CROWDIN_CONFIG') ?: 'config.yml');
$configFilename = $input->getParameterOption(['--config_file', '-c'], getenv('CROWDIN_CONFIG') ?: 'config.yml');
$configFilePath = sprintf(__DIR__ . '/../config/%s', $configFilename);

if (!file_exists(sprintf('%s%s%s', __DIR__, DIRECTORY_SEPARATOR, $configFile))) {
if (!file_exists(sprintf($configFilePath))) {
$output = new ConsoleOutput();
$output->writeln(sprintf(
"\n The file %s%s%s was not found!".
"\n You need to create your own configuration file.".
"\n You can use --config_file[=CONFIG_FILE] to change default configuration file.\n",
__DIR__,
DIRECTORY_SEPARATOR,
$configFile
$configFilePath
));
} else {
$loader = new YamlFileLoader($this->container, new FileLocator(__DIR__));
$loader->load($configFile);
$loader->load($configFilePath);
$this->container->compile();
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ services:
volumes:
- './:/srv/nelson'
working_dir: '/srv/nelson'
environment:
PHP_IDE_CONFIG: 'serverName=nelson-cli'
PHP_XDEBUG_ENABLED: "${PHP_XDEBUG_ENABLED:-0}"
XDEBUG_CONFIG: 'remote_host=172.17.0.1'
18 changes: 3 additions & 15 deletions src/Akeneo/System/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use Psr\Log\LoggerInterface;

/**
* Class Executor
*
* @author Nicolas Dupont <[email protected]>
* @copyright 2016 Akeneo SAS (http://www.akeneo.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Expand All @@ -19,24 +17,18 @@ class Executor
/** @var string */
protected $logFile;

/**
* @param LoggerInterface $logger
* @param string $logFile
*/
public function __construct(LoggerInterface $logger, $logFile)
public function __construct(LoggerInterface $logger, string $logFile)
{
$this->logger = $logger;
$this->logFile = $this->getAbsolutePath($logFile);
}

/**
* @param string $command
*
* @throws \Exception
*
* @return array
*/
public function execute($command, $returnResult = false)
public function execute(string $command, bool $returnResult = false)
{
$returnVar = null;
$output = [];
Expand Down Expand Up @@ -74,12 +66,8 @@ public function execute($command, $returnResult = false)

/**
* Allow user to put relative path, set it absolute from main directory.
*
* @param string $logFile
*
* @return string
*/
protected function getAbsolutePath($logFile)
protected function getAbsolutePath(string $logFile): string
{
if (!preg_match('/^\//', $logFile)) {
$logFile = sprintf('%s%s..%s..%s..%s%s',
Expand Down
8 changes: 6 additions & 2 deletions src/Akeneo/System/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ class Translator extends BaseTranslator
/**
* {@inheritdoc}
*/
public function __construct($locale, MessageSelector $selector = null, $cacheDir = null, $debug = false)
{
public function __construct(
string $locale,
?MessageSelector $selector = null,
?string $cacheDir = null,
?bool $debug = false
) {
parent::__construct($locale, $selector, $cacheDir, $debug);

$this->addLoader('yaml', new YamlFileLoader());
Expand Down

0 comments on commit c916c07

Please sign in to comment.