Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
open-source
sygal-import-ws
Commits
fb2fceae
Commit
fb2fceae
authored
May 11, 2022
by
Bertrand Gauthier
Browse files
Ajout create-version-config-file
parent
40cf9ee2
Pipeline
#14969
passed with stage
in 17 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
create-version-config-file
0 → 100755
View file @
fb2fceae
#!/usr/bin/env php
<?php
/**
* Script à utiliser pour inscrire dans le fichier de config locale le numéro et la date de version de l'application
* spécifiés en argument.
*
* Le chemin du fichier de config créé est par défaut 'config/autoload/auto.version.local.php'.
*
* Usage: ./create-version-config-file --number <version> --date <date> [--file <path>]
* Ex: ./create-version-config-file --number 2.0.0 --date "03/11/2020" --file "config/autoload/auto.version.local.php"
*/
require
'vendor/autoload.php'
;
use
Zend\Config\Writer\PhpArray
;
const
DEFAULT_FILE_PATH
=
'config/autoload/auto.version.local.php'
;
const
ARG_VERSION_NUMBER
=
'--number'
;
const
ARG_VERSION_DATE
=
'--date'
;
const
ARG_FILE_PATH
=
'--file'
;
$versionNumber
=
(
$pos
=
array_search
(
ARG_VERSION_NUMBER
,
$argv
))
!==
false
?
(
$argv
[
$pos
+
1
]
??
null
)
:
null
;
$versionDate
=
(
$pos
=
array_search
(
ARG_VERSION_DATE
,
$argv
))
!==
false
?
(
$argv
[
$pos
+
1
]
??
null
)
:
null
;
$configFilepath
=
(
$pos
=
array_search
(
ARG_FILE_PATH
,
$argv
))
!==
false
?
(
$argv
[
$pos
+
1
]
??
null
)
:
null
;
if
(
$versionNumber
===
null
)
{
echo
":-( Vous devez spécifier le numéro de version via "
.
ARG_VERSION_NUMBER
.
PHP_EOL
;
exit
(
1
);
}
if
(
$versionDate
===
null
)
{
echo
":-( Vous devez spécifier la date de version via "
.
ARG_VERSION_DATE
.
PHP_EOL
;
exit
(
1
);
}
if
(
$configFilepath
===
null
)
{
$configFilepath
=
DEFAULT_FILE_PATH
;
}
$configFilepath
=
realpath
(
$configFilepath
);
$config
=
[
'unicaen-app'
=>
[
'app_infos'
=>
[
'version'
=>
$versionNumber
,
'date'
=>
$versionDate
,
],
],
'comment'
=>
sprintf
(
"Fichier généré le %s avec le script '%s'."
,
date
(
'd/m/Y à H:i:s'
),
basename
(
__FILE__
))
];
$phpArray
=
new
PhpArray
();
$phpArray
->
setUseBracketArraySyntax
(
true
)
->
toFile
(
$configFilepath
,
$config
);
echo
"Fichier de config créé :
$configFilepath
"
.
PHP_EOL
;
echo
" Version inscrite :
$versionNumber
"
.
PHP_EOL
;
echo
" Date inscrite :
$versionDate
"
.
PHP_EOL
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment