Commit a5c357bf authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Nouvelle config pour le numéro de version + script 'bump-version'.

parent 3166993f
Pipeline #3480 passed with stage
in 13 seconds
#!/usr/bin/env php
<?php
/**
* Script à utiliser pour mettre à jour la version courante de l'application,
* configurée dans 'config/autoload/version.global.php'.
*
* Usage: bump-version [<version>]
*
* Ex: bump-version 1.3
*/
require 'vendor/autoload.php';
use Zend\Config\Writer\PhpArray;
$defaultConfig = [
'unicaen-app' => [
'app_infos' => [
'version' => 'Aucune',
],
]
];
$configFilepath = 'config/autoload/version.global.php';
echo "Fichier de config: $configFilepath" . PHP_EOL;
if (!is_readable($configFilepath)) {
echo "Fichier de config $configFilepath introuvable ou illisible." . PHP_EOL;
exit(1);
}
$config = require $configFilepath;
if (! isset($config['unicaen-app']['app_infos']['version'])) {
$config = array_merge_recursive($config, $defaultConfig);
}
$current = $config['unicaen-app']['app_infos']['version'];
echo sprintf("Version actuelle: %s.", $current) . PHP_EOL;
$new = isset($argv[1]) ? $argv[1] : null;
if ($new === null) {
$message = "Nouvelle version ? ";
$new = readline($message);
}
if (version_compare($new, $current) <= 0) {
echo ":-( Impossible, la nouvelle version doit être supérieure à l'actuelle." . PHP_EOL;
exit(1);
}
$config['unicaen-app']['app_infos']['version'] = $new;
$config['unicaen-app']['app_infos']['date'] = date('d/m/Y');
$config['comment'] = "Fichier généré le " . date('d/m/Y à H:i:s') . ' avec ' . __FILE__;
$phpArray = new PhpArray();
$phpArray
->setUseBracketArraySyntax(true)
->toFile($configFilepath, $config);
echo "Nouvelle version inscrite: $new" . PHP_EOL;
<?php
return [
'version' => '1.2.2',
return [
'zf-mvc-auth' => [
'authentication' => [
'adapters' => [
......
<?php
return [
'unicaen-app' => [
'app_infos' => [
'version' => '1.2.3',
'date' => '01/02/2019',
],
],
'comment' => 'Fichier généré le 01/02/2019 à 11:02:57 avec /home/gauthierb/workspace/sygal/bump-version',
];
......@@ -13,7 +13,9 @@ class VersionResourceFactory
public function __invoke(ContainerInterface $container)
{
$config = $container->get('config');
$version = isset($config['version']) ? $config['version'] : null;
$version = isset($config['unicaen-app']['app_infos']['version']) ?
$config['unicaen-app']['app_infos']['version'] :
null;
return new VersionResource($version);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment