diff --git a/.make/release/update-versions.php b/.make/release/update-versions.php new file mode 100644 index 000000000..0f1dcd24e --- /dev/null +++ b/.make/release/update-versions.php @@ -0,0 +1,47 @@ +UpdateAllFiles($sVersionLabel); +} diff --git a/.make/release/update-xml.php b/.make/release/update-xml.php new file mode 100644 index 000000000..9bb042a36 --- /dev/null +++ b/.make/release/update-xml.php @@ -0,0 +1,36 @@ +UpdateAllFiles($sVersionLabel); diff --git a/.make/release/update.classes.inc.php b/.make/release/update.classes.inc.php new file mode 100644 index 000000000..6e20ee0d7 --- /dev/null +++ b/.make/release/update.classes.inc.php @@ -0,0 +1,169 @@ +GetFiles(); + $sFileUpdaterName = get_class($this); + echo "# Updater : $sFileUpdaterName\n"; + foreach ($aFilesToUpdate as $sFileToUpdateFullPath) + { + try + { + $sCurrentFileContent = file_get_contents($sFileToUpdateFullPath); + $sNewFileContent = $this->UpdateFileContent($sVersionLabel, $sCurrentFileContent, $sFileToUpdateFullPath); + file_put_contents($sFileToUpdateFullPath, $sNewFileContent); + echo " - $sFileToUpdateFullPath : OK !\n"; + } + catch (Exception $e) + { + echo " - $sFileToUpdateFullPath : Error :(\n"; + } + } + } +} + +abstract class AbstractSingleFileVersionUpdater extends FileVersionUpdater +{ + private $sFileToUpdate; + + public function __construct($sFileToUpdate) + { + $this->sFileToUpdate = $sFileToUpdate; + } + + public function GetFiles() + { + return array(APPROOT.$this->sFileToUpdate); + } +} + +class iTopVersionFileUpdater extends AbstractSingleFileVersionUpdater +{ + public function __construct() + { + parent::__construct('datamodels/2.x/version.xml'); + } + + /** + * @inheritDoc + */ + public function UpdateFileContent($sVersionLabel, $sFileContent, $sFileFullPath) + { + return preg_replace( + '/()[^<]*(<\/version>)/', + '${1}'.$sVersionLabel.'${2}', + $sFileContent + ); + } +} + +class CssVariablesFileUpdater extends AbstractSingleFileVersionUpdater +{ + public function __construct() + { + parent::__construct('css/css-variables.scss'); + } + + /** + * @inheritDoc + */ + public function UpdateFileContent($sVersionLabel, $sFileContent, $sFileFullPath) + { + return preg_replace( + '/(\$version: "v)[^"]*(";)/', + '${1}'.$sVersionLabel.'${2}', + $sFileContent + ); + } +} + +abstract class AbstractGlobFileVersionUpdater extends FileVersionUpdater +{ + protected $sGlobPattern; + + public function __construct($sGlobPattern) + { + $this->sGlobPattern = $sGlobPattern; + } + + public function GetFiles() + { + return glob($this->sGlobPattern); + } +} + +class DatamodelsModulesFiles extends AbstractGlobFileVersionUpdater +{ + public function __construct() + { + parent::__construct(APPROOT.'datamodels/2.x/*/module.*.php'); + } + + /** + * @inheritDoc + */ + public function UpdateFileContent($sVersionLabel, $sFileContent, $sFileFullPath) + { + $sModulePath = realpath($sFileFullPath); + $sModuleFileName = basename($sModulePath, 1); + $sModuleName = preg_replace('/[^.]+\.([^.]+)\.php/', '$1', $sModuleFileName); + + return preg_replace( + "/('$sModuleName\/)[^']+(')/", + '${1}'.$sVersionLabel.'${2}', + $sFileContent + ); + } +} + +class DatamodelsXmlFiles extends AbstractGlobFileVersionUpdater +{ + public function __construct() + { + parent::__construct(APPROOT.'datamodels/2.x/*/datamodel.*.xml'); + } + + /** + * @inheritDoc + */ + public function UpdateFileContent($sVersionLabel, $sFileContent, $sFileFullPath) + { + return preg_replace( + '/()/', + '${1}'.$sVersionLabel.'${2}', + $sFileContent + ); + } +}