From 0e2ef8f6df24a3422a793d2c014f8ce84d3732dc Mon Sep 17 00:00:00 2001 From: Guite Date: Mon, 31 Jul 2017 12:33:30 +0200 Subject: [PATCH] added extension method for returning semantic core version --- .../zclassic/smallstuff/ComposerFile.xtend | 2 +- .../cartridges/zclassic/smallstuff/Docs.xtend | 2 +- .../zclassic/smallstuff/TravisFile.xtend | 38 +++++---- .../zclassic/smallstuff/ZikulaManifest.xtend | 2 +- .../generator/extensions/Utils.xtend | 80 ++++++++++++------- 5 files changed, 72 insertions(+), 52 deletions(-) diff --git a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/ComposerFile.xtend b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/ComposerFile.xtend index 8fdd2e48b..86f62234a 100644 --- a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/ComposerFile.xtend +++ b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/ComposerFile.xtend @@ -80,7 +80,7 @@ class ComposerFile { }, "extra": { "zikula": { - "core-compatibility": ">=«IF targets('2.0')»2.0.0«ELSE»1.5.0«ENDIF» <3.0", + "core-compatibility": ">=«targetSemVer» <3.0", "class": "«vendor.formatForCodeCapital»\\«name.formatForCodeCapital»Module\\«appName»", "displayname": "«name.formatForDisplayCapital»", "url": "«name.formatForDB»", diff --git a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/Docs.xtend b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/Docs.xtend index 9fc242038..d8823bc02 100644 --- a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/Docs.xtend +++ b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/Docs.xtend @@ -158,7 +158,7 @@ class Docs { «vendor.formatForDisplayCapital»\«name.formatForCodeCapital» module generated by ModuleStudio «msVersion». «ENDIF» - This module is intended for being used with Zikula «IF targets('2.0')»2.0.0«ELSE»1.5.0«ENDIF» and later. + This module is intended for being used with Zikula «targetSemVer» and later. For questions and other remarks visit our homepage «url». diff --git a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/TravisFile.xtend b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/TravisFile.xtend index 503293a4c..c1fc2ec6c 100644 --- a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/TravisFile.xtend +++ b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/TravisFile.xtend @@ -34,24 +34,29 @@ class TravisFile { - 5.6 - 7.0 - 7.1 - - hhvm + - nightly matrix: fast_finish: true allow_failures: - - php: 7.0 - - php: 7.1 - - php: hhvm + «IF !targets('2.0')» + - php: 7.0 + - php: 7.1 + «ENDIF» + - php: nightly services: - mysql before_install: - - if [[ "$TRAVIS_PHP_VERSION" != "nightly" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi; - - if [[ "$TRAVIS_PHP_VERSION" != "nightly" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Let's continue without memcache extension"; fi; - # - if [[ "$TRAVIS_PHP_VERSION" != "nightly" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php -i; fi; + - if [[ "$TRAVIS_PHP_VERSION" != "nightly" ]]; then phpenv config-rm xdebug.ini; fi; + # load memcache.so for php 5 + - if [[ "$TRAVIS_PHP_VERSION" != "nightly" ]] && [ $(php -r "echo PHP_MAJOR_VERSION;") == 5 ]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Continuing without memcache extension"; fi; + # load memcache.so for php >= 7.1 + - if [[ "$TRAVIS_PHP_VERSION" != "nightly" ]] && [ $(php -r "echo PHP_MAJOR_VERSION;") == 7 ] && [ $(php -r "echo PHP_MINOR_VERSION;") >= 1 ]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Continuing without memcache extension"; fi; # Set the COMPOSER_ROOT_VERSION to the right version according to the branch being built - if [ "$TRAVIS_BRANCH" = "master" ]; then export COMPOSER_ROOT_VERSION=dev-master; else export COMPOSER_ROOT_VERSION="$TRAVIS_BRANCH".x-dev; fi; + - composer self-update - if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi; - mysql -e 'create database zk_test;' @@ -59,17 +64,10 @@ class TravisFile { install: - composer install - zip -qr «appName».zip . - «IF targets('2.0')» - - wget http://ci.zikula.org/job/Zikula_Core-2.0.0/lastSuccessfulBuild/artifact/build/archive/Zikula_Core-2.0.0.tar.gz - - tar -xpzf Zikula_Core-2.0.0.tar.gz - - rm Zikula_Core-2.0.0.tar.gz - - cd Zikula_Core-2.0.0 - «ELSE» - - wget http://ci.zikula.org/job/Zikula_Core-1.5.0/lastSuccessfulBuild/artifact/build/archive/Zikula_Core-1.5.0.tar.gz - - tar -xpzf Zikula_Core-1.5.0.tar.gz - - rm Zikula_Core-1.5.0.tar.gz - - cd Zikula_Core-1.5.0 - «ENDIF» + - wget http://ci.zikula.org/job/Zikula_Core-«targetSemVer»/lastSuccessfulBuild/artifact/build/archive/Zikula_Core-«targetSemVer».tar.gz + - tar -xpzf Zikula_Core-«targetSemVer».tar.gz + - rm Zikula_Core-«targetSemVer».tar.gz + - cd Zikula_Core-«targetSemVer» - php app/console zikula:install:start -n --database_user=root --database_name=zk_test --password=12345678 --email=admin@example.com --router:request_context:host=localhost - php app/console zikula:install:finish «IF isSystemModule» @@ -79,7 +77,7 @@ class TravisFile { - unzip -q ../../../«appName» - cd ../.. - php app/console bootstrap:bundles - - mysql -e "INSERT INTO zk_test.modules (id, name, type, displayname, url, description, directory, version, capabilities, state, securityschema, core_min, core_max) VALUES (NULL, '«appName»', '3', '«name.formatForDisplayCapital»', '«name.formatForDB»', '«IF null !== documentation && documentation != ''»«documentation.replace('"', "'")»«ELSE»«appName» module generated by ModuleStudio «msVersion».«ENDIF»', '«appName»', '«version»', 'N;', '3', 'N;', '«IF targets('2.0')»2.0.0«ELSE»1.5.0«ENDIF»', '3.0.0');" + - mysql -e "INSERT INTO zk_test.modules (id, name, type, displayname, url, description, directory, version, capabilities, state, securityschema, core_min, core_max) VALUES (NULL, '«appName»', '3', '«name.formatForDisplayCapital»', '«name.formatForDB»', '«IF null !== documentation && documentation != ''»«documentation.replace('"', "'")»«ELSE»«appName» module generated by ModuleStudio «msVersion».«ENDIF»', '«appName»', '«version»', 'N;', '3', 'N;', '«targetSemVer»', '3.0.0');" «ELSE» - cd modules - mkdir «vendor.formatForDB» @@ -89,7 +87,7 @@ class TravisFile { - unzip -q ../../../../«appName» - cd ../../.. - php app/console bootstrap:bundles - - mysql -e "INSERT INTO zk_test.modules (id, name, type, displayname, url, description, directory, version, capabilities, state, securityschema, core_min, core_max) VALUES (NULL, '«appName»', '3', '«name.formatForDisplayCapital»', '«name.formatForDB»', '«IF null !== documentation && documentation != ''»«documentation.replace('"', "'")»«ELSE»«appName» module generated by ModuleStudio «msVersion».«ENDIF»', '«vendor.formatForDB»/«name.formatForDB»-module', '«version»', 'N;', '3', 'N;', '«IF targets('2.0')»2.0.0«ELSE»1.5.0«ENDIF»', '3.0.0');" + - mysql -e "INSERT INTO zk_test.modules (id, name, type, displayname, url, description, directory, version, capabilities, state, securityschema, core_min, core_max) VALUES (NULL, '«appName»', '3', '«name.formatForDisplayCapital»', '«name.formatForDB»', '«IF null !== documentation && documentation != ''»«documentation.replace('"', "'")»«ELSE»«appName» module generated by ModuleStudio «msVersion».«ENDIF»', '«vendor.formatForDB»/«name.formatForDB»-module', '«version»', 'N;', '3', 'N;', '«targetSemVer»', '3.0.0');" «ENDIF» - php app/console cache:warmup diff --git a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/ZikulaManifest.xtend b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/ZikulaManifest.xtend index fceaf0d33..3cafd6a2d 100644 --- a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/ZikulaManifest.xtend +++ b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/cartridges/zclassic/smallstuff/ZikulaManifest.xtend @@ -40,7 +40,7 @@ class ZikulaManifest { }, "version": { "semver": "«version»", - "compatibility": ">=«IF targets('2.0')»2.0.0«ELSE»1.5.0«ENDIF» <3.0.0", + "compatibility": ">=«targetSemVer» <3.0.0", "composerpath": "composer.json", "description": "«IF null !== documentation && documentation != ''»«documentation.replace('"', "'")»«ELSE»«appName» module generated by ModuleStudio «msVersion».«ENDIF»", "keywords": [ diff --git a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/extensions/Utils.xtend b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/extensions/Utils.xtend index ee908f232..2f1be9843 100644 --- a/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/extensions/Utils.xtend +++ b/bundles/org.zikula.modulestudio.generator/src/org/zikula/modulestudio/generator/extensions/Utils.xtend @@ -22,7 +22,7 @@ class Utils { /** * Returns the version number of ModuleStudio. * - * @return String The version number. + * @return String The version number */ def msVersion() { '1.0.0' @@ -31,7 +31,7 @@ class Utils { /** * Returns the website url of ModuleStudio. * - * @return String The website url. + * @return String The website url */ def msUrl() { 'https://modulestudio.de' @@ -40,9 +40,9 @@ class Utils { /** * Creates a placeholder file in a given file path. * - * @param it The {@link Application} instance. - * @param fsa The file system access. - * @param path The file path. + * @param it The {@link Application} instance + * @param fsa The file system access + * @param path The file path */ def createPlaceholder(Application it, IFileSystemAccess fsa, String path) { var fileName = 'README' @@ -59,9 +59,9 @@ class Utils { /** * Returns a combined title consisting of vendor and name. * - * @param it The {@link Application} instance. + * @param it The {@link Application} instance * - * @return String The formatted name. + * @return String The formatted name */ def String vendorAndName(Application it) { vendor.formatForCode + name.formatForCodeCapital @@ -70,9 +70,9 @@ class Utils { /** * Returns the formatted name of the application. * - * @param it The {@link Application} instance. + * @param it The {@link Application} instance * - * @return String The formatted name. + * @return String The formatted name */ def String appName(Application it) { vendor.formatForCodeCapital + name.formatForCodeCapital + 'Module' @@ -81,9 +81,9 @@ class Utils { /** * Returns the base namespace of the application. * - * @param it The {@link Application} instance. + * @param it The {@link Application} instance * - * @return String The formatted namespace. + * @return String The formatted namespace */ def appNamespace(Application it) { vendor.formatForCodeCapital + '\\' + name.formatForCodeCapital + 'Module' @@ -92,9 +92,9 @@ class Utils { /** * Returns prefix for service names for this application. * - * @param it The {@link Application} instance. + * @param it The {@link Application} instance * - * @return String The formatted service prefix. + * @return String The formatted service prefix */ def String appService(Application it) { vendor.formatForDB + '_' + name.formatForDB + '_module' @@ -103,9 +103,9 @@ class Utils { /** * Returns the lowercase application-specific prefix. * - * @param it The {@link Application} instance. + * @param it The {@link Application} instance * - * @return String The prefix. + * @return String The prefix */ def prefix(Application it) { prefix.formatForDB @@ -114,10 +114,10 @@ class Utils { /** * Checks whether a given core version is targeted or not. * - * @param it The {@link Application} instance. + * @param it The {@link Application} instance * @param version The version in question * - * @return Boolean The result. + * @return Boolean The result */ def Boolean targets(Application it, String version) { val useStable15 = !#['1.5-dev', '2.0', '2.0-dev'].contains(version) @@ -136,12 +136,34 @@ class Utils { } } + /** + * Returns the core version as semantic version number. + * + * @param it The {@link Application} instance + * + * @return String the formatted version number + */ + def targetSemVer(Application it) { + switch getCoreVersion { + case ZK2DEV: + '2.0.1' + case ZK20: + '2.0.0' + case ZK15: + '1.5.0' + case ZK15DEV: + '1.5.1' + default: + '1.5.0' + } + } + /** * Checks whether any variables are part of the model or not. * - * @param it The {@link Application} instance. + * @param it The {@link Application} instance * - * @return Boolean The result. + * @return Boolean The result */ def needsConfig(Application it) { !getAllVariables.empty @@ -150,9 +172,9 @@ class Utils { /** * Checks whether there exist multiple variables containers. * - * @param it The {@link Application} instance. + * @param it The {@link Application} instance * - * @return Boolean The result. + * @return Boolean The result */ def hasMultipleConfigSections(Application it) { variables.size > 1 @@ -161,9 +183,9 @@ class Utils { /** * Returns the variables containers sorted by their sort order. * - * @param it The {@link Application} instance. + * @param it The {@link Application} instance * - * @return List The selected list. + * @return List The selected list */ def getSortedVariableContainers(Application it) { variables.sortBy[sortOrder] @@ -172,9 +194,9 @@ class Utils { /** * Returns all variables for a given application. * - * @param it The {@link Application} instance. + * @param it The {@link Application} instance * - * @return List The selected list. + * @return List The selected list */ def getAllVariables(Application it) { variables.map[vars].flatten.toList @@ -183,10 +205,10 @@ class Utils { /** * Helper function for building id attributes for input fields in edit templates. * - * @param name The given name. - * @param suffix The given suffix. + * @param name The given name + * @param suffix The given suffix * - * @return String The concatenated identifier. + * @return String The concatenated identifier */ def templateIdWithSuffix(String name, String suffix) { if (null !== suffix && suffix != '') @@ -198,7 +220,7 @@ class Utils { /** * Returns the current timestamp to mark the generation time. * - * @return String The current timestamp. + * @return String The current timestamp */ def timestamp() { new Date(System.currentTimeMillis).toString