Initiale Version

This commit is contained in:
Jan Unger
2016-08-16 21:20:53 +02:00
commit 88cf71d772
10930 changed files with 1708903 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache/files
matrix:
include:
- php: 5.3
env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
- php: 5.4
- php: 5.5
- php: 5.6
- php: 7.0
env: DEPENDENCIES=dev
- php: hhvm
before_script:
- if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
- composer update $COMPOSER_FLAGS
script: phpunit --coverage-text --coverage-clover=coverage.clover
after_script:
- wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover

View File

@@ -0,0 +1,27 @@
## 2.1.2 (2015-11-10)
* Mark symfony/yaml 3 as supported to be compatible with Symfony 3
* Dropped support for symfony/yaml 2.2 and older (which are long unmaintained)
* Added testing on PHP 7
## 2.1.1 (2015-06-03)
* Removed usage of a deprecated way to use the Yaml parser
* Added a more detailed exception message when the top-level key is missing
## 2.1.0 (2013-12-07)
* Move most of the logic to a ``Processor`` class which does not depend on the composer event and package. Ref #30
* Add the support of existing empty file for Capifony compatibility
* Add the support of multiple managed files
* Preserve other top-level keys than the configured one in the file
* Add a rename map used to rename parameters when updating the parameters file
* Add the possibility to use another top-level key than ``parameters``
## 2.0.0 (2013-04-06)
* BC BREAK the env map has been changed, inverting the keys and the values. Refs #14
## 1.0.0 (2013-04-06)
Initial release of the library.

View File

@@ -0,0 +1,19 @@
Copyright (c) 2012 Christophe Coevoet
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,167 @@
<?php
namespace Incenteev\ParameterHandler;
use Composer\IO\IOInterface;
use Symfony\Component\Yaml\Inline;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Yaml;
class Processor
{
private $io;
public function __construct(IOInterface $io)
{
$this->io = $io;
}
public function processFile(array $config)
{
$config = $this->processConfig($config);
$realFile = $config['file'];
$parameterKey = $config['parameter-key'];
$exists = is_file($realFile);
$yamlParser = new Parser();
$action = $exists ? 'Updating' : 'Creating';
$this->io->write(sprintf('<info>%s the "%s" file</info>', $action, $realFile));
// Find the expected params
$expectedValues = $yamlParser->parse(file_get_contents($config['dist-file']));
if (!isset($expectedValues[$parameterKey])) {
throw new \InvalidArgumentException(sprintf('The top-level key %s is missing.', $parameterKey));
}
$expectedParams = (array) $expectedValues[$parameterKey];
// find the actual params
$actualValues = array_merge(
// Preserve other top-level keys than `$parameterKey` in the file
$expectedValues,
array($parameterKey => array())
);
if ($exists) {
$existingValues = $yamlParser->parse(file_get_contents($realFile));
if ($existingValues === null) {
$existingValues = array();
}
if (!is_array($existingValues)) {
throw new \InvalidArgumentException(sprintf('The existing "%s" file does not contain an array', $realFile));
}
$actualValues = array_merge($actualValues, $existingValues);
}
$actualValues[$parameterKey] = $this->processParams($config, $expectedParams, (array) $actualValues[$parameterKey]);
if (!is_dir($dir = dirname($realFile))) {
mkdir($dir, 0755, true);
}
file_put_contents($realFile, "# This file is auto-generated during the composer install\n" . Yaml::dump($actualValues, 99));
}
private function processConfig(array $config)
{
if (empty($config['file'])) {
throw new \InvalidArgumentException('The extra.incenteev-parameters.file setting is required to use this script handler.');
}
if (empty($config['dist-file'])) {
$config['dist-file'] = $config['file'].'.dist';
}
if (!is_file($config['dist-file'])) {
throw new \InvalidArgumentException(sprintf('The dist file "%s" does not exist. Check your dist-file config or create it.', $config['dist-file']));
}
if (empty($config['parameter-key'])) {
$config['parameter-key'] = 'parameters';
}
return $config;
}
private function processParams(array $config, array $expectedParams, array $actualParams)
{
// Grab values for parameters that were renamed
$renameMap = empty($config['rename-map']) ? array() : (array) $config['rename-map'];
$actualParams = array_replace($actualParams, $this->processRenamedValues($renameMap, $actualParams));
$keepOutdatedParams = false;
if (isset($config['keep-outdated'])) {
$keepOutdatedParams = (boolean) $config['keep-outdated'];
}
if (!$keepOutdatedParams) {
$actualParams = array_intersect_key($actualParams, $expectedParams);
}
$envMap = empty($config['env-map']) ? array() : (array) $config['env-map'];
// Add the params coming from the environment values
$actualParams = array_replace($actualParams, $this->getEnvValues($envMap));
return $this->getParams($expectedParams, $actualParams);
}
private function getEnvValues(array $envMap)
{
$params = array();
foreach ($envMap as $param => $env) {
$value = getenv($env);
if ($value) {
$params[$param] = Inline::parse($value);
}
}
return $params;
}
private function processRenamedValues(array $renameMap, array $actualParams)
{
foreach ($renameMap as $param => $oldParam) {
if (array_key_exists($param, $actualParams)) {
continue;
}
if (!array_key_exists($oldParam, $actualParams)) {
continue;
}
$actualParams[$param] = $actualParams[$oldParam];
}
return $actualParams;
}
private function getParams(array $expectedParams, array $actualParams)
{
// Simply use the expectedParams value as default for the missing params.
if (!$this->io->isInteractive()) {
return array_replace($expectedParams, $actualParams);
}
$isStarted = false;
foreach ($expectedParams as $key => $message) {
if (array_key_exists($key, $actualParams)) {
continue;
}
if (!$isStarted) {
$isStarted = true;
$this->io->write('<comment>Some parameters are missing. Please provide them.</comment>');
}
$default = Inline::dump($message);
$value = $this->io->ask(sprintf('<question>%s</question> (<comment>%s</comment>): ', $key, $default), $default);
$actualParams[$key] = Inline::parse($value);
}
return $actualParams;
}
}

View File

@@ -0,0 +1,174 @@
# Managing your ignored parameters with Composer
This tool allows you to manage your ignored parameters when running a composer
install or update. It works when storing the parameters in a Yaml file under
a single top-level key (named ``parameters`` by default). Other keys are
copied without change.
[![Build Status](https://travis-ci.org/Incenteev/ParameterHandler.png)](https://travis-ci.org/Incenteev/ParameterHandler)
[![Code Coverage](https://scrutinizer-ci.com/g/Incenteev/ParameterHandler/badges/coverage.png?s=ea5de28d9764fdcb6a576a41e244c0ac537b3c81)](https://scrutinizer-ci.com/g/Incenteev/ParameterHandler/)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/Incenteev/ParameterHandler/badges/quality-score.png?s=6143d945bbdfac5c1114d4fe5d0f4ee737db18bf)](https://scrutinizer-ci.com/g/Incenteev/ParameterHandler/)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/3a432e49-6018-41a5-a37b-b7fb151706c1/mini.png)](https://insight.sensiolabs.com/projects/3a432e49-6018-41a5-a37b-b7fb151706c1)
[![Latest Stable Version](https://poser.pugx.org/incenteev/composer-parameter-handler/v/stable.png)](https://packagist.org/packages/incenteev/composer-parameter-handler)
[![Latest Unstable Version](https://poser.pugx.org/incenteev/composer-parameter-handler/v/unstable.png)](https://packagist.org/packages/incenteev/composer-parameter-handler)
## Usage
Add the following in your root composer.json file:
```json
{
"require": {
"incenteev/composer-parameter-handler": "~2.0"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
]
},
"extra": {
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
}
```
The ``app/config/parameters.yml`` will then be created or updated by the
composer script, to match the structure of the dist file ``app/config/parameters.yml.dist``
by asking you the missing parameters.
By default, the dist file is assumed to be in the same place than the parameters
file, suffixed by ``.dist``. This can be changed in the configuration:
```json
{
"extra": {
"incenteev-parameters": {
"file": "app/config/parameters.yml",
"dist-file": "some/other/folder/to/other/parameters/file/parameters.yml.dist"
}
}
}
```
The script handler will ask you interactively for parameters which are missing
in the parameters file, using the value of the dist file as default value.
All prompted values are parsed as inline Yaml, to allow you to define ``true``,
``false``, ``null`` or numbers easily.
If composer is run in a non-interactive mode, the values of the dist file
will be used for missing parameters.
**Warning:** This parameters handler will overwrite any comments or spaces into
your parameters.yml file so handle with care. If you want to give format
and comments to your parameter's file you should do it on your dist version.
### Keeping outdated parameters
Warning: This script removes outdated params from ``parameters.yml`` which are not in ``parameters.yml.dist``
If you need to keep outdated params you can use `keep-outdated` param in the configuration:
```json
{
"extra": {
"incenteev-parameters": {
"keep-outdated": true
}
}
}
```
### Using a different top-level key
The script handler looks for a ``parameters`` key in your dist file. You can change this by using the
`parameter-key` param in the configuration:
```json
{
"extra": {
"incenteev-parameters": {
"parameter-key": "config"
}
}
}
```
### Using environment variables to set the parameters
For your prod environment, using an interactive prompt may not be possible
when deploying. In this case, you can rely on environment variables to provide
the parameters. This is achieved by providing a map between environment variables
and the parameters they should fill:
```json
{
"extra": {
"incenteev-parameters": {
"env-map": {
"my_first_param": "MY_FIRST_PARAM",
"my_second_param": "MY_SECOND_PARAM"
}
}
}
}
```
If an environment variable is set, its value will always replace the value
set in the existing parameters file.
As environment variables can only be strings, they are also parsed as inline
Yaml values to allows specifying ``null``, ``false``, ``true`` or numbers
easily.
### Renaming parameters
If you are renaming a parameter, the new key will be set according to the usual
routine (prompt if possible, use environment variables, use default).
To have the parameters handler use the value of an (obsolete) parameter, specify
a rename-map:
```json
{
"extra": {
"incenteev-parameters": {
"rename-map": {
"new_param_1": "old_param_1",
"new_param_2": "old_param_2"
}
}
}
}
```
This will create the new parameters new_param_1 and new_param_2 while using the
values from old_param_1 and old_param_2, respectively. It will not remove the
old parameters unless you've also removed them from the dist version.
If the old parameter is no longer present (maybe because it has been renamed and
removed already), no parameters are overwritten. You don't need to remove obsolete
parameters from the rename map once they have been renamed.
### Managing multiple ignored files
The parameter handler can manage multiple ignored files. To use this feature,
the ``incenteev-parameters`` extra should contain a JSON array with multiple
configurations inside it instead of a configuration object:
```json
{
"extra": {
"incenteev-parameters": [
{
"file": "app/config/parameters.yml",
"env-map": {}
},
{
"file": "app/config/databases.yml",
"dist-file": "app/config/databases.dist.yml",
"parameter-key": "config"
}
]
}
}
```

View File

@@ -0,0 +1,37 @@
<?php
namespace Incenteev\ParameterHandler;
use Composer\Script\Event;
class ScriptHandler
{
public static function buildParameters(Event $event)
{
$extras = $event->getComposer()->getPackage()->getExtra();
if (!isset($extras['incenteev-parameters'])) {
throw new \InvalidArgumentException('The parameter handler needs to be configured through the extra.incenteev-parameters setting.');
}
$configs = $extras['incenteev-parameters'];
if (!is_array($configs)) {
throw new \InvalidArgumentException('The extra.incenteev-parameters setting must be an array or a configuration object.');
}
if (array_keys($configs) !== range(0, count($configs) - 1)) {
$configs = array($configs);
}
$processor = new Processor($event->getIO());
foreach ($configs as $config) {
if (!is_array($config)) {
throw new \InvalidArgumentException('The extra.incenteev-parameters setting must be an array of configuration objects.');
}
$processor->processFile($config);
}
}
}

View File

@@ -0,0 +1,174 @@
<?php
namespace Incenteev\ParameterHandler\Tests;
use Incenteev\ParameterHandler\Processor;
use Prophecy\PhpUnit\ProphecyTestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Yaml;
class ProcessorTest extends ProphecyTestCase
{
private $io;
private $environmentBackup = array();
/**
* @var Processor
*/
private $processor;
protected function setUp()
{
parent::setUp();
$this->io = $this->prophesize('Composer\IO\IOInterface');
$this->processor = new Processor($this->io->reveal());
}
protected function tearDown()
{
parent::tearDown();
foreach ($this->environmentBackup as $var => $value) {
if (false === $value) {
putenv($var);
} else {
putenv($var.'='.$value);
}
}
}
/**
* @dataProvider provideInvalidConfiguration
*/
public function testInvalidConfiguration(array $config, $exceptionMessage)
{
chdir(__DIR__);
$this->setExpectedException('InvalidArgumentException', $exceptionMessage);
$this->processor->processFile($config);
}
public function provideInvalidConfiguration()
{
return array(
'no file' => array(
array(),
'The extra.incenteev-parameters.file setting is required to use this script handler.',
),
'missing default dist file' => array(
array(
'file' => 'fixtures/invalid/missing.yml',
),
'The dist file "fixtures/invalid/missing.yml.dist" does not exist. Check your dist-file config or create it.',
),
'missing custom dist file' => array(
array(
'file' => 'fixtures/invalid/missing.yml',
'dist-file' => 'fixtures/invalid/non-existent.dist.yml',
),
'The dist file "fixtures/invalid/non-existent.dist.yml" does not exist. Check your dist-file config or create it.',
),
'missing top level key in dist file' => array(
array(
'file' => 'fixtures/invalid/missing_top_level.yml',
),
'The top-level key parameters is missing.',
),
'invalid values in the existing file' => array(
array(
'file' => 'fixtures/invalid/invalid_existing_values.yml',
),
'The existing "fixtures/invalid/invalid_existing_values.yml" file does not contain an array',
),
);
}
/**
* @dataProvider provideParameterHandlingTestCases
*/
public function testParameterHandling($testCaseName)
{
$dataDir = __DIR__.'/fixtures/testcases/'.$testCaseName;
$testCase = array_replace_recursive(
array(
'title' => 'unknown test',
'config' => array(
'file' => 'parameters.yml',
),
'dist-file' => 'parameters.yml.dist',
'environment' => array(),
'interactive' => false,
),
(array) Yaml::parse(file_get_contents($dataDir.'/setup.yml'))
);
$workingDir = sys_get_temp_dir() . '/incenteev_parameter_handler';
$exists = $this->initializeTestCase($testCase, $dataDir, $workingDir);
$message = sprintf('<info>%s the "%s" file</info>', $exists ? 'Updating' : 'Creating', $testCase['config']['file']);
$this->io->write($message)->shouldBeCalled();
$this->setInteractionExpectations($testCase);
$this->processor->processFile($testCase['config']);
$this->assertFileEquals($dataDir.'/expected.yml', $workingDir.'/'.$testCase['config']['file'], $testCase['title']);
}
private function initializeTestCase(array $testCase, $dataDir, $workingDir)
{
$fs = new Filesystem();
if (is_dir($workingDir)) {
$fs->remove($workingDir);
}
$fs->copy($dataDir.'/dist.yml', $workingDir.'/'. $testCase['dist-file']);
if ($exists = file_exists($dataDir.'/existing.yml')) {
$fs->copy($dataDir.'/existing.yml', $workingDir.'/'.$testCase['config']['file']);
}
foreach ($testCase['environment'] as $var => $value) {
$this->environmentBackup[$var] = getenv($var);
putenv($var.'='.$value);
};
chdir($workingDir);
return $exists;
}
private function setInteractionExpectations(array $testCase)
{
$this->io->isInteractive()->willReturn($testCase['interactive']);
if (!$testCase['interactive']) {
return;
}
if (!empty($testCase['requested_params'])) {
$this->io->write('<comment>Some parameters are missing. Please provide them.</comment>')->shouldBeCalledTimes(1);
}
foreach ($testCase['requested_params'] as $param => $settings) {
$this->io->ask(sprintf('<question>%s</question> (<comment>%s</comment>): ', $param, $settings['default']), $settings['default'])
->willReturn($settings['input'])
->shouldBeCalled();
}
}
public function provideParameterHandlingTestCases()
{
$tests = array();
foreach (glob(__DIR__.'/fixtures/testcases/*/') as $folder) {
$tests[] = array(basename($folder));
}
return $tests;
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace Incenteev\ParameterHandler\Tests;
use Incenteev\ParameterHandler\ScriptHandler;
use Prophecy\PhpUnit\ProphecyTestCase;
class ScriptHandlerTest extends ProphecyTestCase
{
private $event;
private $io;
private $package;
protected function setUp()
{
parent::setUp();
$this->event = $this->prophesize('Composer\Script\Event');
$this->io = $this->prophesize('Composer\IO\IOInterface');
$this->package = $this->prophesize('Composer\Package\PackageInterface');
$composer = $this->prophesize('Composer\Composer');
$composer->getPackage()->willReturn($this->package);
$this->event->getComposer()->willReturn($composer);
$this->event->getIO()->willReturn($this->io);
}
/**
* @dataProvider provideInvalidConfiguration
*/
public function testInvalidConfiguration(array $extras, $exceptionMessage)
{
$this->package->getExtra()->willReturn($extras);
chdir(__DIR__);
$this->setExpectedException('InvalidArgumentException', $exceptionMessage);
ScriptHandler::buildParameters($this->event->reveal());
}
public function provideInvalidConfiguration()
{
return array(
'no extra' => array(
array(),
'The parameter handler needs to be configured through the extra.incenteev-parameters setting.',
),
'invalid type' => array(
array('incenteev-parameters' => 'not an array'),
'The extra.incenteev-parameters setting must be an array or a configuration object.',
),
'invalid type for multiple file' => array(
array('incenteev-parameters' => array('not an array')),
'The extra.incenteev-parameters setting must be an array of configuration objects.',
),
'no file' => array(
array('incenteev-parameters' => array()),
'The extra.incenteev-parameters.file setting is required to use this script handler.',
),
);
}
}

View File

@@ -0,0 +1 @@
another: The parameters key is missing

View File

@@ -0,0 +1,3 @@
parameters:
foo: bar
boolean: false

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false

View File

@@ -0,0 +1,6 @@
title: Existing values are kept
config:
dist-file: parameters.dist.yml
dist-file: parameters.dist.yml

View File

@@ -0,0 +1,7 @@
config:
foo: bar
boolean: false
another: ~
nested:
foo: bar
bar: baz

View File

@@ -0,0 +1,8 @@
# This file is auto-generated during the composer install
config:
foo: existing_foo
boolean: false
another: ~
nested:
foo: bar
bar: baz

View File

@@ -0,0 +1,8 @@
# This file is auto-generated during the composer install
config:
foo: existing_foo
boolean: false
another: null
nested:
foo: bar
bar: baz

View File

@@ -0,0 +1,5 @@
title: Using a custom parameter key
config:
parameter-key: config

View File

@@ -0,0 +1,7 @@
parameters:
foo: bar
boolean: false
another: ~
nested:
foo: bar
bar: baz

View File

@@ -0,0 +1,8 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
another: ~
nested:
foo: bar
bar: baz

View File

@@ -0,0 +1,8 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
another: null
nested:
foo: bar
bar: baz

View File

@@ -0,0 +1 @@
title: Existing values are kept

View File

@@ -0,0 +1,3 @@
# This file is auto-generated during the composer install
parameters:
foo: bar

View File

@@ -0,0 +1 @@
title: Existing empty files are valid (Capifony compatibility)

View File

@@ -0,0 +1,2 @@
# This file is auto-generated during the composer install
foobar: baz

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
foo: bar
foobar: baz

View File

@@ -0,0 +1 @@
title: Existing files without the parameters key are valid

View File

@@ -0,0 +1,5 @@
parameters:
foo: bar
boolean: false
extra_key: a new extra key

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
another_key: foo

View File

@@ -0,0 +1,6 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
extra_key: 'a new extra key'
another_key: foo

View File

@@ -0,0 +1 @@
title: Extra top level keys are preserved

View File

@@ -0,0 +1,4 @@
parameters:
foo: bar
boolean: false
another: ~

View File

@@ -0,0 +1,3 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo

View File

@@ -0,0 +1,5 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
another: 'null'

View File

@@ -0,0 +1,11 @@
title: Existing values are not asked interactively again
interactive: true
requested_params:
boolean:
default: 'false'
input: 'false'
another:
default: 'null'
input: '"null"'

View File

@@ -0,0 +1,4 @@
parameters:
boolean: false
another: test
nested: nested

View File

@@ -0,0 +1,10 @@
# This file is auto-generated during the composer install
parameters:
boolean: true
another: null
nested:
foo: bar
bar:
- foo
- test
- null

View File

@@ -0,0 +1,14 @@
title: Missing keys are asked interactively
interactive: true
requested_params:
boolean:
default: 'false'
input: 'true'
nested:
default: nested
input: '{foo: bar, bar: [foo, test, null]}'
another:
default: test
input: 'null'

View File

@@ -0,0 +1,4 @@
parameters:
boolean: false
another: test
nested: nested

View File

@@ -0,0 +1,10 @@
# This file is auto-generated during the composer install
parameters:
boolean: true
nested:
foo: env_foo
bar:
- env
- test
- null
another: null

View File

@@ -0,0 +1,17 @@
title: Values provided by the environment are not asked interactively
config:
env-map:
boolean: IC_TEST_BOOL
nested: IC_TEST_NESTED
environment:
IC_TEST_BOOL: 'true'
IC_TEST_NESTED: '{foo: env_foo, bar: [env, test, null]}'
interactive: true
requested_params:
another:
default: test
input: 'null'

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
outdated: outdated_param

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
outdated: outdated_param

View File

@@ -0,0 +1,4 @@
title: Outdated keys can be kept in the parameters file
config:
keep-outdated: true

View File

@@ -0,0 +1,7 @@
parameters:
foo: bar
boolean: false
another: ~
nested:
foo: bar
bar: baz

View File

@@ -0,0 +1,8 @@
# This file is auto-generated during the composer install
parameters:
foo: bar
boolean: false
another: null
nested:
foo: bar
bar: baz

View File

@@ -0,0 +1 @@
title: Non existent files are created

View File

@@ -0,0 +1,7 @@
parameters:
foo: bar
boolean: false
another: ~
nested:
foo: bar
bar: baz

View File

@@ -0,0 +1,11 @@
# This file is auto-generated during the composer install
parameters:
foo: foobar
boolean: true
another: null
nested:
foo: env_foo
bar:
- env
- test
- null

View File

@@ -0,0 +1,13 @@
title: Environment variables are used over dist file defaults
config:
env-map:
boolean: IC_TEST_BOOL
foo: IC_TEST_FOO
nested: IC_TEST_NESTED
another: IC_TEST_NOT_SET
environment:
IC_TEST_BOOL: 'true'
IC_TEST_FOO: 'foobar'
IC_TEST_NESTED: '{foo: env_foo, bar: [env, test, null]}'

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
outdated: outdated_param

View File

@@ -0,0 +1,3 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo

View File

@@ -0,0 +1 @@
title: Outdated keys are removed from the parameters file

View File

@@ -0,0 +1,6 @@
parameters:
new: bar
new2: new2
new3: test
new4: test4
new5: test5

View File

@@ -0,0 +1,6 @@
# This file is auto-generated during the composer install
parameters:
old: old_value
new2: foo
old2: bar
old4: old4

View File

@@ -0,0 +1,7 @@
# This file is auto-generated during the composer install
parameters:
new: old_value
new2: foo
new3: test
new4: old4
new5: old4

View File

@@ -0,0 +1,9 @@
title: Key can be renamed and the value is reused
config:
rename-map:
new: old
new2: old2
new3: old3
new4: old4
new5: new4 # Cascade renaming

View File

@@ -0,0 +1,3 @@
parameters:
new: bar
new2: new2

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
old: old_value
old2: old_value2

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
new: new_env_value
new2: old_value2

View File

@@ -0,0 +1,11 @@
title: Environment variables win over renamed keys
config:
rename-map:
new: old
new2: old2
env-map:
new: IC_TEST_NEW
environment:
IC_TEST_NEW: 'new_env_value'

View File

@@ -0,0 +1,3 @@
parameters:
foo: bar
boolean: false

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false

View File

@@ -0,0 +1,4 @@
# This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false

View File

@@ -0,0 +1,6 @@
title: Files can be located in subfolders
config:
file: 'app/parameters.yml'
dist-file: 'app/parameters.yml.dist'

View File

@@ -0,0 +1,3 @@
# This file is auto-generated during the composer install
parameters:
foo: bar

View File

@@ -0,0 +1,7 @@
title: Files can be located in different folders than the dist and the folder is created
config:
file: 'app/parameters.yml'
dist-file: 'dist/parameters.yml'
dist-file: 'dist/parameters.yml'

View File

@@ -0,0 +1,30 @@
{
"name": "incenteev/composer-parameter-handler",
"description": "Composer script handling your ignored parameter file",
"keywords": ["parameters management"],
"homepage": "https://github.com/Incenteev/ParameterHandler",
"license": "MIT",
"authors": [
{
"name": "Christophe Coevoet",
"email": "stof@notk.org"
}
],
"require": {
"php": ">=5.3.3",
"symfony/yaml": "~2.3|~3.0"
},
"require-dev": {
"composer/composer": "1.0.*@dev",
"phpspec/prophecy-phpunit": "~1.0",
"symfony/filesystem": "~2.2"
},
"autoload": {
"psr-4": { "Incenteev\\ParameterHandler\\": "" }
},
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
}
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Incenteev ParameterHandler Test Suite">
<directory suffix="Test.php">./Tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>