Skip to content

Commit

Permalink
added extension method for returning semantic core version
Browse files Browse the repository at this point in the history
  • Loading branch information
Guite committed Jul 31, 2017
1 parent 68e4ed9 commit 0e2ef8f
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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»",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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».

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,42 +34,40 @@ 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;'

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»
Expand All @@ -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»
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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<Variables> The selected list.
* @return List<Variables> The selected list
*/
def getSortedVariableContainers(Application it) {
variables.sortBy[sortOrder]
Expand All @@ -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<Variable> The selected list.
* @return List<Variable> The selected list
*/
def getAllVariables(Application it) {
variables.map[vars].flatten.toList
Expand All @@ -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 != '')
Expand All @@ -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
Expand Down

0 comments on commit 0e2ef8f

Please sign in to comment.