.gitignore 0000644 00000000047 13634260771 0006546 0 ustar 00 composer.lock
phpunit.xml
vendor
build
.travis.yml 0000644 00000002053 13634260771 0006666 0 ustar 00 language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache/files
- $HOME/.phpunit-bridge
env:
global:
- SYMFONY_PHPUNIT_DIR=$HOME/.phpunit-bridge
- SYMFONY_PHPUNIT_REMOVE='' # don't remove prophecy
- SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1
php: [7.4, 7.3, 7.2, 7.1, 7.0, 5.6]
matrix:
include:
- php: 7.2
env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
- php: 5.3
dist: precise
- php: 5.4
dist: trusty
- php: 5.5
dist: trusty
- php: 7.4
env: STABILITY=dev
before_install:
- if [[ -v $STABILITY ]]; then composer config minimum-stability $STABILITY; fi;
install:
- composer update --prefer-dist --no-interaction $COMPOSER_FLAGS
- vendor/bin/simple-phpunit install
script: vendor/bin/simple-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
CHANGELOG.md 0000644 00000002161 13634260771 0006366 0 ustar 00 ## 2.1.4 (2020-03-17)
* Mark symfony/yaml 5 as supported
## 2.1.3 (2018-02-13)
* Mark symfony/yaml 4 as supported to be compatible with Symfony 4
## 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.
LICENSE 0000644 00000002046 13634260771 0005564 0 ustar 00 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.
Processor.php 0000644 00000012577 13634260771 0007261 0 ustar 00 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('%s the "%s" file', $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('Some parameters are missing. Please provide them.');
}
$default = Inline::dump($message);
$value = $this->io->ask(sprintf('%s (%s): ', $key, $default), $default);
$actualParams[$key] = Inline::parse($value);
}
return $actualParams;
}
}
README.md 0000644 00000013773 13634260771 0006047 0 ustar 00 # 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"
}
]
}
}
```
ScriptHandler.php 0000644 00000002166 13634260771 0010035 0 ustar 00 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);
}
}
}
Tests/ProcessorTest.php 0000644 00000013210 13634260771 0011204 0 ustar 00 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__);
if (method_exists($this, 'expectException')) {
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage($exceptionMessage);
} else {
$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('%s the "%s" file', $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('Some parameters are missing. Please provide them.')->shouldBeCalledTimes(1);
}
foreach ($testCase['requested_params'] as $param => $settings) {
$this->io->ask(sprintf('%s (%s): ', $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;
}
}
Tests/ScriptHandlerTest.php 0000644 00000004403 13634260771 0011773 0 ustar 00 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__);
if (method_exists($this, 'expectException')) {
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage($exceptionMessage);
} else {
$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.',
),
);
}
}
Tests/fixtures/invalid/invalid_existing_values.yml 0000644 00000000015 13634260771 0016614 0 ustar 00 not an array
Tests/fixtures/invalid/invalid_existing_values.yml.dist 0000644 00000000031 13634260771 0017554 0 ustar 00 parameters:
foo: bar
Tests/fixtures/invalid/missing_top_level.yml.dist 0000644 00000000047 13634260771 0016366 0 ustar 00 another: The parameters key is missing
Tests/fixtures/testcases/custom_dist_file/dist.yml 0000644 00000000054 13634260771 0016547 0 ustar 00 parameters:
foo: bar
boolean: false
Tests/fixtures/testcases/custom_dist_file/existing.yml 0000644 00000000157 13634260771 0017442 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
Tests/fixtures/testcases/custom_dist_file/expected.yml 0000644 00000000157 13634260771 0017411 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
Tests/fixtures/testcases/custom_dist_file/setup.yml 0000644 00000000154 13634260771 0016745 0 ustar 00 title: Existing values are kept
config:
dist-file: parameters.dist.yml
dist-file: parameters.dist.yml
Tests/fixtures/testcases/custom_key/dist.yml 0000644 00000000145 13634260771 0015376 0 ustar 00 config:
foo: bar
boolean: false
another: ~
nested:
foo: bar
bar: baz
Tests/fixtures/testcases/custom_key/existing.yml 0000644 00000000250 13634260771 0016262 0 ustar 00 # This file is auto-generated during the composer install
config:
foo: existing_foo
boolean: false
another: ~
nested:
foo: bar
bar: baz
Tests/fixtures/testcases/custom_key/expected.yml 0000644 00000000253 13634260771 0016234 0 ustar 00 # This file is auto-generated during the composer install
config:
foo: existing_foo
boolean: false
another: null
nested:
foo: bar
bar: baz
Tests/fixtures/testcases/custom_key/setup.yml 0000644 00000000110 13634260771 0015563 0 ustar 00 title: Using a custom parameter key
config:
parameter-key: config
Tests/fixtures/testcases/existent/dist.yml 0000644 00000000151 13634260771 0015054 0 ustar 00 parameters:
foo: bar
boolean: false
another: ~
nested:
foo: bar
bar: baz
Tests/fixtures/testcases/existent/existing.yml 0000644 00000000254 13634260771 0015747 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
another: ~
nested:
foo: bar
bar: baz
Tests/fixtures/testcases/existent/expected.yml 0000644 00000000257 13634260771 0015721 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
another: null
nested:
foo: bar
bar: baz
Tests/fixtures/testcases/existent/setup.yml 0000644 00000000040 13634260771 0015246 0 ustar 00 title: Existing values are kept
Tests/fixtures/testcases/existent_empty/dist.yml 0000644 00000000031 13634260771 0016267 0 ustar 00 parameters:
foo: bar
Tests/fixtures/testcases/existent_empty/existing.yml 0000644 00000000000 13634260771 0017152 0 ustar 00 Tests/fixtures/testcases/existent_empty/expected.yml 0000644 00000000123 13634260771 0017127 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: bar
Tests/fixtures/testcases/existent_empty/setup.yml 0000644 00000000077 13634260771 0016476 0 ustar 00 title: Existing empty files are valid (Capifony compatibility)
Tests/fixtures/testcases/existent_without_key/dist.yml 0000644 00000000031 13634260771 0017504 0 ustar 00 parameters:
foo: bar
Tests/fixtures/testcases/existent_without_key/existing.yml 0000644 00000000106 13634260771 0020376 0 ustar 00 # This file is auto-generated during the composer install
foobar: baz
Tests/fixtures/testcases/existent_without_key/expected.yml 0000644 00000000137 13634260771 0020351 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: bar
foobar: baz
Tests/fixtures/testcases/existent_without_key/setup.yml 0000644 00000000073 13634260771 0017707 0 ustar 00 title: Existing files without the parameters key are valid
Tests/fixtures/testcases/extra_keys/dist.yml 0000644 00000000110 13634260771 0015362 0 ustar 00 parameters:
foo: bar
boolean: false
extra_key: a new extra key
Tests/fixtures/testcases/extra_keys/existing.yml 0000644 00000000155 13634260771 0016262 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
another_key: foo
Tests/fixtures/testcases/extra_keys/expected.yml 0000644 00000000235 13634260771 0016230 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
extra_key: 'a new extra key'
another_key: foo
Tests/fixtures/testcases/extra_keys/setup.yml 0000644 00000000052 13634260771 0015564 0 ustar 00 title: Extra top level keys are preserved
Tests/fixtures/testcases/interaction_existent/dist.yml 0000644 00000000073 13634260771 0017456 0 ustar 00 parameters:
foo: bar
boolean: false
another: ~
Tests/fixtures/testcases/interaction_existent/existing.yml 0000644 00000000134 13634260771 0020343 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
Tests/fixtures/testcases/interaction_existent/expected.yml 0000644 00000000203 13634260771 0020307 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
another: 'null'
Tests/fixtures/testcases/interaction_existent/setup.yml 0000644 00000000331 13634260771 0017650 0 ustar 00 title: Existing values are not asked interactively again
interactive: true
requested_params:
boolean:
default: 'false'
input: 'false'
another:
default: 'null'
input: '"null"'
Tests/fixtures/testcases/interaction_non_existent/dist.yml 0000644 00000000104 13634260771 0020323 0 ustar 00 parameters:
boolean: false
another: test
nested: nested
Tests/fixtures/testcases/interaction_non_existent/expected.yml 0000644 00000000314 13634260771 0021164 0 ustar 00 # This file is auto-generated during the composer install
parameters:
boolean: true
another: null
nested:
foo: bar
bar:
- foo
- test
- null
Tests/fixtures/testcases/interaction_non_existent/setup.yml 0000644 00000000437 13634260771 0020531 0 ustar 00 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'
Tests/fixtures/testcases/interaction_with_environment/dist.yml 0000644 00000000104 13634260771 0021205 0 ustar 00 parameters:
boolean: false
another: test
nested: nested
Tests/fixtures/testcases/interaction_with_environment/expected.yml 0000644 00000000320 13634260771 0022043 0 ustar 00 # This file is auto-generated during the composer install
parameters:
boolean: true
nested:
foo: env_foo
bar:
- env
- test
- null
another: null
Tests/fixtures/testcases/interaction_with_environment/setup.yml 0000644 00000000534 13634260771 0021411 0 ustar 00 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'
Tests/fixtures/testcases/keep_outdated/dist.yml 0000644 00000000031 13634260771 0016023 0 ustar 00 parameters:
foo: bar
Tests/fixtures/testcases/keep_outdated/existing.yml 0000644 00000000171 13634260771 0016717 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
outdated: outdated_param
Tests/fixtures/testcases/keep_outdated/expected.yml 0000644 00000000171 13634260771 0016666 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
outdated: outdated_param
Tests/fixtures/testcases/keep_outdated/setup.yml 0000644 00000000131 13634260771 0016221 0 ustar 00 title: Outdated keys can be kept in the parameters file
config:
keep-outdated: true
Tests/fixtures/testcases/non_existent/dist.yml 0000644 00000000151 13634260771 0015726 0 ustar 00 parameters:
foo: bar
boolean: false
another: ~
nested:
foo: bar
bar: baz
Tests/fixtures/testcases/non_existent/expected.yml 0000644 00000000246 13634260771 0016571 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: bar
boolean: false
another: null
nested:
foo: bar
bar: baz
Tests/fixtures/testcases/non_existent/setup.yml 0000644 00000000046 13634260771 0016126 0 ustar 00 title: Non existent files are created
Tests/fixtures/testcases/non_existent_with_environment/dist.yml 0000644 00000000151 13634260771 0021405 0 ustar 00 parameters:
foo: bar
boolean: false
another: ~
nested:
foo: bar
bar: baz
Tests/fixtures/testcases/non_existent_with_environment/expected.yml 0000644 00000000340 13634260771 0022243 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: foobar
boolean: true
another: null
nested:
foo: env_foo
bar:
- env
- test
- null
Tests/fixtures/testcases/non_existent_with_environment/setup.yml 0000644 00000000511 13634260771 0021602 0 ustar 00 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]}'
Tests/fixtures/testcases/remove_outdated/dist.yml 0000644 00000000031 13634260771 0016374 0 ustar 00 parameters:
foo: bar
Tests/fixtures/testcases/remove_outdated/existing.yml 0000644 00000000171 13634260771 0017270 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
outdated: outdated_param
Tests/fixtures/testcases/remove_outdated/expected.yml 0000644 00000000134 13634260771 0017236 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
Tests/fixtures/testcases/remove_outdated/setup.yml 0000644 00000000072 13634260771 0016576 0 ustar 00 title: Outdated keys are removed from the parameters file
Tests/fixtures/testcases/renamed/dist.yml 0000644 00000000127 13634260771 0014627 0 ustar 00 parameters:
new: bar
new2: new2
new3: test
new4: test4
new5: test5
Tests/fixtures/testcases/renamed/existing.yml 0000644 00000000204 13634260771 0015512 0 ustar 00 # This file is auto-generated during the composer install
parameters:
old: old_value
new2: foo
old2: bar
old4: old4
Tests/fixtures/testcases/renamed/expected.yml 0000644 00000000224 13634260771 0015463 0 ustar 00 # This file is auto-generated during the composer install
parameters:
new: old_value
new2: foo
new3: test
new4: old4
new5: old4
Tests/fixtures/testcases/renamed/setup.yml 0000644 00000000273 13634260771 0015026 0 ustar 00 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
Tests/fixtures/testcases/renamed_and_environment/dist.yml 0000644 00000000050 13634260771 0020070 0 ustar 00 parameters:
new: bar
new2: new2
Tests/fixtures/testcases/renamed_and_environment/existing.yml 0000644 00000000156 13634260771 0020766 0 ustar 00 # This file is auto-generated during the composer install
parameters:
old: old_value
old2: old_value2
Tests/fixtures/testcases/renamed_and_environment/expected.yml 0000644 00000000162 13634260771 0020732 0 ustar 00 # This file is auto-generated during the composer install
parameters:
new: new_env_value
new2: old_value2
Tests/fixtures/testcases/renamed_and_environment/setup.yml 0000644 00000000305 13634260771 0020270 0 ustar 00 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'
Tests/fixtures/testcases/subfolder/dist.yml 0000644 00000000054 13634260771 0015200 0 ustar 00 parameters:
foo: bar
boolean: false
Tests/fixtures/testcases/subfolder/existing.yml 0000644 00000000157 13634260771 0016073 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
Tests/fixtures/testcases/subfolder/expected.yml 0000644 00000000157 13634260771 0016042 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: existing_foo
boolean: false
Tests/fixtures/testcases/subfolder/setup.yml 0000644 00000000170 13634260771 0015374 0 ustar 00 title: Files can be located in subfolders
config:
file: 'app/parameters.yml'
dist-file: 'app/parameters.yml.dist'
Tests/fixtures/testcases/subfolder_created/dist.yml 0000644 00000000031 13634260771 0016662 0 ustar 00 parameters:
foo: bar
Tests/fixtures/testcases/subfolder_created/expected.yml 0000644 00000000123 13634260771 0017522 0 ustar 00 # This file is auto-generated during the composer install
parameters:
foo: bar
Tests/fixtures/testcases/subfolder_created/setup.yml 0000644 00000000310 13634260771 0017057 0 ustar 00 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'
composer.json 0000644 00000001510 13634260771 0007274 0 ustar 00 {
"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 || ^4.0 || ^5.0"
},
"require-dev": {
"composer/composer": "^1.0@dev",
"symfony/filesystem": "^2.3 || ^3 || ^4 || ^5",
"symfony/phpunit-bridge": "^4.0 || ^5.0"
},
"autoload": {
"psr-4": { "Incenteev\\ParameterHandler\\": "" }
},
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
}
}
phpunit.xml.dist 0000644 00000001031 13634260771 0007723 0 ustar 00
./Tests/
./
./Tests
./vendor