diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8d85bcf --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "launcher"] + path = launcher + url = https://github.com/WiproOpenSourcePractice/openapphack-launcher.git +[submodule "shell"] + path = shell + url = https://github.com/WiproOpenSourcePractice/openapphack-shell.git +[submodule "tools/generators"] + path = tools/generators + url = https://github.com/WiproOpenSourcePractice/generator-openapphack.git diff --git a/Dockerfile b/Dockerfile index 694b9b8..23263bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM dockerfile/java +FROM dockerfile/ansible # Copy all here -RUN mkdir -p /usr/src/app -ADD . /usr/src/app -WORKDIR /usr/src/app +RUN mkdir -p /usr/src/oah +ADD . /usr/src/oah +WORKDIR /usr/src/oah -CMD ["./gradlew"] +CMD ["./bin/install.sh"] diff --git a/README.md b/README.md index db490d6..f0ad691 100644 --- a/README.md +++ b/README.md @@ -2,78 +2,117 @@ [![Join the chat at https://gitter.im/WiproOpenSourcePractice/openapphack](https://badges.gitter.im/WiproOpenSourcePractice/openapphack.svg)](https://gitter.im/WiproOpenSourcePractice/openapphack?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -Openapphack is an attempt to enable end to end automation of Application Development using opensource tools for provisioning , code authoring and scaffolding. +Openapphack is an opensource application aggregrator. -Openapphack leverages vagrant, ansible and yeoman to do this. +Simplifies experimenting with opensource application . OpenAppHack projects can be used for testing and rapid prototyping of opensource solutions . OpenAppHack projects can also be run on low cost RPI cluster -The goal is to get a collection of fully functional , customizable apps working on the [openapphack-vm](https://github.com/WiproOpenSourcePractice/openapphack-vm) from a set of plain `yaml` files. - -The broader purpose is to provide a simplified path for full stack developers to quickly get started on opensource technologies and experiment freely. +The broader purpose is to provide a simplified path for full stack developers to quickly get started on opensource applications and experiment freely on deciding which opensource applications should be considered for building an opensource solution. ### Index -- [What is OpenAppHack Project?](https://github.com/WiproOpenSourcePractice/openapphack#what-is-openapphack-project) -- [Openapphack repositories](https://github.com/WiproOpenSourcePractice/openapphack#openapphack-repositories) -- [Contributing to this project](https://github.com/WiproOpenSourcePractice/openapphack#contributing-to-this-project) -- [How do you start your openapphack-project?](https://github.com/WiproOpenSourcePractice/openapphack#how-do-you-start-your-openapphack-project) - - [How do you customize your openapphack-project?](https://github.com/WiproOpenSourcePractice/openapphack#how-do-you-customize-your-openapphack-project) - - [How do you test your openapphack-project?](https://github.com/WiproOpenSourcePractice/openapphack#how-do-you-test-your-openapphack-project) - - [How do you submit your openapphack-project?](https://github.com/WiproOpenSourcePractice/openapphack#how-do-you-submit-your-openapphack-project) - +- [What is OpenAppHack Project?](https://github.com/WiproOpenSourcePractice/openapphack#what-is-openapphack-vm-project) +- [Openapphack subprojects and repositories ](https://github.com/WiproOpenSourcePractice/openapphack#openapphack-subprojects-and-repositories ) + - [Openapphack Template Projects](https://github.com/WiproOpenSourcePractice/openapphack#openapphack-template-projects) + - [Openapphack Extension Projects](https://github.com/WiproOpenSourcePractice/openapphack#openapphack-extension-projects) +- [Openapphack PI Cluster](https://github.com/WiproOpenSourcePractice/openapphack#openapphack-pi-cluster) ### What is OpenAppHack Project? -An **OpenAppHack Project** is a repository forked from the [openapphack-vm](https://github.com/WiproOpenSourcePractice/openapphack-vm) to your github organization or individual namespace. +An openapphack project is a git repository derived from one of the openapphack vm or cluster project templates -You need to make use of the openapphack [ansible](http://www.ansible.com/) roles and openapphack [yeoman](http://yeoman.io/) generators and build an impressive fully functional opensource application. +Openapphack and its subprojects help aggregate ,validate and test github repositories that derived from openapphack-vm, openapphack-cluster, openapphack-pi-vm, openapphack-pi-cluster repositories -*** +Openapphack also enables end to end automation of application deployment which can be leveraged for prototyping and distributed deployment of opensource applications . -### Openapphack repositories +Openapphack uses opensource tools for provisioning , code authoring and scaffolding. -The others repositories used by the openapphack project are: +The project templates are -[**Openapphack-vm**](https://github.com/WiproOpenSourcePractice/openapphack-vm) : Main repository which participants have to fork and will submit their pull requests. +- openapphack-vm : Template used for setting up a single openapphack vm. +- openapphack-pi-vm :Template used for setting up a single openapphack vm on RPI's. +- openapphack-cluster : Template used for setting up multi or load balanced/ HA cluster for the application. +- openapphack-pi-cluster : Template used for setting up multi or load balanced /HA cluster on openapphack RPI cluster. -[**Openapphack-ansible-roles**](https://github.com/WiproOpenSourcePractice/openapphack-ansible-roles) : Repository for ansible roles that can be used by openapphack projects, You can also add your own ansible roles that work on openapphack-vm +All openapphack projects github repositories must follows a naming convention and github repository names must end with either an xxx-vm, xxx-pi-vm ,xxx-pi-cluster or xxx-cluster to be picked up by the openapphack for analysis and testing. -[**Openapphack-yeoman-generators**](https://github.com/WiproOpenSourcePractice/openapphack-yeoman-generators) : Repository for the generators. You can also add your own yeoman generators that work on openapphack-vm, [more info](https://github.com/WiproOpenSourcePractice/openapphack-yeoman-generators/wiki/Openapphack-Yeoman-Generators) +Openapphack-vms/clusters leverages vagrant, ansible ,yeoman,virtualbox and docker for automation. *** -### Contributing to this project -You can start contributing to this project by starting your own openapphack project as mentioned below. +### Openapphack subprojects and repositories + +**Openapphack core projects** + +[**Openapphack-shell(oah)**](https://github.com/WiproOpenSourcePractice/openapphack-shell) : Shell for openapphack.. + +[**OpenAppHack-launcher(oah-app)**](): Openapphack Launcher + +[**Openapphack-stats**](https://github.com/WiproOpenSourcePractice/openapphack-stats) : The repository that will be updated periodically with test results and details from validated openapphack-vm/clusters.. + +#### **Openapphack Template Projects** + +[**Openapphack-vm**](https://github.com/WiproOpenSourcePractice/openapphack-vm) : The repository from which all openapphack-xxx-vm repos are derived. + +[**Openapphack-cluster**](https://github.com/WiproOpenSourcePractice/openapphack-cluster) : The repository from which all openapphack-xxx-cluster repos are derived.. + +[**Openapphack-pi-vm**](https://github.com/WiproOpenSourcePractice/openapphack-pi-vm) : The repository from which all openapphack-xxx-pi-vm repos are derived. -#### How do you start your openapphack-project? +[**Openapphack-pi-cluster**](https://github.com/WiproOpenSourcePractice/openapphack-pi-cluster) : The repository from which all openapphack-xxx-pi-cluster repos are derived.. -You begin by forking an [openapphack-vm](https://github.com/WiproOpenSourcePractice/openapphack-vm/) and follow the instructions mentioned [here](https://github.com/WiproOpenSourcePractice/openapphack-vm/blob/master/README.md) +##### **Openapphack Extension Projects** -#### How do you customize your openapphack-project? +This includes the various git repositories -You are free to tweak the vm configurations as long as the base vagrant box and the openapphack vm folder structure is maintained. Any additional customization must be done only in the `yaml` files. +- openapphack-XXXX-launcher-plugins(oah-launcher-plugins), +- ansible-role-openapphack-XXXX (oah-ansible-roles), +- openapphack-XXXX-vm (oah-vms), +- openapphack-XXXX-cluster (oah-clusters), +- openapphack-XXXX-recipes (oah-recipes), +- openapphack-XXXX-pi-cluster (oah-pi-clusters), +- openapphack-XXXX-pi-vm (oah-pi-vms) -You are also free to add (**only add**) and include your own yeoman generator and ansible roles as long as they work together on the openapphack-vm. +#### **Openapphack dev tools projects** -Please take a look [here](https://github.com/WiproOpenSourcePractice/openapphack-ansible-roles/wiki/Openapphack-Ansible-Roles) , on how to add your own openapphack ansible role +[**Openapphack-ansible-roles**](https://github.com/WiproOpenSourcePractice/openapphack-ansible-roles) : Repository used to organize all openapphack ansible roles . These can be used by openapphack projects, You can also add your own ansible roles that work on openapphack-vm -Please take a look [here](https://github.com/WiproOpenSourcePractice/openapphack-yeoman-generators/wiki/Openapphack-Yeoman-Generators) , on how to add your own openapphack yeoman generator +[**Openapphack-yeoman-generators**](https://github.com/WiproOpenSourcePractice/openapphack-yeoman-generators) : Repository used to organize all yeoman generators used by openapphack vm/clusters. You can also add your own yeoman generators that work on openapphack-vm, [more info](https://github.com/WiproOpenSourcePractice/openapphack-yeoman-generators/wiki/Openapphack-Yeoman-Generators) -#### How do you test your openapphack-project? +[**generator-openapphack**](https://github.com/WiproOpenSourcePractice/generator-openapphack) : Yeoman generator to generate openapphack vms/clusters , would be reorganized under openapphack-tools.. -clone your `openapphack-vm` associated with your githubid or org and run vagrant up , vagrant provision. +*** +### Openapphack PI Cluster -You should be able to validate and test your vm. +An openapphack-pi-cluster can be used to test your openapphack pi-vm/cluster projects -#### How do you submit your openapphack-project? ### +![Image of a DIY openapphack pi cluster](https://cloud.githubusercontent.com/assets/8347838/15924963/ab4d9504-2e52-11e6-8e04-c58c2bcb0fb2.png) -You will have to submit a pull request to [openapphack repository](https://github.com/WiproOpenSourcePractice/openapphack) to do so. +### Contributing to this project -If you are unsure on how to make a pull request. Please refer [github's guide on creating a pull request](https://help.github.com/articles/creating-a-pull-request/) +You can start contributing to this project by joining in on any of the openapphack projects mentioned above. -Do mention your github repository url and details of any ansible or yeoman generators you have included to get your openapphack project working. +#### How do you start your openapphack project? +This section is currently being revamped as openapphack project is being reorganized to enable greated community participation. -Please join the community @ https://groups.google.com/forum/#!forum/openapphack. +Please join the community @ https://groups.google.com/forum/#!forum/openapphack , to know more about the project. If you have any questions/suggestions please email to [openapphack-queries@googlegroups.com](mailto:openapphack-queries@googlegroups.com) + +#### Interested in going the extra mile : + +If you want to contribute to the development of openapphack main project please do take a look at the [issues](https://github.com/WiproOpenSourcePractice/openapphack/issues) + +You can get details on the branching model that will be followed [here] (http://nvie.com/posts/a-successful-git-branching-model/) , + + +## License + +This project is licensed under the MIT open source license. + +## Credits + +Still compiling this.. Lot of Folks to thank, we are standing on the shoulders of a lot of excellant programmers and a lot of opensource projects. + +here is a [list](https://github.com/WiproOpenSourcePractice/openapphack/wiki/Opensource-Projects-that-got-us-where-we-are-,-and-keeps-us-inspired-to-do-more..).. + diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..ab23e32 --- /dev/null +++ b/TODO.md @@ -0,0 +1,5 @@ +Refactoring TODOs + +a) Refactor openapphack as a toplevel ansible project , that is also an ansible role to install openapphack depending on where openapphack is being installed + + diff --git a/bin/install.sh b/bin/install.sh new file mode 100755 index 0000000..d5c3ae0 --- /dev/null +++ b/bin/install.sh @@ -0,0 +1,151 @@ +#!/bin/bash + +# Global variables +OPENAPPHACK_SERVICE="http://wiproopensourcepractice.github.io/openapphack/" +OPENAPPHACK_VERSION="0.0.1" +#OPENAPPHACK_DIR="${0%/*/*}" +OPENAPPHACK_DIR="${HOME}/.ove" + +# Local variables +openapphack_bin_folder="${OPENAPPHACK_DIR}/bin" +openapphack_tmp_folder="${OPENAPPHACK_DIR}/tmp" +openapphack_stage_folder="${openapphack_tmp_folder}/stage" +openapphack_etc_folder="${OPENAPPHACK_DIR}/etc" +openapphack_var_folder="${OPENAPPHACK_DIR}/var" +openapphack_config_file="${openapphack_etc_folder}/config" +openapphack_bash_profile="${HOME}/.bash_profile" +openapphack_profile="${HOME}/.profile" +openapphack_bashrc="${HOME}/.bashrc" +openapphack_zshrc="${HOME}/.zshrc" +openapphack_platform=$(uname) + +openapphack_init_snippet=$( cat << EOF +#THIS MUST BE AT THE END OF THE FILE FOR OPENAPPHACK CLI TO WORK!!! +[[ -s "${OPENAPPHACK_DIR}/bin/oah-init.sh" ]] && source "${OPENAPPHACK_DIR}/bin/oah-init.sh" +EOF +) + + +echo ' ' +echo 'Thanks for using OPENAPPHACK ' +echo ' ' +echo ' ' +echo ' Will now attempt installing...' +echo ' ' + + +# Sanity checks + +echo "Looking for a previous installation of OPENAPPHACK..." +if [ -d "${OPENAPPHACK_DIR}" ]; then + echo "OPENAPPHACK found." + echo "" + echo "======================================================================================================" + echo " You already have OPENAPPHACK installed." + echo " OPENAPPHACK was found at:" + echo "" + echo " ${OPENAPPHACK_DIR}" + echo "" + echo " Please consider running the following if you need to upgrade." + echo "" + echo " $ oah selfupdate" + echo "" + echo "======================================================================================================" + echo "" + exit 0 +fi + +echo "Looking for git..." +if [ -z $(which git) ]; then + echo "Not found." + echo "" + echo "======================================================================================================" + echo " Please install git on your system using your favourite package manager." + echo "" + echo " OPENAPPHACK uses git for crucial interactions with it's github repos." + echo "" + echo " Restart after installing git." + echo "======================================================================================================" + echo "" + exit 0 +fi + +echo "Looking for unzip..." +if [ -z $(which unzip) ]; then + echo "Not found." + echo "======================================================================================================" + echo " Please install unzip on your system using your favourite package manager." + echo "" + echo " Restart after installing unzip." + echo "======================================================================================================" + echo "" + exit 0 +fi + + +echo "Looking for curl..." +if [ -z $(which curl) ]; then + echo "Not found." + echo "" + echo "======================================================================================================" + echo " Please install curl on your system using your favourite package manager." + echo "" + echo " OPENAPPHACK uses curl for crucial interactions with it's github pages." + echo "" + echo " Restart after installing curl." + echo "======================================================================================================" + echo "" + exit 0 +fi + +echo "Looking for sed..." +if [ -z $(which sed) ]; then + echo "Not found." + echo "" + echo "======================================================================================================" + echo " Please install sed on your system using your favourite package manager." + echo "" + echo " OPENAPPHACK uses sed extensively." + echo "" + echo " Restart after installing sed." + echo "======================================================================================================" + echo "" + exit 0 +fi + + +echo "Looking for vagrant..." +if [ -z $(which vagrant) ]; then + echo "Not found." + echo "" + echo "======================================================================================================" + echo " Please install vagrant on your system using your favourite package manager." + echo "" + echo " OPENAPPHACK uses vagrant extensively." + echo "" + echo " Restart after installing vagrant." + echo "======================================================================================================" + echo "" + exit 0 +fi + +echo "Looking for ansible..." +if [ -z $(which ansible) ]; then + echo "Not found." + echo "" + echo "======================================================================================================" + echo " Please install ansible on your system using your favourite package manager." + echo "" + echo " OPENAPPHACK uses ansible extensively." + echo "" + echo " Restart after installing ansible." + echo "======================================================================================================" + echo "" + exit 0 +fi + +# if hostmachine then vagrant or Docker must be installed +# if client machine disable vagrant up commands +# TODO Set the Global var for OAH_HOST and OAH_CLIENT +ansible-galaxy install -r ../data/requirements.yml +ansible-playbook ../data/setup.yml diff --git a/src/main/bash/selfupdate.sh b/bin/selfupdate.sh old mode 100644 new mode 100755 similarity index 69% rename from src/main/bash/selfupdate.sh rename to bin/selfupdate.sh index cf235d6..87a01b2 --- a/src/main/bash/selfupdate.sh +++ b/bin/selfupdate.sh @@ -9,9 +9,10 @@ function openapphack_echo_debug { echo "" echo "Updating openapphack..." -OPENAPPHACK_VERSION="@OPENAPPHACK_VERSION@" +OPENAPPHACK_VERSION="0.0.1" if [ -z "${OPENAPPHACK_DIR}" ]; then - OPENAPPHACK_DIR="$HOME/.openapphack" +# OPENAPPHACK_DIR="${0%/*/*}" + OPENAPPHACK_DIR="~/.oah" fi # OS specific support (must be 'true' or 'false'). @@ -35,23 +36,10 @@ esac openapphack_platform=$(uname) openapphack_bin_folder="${OPENAPPHACK_DIR}/bin" -openapphack_tmp_zip="${OPENAPPHACK_DIR}/tmp/res-${OPENAPPHACK_VERSION}.zip" openapphack_stage_folder="${OPENAPPHACK_DIR}/tmp/stage" -openapphack_src_folder="${OPENAPPHACK_DIR}/src" - -openapphack_echo_debug "Purge existing scripts..." -rm -rf "${openapphack_bin_folder}" -rm -rf "${openapphack_src_folder}" - -openapphack_echo_debug "Refresh directory structure..." -mkdir -p "${OPENAPPHACK_DIR}/bin" -mkdir -p "${OPENAPPHACK_DIR}/ext" -mkdir -p "${OPENAPPHACK_DIR}/etc" -mkdir -p "${OPENAPPHACK_DIR}/src" -mkdir -p "${OPENAPPHACK_DIR}/var" -mkdir -p "${OPENAPPHACK_DIR}/tmp" -mkdir -p "${OPENAPPHACK_DIR}/vm" -mkdir -p "${OPENAPPHACK_DIR}/.vms" + +openapphack_echo_debug "git pull..." +git pull # prepare candidates OPENAPPHACK_CANDIDATES_CSV=$(curl -s "${OPENAPPHACK_SERVICE}/candidates") @@ -69,8 +57,8 @@ IFS="$OLD_IFS" for candidate in "${OPENAPPHACK_CANDIDATES[@]}"; do if [[ -n "$candidate" ]]; then - mkdir -p "${OPENAPPHACK_DIR}/.vms/${candidate}" - openapphack_echo_debug "Created for ${candidate}: ${OPENAPPHACK_DIR}/.vms/${candidate}" + mkdir -p "${OPENAPPHACK_DIR}/${candidate}" + openapphack_echo_debug "Created for ${candidate}: ${OPENAPPHACK_DIR}/${candidate}" fi done @@ -95,8 +83,7 @@ if [[ -z $(cat ${openapphack_config_file} | grep 'openapphack_insecure_ssl') ]]; fi openapphack_echo_debug "Download new scripts to: ${openapphack_tmp_zip}" -#https://github.com/WiproOpenSourcePractice/openapphack/raw/gh-pages/ -curl -s "${OPENAPPHACK_SERVICE}/res/platform/${openapphack_platform}/purpose/selfupdate/openapphack-cli-scripts.zip" > "${openapphack_tmp_zip}" +curl -s "${OPENAPPHACK_SERVICE}/platform/${openapphack_platform}/oah_scripts.zip" > "${openapphack_tmp_zip}" openapphack_echo_debug "Extract script archive..." openapphack_echo_debug "Unziping scripts to: ${openapphack_stage_folder}" @@ -107,21 +94,21 @@ else unzip -qo "${openapphack_tmp_zip}" -d "${openapphack_stage_folder}" fi -openapphack_echo_debug "Moving app-init file to bin folder..." -mv "${openapphack_stage_folder}/app-init.sh" "${openapphack_bin_folder}" +openapphack_echo_debug "Moving oah-init file to bin folder..." +mv "${openapphack_stage_folder}/oah-init.sh" "${openapphack_bin_folder}" openapphack_echo_debug "Move remaining module scripts to src folder: ${openapphack_src_folder}" -mv "${openapphack_stage_folder}"/app-* "${openapphack_src_folder}" +mv "${openapphack_stage_folder}"/oah-* "${openapphack_src_folder}" openapphack_echo_debug "Clean up staging folder..." rm -rf "${openapphack_stage_folder}" echo "" echo "" -echo "Successfully upgraded OpenAppHack CLI." +echo "Successfully upgraded OPENAPPHACK." echo "" echo "Please open a new terminal, or run the following in the existing one:" echo "" -echo " source \"${OPENAPPHACK_DIR}/bin/app-init.sh\"" +echo " source \"${OPENAPPHACK_DIR}/bin/oah-init.sh\"" echo "" echo "" diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 56ee3c2..0000000 --- a/build.gradle +++ /dev/null @@ -1,117 +0,0 @@ -import org.apache.tools.ant.filters.* - -buildscript { - repositories { - jcenter() - } -} - -apply plugin: 'groovy' -apply plugin: 'idea' -apply plugin: 'eclipse' - -defaultTasks 'clean', 'prepareTestScripts', 'prepareScripts', 'prepareServer', 'prepareTemplates', 'assembleArchive', 'test' - -def userHome = System.getProperty('user.home') -ext.installBinDir = "${userHome}/.openapphack/bin" -ext.installSrcDir = "${userHome}/.openapphack/src" - -ext.defaultopenapphackVersion = '1.0.0-SNAPSHOT' - -loadConfiguration() - -repositories { - jcenter() -} - -dependencies { - compile 'org.codehaus.groovy:groovy:2.3.7' - compile 'org.codehaus.groovy:groovy-templates:2.3.7' - testCompile 'junit:junit:4.11' - testCompile 'info.cukes:cucumber-groovy:1.1.8' - testCompile 'info.cukes:cucumber-junit:1.1.8' - testCompile 'org.spockframework:spock-core:0.7-groovy-2.0' - testCompile 'com.github.tomakehurst:wiremock:1.46' -} - -test.testLogging.exceptionFormat = 'full' - -def loadConfiguration() { - def environment = hasProperty('env') ? env : 'local' - ext.environment = environment - println "Environment is set to: $environment" - - def configFile = file('config.groovy') - def config = new ConfigSlurper(environment).parse(configFile.toURL()) - ext.config = config -} - -task prepareTemplates(type: Copy) { - from "src/main/templates" - into "build/templates" - include "*.gtpl" -} - -task prepareServer(type: Copy){ - from 'src/main/vertx' - into 'build/server' - include 'server.groovy' - filter(ReplaceTokens, tokens: [OPENAPPHACK_VERSION:config.openapphackVersion ?: defaultopenapphackVersion, VERTX_VERSION:config.vertxVersion]) -} - -task prepareTestScripts(type: Copy) { - from 'src/main/bash' - into 'build/testScripts' - include '**/*' - filter(ReplaceTokens, tokens: - [ - OPENAPPHACK_VERSION : "x.y.z", - OPENAPPHACK_SERVICE : config.openapphackService, - OPENAPPHACK_BROKER_SERVICE : config.openapphackBrokerService, - OPENAPPHACK_BROADCAST_SERVICE: config.openapphackBroadcastService - ] - ) -} - -task prepareScripts(type: Copy) { - from 'src/main/bash' - into 'build/scripts' - include '**/*' - filter(ReplaceTokens, tokens: - [ - OPENAPPHACK_VERSION : config.openapphackVersion ?: defaultopenapphackVersion, - OPENAPPHACK_SERVICE : config.openapphackService, - OPENAPPHACK_BROKER_SERVICE : config.openapphackBrokerService, - OPENAPPHACK_BROADCAST_SERVICE: config.openapphackBroadcastService - ] - ) -} - -task assembleArchive(type: Zip) { - classifier = 'scripts' - from "build/scripts" - include "app*" -} - -task cleanInstallInit(type: Delete) { - delete installBinDir -} - -task cleanInstallModules(type: Delete) { - delete installSrcDir -} - -task installInit(type: Copy, dependsOn: [cleanInstallInit, prepareScripts]) { - from "build/scripts" - into installBinDir - include "app-init.sh" -} - -task installModules(type: Copy, dependsOn: [cleanInstallModules, prepareScripts]) { - from "build/scripts" - into installSrcDir - include "app-*.sh" - exclude "app-init.sh" -} - -task install(dependsOn: [installInit, installModules]) diff --git a/config.groovy b/config.groovy deleted file mode 100644 index 86848b8..0000000 --- a/config.groovy +++ /dev/null @@ -1,19 +0,0 @@ -vertxVersion = '1.3.1.final' -openapphackVersion = '0.0.1' -environments { - local { - openapphackService = 'http://localhost:8080' - openapphackBroadcastService = 'http://localhost:8080' - openapphackBrokerService = 'http://localhost:8080' - } - master { - openapphackService = 'https://raw.githubusercontent.com/WiproOpenSourcePractice/openapphack/gh-pages' - openapphackBroadcastService = 'https://raw.githubusercontent.com/WiproOpenSourcePractice/openapphack/gh-pages/broadcast' - openapphackBrokerService = 'https://raw.githubusercontent.com/WiproOpenSourcePractice/openapphack/gh-pages/broker' - } - production { - openapphackService = 'https://raw.githubusercontent.com/openapphack/openapphack/gh-pages' - openapphackBroadcastService = 'https://raw.githubusercontent.com/openapphack/openapphack/gh-pages/broadcast' - openapphackBrokerService = 'https://raw.githubusercontent.com/openapphack/openapphack/gh-pages/broker' - } -} diff --git a/data/inventory b/data/inventory new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/data/inventory @@ -0,0 +1 @@ +localhost diff --git a/data/requirements.yml b/data/requirements.yml new file mode 100644 index 0000000..1c4071f --- /dev/null +++ b/data/requirements.yml @@ -0,0 +1,4 @@ + # from GitHub, overriding the name and specifying a specific tag + - src: https://github.com/openapphack/ansible-role-openapphack-setup + version: master + name: openapphack.setup diff --git a/data/setup.yml b/data/setup.yml new file mode 100644 index 0000000..1ad8168 --- /dev/null +++ b/data/setup.yml @@ -0,0 +1,7 @@ +--- + host: All + task: + - name: "Installing Openapphack shell" + shell: echo "Installing OAH shell" + roles: + openapphack.setup diff --git a/docs/design.md b/docs/design.md new file mode 100644 index 0000000..fc2ae6c --- /dev/null +++ b/docs/design.md @@ -0,0 +1,119 @@ +# Design principles + +- Simplify using a provisioning tool +- Standardize roles for install speed +- Preference will be given to a single OS per role. +- All VM/Cluster will be optimized for RPIs +- Tuned each vm to run with least resource requirement. +- High availability configuration must for clusters. +- Adhere to folder structure of oah-vms, oah-cluster and oah-roles +- Should be easy to get off the island , never get stuck with a framework or provisioning tools + +# oah shell + +- The oah shell when installed will enable executing the oah command on the shell prompt + + +## oah shell Commands on host + +oah help + +oah version + +oah install {vm_name/cluster_name} + +oah reset + +oah remove + +oah up + +oah down + +oah provision + +oah status + +oah list {roles,vms,cluster} + +oah show {roles} + + +## oah shell Commands on client + +oah version + +oah help + +oah list + +oah show {roles} + +oah reset + +oah validate + +## oah shell tools Commands + +oah generate-role {role_name} + +oah generate-vm {vm_name} + +oah generate-cluster {cluster_name} + +oah generate-launcher-plugin {plugin_name} + +### oah config Commands + +oah config set-oah-engine {ansible| any_other_oah_engine_name} + +oah config set-oah-playbook-executor {ansible-playbook| any_other_playbook_executor_name} + +oah config set-oah-roles-downloader {ansible-galaxy | any_other_roles_downloader_name} + +oah config set-oah-generator { yo | any_other_code_generator_name } + +# OAH role Specifications + +Layout : + +Files : + +Default Configurations: + +# VM Specifications + + +Layout for oah-vms: + +openapphack-xxxx-vm // root folder of VM + - README.md + - oah-config.yml + - provisioning // folder with all playbook + - oah-main.yml // default playbook + - oah-install.yml + - oah-reset.yml + - oah-remove.yml + - oah-requirements.yml + - host // folder to run the vm on host + - vagrant // provisioner is set to vagrant + - vagrantfile + - docker // provisioner is set to docker + - dockerfile + - runc // provisioner is set to runc + - runcfile + +Files : + + +Default Configurations : + +- oah-config.yml + +# Cluster Specifications + +Layout for oah-clusters: + +Files : + +Default Configurations : diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 085a1cd..0000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 4f5b518..0000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Sun Mar 01 11:06:52 GMT 2015 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip diff --git a/gradlew b/gradlew deleted file mode 100755 index 91a7e26..0000000 --- a/gradlew +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/launcher b/launcher new file mode 160000 index 0000000..622e85a --- /dev/null +++ b/launcher @@ -0,0 +1 @@ +Subproject commit 622e85af279fda381c12332a90ff71c98ac14d28 diff --git a/lib/heroku-javaagent-1.4.jar b/lib/heroku-javaagent-1.4.jar deleted file mode 100644 index fc7108e..0000000 Binary files a/lib/heroku-javaagent-1.4.jar and /dev/null differ diff --git a/mods/vertx.mongo-persistor-v1.2/lib/mongo-java-driver-2.9.0.jar b/mods/vertx.mongo-persistor-v1.2/lib/mongo-java-driver-2.9.0.jar deleted file mode 100644 index ea556b1..0000000 Binary files a/mods/vertx.mongo-persistor-v1.2/lib/mongo-java-driver-2.9.0.jar and /dev/null differ diff --git a/mods/vertx.mongo-persistor-v1.2/mod.json b/mods/vertx.mongo-persistor-v1.2/mod.json deleted file mode 100644 index a6dd373..0000000 --- a/mods/vertx.mongo-persistor-v1.2/mod.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "main": "org.vertx.mods.MongoPersistor", - "worker": true -} \ No newline at end of file diff --git a/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor$1.class b/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor$1.class deleted file mode 100644 index 2d1f746..0000000 Binary files a/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor$1.class and /dev/null differ diff --git a/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor$2.class b/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor$2.class deleted file mode 100644 index 872d56b..0000000 Binary files a/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor$2.class and /dev/null differ diff --git a/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor$3.class b/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor$3.class deleted file mode 100644 index 13ea7c6..0000000 Binary files a/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor$3.class and /dev/null differ diff --git a/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor.class b/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor.class deleted file mode 100644 index 7f87c80..0000000 Binary files a/mods/vertx.mongo-persistor-v1.2/org/vertx/mods/MongoPersistor.class and /dev/null differ diff --git a/openapphack_repo_submission_template.md b/openapphack_repo_submission_template.md new file mode 100644 index 0000000..f1e1a55 --- /dev/null +++ b/openapphack_repo_submission_template.md @@ -0,0 +1,11 @@ +Name: {Add your github repo name} + +- Description : {Add a meaningful description} + +- Version : {Add the github release tag} + +- Github-URL : {Add your github url} + +- Ansible-Roles: {List the ansible roles leveraged} + +- Yeoman-Generators: {List the yeoman generators leveraged.} diff --git a/openapphackprojects.md b/openapphackprojects.md deleted file mode 100644 index f56d495..0000000 --- a/openapphackprojects.md +++ /dev/null @@ -1,2 +0,0 @@ -List of Openapphack projects validated on openapphack-vm (version 0.1) - diff --git a/shell b/shell new file mode 160000 index 0000000..4e32478 --- /dev/null +++ b/shell @@ -0,0 +1 @@ +Subproject commit 4e324786b9090008f0633fd8b8df1dca4c4cc583 diff --git a/src/main/bash/app-broadcast.sh b/src/main/bash/app-broadcast.sh deleted file mode 100644 index eb0e7a4..0000000 --- a/src/main/bash/app-broadcast.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - - -function __apptool_broadcast { - if [ "${BROADCAST_OLD_TEXT}" ]; then - echo "${BROADCAST_OLD_TEXT}" - else - echo "${BROADCAST_LIVE_TEXT}" - fi -} - -function openapphack_update_broadcast_or_force_offline { - BROADCAST_LIVE_ID=$(openapphack_infer_broadcast_id) - - openapphack_force_offline_on_proxy "$BROADCAST_LIVE_ID" - if [[ "$OPENAPPHACK_FORCE_OFFLINE" == 'true' ]]; then BROADCAST_LIVE_ID=""; fi - - openapphack_display_online_availability - openapphack_determine_offline "$BROADCAST_LIVE_ID" - - apptool_update_broadcast "$COMMAND" "$BROADCAST_LIVE_ID" -} - -function openapphack_infer_broadcast_id { - if [[ "$OPENAPPHACK_FORCE_OFFLINE" == "true" || ( "$COMMAND" == "offline" && "$QUALIFIER" == "enable" ) ]]; then - echo "" - else - echo $(curl -s "${OPENAPPHACK_BROADCAST_SERVICE}/broadcast/latest/id") - fi -} - -function openapphack_display_online_availability { - if [[ -z "$BROADCAST_LIVE_ID" && "$OPENAPPHACK_ONLINE" == "true" && "$COMMAND" != "offline" ]]; then - echo "$OFFLINE_BROADCAST" - fi - - if [[ -n "$BROADCAST_LIVE_ID" && "$OPENAPPHACK_ONLINE" == "false" ]]; then - echo "$ONLINE_BROADCAST" - fi -} - -function apptool_update_broadcast { - local command="$1" - local broadcast_live_id="$2" - - local broadcast_id_file="${OPENAPPHACK_DIR}/var/broadcast_id" - local broadcast_text_file="${OPENAPPHACK_DIR}/var/broadcast" - - local broadcast_old_id="" - - if [[ -f "$broadcast_id_file" ]]; then - broadcast_old_id=$(cat "$broadcast_id_file"); - fi - - if [[ -f "$broadcast_text_file" ]]; then - BROADCAST_OLD_TEXT=$(cat "$broadcast_text_file"); - fi - - if [[ "${OPENAPPHACK_AVAILABLE}" == "true" && "$broadcast_live_id" != "${broadcast_old_id}" && "$command" != "selfupdate" && "$command" != "flush" ]]; then - mkdir -p "${OPENAPPHACK_DIR}/var" - - echo "${broadcast_live_id}" > "$broadcast_id_file" - - BROADCAST_LIVE_TEXT=$(curl -s "${OPENAPPHACK_BROADCAST_SERVICE}/broadcast/latest") - echo "${BROADCAST_LIVE_TEXT}" > "${broadcast_text_file}" - echo "${BROADCAST_LIVE_TEXT}" - fi -} diff --git a/src/main/bash/app-common.sh b/src/main/bash/app-common.sh deleted file mode 100644 index beddae2..0000000 --- a/src/main/bash/app-common.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash - -# -# common internal function definitions -# - -function __apptool_check_candidate_present { - if [ -z "$1" ]; then - echo -e "\nNo candidate provided." - __apptool_help - return 1 - fi -} - -function __apptool_check_version_present { - if [ -z "$1" ]; then - echo -e "\nNo candidate version provided." - __apptool_help - return 1 - fi -} - -function __apptool_determine_version { - - if [[ "${OPENAPPHACK_AVAILABLE}" == "false" && -n "$1" && -d "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/$1" ]]; then - VERSION="$1" - - elif [[ "${OPENAPPHACK_AVAILABLE}" == "false" && -z "$1" && -L "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/current" ]]; then - - VERSION=$(readlink "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/current" | sed "s!${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/!!g") - - elif [[ "${OPENAPPHACK_AVAILABLE}" == "false" && -n "$1" ]]; then - echo "Stop! ${CANDIDATE} ${1} is not available in offline mode." - return 1 - - elif [[ "${OPENAPPHACK_AVAILABLE}" == "false" && -z "$1" ]]; then - echo "${OFFLINE_MESSAGE}" - return 1 - - elif [[ "${OPENAPPHACK_AVAILABLE}" == "true" && -z "$1" ]]; then - VERSION_VALID='valid' - VERSION=$(curl -s "${OPENAPPHACK_SERVICE}/candidates/${CANDIDATE}/default") - - else - VERSION_VALID=$(curl -s "${OPENAPPHACK_SERVICE}/candidates/${CANDIDATE}/$1") - if [[ "${VERSION_VALID}" == 'valid' || ( "${VERSION_VALID}" == 'invalid' && -n "$2" ) ]]; then - VERSION="$1" - - elif [[ "${VERSION_VALID}" == 'invalid' && -h "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/$1" ]]; then - VERSION="$1" - - elif [[ "${VERSION_VALID}" == 'invalid' && -d "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/$1" ]]; then - VERSION="$1" - - else - echo "" - echo "Stop! $1 is not a valid ${CANDIDATE} version." - return 1 - fi - fi -} - -function __apptool_default_environment_variables { - - if [ ! "$OPENAPPHACK_FORCE_OFFLINE" ]; then - OPENAPPHACK_FORCE_OFFLINE="false" - fi - - if [ ! "$OPENAPPHACK_ONLINE" ]; then - OPENAPPHACK_ONLINE="true" - fi - - if [[ "${OPENAPPHACK_ONLINE}" == "false" || "${OPENAPPHACK_FORCE_OFFLINE}" == "true" ]]; then - OPENAPPHACK_AVAILABLE="false" - else - OPENAPPHACK_AVAILABLE="true" - fi -} - -function __apptool_link_candidate_version { - CANDIDATE="$1" - VERSION="$2" - - # Change the 'current' symlink for the candidate, hence affecting all shells. - if [ -L "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/current" ]; then - unlink "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/current" - fi - ln -s "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/${VERSION}" "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/current" -} diff --git a/src/main/bash/app-current.sh b/src/main/bash/app-current.sh deleted file mode 100644 index 4a6baa9..0000000 --- a/src/main/bash/app-current.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -function __apptool_determine_current_version { - CANDIDATE="$1" - if [[ "${solaris}" == true ]]; then - CURRENT=$(echo $PATH | gsed -r "s|${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/([^/]+)/bin|!!\1!!|1" | gsed -r "s|^.*!!(.+)!!.*$|\1|g") - elif [[ "${darwin}" == true ]]; then - CURRENT=$(echo $PATH | sed -E "s|${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/([^/]+)/bin|!!\1!!|1" | sed -E "s|^.*!!(.+)!!.*$|\1|g") - else - CURRENT=$(echo $PATH | sed -r "s|${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/([^/]+)/bin|!!\1!!|1" | sed -r "s|^.*!!(.+)!!.*$|\1|g") - fi - - if [[ "${CURRENT}" == "current" ]]; then - unset CURRENT - fi - - if [[ -z ${CURRENT} ]]; then - CURRENT=$(readlink "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/current" | sed "s!${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/!!g") - fi -} - -function __apptool_current { - if [ -n "$1" ]; then - CANDIDATE="$1" - __apptool_determine_current_version "${CANDIDATE}" - if [ -n "${CURRENT}" ]; then - echo "Using ${CANDIDATE} version ${CURRENT}" - else - echo "Not using any version of ${CANDIDATE}" - fi - else - INSTALLED_COUNT=0 - for (( i=0; i <= ${#OPENAPPHACK_CANDIDATES}; i++ )); do - # Eliminate empty entries due to incompatibility - if [[ -n ${OPENAPPHACK_CANDIDATES[${i}]} ]]; then - __apptool_determine_current_version "${OPENAPPHACK_CANDIDATES[${i}]}" - if [ -n "${CURRENT}" ]; then - if [ ${INSTALLED_COUNT} -eq 0 ]; then - echo 'Using:' - fi - echo "${OPENAPPHACK_CANDIDATES[${i}]}: ${CURRENT}" - (( INSTALLED_COUNT += 1 )) - fi - fi - done - if [ ${INSTALLED_COUNT} -eq 0 ]; then - echo 'No candidates are in use' - fi - fi -} diff --git a/src/main/bash/app-default.sh b/src/main/bash/app-default.sh deleted file mode 100644 index 1af7737..0000000 --- a/src/main/bash/app-default.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - - - -function __apptool_default { - CANDIDATE="$1" - __apptool_check_candidate_present "${CANDIDATE}" || return 1 - __apptool_determine_version "$2" || return 1 - - if [ ! -d "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/${VERSION}" ]; then - echo "" - echo "Stop! ${CANDIDATE} ${VERSION} is not installed." - return 1 - fi - - __apptool_link_candidate_version "${CANDIDATE}" "${VERSION}" - - echo "" - echo "Default ${CANDIDATE} version set to ${VERSION}" -} diff --git a/src/main/bash/app-destroy.sh b/src/main/bash/app-destroy.sh deleted file mode 100644 index 3ab137f..0000000 --- a/src/main/bash/app-destroy.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -function __apptool_destroy { - vagrant destroy -} diff --git a/src/main/bash/app-flush.sh b/src/main/bash/app-flush.sh deleted file mode 100644 index 1f92554..0000000 --- a/src/main/bash/app-flush.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - - -function __apptool_cleanup_folder { - OPENAPPHACK_CLEANUP_DIR="${OPENAPPHACK_DIR}/${1}" - OPENAPPHACK_CLEANUP_DU=$(du -sh "$OPENAPPHACK_CLEANUP_DIR") - OPENAPPHACK_CLEANUP_COUNT=$(ls -1 "$OPENAPPHACK_CLEANUP_DIR" | wc -l) - - rm -rf "${OPENAPPHACK_DIR}/${1}" - mkdir "${OPENAPPHACK_DIR}/${1}" - - echo "${OPENAPPHACK_CLEANUP_COUNT} archive(s) flushed, freeing ${OPENAPPHACK_CLEANUP_DU}." - - unset OPENAPPHACK_CLEANUP_DIR - unset OPENAPPHACK_CLEANUP_DU - unset OPENAPPHACK_CLEANUP_COUNT -} - -function __apptool_flush { - QUALIFIER="$1" - case "$QUALIFIER" in - candidates) - if [[ -f "${OPENAPPHACK_DIR}/var/candidates" ]]; then - rm "${OPENAPPHACK_DIR}/var/candidates" - echo "Candidates have been flushed." - else - echo "No candidate list found so not flushed." - fi - ;; - broadcast) - if [[ -f "${OPENAPPHACK_DIR}/var/broadcast" ]]; then - rm "${OPENAPPHACK_DIR}/var/broadcast" - echo "Broadcast has been flushed." - else - echo "No prior broadcast found so not flushed." - fi - ;; - version) - if [[ -f "${OPENAPPHACK_DIR}/var/version" ]]; then - rm "${OPENAPPHACK_DIR}/var/version" - echo "Version Token has been flushed." - else - echo "No prior Remote Version found so not flushed." - fi - ;; - vms) - __apptool_cleanup_folder ".vms" - ;; - archives) - __apptool_cleanup_folder "archives" - ;; - temp) - __apptool_cleanup_folder "tmp" - ;; - tmp) - __apptool_cleanup_folder "tmp" - ;; - *) - echo "Stop! Please specify what you want to flush." - ;; - esac -} diff --git a/src/main/bash/app-halt.sh b/src/main/bash/app-halt.sh deleted file mode 100644 index 0770d89..0000000 --- a/src/main/bash/app-halt.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -function __apptool_halt { - vagrant halt -} diff --git a/src/main/bash/app-help.sh b/src/main/bash/app-help.sh deleted file mode 100644 index 228ab6e..0000000 --- a/src/main/bash/app-help.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - - - -function __apptool_help { - echo "" - echo "Usage: app [version]" - echo " app offline " - echo "" - echo " commands:" - echo " install or i [version]" - echo " uninstall or rm " - echo " list or ls " - echo " use or u [version]" - echo " default or d [version]" - echo " current or c [candidate]" - echo " outdated or o [candidate]" - echo " up or up" - echo " halt or k" - echo " provision or p" - echo " destroy or x" - echo " version or v" - echo " broadcast or b" - echo " help or h" - echo " offline " - echo " selfupdate [force]" - echo " flush " - echo "" - echo -n " candidate : " - echo "$OPENAPPHACK_CANDIDATES_CSV" | sed 's/,/, /g' - echo " version : where optional, defaults to latest stable if not provided" - echo "" - echo "eg: app install openapphack" -} diff --git a/src/main/bash/app-init.sh b/src/main/bash/app-init.sh deleted file mode 100644 index 27b0b40..0000000 --- a/src/main/bash/app-init.sh +++ /dev/null @@ -1,175 +0,0 @@ -#!/bin/bash - - -export OPENAPPHACK_VERSION="@OPENAPPHACK_VERSION@" -export OPENAPPHACK_PLATFORM=$(uname) - -if [ -z "${OPENAPPHACK_SERVICE}" ]; then - export OPENAPPHACK_SERVICE="@OPENAPPHACK_SERVICE@" -fi - -if [ -z "${OPENAPPHACK_BROADCAST_SERVICE}" ]; then - export OPENAPPHACK_BROADCAST_SERVICE="@OPENAPPHACK_BROADCAST_SERVICE@" -fi - -if [ -z "${OPENAPPHACK_BROKER_SERVICE}" ]; then - export OPENAPPHACK_BROKER_SERVICE="@OPENAPPHACK_BROKER_SERVICE@" -fi - -if [ -z "${OPENAPPHACK_DIR}" ]; then - export OPENAPPHACK_DIR="$HOME/.openapphack" -fi - -# force zsh to behave well -if [[ -n "$ZSH_VERSION" ]]; then - setopt shwordsplit -fi - -# OS specific support (must be 'true' or 'false'). -cygwin=false; -darwin=false; -solaris=false; -freebsd=false; -case "$(uname)" in - CYGWIN*) - cygwin=true - ;; - Darwin*) - darwin=true - ;; - SunOS*) - solaris=true - ;; - FreeBSD*) - freebsd=true -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if ${cygwin} ; then - [ -n "${JAVACMD}" ] && JAVACMD=$(cygpath --unix "${JAVACMD}") - [ -n "${JAVA_HOME}" ] && JAVA_HOME=$(cygpath --unix "${JAVA_HOME}") - [ -n "${CP}" ] && CP=$(cygpath --path --unix "${CP}") -fi - - -OFFLINE_BROADCAST=$( cat << EOF -==== BROADCAST ============================================= - -OFFLINE MODE ENABLED! Some functionality is now disabled. - -============================================================ -EOF -) - -ONLINE_BROADCAST=$( cat << EOF -==== BROADCAST ============================================= - -ONLINE MODE RE-ENABLED! All functionality now restored. - -============================================================ -EOF -) - -OFFLINE_MESSAGE="This command is not available in offline mode." - -# fabricate list of candidates -if [[ -f "${OPENAPPHACK_DIR}/var/candidates" ]]; then - OPENAPPHACK_CANDIDATES_CSV=$(cat "${OPENAPPHACK_DIR}/var/candidates") -else - OPENAPPHACK_CANDIDATES_CSV=$(curl -s "${OPENAPPHACK_SERVICE}/candidates") - echo "$OPENAPPHACK_CANDIDATES_CSV" > "${OPENAPPHACK_DIR}/var/candidates" -fi - - - -# Set the candidate array -OLD_IFS="$IFS" -IFS="," -OPENAPPHACK_CANDIDATES=(${OPENAPPHACK_CANDIDATES_CSV}) -IFS="$OLD_IFS" - -# Source openapphack module scripts. -for f in $(find "${OPENAPPHACK_DIR}/src" -type f -name 'app-*' -exec basename {} \;); do - source "${OPENAPPHACK_DIR}/src/${f}" -done - -# Source extension files prefixed with 'app-' and found in the ext/ folder -# Use this if extensions are written with the functional approach and want -# to use functions in the main openapphack script. -for f in $(find "${OPENAPPHACK_DIR}/ext" -type f -name 'app-*' -exec basename {} \;); do - source "${OPENAPPHACK_DIR}/ext/${f}" -done -unset f - -# Attempt to set JAVA_HOME if it's not already set. -if [ -z "${JAVA_HOME}" ] ; then - if ${darwin} ; then - [ -z "${JAVA_HOME}" -a -f "/usr/libexec/java_home" ] && export JAVA_HOME=$(/usr/libexec/java_home) - [ -z "${JAVA_HOME}" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home" - [ -z "${JAVA_HOME}" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home" - else - javaExecutable="$(which javac 2> /dev/null)" - [[ -z "${javaExecutable}" ]] && echo "OPENAPPHACK: JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME." && return - - readLink="$(which readlink 2> /dev/null)" - [[ -z "${readLink}" ]] && echo "OPENAPPHACK: JAVA_HOME not set and readlink not available, please set JAVA_HOME." && return - - javaExecutable="$(readlink -f "${javaExecutable}")" - javaHome="$(dirname "${javaExecutable}")" - javaHome=$(expr "${javaHome}" : '\(.*\)/bin') - JAVA_HOME="${javaHome}" - [[ -z "${JAVA_HOME}" ]] && echo "OPENAPPHACK: could not find java, please set JAVA_HOME" && return - export JAVA_HOME - fi -fi - -# Load the openapphack config if it exists. -if [ -f "${OPENAPPHACK_DIR}/etc/config" ]; then - source "${OPENAPPHACK_DIR}/etc/config" -fi - -# Create upgrade delay token if it doesn't exist -if [[ ! -f "${OPENAPPHACK_DIR}/var/delay_upgrade" ]]; then - touch "${OPENAPPHACK_DIR}/var/delay_upgrade" -fi - -# determine if up to date -OPENAPPHACK_VERSION_TOKEN="${OPENAPPHACK_DIR}/var/version" -if [[ -f "$OPENAPPHACK_VERSION_TOKEN" && -z "$(find "$OPENAPPHACK_VERSION_TOKEN" -mmin +$((60*24)))" ]]; then - OPENAPPHACK_REMOTE_VERSION=$(cat "$OPENAPPHACK_VERSION_TOKEN") - -else - OPENAPPHACK_REMOTE_VERSION=$(curl -s "${OPENAPPHACK_SERVICE}/app/version" --connect-timeout 1 --max-time 1) - openapphack_force_offline_on_proxy "$OPENAPPHACK_REMOTE_VERSION" - if [[ -z "$OPENAPPHACK_REMOTE_VERSION" || "$OPENAPPHACK_FORCE_OFFLINE" == 'true' ]]; then - OPENAPPHACK_REMOTE_VERSION="$OPENAPPHACK_VERSION" - else - echo ${OPENAPPHACK_REMOTE_VERSION} > "$OPENAPPHACK_VERSION_TOKEN" - fi -fi - -# initialise once only -if [[ "${OPENAPPHACK_INIT}" != "true" ]]; then - # Build _HOME environment variables and prefix them all to PATH - - # The candidates are assigned to an array for zsh compliance, a list of words is not iterable - # Arrays are the only way, but unfortunately zsh arrays are not backward compatible with bash - # In bash arrays are zero index based, in zsh they are 1 based(!) - for (( i=0; i <= ${#OPENAPPHACK_CANDIDATES}; i++ )); do - # Eliminate empty entries due to incompatibility - if [[ -n ${OPENAPPHACK_CANDIDATES[${i}]} ]]; then - CANDIDATE_NAME="${OPENAPPHACK_CANDIDATES[${i}]}" - CANDIDATE_HOME_VAR="$(echo ${CANDIDATE_NAME} | tr '[:lower:]' '[:upper:]')_HOME" - CANDIDATE_DIR="${OPENAPPHACK_DIR}/${CANDIDATE_NAME}/current" - export $(echo ${CANDIDATE_HOME_VAR})="$CANDIDATE_DIR" - PATH="${CANDIDATE_DIR}/bin:${PATH}" - unset CANDIDATE_HOME_VAR - unset CANDIDATE_NAME - unset CANDIDATE_DIR - fi - done - unset i - export PATH - - export OPENAPPHACK_INIT="true" -fi diff --git a/src/main/bash/app-install.sh b/src/main/bash/app-install.sh deleted file mode 100644 index b3e5d88..0000000 --- a/src/main/bash/app-install.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash - -function __apptool_download { - CANDIDATE="$1" - VERSION="${2:=master}" - mkdir -p "${OPENAPPHACK_DIR}/archives" - if [ ! -f "${OPENAPPHACK_DIR}/archives/${CANDIDATE}-${VERSION}.zip" ]; then - echo "" - echo "Downloading: ${CANDIDATE} ${VERSION}" - echo "" - DOWNLOAD_URL="${OPENAPPHACK_SERVICE}/download/${CANDIDATE}/${VERSION}/platform/${OPENAPPHACK_PLATFORM}/openapphackvm-${VERSION}.zip" - ZIP_ARCHIVE="${OPENAPPHACK_DIR}/archives/${CANDIDATE}-${VERSION}.zip" - if [[ "$openapphack_insecure_ssl" == "true" ]]; then - curl -k -L "${DOWNLOAD_URL}" > "${ZIP_ARCHIVE}" - else - curl -L "${DOWNLOAD_URL}" > "${ZIP_ARCHIVE}" - fi - __apptool_validate_zip "${ZIP_ARCHIVE}" || return 1 - else - echo "" - echo "Found a previously downloaded ${CANDIDATE} ${VERSION} archive. Not downloading it again..." - __apptool_validate_zip "${OPENAPPHACK_DIR}/archives/${CANDIDATE}-${VERSION}.zip" || return 1 - fi - echo "" -} - -function __apptool_validate_zip { - ZIP_ARCHIVE="$1" - ZIP_OK=$(unzip -t "${ZIP_ARCHIVE}" | grep 'No errors detected in compressed data') - if [ -z "${ZIP_OK}" ]; then - rm "${ZIP_ARCHIVE}" - echo "" - echo "Stop! The archive was corrupt and has been removed! Please try installing again." - return 1 - fi -} - -function __apptool_install { - CANDIDATE="$1" - LOCAL_FOLDER="$3" - __apptool_check_candidate_present "${CANDIDATE}" || return 1 - __apptool_determine_version "$2" "$3" || return 1 - - if [[ -d "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/${VERSION}" || -h "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/${VERSION}" ]]; then - echo "" - echo "Stop! ${CANDIDATE} ${VERSION} is already installed." - return 0 - fi - - if [[ ${VERSION_VALID} == 'valid' ]]; then - __apptool_install_candidate_version "${CANDIDATE}" "${VERSION}" || return 1 - - if [[ "${openapphack_auto_answer}" != 'true' ]]; then - echo -n "Do you want ${CANDIDATE} ${VERSION} to be set as default? (Y/n): " - read USE - fi - if [[ -z "${USE}" || "${USE}" == "y" || "${USE}" == "Y" ]]; then - echo "" - echo "Setting ${CANDIDATE} ${VERSION} as default." - __apptool_link_candidate_version "${CANDIDATE}" "${VERSION}" - fi - return 0 - - elif [[ "${VERSION_VALID}" == 'invalid' && -n "${LOCAL_FOLDER}" ]]; then - __apptool_install_local_version "${CANDIDATE}" "${VERSION}" "${LOCAL_FOLDER}" || return 1 - - else - echo "" - echo "Stop! $1 is not a valid ${CANDIDATE} version." - return 1 - fi -} - - -function __apptool_install_local_version { - CANDIDATE="$1" - VERSION="${2:=master}" - LOCAL_FOLDER="$3" - CANDIDATE_VM_LOCATION="${OPENAPPHACK_DIR}/.vms/${CANDIDATE}" - mkdir -p "${CANDIDATE_VM_LOCATION}" - - echo "Linking ${CANDIDATE} ${VERSION} to ${LOCAL_FOLDER}" - ln -s "${LOCAL_FOLDER}" "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/${VERSION}" - echo "Done installing!" - echo "" -} - - -function __apptool_install_candidate_version { - CANDIDATE="$1" - # version defaults to master if no tag is giving - VERSION="${2:=master}" - echo "Installing: ${CANDIDATE} ${VERSION}" - - CANDIDATE_VM_LOCATION="${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/${VERSION}" - CANDIDATE_VM_LOCATION_CURRENT="${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/current" - VM_LOCATION="${OPENAPPHACK_DIR}/vm" - - mkdir -p "${CANDIDATE_VM_LOCATION}" - pushd . - cd "${CANDIDATE_VM_LOCATION}" - - git clone https://github.com/${CANDIDATE}/openapphack-vm.git - - #TODO check for valid tag before checkout of TAG - - if [[ -z "${VERSION}" || "${VERSION}" != "master" ]]; then - git checkout "tags/${VERSION}" - fi - - # Change the 'vm' symlink , hence affecting all shells. - if [ -L "${VM_LOCATION}" ]; then - unlink "${VM_LOCATION}" - fi - - - # Change the 'current candidate vm' symlink , hence affecting all shells. - if [ -L "${CANDIDATE_VM_LOCATION_CURRENT}" ]; then - unlink "${CANDIDATE_VM_LOCATION_CURRENT}" - fi - - ln -s "${CANDIDATE_VM_LOCATION_CURRENT}" "${CANDIDATE_VM_LOCATION}" - - ln -s "${VM_LOCATION}" "${CANDIDATE_VM_LOCATION_CURRENT}" - - popd - - echo "Done installing!" - echo "" -} diff --git a/src/main/bash/app-list.sh b/src/main/bash/app-list.sh deleted file mode 100644 index a449907..0000000 --- a/src/main/bash/app-list.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - - -function __apptool_build_version_csv { - CANDIDATE="$1" - CSV="" - for version in $(find "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}" -maxdepth 1 -mindepth 1 -exec basename '{}' \; | sort); do - if [[ "${version}" != 'current' ]]; then - CSV="${version},${CSV}" - fi - done - CSV=${CSV%?} -} - -function __apptool_offline_list { - echo "------------------------------------------------------------" - echo "Offline Mode: only showing installed ${CANDIDATE} versions" - echo "------------------------------------------------------------" - echo " " - - openapphack_versions=($(echo ${CSV//,/ })) - for (( i=0 ; i <= ${#openapphack_versions} ; i++ )); do - if [[ -n "${openapphack_versions[${i}]}" ]]; then - if [[ "${openapphack_versions[${i}]}" == "${CURRENT}" ]]; then - echo -e " > ${openapphack_versions[${i}]}" - else - echo -e " * ${openapphack_versions[${i}]}" - fi - fi - done - - if [[ -z "${openapphack_versions[@]}" ]]; then - echo " None installed!" - fi - - echo "------------------------------------------------------------" - echo "* - installed " - echo "> - currently in use " - echo "------------------------------------------------------------" - - unset CSV openapphack_versions -} - -function __apptool_list { - CANDIDATE="$1" - __apptool_check_candidate_present "${CANDIDATE}" || return 1 - __apptool_build_version_csv "${CANDIDATE}" - __apptool_determine_current_version "${CANDIDATE}" - - if [[ "${OPENAPPHACK_AVAILABLE}" == "false" ]]; then - __apptool_offline_list - else - FRAGMENT=$(curl -s "${OPENAPPHACK_SERVICE}/candidates/${CANDIDATE}/list?platform=${OPENAPPHACK_PLATFORM}¤t=${CURRENT}&installed=${CSV}") - echo "${FRAGMENT}" - unset FRAGMENT - fi -} diff --git a/src/main/bash/app-main.sh b/src/main/bash/app-main.sh deleted file mode 100644 index c154e67..0000000 --- a/src/main/bash/app-main.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash - - -function app { - - COMMAND="$1" - QUALIFIER="$2" - - case "$COMMAND" in - l) - COMMAND="list";; - ls) - COMMAND="list";; - h) - COMMAND="help";; - v) - COMMAND="version";; - u) - COMMAND="use";; - up) - COMMAND="up";; - halt) - COMMAND="halt";; - k) - COMMAND="halt";; - provision) - COMMAND="provision";; - p) - COMMAND="provision";; - - destroy) - COMMAND="destroy";; - x) - COMMAND="destroy";; - i) - COMMAND="install";; - rm) - COMMAND="uninstall";; - c) - COMMAND="current";; - o) - COMMAND="outdated";; - d) - COMMAND="default";; - b) - COMMAND="broadcast";; - esac - - # - # Various sanity checks and default settings - # - __apptool_default_environment_variables - - mkdir -p "$OPENAPPHACK_DIR" - - openapphack_update_broadcast_or_force_offline - - # Load the openapphack config if it exists. - if [ -f "${OPENAPPHACK_DIR}/etc/config" ]; then - source "${OPENAPPHACK_DIR}/etc/config" - fi - - # no command provided - if [[ -z "$COMMAND" ]]; then - __apptool_help - return 1 - fi - - # Check if it is a valid command - CMD_FOUND="" - CMD_TARGET="${OPENAPPHACK_DIR}/src/app-${COMMAND}.sh" - if [[ -f "$CMD_TARGET" ]]; then - CMD_FOUND="$CMD_TARGET" - fi - - # Check if it is a sourced function - CMD_TARGET="${OPENAPPHACK_DIR}/ext/app-${COMMAND}.sh" - if [[ -f "$CMD_TARGET" ]]; then - CMD_FOUND="$CMD_TARGET" - fi - - # couldn't find the command - if [[ -z "$CMD_FOUND" ]]; then - echo "Invalid command: $COMMAND" - __apptool_help - fi - - # Check whether the candidate exists - local openapphack_valid_candidate=$(echo ${OPENAPPHACK_CANDIDATES[@]} | grep -w "$QUALIFIER") - if [[ -n "$QUALIFIER" && "$COMMAND" != "offline" && "$COMMAND" != "flush" && "$COMMAND" != "selfupdate" && -z "$openapphack_valid_candidate" ]]; then - echo -e "\nStop! $QUALIFIER is not a valid candidate." - return 1 - fi - - if [[ "$COMMAND" == "offline" && -z "$QUALIFIER" ]]; then - echo -e "\nStop! Specify a valid offline mode." - elif [[ "$COMMAND" == "offline" && ( -z $(echo "enable disable" | grep -w "$QUALIFIER")) ]]; then - echo -e "\nStop! $QUALIFIER is not a valid offline mode." - fi - - # Check whether the command exists as an internal function... - # - # NOTE Internal commands use underscores rather than hyphens, - # hence the name conversion as the first step here. - CONVERTED_CMD_NAME=$(echo "$COMMAND" | tr '-' '_') - - # Execute the requested command - if [ -n "$CMD_FOUND" ]; then - # It's available as a shell function - __apptool_"$CONVERTED_CMD_NAME" "$QUALIFIER" "$3" "$4" - fi - - # Attempt upgrade after all is done - if [[ "$COMMAND" != "selfupdate" ]]; then - __apptool_auto_update "$OPENAPPHACK_REMOTE_VERSION" "$OPENAPPHACK_VERSION" - fi -} diff --git a/src/main/bash/app-offline.sh b/src/main/bash/app-offline.sh deleted file mode 100644 index 6ee9250..0000000 --- a/src/main/bash/app-offline.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - - -function __apptool_offline { - if [[ "$1" == "enable" ]]; then - OPENAPPHACK_FORCE_OFFLINE="true" - echo "Forced offline mode enabled." - fi - if [[ "$1" == "disable" ]]; then - OPENAPPHACK_FORCE_OFFLINE="false" - OPENAPPHACK_ONLINE="true" - echo "Online mode re-enabled!" - fi -} - -function openapphack_determine_offline { - local input="$1" - if [[ -z "$input" ]]; then - OPENAPPHACK_ONLINE="false" - OPENAPPHACK_AVAILABLE="false" - else - OPENAPPHACK_ONLINE="true" - fi -} - -function openapphack_force_offline_on_proxy { - local response="$1" - local detect_html="$(echo "$response" | tr '[:upper:]' '[:lower:]' | grep 'html')" - if [[ -n "$detect_html" ]]; then - echo "OPENAPPHACK can't reach the internet so going offline. Re-enable online with:" - echo "" - echo " $ app offline disable" - echo "" - OPENAPPHACK_FORCE_OFFLINE="true" - else - OPENAPPHACK_FORCE_OFFLINE="false" - fi -} diff --git a/src/main/bash/app-outdated.sh b/src/main/bash/app-outdated.sh deleted file mode 100644 index ff8ce32..0000000 --- a/src/main/bash/app-outdated.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -function __apptool_determine_outdated_version { - local candidate local_versions remote_default_version - candidate="$1" - - # Resolve local versions - local_versions="$(echo $(find "${OPENAPPHACK_DIR}/${candidate}" -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \;) | sed -e "s/ /, /g" )" - if [ ${#local_versions} -eq 0 ]; then - return 1 - fi - - # Resolve remote default version - remote_default_version="$(curl -s "${OPENAPPHACK_SERVICE}/candidates/${candidate}/default")" - if [ -z "$remote_default_version" ]; then - return 2 - fi - - # Check outdated or not - if [ ! -d "${OPENAPPHACK_DIR}/${candidate}/${remote_default_version}" ]; then - echo "${candidate} (${local_versions} < ${remote_default_version})" - fi -} - -function __apptool_outdated { - local all candidates candidate outdated installed_count outdated_count - if [ -n "$1" ]; then - all=false - candidates=$1 - else - all=true - candidates=${OPENAPPHACK_CANDIDATES[@]} - fi - installed_count=0 - outdated_count=0 - for candidate in ${candidates}; do - outdated="$(__apptool_determine_outdated_version "${candidate}")" - case $? in - 1) - $all || echo "Not using any version of ${candidate}" - ;; - 2) - echo "" - echo "Stop! Could not get remote version of ${candidate}" - return 1 - ;; - *) - if [ -n "${outdated}" ]; then - [ ${outdated_count} -eq 0 ] && echo "Outdated:" - echo "${outdated}" - (( outdated_count += 1 )) - fi - (( installed_count += 1 )) - ;; - esac - done - if $all; then - if [ ${installed_count} -eq 0 ]; then - echo 'No candidates are in use' - elif [ ${outdated_count} -eq 0 ]; then - echo "All candidates are up-to-date" - fi - elif [ ${outdated_count} -eq 0 ]; then - echo "${candidate} is up-to-date" - fi -} diff --git a/src/main/bash/app-provision.sh b/src/main/bash/app-provision.sh deleted file mode 100644 index e228882..0000000 --- a/src/main/bash/app-provision.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -function __apptool_provision { - vagrant provision -} diff --git a/src/main/bash/app-selfupdate.sh b/src/main/bash/app-selfupdate.sh deleted file mode 100644 index 1926e5b..0000000 --- a/src/main/bash/app-selfupdate.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - - -function __apptool_selfupdate { - OPENAPPHACK_FORCE_SELFUPDATE="$1" - if [[ "$OPENAPPHACK_AVAILABLE" == "false" ]]; then - echo "$OFFLINE_MESSAGE" - - elif [[ "$OPENAPPHACK_REMOTE_VERSION" == "$OPENAPPHACK_VERSION" && "$OPENAPPHACK_FORCE_SELFUPDATE" != "force" ]]; then - echo "No update available at this time." - - else - curl -s "${OPENAPPHACK_SERVICE}/selfupdate" | bash - fi - unset OPENAPPHACK_FORCE_SELFUPDATE -} - -function __apptool_auto_update { - - local OPENAPPHACK_REMOTE_VERSION="$1" - local OPENAPPHACK_VERSION="$2" - - OPENAPPHACK_DELAY_UPGRADE="${OPENAPPHACK_DIR}/var/delay_upgrade" - - if [[ -n "$(find "$OPENAPPHACK_DELAY_UPGRADE" -mtime +1)" && ( "$OPENAPPHACK_REMOTE_VERSION" != "$OPENAPPHACK_VERSION" ) ]]; then - echo "" - echo "" - echo "ATTENTION: A new version of OPENAPPHACK is available..." - echo "" - echo "The current version is $OPENAPPHACK_REMOTE_VERSION, but you have $OPENAPPHACK_VERSION." - echo "" - - if [[ "$openapphack_auto_selfupdate" != "true" ]]; then - echo -n "Would you like to upgrade now? (Y/n)" - read upgrade - fi - - if [[ -z "$upgrade" ]]; then upgrade="Y"; fi - - if [[ "$upgrade" == "Y" || "$upgrade" == "y" ]]; then - __apptool_selfupdate - unset upgrade - else - echo "Not upgrading today..." - fi - - touch "${OPENAPPHACK_DELAY_UPGRADE}" - fi - -} diff --git a/src/main/bash/app-uninstall.sh b/src/main/bash/app-uninstall.sh deleted file mode 100644 index 8779cf5..0000000 --- a/src/main/bash/app-uninstall.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - - -function __apptool_uninstall { - CANDIDATE="$1" - VERSION="$2" - __apptool_check_candidate_present "${CANDIDATE}" || return 1 - __apptool_check_version_present "${VERSION}" || return 1 - CURRENT=$(readlink "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/current" | sed "s_${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/__g") - if [[ -h "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/current" && ( "${VERSION}" == "${CURRENT}" ) ]]; then - echo "" - echo "Unselecting ${CANDIDATE} ${VERSION}..." - unlink "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/current" - fi - echo "" - if [ -d "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/${VERSION}" ]; then - echo "Uninstalling ${CANDIDATE} ${VERSION}..." - rm -rf "${OPENAPPHACK_DIR}/.vms/${CANDIDATE}/${VERSION}" - else - echo "${CANDIDATE} ${VERSION} is not installed." - fi -} diff --git a/src/main/bash/app-up.sh b/src/main/bash/app-up.sh deleted file mode 100644 index a102360..0000000 --- a/src/main/bash/app-up.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -function __apptool_up { - vagrant up -} diff --git a/src/main/bash/app-use.sh b/src/main/bash/app-use.sh deleted file mode 100644 index 6d41ef7..0000000 --- a/src/main/bash/app-use.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - - -function __apptool_use { - CANDIDATE="$1" - __apptool_check_candidate_present "${CANDIDATE}" || return 1 - __apptool_determine_version "$2" || return 1 - - if [[ ! -d "${OPENAPPHACK_DIR}/${CANDIDATE}/${VERSION}" ]]; then - echo "" - echo "Stop! ${CANDIDATE} ${VERSION} is not installed." - if [[ "${openapphack_auto_answer}" != 'true' ]]; then - echo -n "Do you want to install it now? (Y/n): " - read INSTALL - fi - if [[ -z "${INSTALL}" || "${INSTALL}" == "y" || "${INSTALL}" == "Y" ]]; then - __apptool_install_candidate_version "${CANDIDATE}" "${VERSION}" - else - return 1 - fi - fi - - # Just update the *_HOME and PATH for this shell. - UPPER_CANDIDATE=$(echo "${CANDIDATE}" | tr '[:lower:]' '[:upper:]') - export "${UPPER_CANDIDATE}_HOME"="${OPENAPPHACK_DIR}/${CANDIDATE}/${VERSION}" - - # Replace the current path for the candidate with the selected version. - if [[ "${solaris}" == true ]]; then - export PATH=$(echo $PATH | gsed -r "s!${OPENAPPHACK_DIR}/${CANDIDATE}/([^/]+)!${OPENAPPHACK_DIR}/${CANDIDATE}/${VERSION}!g") - - elif [[ "${darwin}" == true ]]; then - export PATH=$(echo $PATH | sed -E "s!${OPENAPPHACK_DIR}/${CANDIDATE}/([^/]+)!${OPENAPPHACK_DIR}/${CANDIDATE}/${VERSION}!g") - - else - export PATH=$(echo $PATH | sed -r "s!${OPENAPPHACK_DIR}/${CANDIDATE}/([^/]+)!${OPENAPPHACK_DIR}/${CANDIDATE}/${VERSION}!g") - fi - - echo "" - echo Using "${CANDIDATE}" version "${VERSION} in this shell." -} diff --git a/src/main/bash/app-version.sh b/src/main/bash/app-version.sh deleted file mode 100644 index 3ed5a1e..0000000 --- a/src/main/bash/app-version.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - - -function __apptool_version { - echo "OpenAppHack CLI ${OPENAPPHACK_VERSION}" -} diff --git a/src/main/bash/install.sh b/src/main/bash/install.sh deleted file mode 100644 index 5938bd6..0000000 --- a/src/main/bash/install.sh +++ /dev/null @@ -1,284 +0,0 @@ -#!/bin/bash - -# Global variables -OPENAPPHACK_SERVICE="@OPENAPPHACK_SERVICE@" -OPENAPPHACK_BROKER_SERVICE="@OPENAPPHACK_BROKER_SERVICE@" -OPENAPPHACK_VERSION="@OPENAPPHACK_VERSION@" -OPENAPPHACK_DIR="$HOME/.openapphack" - -# Local variables -openapphack_bin_folder="${OPENAPPHACK_DIR}/bin" -openapphack_src_folder="${OPENAPPHACK_DIR}/src" -openapphack_tmp_folder="${OPENAPPHACK_DIR}/tmp" -openapphack_stage_folder="${openapphack_tmp_folder}/stage" -openapphack_zip_file="${openapphack_tmp_folder}/res-${OPENAPPHACK_VERSION}.zip" -openapphack_ext_folder="${OPENAPPHACK_DIR}/ext" -openapphack_etc_folder="${OPENAPPHACK_DIR}/etc" -openapphack_var_folder="${OPENAPPHACK_DIR}/var" -openapphack_vm_folder="${OPENAPPHACK_DIR}/vm" -openapphack_dotvms_folder="${OPENAPPHACK_DIR}/.vms" -openapphack_config_file="${openapphack_etc_folder}/config" -openapphack_bash_profile="${HOME}/.bash_profile" -openapphack_profile="${HOME}/.profile" -openapphack_bashrc="${HOME}/.bashrc" -openapphack_zshrc="${HOME}/.zshrc" -openapphack_platform=$(uname) - -openapphack_init_snippet=$( cat << EOF -#THIS MUST BE AT THE END OF THE FILE FOR OPENAPPHACK TO WORK!!! -[[ -s "${OPENAPPHACK_DIR}/bin/app-init.sh" ]] && source "${OPENAPPHACK_DIR}/bin/app-init.sh" -EOF -) - -# OS specific support (must be 'true' or 'false'). -cygwin=false; -darwin=false; -solaris=false; -freebsd=false; -case "$(uname)" in - CYGWIN*) - cygwin=true - ;; - Darwin*) - darwin=true - ;; - SunOS*) - solaris=true - ;; - FreeBSD*) - freebsd=true -esac - -echo ' ' -echo 'Thanks for using OpenAppHack Cli ' -echo ' ' -echo ' ' -echo ' Will now attempt installing...' -echo ' ' - - -# Sanity checks - -echo "Looking for a previous installation of OPENAPPHACK..." -if [ -d "${OPENAPPHACK_DIR}" ]; then - echo "OPENAPPHACK found." - echo "" - echo "======================================================================================================" - echo " You already have OPENAPPHACK installed." - echo " OPENAPPHACK was found at:" - echo "" - echo " ${OPENAPPHACK_DIR}" - echo "" - echo " Please consider running the following if you need to upgrade." - echo "" - echo " $ app selfupdate" - echo "" - echo "======================================================================================================" - echo "" - exit 0 -fi - -echo "Looking for git..." -if [ -z $(which git) ]; then - echo "Not found." - echo "======================================================================================================" - echo " Please install git on your system using your favourite package manager." - echo "" - echo " Restart after installing git." - echo "======================================================================================================" - echo "" - exit 0 -fi - -echo "Looking for vagrant..." -if [ -z $(which vagrant) ]; then - echo "Not found." - echo "" - echo "======================================================================================================" - echo " Please install vagrant on your system ." - echo "" - echo " OPENAPPHACK uses vagrant extensively." - echo "" - echo " Restart after installing vagrant." - echo "======================================================================================================" - echo "" - exit 0 -fi - -echo "Looking for unzip..." -if [ -z $(which unzip) ]; then - echo "Not found." - echo "======================================================================================================" - echo " Please install unzip on your system using your favourite package manager." - echo "" - echo " Restart after installing unzip." - echo "======================================================================================================" - echo "" - exit 0 -fi - -echo "Looking for curl..." -if [ -z $(which curl) ]; then - echo "Not found." - echo "" - echo "======================================================================================================" - echo " Please install curl on your system using your favourite package manager." - echo "" - echo " OPENAPPHACK uses curl for crucial interactions with it's backend server." - echo "" - echo " Restart after installing curl." - echo "======================================================================================================" - echo "" - exit 0 -fi - -echo "Looking for sed..." -if [ -z $(which sed) ]; then - echo "Not found." - echo "" - echo "======================================================================================================" - echo " Please install sed on your system using your favourite package manager." - echo "" - echo " OPENAPPHACK uses sed extensively." - echo "" - echo " Restart after installing sed." - echo "======================================================================================================" - echo "" - exit 0 -fi - -if [[ "${solaris}" == true ]]; then - echo "Looking for gsed..." - if [ -z $(which gsed) ]; then - echo "Not found." - echo "" - echo "======================================================================================================" - echo " Please install gsed on your solaris system." - echo "" - echo " OPENAPPHACK uses gsed extensively." - echo "" - echo " Restart after installing gsed." - echo "======================================================================================================" - echo "" - exit 0 - fi -fi - - -echo "Installing openapphack scripts..." - - -# Create directory structure - -echo "Create distribution directories..." -mkdir -p "${openapphack_bin_folder}" -mkdir -p "${openapphack_src_folder}" -mkdir -p "${openapphack_tmp_folder}" -mkdir -p "${openapphack_stage_folder}" -mkdir -p "${openapphack_ext_folder}" -mkdir -p "${openapphack_etc_folder}" -mkdir -p "${openapphack_var_folder}" -mkdir -p "${openapphack_vm_folder}" -mkdir -p "${openapphack_dotvms_folder}" - -echo "Create candidate directories..." - -OPENAPPHACK_CANDIDATES_CSV=$(curl -s "${OPENAPPHACK_SERVICE}/candidates") -echo "$OPENAPPHACK_CANDIDATES_CSV" > "${OPENAPPHACK_DIR}/var/candidates" - -echo "$OPENAPPHACK_VERSION" > "${OPENAPPHACK_DIR}/var/version" - -# convert csv to array -OLD_IFS="$IFS" -IFS="," -OPENAPPHACK_CANDIDATES=(${OPENAPPHACK_CANDIDATES_CSV}) -IFS="$OLD_IFS" - -for (( i=0; i <= ${#OPENAPPHACK_CANDIDATES}; i++ )); do - # Eliminate empty entries due to incompatibility - if [[ -n ${OPENAPPHACK_CANDIDATES[${i}]} ]]; then - CANDIDATE_NAME="${OPENAPPHACK_CANDIDATES[${i}]}" - mkdir -p "${OPENAPPHACK_DIR}/.vms/${CANDIDATE_NAME}" - echo "Created for ${CANDIDATE_NAME}: ${OPENAPPHACK_DIR}/.vms/${CANDIDATE_NAME}" - unset CANDIDATE_NAME - fi -done - -echo "Prime the config file..." -touch "${openapphack_config_file}" -echo "openapphack_auto_answer=false" >> "${openapphack_config_file}" -echo "openapphack_auto_selfupdate=false" >> "${openapphack_config_file}" -echo "openapphack_insecure_ssl=false" >> "${openapphack_config_file}" - -echo "Download script archive..." -#https://github.com/WiproOpenSourcePractice/openapphack/raw/gh-pages/ -curl -s "${OPENAPPHACK_SERVICE}/res/platform/${openapphack_platform}/purpose/install/openapphack-cli-scripts.zip" > "${openapphack_zip_file}" - - - -echo "Extract script archive..." -if [[ "${cygwin}" == 'true' ]]; then - echo "Cygwin detected - normalizing paths for unzip..." - openapphack_zip_file=$(cygpath -w "${openapphack_zip_file}") - openapphack_stage_folder=$(cygpath -w "${openapphack_stage_folder}") -fi -unzip -qo "${openapphack_zip_file}" -d "${openapphack_stage_folder}" - -echo "Install scripts..." -mv "${openapphack_stage_folder}/app-init.sh" "${openapphack_bin_folder}" -mv "${openapphack_stage_folder}"/app-* "${openapphack_src_folder}" - -echo "Attempt update of bash profiles..." -if [ ! -f "${openapphack_bash_profile}" -a ! -f "${openapphack_profile}" ]; then - echo "#!/bin/bash" > "${openapphack_bash_profile}" - echo "${openapphack_init_snippet}" >> "${openapphack_bash_profile}" - echo "Created and initialised ${openapphack_bash_profile}" -else - if [ -f "${openapphack_bash_profile}" ]; then - if [[ -z `grep 'app-init.sh' "${openapphack_bash_profile}"` ]]; then - echo -e "\n${openapphack_init_snippet}" >> "${openapphack_bash_profile}" - echo "Updated existing ${openapphack_bash_profile}" - fi - fi - - if [ -f "${openapphack_profile}" ]; then - if [[ -z `grep 'app-init.sh' "${openapphack_profile}"` ]]; then - echo -e "\n${openapphack_init_snippet}" >> "${openapphack_profile}" - echo "Updated existing ${openapphack_profile}" - fi - fi -fi - -if [ ! -f "${openapphack_bashrc}" ]; then - echo "#!/bin/bash" > "${openapphack_bashrc}" - echo "${openapphack_init_snippet}" >> "${openapphack_bashrc}" - echo "Created and initialised ${openapphack_bashrc}" -else - if [[ -z `grep 'app-init.sh' "${openapphack_bashrc}"` ]]; then - echo -e "\n${openapphack_init_snippet}" >> "${openapphack_bashrc}" - echo "Updated existing ${openapphack_bashrc}" - fi -fi - -echo "Attempt update of zsh profiles..." -if [ ! -f "${openapphack_zshrc}" ]; then - echo "${openapphack_init_snippet}" >> "${openapphack_zshrc}" - echo "Created and initialised ${openapphack_zshrc}" -else - if [[ -z `grep 'app-init.sh' "${openapphack_zshrc}"` ]]; then - echo -e "\n${openapphack_init_snippet}" >> "${openapphack_zshrc}" - echo "Updated existing ${openapphack_zshrc}" - fi -fi - -echo -e "\n\n\nAll done!\n\n" - -echo "Please open a new terminal, or run the following in the existing one:" -echo "" -echo " source \"${OPENAPPHACK_DIR}/bin/app-init.sh\"" -echo "" -echo "Then issue the following command:" -echo "" -echo " app help" -echo "" -echo "Enjoy!!!" diff --git a/src/main/templates/broadcast.gtpl b/src/main/templates/broadcast.gtpl deleted file mode 100644 index d9e1a27..0000000 --- a/src/main/templates/broadcast.gtpl +++ /dev/null @@ -1,11 +0,0 @@ - -==== BROADCAST ================================================================= - -<% - broadcasts.each { broadcast -> - println broadcast.text - } -%> -Running OPENAPPHACK server ${openapphackVersion} on vertx ${vertxVersion} - -================================================================================ diff --git a/src/main/templates/legacy.gtpl b/src/main/templates/legacy.gtpl deleted file mode 100644 index 2cd5624..0000000 --- a/src/main/templates/legacy.gtpl +++ /dev/null @@ -1,13 +0,0 @@ - -==== BROADCAST ================================================================= - -Please upgrade right away using: - - $ app selfupdate - - -Warning! You might see some jumbled text on the console. - -This has been rectified in the subsequent release. - -================================================================================ diff --git a/src/main/templates/list.gtpl b/src/main/templates/list.gtpl deleted file mode 100644 index dd0393a..0000000 --- a/src/main/templates/list.gtpl +++ /dev/null @@ -1,29 +0,0 @@ - -============================================================ -Available ${candidate.capitalize()} Versions -============================================================ -<% - if(local){ - local.each { version -> - if(current == version) { - println " > + ${version}" - } else { - println " + ${version}" - } - } - } - available.each { version -> - if(current == version) { - println " > * ${version}" - } else if(installed.contains(version)){ - println " * ${version}" - } else { - println " ${version}" - } - } -%> -============================================================ -+ - local version -* - installed -> - currently in use -============================================================ diff --git a/src/main/templates/list_2.gtpl b/src/main/templates/list_2.gtpl deleted file mode 100644 index 3541f1b..0000000 --- a/src/main/templates/list_2.gtpl +++ /dev/null @@ -1,10 +0,0 @@ - -================================================================================ -Available ${candidate.capitalize()} Versions -================================================================================ -${content} -================================================================================ -+ - local version -* - installed -> - currently in use -================================================================================ diff --git a/src/main/templates/robots.txt b/src/main/templates/robots.txt deleted file mode 100644 index 1f53798..0000000 --- a/src/main/templates/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Disallow: / diff --git a/src/main/vertx/server.groovy b/src/main/vertx/server.groovy deleted file mode 100644 index 3802bab..0000000 --- a/src/main/vertx/server.groovy +++ /dev/null @@ -1,269 +0,0 @@ - -import groovy.text.SimpleTemplateEngine -import org.vertx.groovy.core.http.RouteMatcher - -final OPENAPPHACK_VERSION = '@OPENAPPHACK_VERSION@' -final VERTX_VERSION = '@VERTX_VERSION@' -final COLUMN_LENGTH = 15 - -// -// datasource configuration -// - -def config = [ - address: (System.getenv('OPENAPPHACK_DB_ADDRESS') ?: 'mongo-persistor'), - db_name: (System.getenv('OPENAPPHACK_DB_NAME') ?: 'openapphack'), - host: System.getenv('OPENAPPHACK_DB_HOST'), - port: System.getenv('OPENAPPHACK_DB_PORT')?.toInteger(), - username: System.getenv('OPENAPPHACK_DB_USERNAME'), - password: System.getenv('OPENAPPHACK_DB_PASSWORD') -] - -container.deployModule 'vertx.mongo-persistor-v1.2', config - -def templateEngine = new SimpleTemplateEngine() - -def templateBase = "build/templates" - -def listTemplateFile = "${templateBase}/list_2.gtpl" as File -def listTemplate = templateEngine.createTemplate(listTemplateFile) - -def broadcastTemplateFile = "${templateBase}/broadcast.gtpl" as File -def broadcastTemplate = templateEngine.createTemplate(broadcastTemplateFile) - - -// -// route matcher implementations -// - -def rm = new RouteMatcher() - -rm.get("/") { req -> - addPlainTextHeader req - req.response.sendFile('build/scripts/install.sh') -} - -rm.get("/selfupdate") { req -> - addPlainTextHeader req - req.response.sendFile('build/scripts/selfupdate.sh') -} - -rm.get("/robots.txt") { req -> - addPlainTextHeader req - req.response.sendFile('build/resources/main/templates/robots.txt') -} - -rm.get("/alive") { req -> - def cmd = [action:"find", collection:"application", matcher:[alive:"OK"]] - vertx.eventBus.send("mongo-persistor", cmd){ msg -> - def alive = msg.body.results.alive.first() - addPlainTextHeader req - req.response.end alive - } -} - -rm.get("/res") { req -> - def purpose = req.params['purpose'] - log purpose, 'openapphack', OPENAPPHACK_VERSION, req - - def zipFile = 'build/distributions/openapphack-scripts.zip' as File - req.response.putHeader("Content-Type", "application/zip") - req.response.sendFile zipFile.absolutePath -} - -rm.get("/candidates") { req -> - def cmd = [action:"find", collection:"candidates", matcher:[:], keys:[candidate:1]] - vertx.eventBus.send("mongo-persistor", cmd){ msg -> - def candidates = msg.body.results.collect(new TreeSet()) { it.candidate } - addPlainTextHeader req - req.response.end candidates.join(',') - } -} - -rm.get("/candidates/:candidate") { req -> - def candidate = req.params['candidate'] - def cmd = [action:"find", collection:"versions", matcher:[candidate:candidate], keys:["version":1]] - vertx.eventBus.send("mongo-persistor", cmd){ msg -> - def response - if(msg.body.results){ - def versions = msg.body.results.collect(new TreeSet()) { it.version } - response = versions.join(',') - - } else { - response = "invalid" - } - - addPlainTextHeader req - req.response.end response - } -} - -rm.get("/candidates/:candidate/default") { req -> - def candidate = req.params['candidate'] - def cmd = [action:"find", collection:"candidates", matcher:[candidate:candidate], keys:["default":1]] - vertx.eventBus.send("mongo-persistor", cmd){ msg -> - addPlainTextHeader req - def defaultVersion = msg.body.results.default - req.response.end (defaultVersion ?: "") - } -} - -rm.get("/candidates/:candidate/list") { req -> - def candidate = req.params['candidate'] - def current = req.params['current'] ?: '' - def installed = req.params['installed'] ? req.params['installed'].tokenize(',') : [] - - def cmd = [action:"find", collection:"versions", matcher:[candidate:candidate], keys:["version":1], sort:["version":-1]] - vertx.eventBus.send("mongo-persistor", cmd){ msg -> - def available = msg.body.results.collect { it.version } - - def combined = combine(available, installed) - def local = determineLocal(available, installed) - - def content = prepareListView(combined, current, installed, local, COLUMN_LENGTH) - def binding = [candidate: candidate, content:content] - def template = listTemplate.make(binding) - - addPlainTextHeader req - req.response.end template.toString() - } -} - -private prepareListView(combined, current, installed, local, colLength){ - def builder = new StringBuilder() - for (i in (0..(colLength-1))){ - def versionColumn1 = prepareVersion(combined[i], current, installed, local) - def versionColumn2 = prepareVersion(combined[i+(colLength*1)], current, installed, local) - def versionColumn3 = prepareVersion(combined[i+(colLength*2)], current, installed, local) - def versionColumn4 = prepareVersion(combined[i+(colLength*3)], current, installed, local) - builder << "${pad(versionColumn1)} ${pad(versionColumn2)} ${pad(versionColumn3)} ${pad(versionColumn4)}\n" - } - builder.toString() -} - -private prepareVersion(version, current, installed, local){ - def isCurrent = (current == version) - def isInstalled = installed.contains(version) - def isLocalOnly = local.contains(version) - decorateVersion(version, isCurrent, isInstalled, isLocalOnly) -} - -private decorateVersion(version, isCurrent, isInstalled, isLocalOnly) { - " ${markCurrent(isCurrent)} ${markStatus(isInstalled, isLocalOnly)} ${version ?: ''}" -} - -private pad(col, width=20) { - (col ?: "").take(width).padRight(width) -} - -private markCurrent(isCurrent){ - isCurrent ? '>' : ' ' -} - - -private markStatus(isInstalled, isLocalOnly){ - if(isInstalled && isLocalOnly) '+' - else if(isInstalled) '*' - else ' ' -} - -private determineLocal(available, installed){ - installed.findAll { ! available.contains(it) } -} - -private combine(available, installed){ - def combined = [] as TreeSet - combined.addAll installed - combined.addAll available - combined.toList().reverse() -} - -def validationHandler = { req -> - def candidate = req.params['candidate'] - def version = req.params['version'] - def cmd = [action:"find", collection:"versions", matcher:[candidate:candidate, version:version]] - vertx.eventBus.send("mongo-persistor", cmd){ msg -> - addPlainTextHeader req - if(msg.body.results) { - req.response.end 'valid' - } else { - req.response.end 'invalid' - } - } -} - -rm.get("/candidates/:candidate/:version/validate", validationHandler) -rm.get("/candidates/:candidate/:version", validationHandler) - -def downloadHandler = { req -> - def candidate = req.params['candidate'] - def version = req.params['version'] - - log 'install', candidate, version, req - - def cmd = [action:"find", collection:"versions", matcher:[candidate:candidate, version:version], keys:["url":1]] - vertx.eventBus.send("mongo-persistor", cmd){ msg -> - req.response.headers['Location'] = msg.body.results.url.first() - req.response.statusCode = 302 - req.response.end() - } -} - -rm.get("/candidates/:candidate/:version/download", downloadHandler) -rm.get("/download/:candidate/:version", downloadHandler) - -def versionHandler = { req -> - addPlainTextHeader req - req.response.end OPENAPPHACK_VERSION -} - -rm.get("/app/version", versionHandler) -rm.get("/api/version", versionHandler) - -def broadcastHandler = { req -> - addPlainTextHeader req - req.response.end "This Broadcast API is being discontinued. \nPlease upgrade to the latest version of OPENAPPHACK!" -} - -rm.get("/broadcast", broadcastHandler) -rm.get("/broadcast/:version", broadcastHandler) -rm.get("/api/broadcast", broadcastHandler) -rm.get("/api/broadcast/:version", broadcastHandler) - - -// -// private methods -// - -private addPlainTextHeader(req){ - req.response.putHeader("Content-Type", "text/plain") -} - -private log(command, candidate, version, req){ - def date = new Date() - def host = req.headers['x-forwarded-for'] - def agent = req.headers['user-agent'] - def platform = req.params['platform'] - - def document = [ - command:command, - candidate:candidate, - version:version, - host:host, - agent:agent, - platform:platform, - date:date - ] - - def cmd = [action:'save', collection:'audit', document:document] - - vertx.eventBus.send 'mongo-persistor', cmd -} - -// -// startup server -// -def port = System.getenv('PORT') ?: 8080 -def host = System.getenv('PORT') ? '0.0.0.0' : 'localhost' -println "Starting vertx on $host:$port" -vertx.createHttpServer().requestHandler(rm.asClosure()).listen(port as int, host) diff --git a/src/test/cucumber/openapphack/broadcast.feature b/src/test/cucumber/openapphack/broadcast.feature deleted file mode 100644 index 886d43f..0000000 --- a/src/test/cucumber/openapphack/broadcast.feature +++ /dev/null @@ -1,35 +0,0 @@ -Feature: Broadcast - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: A command is issued with no prior Broadcast received - Given no prior Broadcast was received - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "app version" - Then I see "This is a LIVE Broadcast!" - - Scenario: A command is issued where the prior Broadcast was different to the Live one - Given a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "app version" - Then I see "This is a LIVE Broadcast!" - - Scenario: A command is issued where the prior Broadcast was the same as the Live one - Given a prior Broadcast "This is a LIVE Broadcast!" with id "12345" was issued - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "app version" - Then I do not see "This is a LIVE Broadcast!" - - Scenario: A Broadcast command recalls a prior Broadcast - Given a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And a new Broadcast "This is an OLD Broadcast!" with id "12344" is available - When I enter "app broadcast" - Then I see "This is an OLD Broadcast!" - - Scenario: A Broadcast command is issued with no prior Broadcast received - Given no prior Broadcast was received - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "app broadcast" - Then I see "This is a LIVE Broadcast!" diff --git a/src/test/cucumber/openapphack/command_line_interop.feature b/src/test/cucumber/openapphack/command_line_interop.feature deleted file mode 100644 index fb0722a..0000000 --- a/src/test/cucumber/openapphack/command_line_interop.feature +++ /dev/null @@ -1,23 +0,0 @@ -Feature: Command Line Interop - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Enter app - When I enter "app" - Then I see "Usage: app [version]" - And I see "app offline " - - Scenario: Ask for help - When I enter "app help" - Then I see "Usage: app [version]" - - Scenario: Enter an invalid Command - When I enter "app somecommand openapphack" - Then I see "Invalid command: somecommand" - And I see "Usage: app [version]" - - Scenario: Enter an invalid Candidate - When I enter "app install something" - Then I see "Stop! something is not a valid candidate." diff --git a/src/test/cucumber/openapphack/current_candidate.feature b/src/test/cucumber/openapphack/current_candidate.feature deleted file mode 100644 index fbb3f35..0000000 --- a/src/test/cucumber/openapphack/current_candidate.feature +++ /dev/null @@ -1,34 +0,0 @@ -Feature: Current Candidate - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Display current candidate version in use - Given the candidate "panickervinod" version "master" is already installed and default - When I enter "app current panickervinod" - Then I see "Using panickervinod version master" - - Scenario: Display current candidate version when none is in use - Given the candidate "panickervinod" version "master" is already installed but not default - When I enter "app current panickervinod" - Then I see "Not using any version of panickervinod" - - Scenario: Display current candidate versions when none is specified and none is in use - Given the candidate "panickervinod" version "master" is already installed but not default - When I enter "app current" - Then I see "No candidates are in use" - - Scenario: Display current candidate versions when none is specified and one is in use - Given the candidate "panickervinod" version "master" is already installed and default - When I enter "app current" - Then I see "Using:" - And I see "panickervinod: master" - - Scenario: Display current candidate versions when none is specified and multiple are in use - Given the candidate "openapphack" version "master" is already installed and default - And the candidate "panickervinod" version "master" is already installed and default - When I enter "app current" - Then I see "Using:" - And I see "panickervinod: master" - And I see "openapphack: master" diff --git a/src/test/cucumber/openapphack/flush.feature b/src/test/cucumber/openapphack/flush.feature deleted file mode 100644 index 95c6af0..0000000 --- a/src/test/cucumber/openapphack/flush.feature +++ /dev/null @@ -1,54 +0,0 @@ -Feature: Flush - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Flush omitting the Qualifier - When I enter "app flush" - Then I see "Stop! Please specify what you want to flush." - - Scenario: Clear out the Candidate List - Given the candidate "panickervinod" is known locally - When I enter "app flush candidates" - Then no candidates are know locally - And I see "Candidates have been flushed." - - Scenario: Clear out an uninitialised Candidate List - Given I enter "app flush candidates" - When I enter "app flush candidates" - Then I see "No candidate list found so not flushed." - - Scenario: Clean up the current Broadcast - Given a prior Broadcast "This is an old broadcast" with id "12344" was issued - When I enter "app flush broadcast" - Then no broadcast message can be found - And I see "Broadcast has been flushed." - - Scenario: Clean up an uninitialised Broadcast - Given the broadcast has been flushed - When I enter "app flush broadcast" - Then I see "No prior broadcast found so not flushed." - - Scenario: Clean up the last known Remote Version - Given a prior version "x.y.z" was detected - When I enter "app flush version" - Then no version token can be found - And I see "Version Token has been flushed." - - Scenario: Clean up an uninitialised last known Remote Version - Given the Remote Version has been flushed - When I enter "app flush version" - Then I see "No prior Remote Version found so not flushed." - - Scenario: Clear out the cached vm - Given the vm "panickervinod"-"0.0.1" has been cached - When I enter "app flush vm" - Then no vm are cached - And I see "1 vm(s) flushed" - - Scenario: Clear out the temporary space - Given the file "res-1.2.0.zip" in temporary storage - When I enter "app flush temp" - Then no "res-1.2.0.zip" file is present in temporary storage - And I see "1 archive(s) flushed" diff --git a/src/test/cucumber/openapphack/forced_offline_mode.feature b/src/test/cucumber/openapphack/forced_offline_mode.feature deleted file mode 100644 index 9d92c2c..0000000 --- a/src/test/cucumber/openapphack/forced_offline_mode.feature +++ /dev/null @@ -1,120 +0,0 @@ -Feature: Forced Offline Mode - - #offline modes - - Scenario: Enter an invalid offline mode - Given offline mode is disabled with reachable internet - And an initialised environment - When I enter "app offline panickervinod" - Then I see "Stop! panickervinod is not a valid offline mode." - - Scenario: Issue Offline command without qualification - Given offline mode is disabled with reachable internet - And an initialised environment - When I enter "app offline" - Then I see "Stop! Specify a valid offline mode." - - Scenario: Enable Offline Mode with internet reachable - Given offline mode is disabled with reachable internet - And an initialised environment - When I enter "app offline enable" - Then I see "Forced offline mode enabled." - And I do not see "OFFLINE MODE ENABLED!" - When I enter "app install panickervinod master" - Then I see "Stop! panickervinod master is not available in offline mode." - - Scenario: Disable Offline Mode with internet reachable - Given offline mode is enabled with reachable internet - And an initialised environment - And the candidate "panickervinod" version "master" is available for download - When I enter "app offline disable" - Then I see "Online mode re-enabled!" - When I enter "app install panickervinod master" and answer "Y" - Then I see "Done installing!" - And the candidate "panickervinod" version "master" is installed - - Scenario: Disable Offline Mode with internet unreachable - Given offline mode is enabled with unreachable internet - And an initialised environment - When I enter "app offline disable" - Then I see "Online mode re-enabled!" - When I enter "app install panickervinod master" - Then I see "OFFLINE MODE ENABLED!" - And I see "Stop! panickervinod master is not available in offline mode." - - #broadcast - Scenario: Recall a broadcast while Forced Offline - Given offline mode is enabled with reachable internet - And an initialised environment - When a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And I enter "app broadcast" - Then I see "This is an OLD Broadcast!" - - #openapphack version - Scenario: Determine the OpenAppHack CLI version while Forced Offline - Given offline mode is enabled with reachable internet - And an initialised environment - When I enter "app version" - Then I see the current app version - - #list candidate version - Scenario: List candidate versions found while Forced Offline - Given offline mode is enabled with reachable internet - And an initialised environment - When I enter "app list panickervinod" - Then I see "Offline Mode: only showing installed panickervinod versions" - - #use version - Scenario: Use an uninstalled candidate version while Forced Offline - Given offline mode is enabled with reachable internet - And an initialised environment - And the candidate "panickervinod" version "0.0.1" is already installed and default - And the candidate "panickervinod" version "master" is not installed - When I enter "app use panickervinod master" - Then I see "Stop! panickervinod master is not available in offline mode." - - #default version - Scenario: Set the default to an uninstalled candidate version while Forced Offline - Given offline mode is enabled with reachable internet - And an initialised environment - And the candidate "panickervinod" version "0.0.1" is already installed and default - When I enter "app default panickervinod master" - Then I see "Stop! panickervinod master is not available in offline mode." - - #install command - Scenario: Install a candidate version that is not installed while Forced Offline - Given offline mode is enabled with reachable internet - And an initialised environment - And the candidate "panickervinod" version "master" is not installed - When I enter "app install panickervinod master" - Then I see "Stop! panickervinod master is not available in offline mode." - - #uninstall command - Scenario: Uninstall a candidate version while Forced Offline - Given offline mode is enabled with reachable internet - And an initialised environment - And the candidate "panickervinod" version "master" is already installed and default - When I enter "app uninstall panickervinod master" - And the candidate "panickervinod" version "master" is not installed - - #current command - Scenario: Display the current version of a candidate while Forced Offline - Given offline mode is enabled with reachable internet - And an initialised environment - And the candidate "panickervinod" version "master" is already installed and default - When I enter "app current panickervinod" - Then I see "Using panickervinod version master" - - #help command - Scenario: Request help while Forced Offline - Given offline mode is enabled with reachable internet - And an initialised environment - When I enter "app help" - Then I see "Usage: app [version]" - - #selfupdate command - Scenario: Attempt self-update while Forced Offline - Given offline mode is enabled with reachable internet - And an initialised environment - When I enter "app selfupdate" - Then I see "This command is not available in offline mode." diff --git a/src/test/cucumber/openapphack/idempotent_self_update.feature b/src/test/cucumber/openapphack/idempotent_self_update.feature deleted file mode 100644 index 9409c8e..0000000 --- a/src/test/cucumber/openapphack/idempotent_self_update.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: Idempotent Self Update - - Background: - Given the internet is reachable - And an initialised environment - And an available selfupdate - - Scenario: Attempt Self Update on an up to date system - When I enter "app selfupdate" - Then I see "No update available at this time." - - Scenario: Force Self Update on an up to date system - When I enter "app selfupdate force" - Then I see "Successfully upgraded OpenAppHack CLI." diff --git a/src/test/cucumber/openapphack/initialisation.feature b/src/test/cucumber/openapphack/initialisation.feature deleted file mode 100644 index 701ab42..0000000 --- a/src/test/cucumber/openapphack/initialisation.feature +++ /dev/null @@ -1,27 +0,0 @@ -Feature: Initialisation - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Use app for the first time - When I enter "app" - Then the openapphack work folder is created - - Scenario: Use app after initialisation - When I enter "app" - Then I see "Usage: app [version]" - Then the openapphack work folder is created - - Scenario: app is initialised for the first time - Given an initialised shell - When I enter "echo $OPENAPPHACK_INIT" - Then I see "true" - When I enter "echo $PATH" - Then I see a single occurrence of "panickervinod" - - Scenario: app is initialised a subsequent time - Given an initialised shell - When I reinitialise the shell - And I enter "echo $PATH" - Then I see a single occurrence of "panickervinod" diff --git a/src/test/cucumber/openapphack/install_candidate.feature b/src/test/cucumber/openapphack/install_candidate.feature deleted file mode 100644 index aa30e41..0000000 --- a/src/test/cucumber/openapphack/install_candidate.feature +++ /dev/null @@ -1,64 +0,0 @@ -Feature: Install Candidate - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Install a default Candidate - Given the default "panickervinod" candidate is "master" - When I enter "app install panickervinod" and answer "Y" - Then I see "Done installing!" - Then the candidate "panickervinod" version "master" is installed - - Scenario: Install a specific Candidate - And the candidate "openapphack" version "master" is available - When I enter "app install openapphack master" and answer "Y" - Then I see "Done installing!" - Then the candidate "openapphack" version "master" is installed - - Scenario: Install a Candidate version that does not exist - Given the candidate "openapphack" version "0.0.1" is not available - When I enter "app install openapphack 0.0.1" - Then I see "Stop! 0.0.1 is not a valid openapphack version." - - Scenario: Install a Candidate version that is already installed - Given the candidate "panickervinod" version "master" is available - And the candidate "panickervinod" version "master" is already installed and default - When I enter "app install panickervinod master" - Then I see "Stop! panickervinod master is already installed." - - Scenario: Install a candidate and select to use it - Given the candidate "panickervinod" version "0.0.1" is available - When I enter "app install panickervinod 0.0.1" and answer "Y" - Then the candidate "panickervinod" version "0.0.1" is installed - And I see "Done installing!" - And I see "Do you want panickervinod 0.0.1 to be set as default? (Y/n)" - And I see "Setting panickervinod 0.0.1 as default." - Then the candidate "panickervinod" version "0.0.1" should be the default - - Scenario: Install a candidate and select to use it automatically - Given the candidate "panickervinod" version "0.0.1" is available - And I have configured "openapphack_auto_answer" to "true" - When I enter "app install panickervinod 0.0.1" - Then the candidate "panickervinod" version "0.0.1" is installed - And I see "Done installing!" - And I see "Setting panickervinod 0.0.1 as default." - Then the candidate "panickervinod" version "0.0.1" should be the default - - Scenario: Install a candidate and do not select to use it - Given the candidate "panickervinod" version "0.0.1" is available - When I enter "app install panickervinod 0.0.1" and answer "n" - Then the candidate "panickervinod" version "0.0.1" is installed - And I see "Done installing!" - And I see "Do you want panickervinod 0.0.1 to be set as default? (Y/n)" - And I do not see "Setting panickervinod 0.0.1 as default." - Then the candidate "panickervinod" version "0.0.1" should not be the default - - #revisit to reinstall automatically - Scenario: Abort installation of a incorrect Candidate - Given the candidate "panickervinod" version "0.0.0" is available - And the archive for candidate "panickervinod" version "0.0.0" is corrupt - When I enter "app install panickervinod 0.0.0" - Then I see "Stop! incorrect candidate! Please try installing again." - And the candidate "panickervinod" version "0.0.0" is not installed - And the archive for candidate "panickervinod" version "0.0.0" is removed diff --git a/src/test/cucumber/openapphack/install_openapphack.feature b/src/test/cucumber/openapphack/install_openapphack.feature deleted file mode 100644 index 52c26ec..0000000 --- a/src/test/cucumber/openapphack/install_openapphack.feature +++ /dev/null @@ -1,82 +0,0 @@ -@manual -Feature: Install OpenAppHack CLI - - Platform defaults as follows: - * Ubuntu: .profile, .bashrc - * Fedora: .bash_profile, .bashrc - * OS X: no skeleton files in user home (nice one Apple!) - * Cygwin: .bash_profile, .profile and .bashrc - * Solaris: .profile, .bashrc - * FreeBSD: .profile with NO .bashrc or bash pre-installed - - Order of precedence: - Login shells (all new terminals) are initialised with the first file found in this order: - * .bash_profile - * .bash_login - * .profile - Non-login shells (like xterm shells) read the .bashrc file. - - Also important to note that usually the .bash_profile or .profile login shell files - will check for the .bashrc file and invoke if present! - - Background: - Given a user home exists - - Scenario: Creates and initialises .bash_profile on absence of login shell dot files - Given the user home directory contains no ".bash_profile" file - And the user home directory contains no ".profile" file - When I run the installation script - Then the user home contains a ".bash_profile" file - And the ".bash_profile" contains an Initialisation Snippet - - Scenario: Add Init Snippet to the .bash_profile if present - Given the user home contains a ".bash_profile" file - When I run the installation script - Then the ".bash_profile" contains an Initialisation Snippet - - Scenario: Add Init Snippet to the .profile if present - Given the user home contains a ".profile" file - When I run the installation script - Then the ".profile" contains an Initialisation Snippet - - Scenario: Creates and initialises .bashrc on absence of non-login dot files - Given the user home directory contains no ".bashrc" file - When I run the installation script - Then the user home contains a ".bashrc" file - And the ".bashrc" contains an Initialisation Snippet - - Scenario: Always adds Init Snippet to the .bashrc - Given the user home contains a ".bashrc" file - When I run the installation script - Then the ".bashrc" contains an Initialisation Snippet - - Scenario: Creates and initialises .zshrc on absence of the file - Given the user home directory contains no ".zshrc" file - When I run the installation script - Then the user home contains a ".zshrc" file - And the ".zshrc" contains an Initialisation Snippet - - Scenario: Always adds Init Snippet to the .zshrc - Given the user home contains a ".zshrc" file - When I run the installation script - Then the ".zshrc" contains an Initialisation Snippet - - Scenario: Source the Initialisation Script on first invokation of the Init Snippet - Given the user home contains a ".bash_profile" file - And the ".bash_profile" contains an Initialisation Snippet - When I open a new Login Shell - Then the "app-init.sh" script is sourced once only - - Scenario: Do not Source the Initialisation Script on subsequent invocation of the Init Snippet - Given the user home contains a ".bash_profile" file - And the ".bash_profile" contains an Initialisation Snippet - And the user home contains a ".bashrc" file - And the ".bashrc" contains an Initialisation Snippet - When I open a new Login Shell - Then the "app-init.sh" script is sourced once only - - Scenario: Upgrade an installation without configuration - Given an uninitialised system - And the configuration file has not been primed - When I run the installation script - Then the configuration file is present diff --git a/src/test/cucumber/openapphack/list_candidates.feature b/src/test/cucumber/openapphack/list_candidates.feature deleted file mode 100644 index 988063d..0000000 --- a/src/test/cucumber/openapphack/list_candidates.feature +++ /dev/null @@ -1,39 +0,0 @@ -@manual -Feature: List Candidates - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: List an uninstalled available Version - Given I do not have a "panickervinod" candidate installed - When I enter "app list panickervinod" - Then I see "Available OpenAppHack Versions" - And I see " master" - - Scenario: List an installed available Version not in use - Given the candidate "panickervinod" version "0.0.1" is already installed but not default - When I enter "app list panickervinod" - Then I see "Available OpenAppHack Versions" - And I see " * master" - - Scenario: List an installed available Version in use - Given the candidate "panickervinod" version "master" is already installed and default - When I enter "app list panickervinod" - Then I see "Available OpenAppHack Versions" - And I see " > * master" - - Scenario: List an installed local version not in use - Given I have a local candidate "panickervinod" version "0.0.1" at "/.vms/panickervinod/0.0.1" - And the candidate "openapphack" version "master" is already linked to "/.vms/openapphack/master" - When I enter "app list openapphack" - Then I see "Available openapphack Versions" - And I see " + master" - - Scenario: List an installed local Version in use - Given I have a local candidate "openapphack" version "master" at "/.vms/openapphack/master" - And the candidate "openapphack" version "master" is already linked to "/.vms/openapphack/master" - And the candidate "openapphack" version "master" is the default - When I enter "app list openapphack" - Then I see "Available openapphack Versions" - And I see " > + master" diff --git a/src/test/cucumber/openapphack/local_developement_versions.feature b/src/test/cucumber/openapphack/local_developement_versions.feature deleted file mode 100644 index 6225d31..0000000 --- a/src/test/cucumber/openapphack/local_developement_versions.feature +++ /dev/null @@ -1,46 +0,0 @@ -Feature: Local Development Versions - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Install a new local development version - Given the candidate "openapphack" version "master" is not available - And I have a local candidate "openapphack" version "master" at "/.vms/openapphack/master" - When I enter "app install openapphack master /.vms/openapphack/master" - Then I see "Linking openapphack master to /.vms/openapphack/master" - And the candidate "openapphack" version "master" is linked to /.vms/openapphack/master" - - Scenario: Attempt installing a local development version that already exists - Given the candidate "openapphack" version "master" is not available - And the candidate "openapphack" version "master" is already linked to "/.vms/openapphack/master" - When I enter "app install openapphack master /.vms/openapphack/master" - Then I see "Stop! openapphack master is already installed." - And the candidate "openapphack" version "master" is linked to "/.vms/openapphack/master" - - Scenario: Uninstall a local development version - Given the candidate "openapphack" version "master" is already linked to "/.vms/openapphack/master" - When I enter "app uninstall openapphack master" - Then I see "Uninstalling openapphack master" - And the candidate "openapphack" version "master" is not installed - - Scenario: Attempt uninstalling a local development version that is not installed - Given the candidate "openapphack" version "master" is not installed - When I enter "app uninstall openapphack master" - Then I see "openapphack master is not installed." - - Scenario: Make the local development version the default for the candidate - Given the candidate "openapphack" version "0.0.1" is already installed and default - And the candidate "openapphack" version "master" is not available - And the candidate "openapphack" version "master" is already linked to "/.vms/openapphack/master" - When I enter "app default openapphack master" - Then I see "Default openapphack version set to master" - And the candidate "openapphack" version "master" should be the default - - Scenario: Use a local development version - Given the candidate "openapphack" version "0.0.1" is already installed and default - And the candidate "openapphack" version "master" is not available - And the candidate "openapphack" version "master" is already linked to "/.vms/openapphack/master" - When I enter "app use openapphack master" - Then I see "Using openapphack version master in this shell" - And the candidate "openapphack" version "master" should be in use diff --git a/src/test/cucumber/openapphack/mnemonics.feature b/src/test/cucumber/openapphack/mnemonics.feature deleted file mode 100644 index 3444918..0000000 --- a/src/test/cucumber/openapphack/mnemonics.feature +++ /dev/null @@ -1,91 +0,0 @@ -Feature: Mnemonics - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Shortcut for listing an uninstalled available Version - Given I do not have a "panickervinod" candidate installed - And a "panickervinod" list view is available for consumption - When I enter "app l panickervinod" - Then I see "Available Panickervinod Versions" - - Scenario: Alternate shortcut for listing uninstalled available Version - Given I do not have a "panickervinod" candidate installed - And a "panickervinod" list view is available for consumption - When I enter "app ls panickervinod" - Then I see "Available Panickervinod Versions" - - Scenario: Shortcut for asking help - When I enter "app h" - Then I see "Usage: app [version]" - - Scenario: Shortcut for displaying current Candidate Version in use - Given the candidate "panickervinod" version "0.0.1" is already installed and default - When I enter "app c panickervinod" - Then I see "Using panickervinod version 0.0.1" - - Scenario: Shortcut for displaying current Candidate Versions - Given the candidate "openapphack" version "master" is already installed and default - And the candidate "panickervinod" version "master" is already installed and default - When I enter "app c" - Then I see "Using:" - And I see "panickervinod: master" - And I see "openapphack: master" - - Scenario: Shortcut for displaying outdated Candidate Version in use - Given the candidate "panickervinod" version "0.0.1" is already installed and default - And the default "panickervinod" candidate is "master" - When I enter "app o panickervinod" - Then I see "Outdated:" - And I see "panickervinod (0.0.1 < master)" - - Scenario: Shortcut for displaying outdated Candidate Versions - Given the candidate "panickervinod" version "0.0.1" is already installed and default - And the default "panickervinod" candidate is "master" - And the candidate "openapphack" version "0.0.1" is already installed and default - And the default "openapphack" candidate is "master" - When I enter "app o" - Then I see "Outdated:" - And I see "panickervinod (0.0.1 < master)" - And I see "openapphack (0.0.1 < master)" - - Scenario: Shortcut for installing a Candidate Version - Given the candidate "panickervinod" version "master" is not installed - And the candidate "panickervinod" version "master" is available for download - When I enter "app i panickervinod master" and answer "Y" - Then I see "Installing: panickervinod master" - And the candidate "panickervinod" version "master" is installed - - Scenario: Shortcut for uninstalling a Candidate Version - Given the candidate "openapphack" version "master" is already installed and default - When I enter "app rm openapphack master" - Then I see "Uninstalling openapphack master" - And the candidate "openapphack" version "master" is not installed - - Scenario: Shortcut for showing the current Version of app - When I enter "app v" - Then I see "OpenAppHack CLI x.y.z" - - Scenario: Shortcut for using a candidate version that is installed - Given the candidate "panickervinod" version "master" is already installed and default - And the candidate "panickervinod" version "master" is a valid candidate version - And the candidate "panickervinod" version "0.0.1" is already installed but not default - And the candidate "panickervinod" version "0.0.1" is a valid candidate version - When I enter "app u panickervinod 0.0.1" - Then I see "Using panickervinod version 0.0.1 in this shell." - Then the candidate "panickervinod" version "0.0.1" should be in use - And the candidate "panickervinod" version "master" should be the default - - Scenario: Shortcut for defaulting a Candidate Version that is installed and not default - Given the candidate "openapphack" version "master" is already installed but not default - And the candidate "openapphack" version "master" is a valid candidate version - When I enter "app d openapphack master" - Then I see "Default openapphack version set to master" - And the candidate "openapphack" version "master" should be the default - - Scenario: Shortcut for a Broadcast command issued - Given no prior Broadcast was received - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "app b" - Then I see "This is a LIVE Broadcast!" diff --git a/src/test/cucumber/openapphack/offline_mode.feature b/src/test/cucumber/openapphack/offline_mode.feature deleted file mode 100644 index 098c0a8..0000000 --- a/src/test/cucumber/openapphack/offline_mode.feature +++ /dev/null @@ -1,129 +0,0 @@ -Feature: Offline Mode - - Background: - Given the internet is not reachable - And an initialised environment - - # list command - - Scenario: List candidate versions found while Offline - Given the candidate "panickervinod" version "master" is already installed and default - And the candidate "panickervinod" version "0.0.1" is already installed but not default - When I enter "app list panickervinod" - Then I see "Offline Mode: only showing installed panickervinod versions" - And I see "> master" - And I see "* 0.0.1" - - Scenario: List candidate versions not found while Offline - When I enter "app list panickervinod" - Then I see "Offline Mode: only showing installed panickervinod versions" - And I see "None installed!" - -# use command - - Scenario: Use the default candidate version while Offline - Given the candidate "panickervinod" version "master" is already installed and default - And the candidate "panickervinod" version "0.0.1" is already installed but not default - When I enter "app use panickervinod" - Then I see "Using panickervinod version master in this shell." - - Scenario: Use the default candidate version when non selected while Offline - Given the candidate "panickervinod" version "0.0.1" is already installed but not default - Given the candidate "panickervinod" version "master" is already installed but not default - When I enter "app use panickervinod" - Then I see "This command is not available in offline mode." - - Scenario: Use an uninstalled candidate version while Offline - Given the candidate "panickervinod" version "0.0.1" is already installed and default - And the candidate "panickervinod" version "master" is not installed - When I enter "app use panickervinod master" - Then I see "Stop! panickervinod master is not available in offline mode." - - Scenario: Use an invalid candidate version while Offline - Given the candidate "panickervinod" version "0.0.1" is already installed and default - When I enter "app use panickervinod 9.9.9" - Then I see "Stop! panickervinod 9.9.9 is not available in offline mode." - - Scenario: Use an installed candidate version while Offline - Given the candidate "panickervinod" version "master" is already installed and default - And the candidate "panickervinod" version "0.0.1" is already installed but not default - When I enter "app use panickervinod 0.0.1" - Then I see "Using panickervinod version 0.0.1 in this shell." - - # default command - - Scenario: Set the default to an uninstalled candidate version while Offline - Given the candidate "panickervinod" version "0.0.1" is already installed and default - When I enter "app default panickervinod master" - Then I see "Stop! panickervinod master is not available in offline mode." - - Scenario: Set the default to an invalid candidate version while Offline - Given the candidate "panickervinod" version "0.0.1" is already installed and default - When I enter "app default panickervinod 999" - Then I see "Stop! panickervinod 999 is not available in offline mode." - - Scenario: Set the default to an installed candidate version while Offline - Given the candidate "panickervinod" version "master" is already installed and default - And the candidate "panickervinod" version "0.0.1" is already installed but not default - When I enter "app default panickervinod 0.0.1" - Then I see "Default panickervinod version set to 0.0.1" - - # install command - Scenario: Install a candidate version that is not installed while Offline - Given the candidate "panickervinod" version "master" is not installed - When I enter "app install panickervinod master" - Then I see "Stop! panickervinod master is not available in offline mode." - - Scenario: Install a candidate version that is already installed while Offline - Given the candidate "panickervinod" version "master" is already installed and default - When I enter "app install panickervinod master" - Then I see "Stop! panickervinod master is already installed." - - # uninstall command - Scenario: Uninstall a candidate version while Offline - Given the candidate "panickervinod" version "master" is already installed and default - When I enter "app uninstall panickervinod master" - Then I see "Unselecting panickervinod master..." - And I see "Uninstalling panickervinod master..." - And the candidate "panickervinod" version "master" is not in use - And the candidate "panickervinod" version "master" is not installed - - Scenario: Uninstall a candidate version that is not installed while Offline - Given the candidate "panickervinod" version "master" is not installed - When I enter "app uninstall panickervinod master" - Then I see "panickervinod master is not installed." - - # current command - Scenario: Display the current version of a candidate while Offline - Given the candidate "panickervinod" version "master" is already installed and default - When I enter "app current panickervinod" - Then I see "Using panickervinod version master" - - Scenario: Display the current version of all candidates while Offline - Given the candidate "panickervinod" version "master" is already installed and default - And the candidate "openapphack" version "master" is already installed and default - When I enter "app current" - Then I see "Using:" - And I see "panickervinod: master" - And I see "openapphack: master" - - # version command - Scenario: Determine the OpenAppHack CLI version when Offline - When I enter "app version" - Then I see the current app version - - # broadcast command - Scenario: Recall a broadcast while Offline - Given a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - When I enter "app broadcast" - Then I see "This is an OLD Broadcast!" - - # help command - Scenario: Request help while Offline - When I enter "app help" - Then I see "Usage: app [version]" - - # selfupdate command - Scenario: Attempt self-update while Offline - When I enter "app selfupdate" - Then I see "This command is not available in offline mode." diff --git a/src/test/cucumber/openapphack/outdated_candidate.feature b/src/test/cucumber/openapphack/outdated_candidate.feature deleted file mode 100644 index 2322d9c..0000000 --- a/src/test/cucumber/openapphack/outdated_candidate.feature +++ /dev/null @@ -1,53 +0,0 @@ -Feature: Outdated Candidate - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Display outdated candidate version in use when it is outdated - Given the candidate "panickervinod" version "master" is already installed and default - And the default "panickervinod" candidate is "2.4.4" - When I enter "app outdated panickervinod" - Then I see "Outdated:" - And I see "panickervinod (master < 2.4.4)" - - Scenario: Display outdated candidate version in use when it is not outdated - Given the candidate "panickervinod" version "0.0.1" is already installed and default - And the default "panickervinod" candidate is "0.0.1" - When I enter "app outdated panickervinod" - Then I see "panickervinod is up-to-date" - - Scenario: Display outdated candidate version when none is in use - Given the candidate "panickervinod" does not exist - When I enter "app outdated panickervinod" - Then I see "Not using any version of panickervinod" - - Scenario: Display outdated candidate versions when none is specified and none is in use - Given the candidate "panickervinod" does not exist - When I enter "app outdated" - Then I see "No candidates are in use" - - Scenario: Display outdated candidate versions when none is specified and one is in use - Given the candidate "panickervinod" version "master" is already installed and default - And the default "panickervinod" candidate is "2.4.4" - When I enter "app outdated" - Then I see "Outdated:" - And I see "panickervinod (master < 2.4.4)" - - Scenario: Display outdated candidate versions when none is specified and multiple are in use - Given the candidate "panickervinod" version "master" is already installed and default - And the default "panickervinod" candidate is "2.4.4" - And the candidate "openapphack" version "master" is already installed and default - And the default "openapphack" candidate is "2.4.1" - When I enter "app outdated" - Then I see "Outdated:" - And I see "panickervinod (master < 2.4.4)" - And I see "openapphack (master < 2.4.1)" - - Scenario: Display outdated candidate versions when none is specified and multiple are in use but they are not outdated - Given the candidate "panickervinod" version "master" is already installed and default - And the default "panickervinod" candidate is "master" - And the candidate "openapphack" version "master" is already installed and default - And the default "openapphack" candidate is "master" - When I enter "app outdated" - Then I see "All candidates are up-to-date" diff --git a/src/test/cucumber/openapphack/self_update.feature b/src/test/cucumber/openapphack/self_update.feature deleted file mode 100644 index b44c0c5..0000000 --- a/src/test/cucumber/openapphack/self_update.feature +++ /dev/null @@ -1,73 +0,0 @@ -Feature: Self Update - - Background: - Given the internet is reachable - - Scenario: Force a Selfupdate - Given an initialised environment - When I enter "app selfupdate force" - Then I do not see "A new version of OPENAPPHACK is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading today..." - And I see "Updating openapphack..." - And I see "Successfully upgraded OpenAppHack CLI." - - Scenario: Selfupdate when out of date - Given an outdated initialised environment - When I enter "app selfupdate" - Then I do not see "A new version of OPENAPPHACK is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading today..." - And I see "Updating openapphack..." - And I see "Successfully upgraded OpenAppHack CLI." - - Scenario: Agree to a suggested Selfupdate - Given an outdated initialised environment - When I enter "app help" and answer "Y" - Then I see "A new version of OPENAPPHACK is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Successfully upgraded OpenAppHack CLI." - And I do not see "Not upgrading today..." - - Scenario: Do not agree to a suggested Selfupdate - Given an outdated initialised environment - When I enter "app help" and answer "N" - Then I see "A new version of OPENAPPHACK is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Not upgrading today..." - And I do not see "Successfully upgraded OpenAppHack CLI." - - Scenario: Automatically Selfupdate - Given an outdated initialised environment - And the configuration file has been primed with "openapphack_auto_selfupdate=true" - When I enter "app help" - Then I see "A new version of OPENAPPHACK is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading today..." - And I see "Successfully upgraded OpenAppHack CLI." - - Scenario: Do not automatically Selfupdate - Given an outdated initialised environment - And the configuration file has been primed with "openapphack_auto_selfupdate=false" - When I enter "app help" and answer "n" - Then I see "A new version of OPENAPPHACK is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Not upgrading today..." - And I do not see "Successfully upgraded OpenAppHack CLI." - - Scenario: Bother the user with Upgrade message once a day - Given an outdated initialised environment - When I enter "app help" and answer "N" - Then I see "A new version of OPENAPPHACK is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Not upgrading today..." - And I enter "app help" - Then I do not see "A new version of OPENAPPHACK is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading now..." - And I do not see "Successfully upgraded OpenAppHack CLI." - - Scenario: Selfupdate when not out of date - Given an initialised environment - When I enter "app selfupdate" - Then I see "No update available at this time." diff --git a/src/test/cucumber/openapphack/uninstall_candidate.feature b/src/test/cucumber/openapphack/uninstall_candidate.feature deleted file mode 100644 index 174e1ef..0000000 --- a/src/test/cucumber/openapphack/uninstall_candidate.feature +++ /dev/null @@ -1,37 +0,0 @@ -Feature: Uninstall Candidate - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Uninstall an installed Candidate Version not in use - Given the candidate "panickervinod" version "master" is already installed but not default - When I enter "app uninstall panickervinod master" - Then I do not see "Unselecting panickervinod master" - Then I see "Uninstalling panickervinod master" - And the candidate "panickervinod" version "master" is not installed - - Scenario: Uninstall a Candidate Version in use - Given the candidate "panickervinod" version "master" is already installed and default - When I enter "app uninstall panickervinod master" - Then I see "Unselecting panickervinod master" - And I see "Uninstalling panickervinod master" - And the candidate "panickervinod" version "master" is not installed - And the candidate "panickervinod" is no longer selected - - Scenario: Attempt uninstalling a Candidate Version that is not installed - Given the candidate "panickervinod" version "0.0.1" is not installed - When I enter "app uninstall panickervinod 0.0.1" - Then I see "panickervinod 0.0.1 is not installed." - - Scenario: Attempt uninstalling with no Candidate specified - When I enter "app uninstall" - Then I see "No candidate provided." - - Scenario: Attempt uninstalling with an invalid Candidate specified - When I enter "app uninstall groffle" - Then I see "Stop! groffle is not a valid candidate." - - Scenario: Attempt uninstalling without a version provided - When I enter "app uninstall panickervinod" - Then I see "No candidate version provided." diff --git a/src/test/cucumber/openapphack/use_and_default_candidate.feature b/src/test/cucumber/openapphack/use_and_default_candidate.feature deleted file mode 100644 index 5acaae1..0000000 --- a/src/test/cucumber/openapphack/use_and_default_candidate.feature +++ /dev/null @@ -1,67 +0,0 @@ -Feature: Use and Default Candidate - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Use without providing a Candidate - When I enter "app use" - Then I see "Usage: app [version]" - - Scenario: Use a candidate version that is installed - Given the candidate "panickervinod" version "master" is already installed and default - And the candidate "panickervinod" version "0.0.1" is a valid candidate version - And the candidate "panickervinod" version "0.0.1" is already installed but not default - When I enter "app use panickervinod 0.0.1" - Then I see "Using panickervinod version 0.0.1 in this shell." - Then the candidate "panickervinod" version "0.0.1" should be in use - And the candidate "panickervinod" version "master" should be the default - - Scenario: Use a candidate version that is not installed - Given the candidate "panickervinod" version "0.0.1" is available for download - When I enter "app use panickervinod 0.0.1" and answer "Y" - Then I see "Using panickervinod version 0.0.1 in this shell." - And the candidate "panickervinod" version "0.0.1" should be in use - - Scenario: Use a candidate version that is automatically installed - Given I have configured "openapphack_auto_answer" to "true" - And the candidate "panickervinod" version "0.0.1" is available for download - When I enter "app use panickervinod 0.0.1" - Then I see "Stop! panickervinod 0.0.1 is not installed." - Then I see "Using panickervinod version 0.0.1 in this shell." - And the candidate "panickervinod" version "0.0.1" should be in use - - Scenario: Use a candidate version that does not exist - Given the candidate "openapphack" version "1.9.9" is not available for download - When I enter "app use openapphack 1.9.9" - Then I see "Stop! 1.9.9 is not a valid openapphack version." - - Scenario: Use a candidate version that only exists locally - Given the candidate "panickervinod" version "2.0.0.M1" is not available for download - And the candidate "panickervinod" version "2.0.0.M1" is already installed but not default - When I enter "app use panickervinod 2.0.0.M1" - Then I see "Using panickervinod version 2.0.0.M1 in this shell." - - Scenario: Default a candidate version that is not installed - Given the candidate "openapphack" version "master" is a valid candidate version - When I enter "app default openapphack master" - Then I see "Stop! openapphack master is not installed." - - Scenario: Default a candidate version that is installed and not default - Given the candidate "openapphack" version "master" is a valid candidate version - And the candidate "openapphack" version "master" is already installed but not default - When I enter "app default openapphack master" - Then I see "Default openapphack version set to master" - And the candidate "openapphack" version "master" should be the default - - Scenario: Default a candidate version that is installed and already default - Given the candidate "openapphack" version "master" is a valid candidate version - And the candidate "openapphack" version "master" is already installed and default - When I enter "app default openapphack master" - Then I see "Default openapphack version set to master" - And the candidate "openapphack" version "master" should be the default - - Scenario: Default a candidate version that does not exist - Given the candidate "openapphack" version "2.9.9" is not available for download - When I enter "app default openapphack 2.9.9" - Then I see "Stop! 2.9.9 is not a valid openapphack version." diff --git a/src/test/cucumber/openapphack/version.feature b/src/test/cucumber/openapphack/version.feature deleted file mode 100644 index c027ccf..0000000 --- a/src/test/cucumber/openapphack/version.feature +++ /dev/null @@ -1,9 +0,0 @@ -Feature: Version - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Show the current version of app - When I enter "app version" - Then I see "OpenAppHack CLI x.y.z" diff --git a/src/test/groovy/openapphack/cucumber/RunCukeTests.groovy b/src/test/groovy/openapphack/cucumber/RunCukeTests.groovy deleted file mode 100644 index 9509b30..0000000 --- a/src/test/groovy/openapphack/cucumber/RunCukeTests.groovy +++ /dev/null @@ -1,14 +0,0 @@ -package openapphack.cucumber - -import cucumber.api.junit.Cucumber -import org.junit.runner.RunWith - -@RunWith(Cucumber) -@Cucumber.Options( - format=["pretty", "html:build/reports/cucumber"], - strict=true, - features=["src/test/cucumber"], - glue=["src/test/steps"], - tags=["~@manual", "~@review"] -) -class RunCukesTest {} diff --git a/src/test/groovy/openapphack/env/BashEnv.groovy b/src/test/groovy/openapphack/env/BashEnv.groovy deleted file mode 100644 index 2b41115..0000000 --- a/src/test/groovy/openapphack/env/BashEnv.groovy +++ /dev/null @@ -1,165 +0,0 @@ -package openapphack.env - -/** - *

As part of the openapphack test suite we need to launch a bash shell and execute - * multiple commands in it. This is tricky to do using Java's support for - * working with external processes as the API can't tell you when a command - * has finished executing.

- *

This class provides some hacks that allow you to serially execute commands - * in an external bash process in a fairly reliable manner and to retrieve the - * output of those commands.

- */ -class BashEnv { - - static final PROMPT = "" - static final EXIT_CODE_CMD = 'echo "Exit code is: $?"' - static final EXIT_CODE_PATTERN = ~/Exit code is: (\d+)\s*${PROMPT}?$/ - - private final Object outputLock = new Object() - - def exitCode - def process - def processOutput = new StringBuilder() - def commandOutput - - // Command timeout in milliseconds - def timeout = 5000 - def workDir - def env - - BashEnv(workDir, Map env) { - this.workDir = workDir as File - - def basicPath = "/usr/sbin:/usr/bin:/sbin:/bin" - def localBinDir = "${workDir}/bin" - - def modifiedPath = "$localBinDir:$basicPath" - - env = env + [PS1: PROMPT, PATH: modifiedPath] - this.env = env.collect { k, v -> k + '=' + v } - } - - /** - * Starts the external bash process. - */ - void start() { - process = ["bash", "--noprofile", "--norc", "-i"].execute(env, workDir) - - consumeProcessStream(process.inputStream) - consumeProcessStream(process.errorStream) - } - - /** - * Stops the external bash process and waits for it to finish. - */ - void stop() { - execute("exit") - process.waitFor() - } - - /** - * Sends a command line to the external bash process and returns once the - * command has finished executing. If the command is interactive and requires - * input during it's execution (for example a y/n answer to a question) you - * can provide that input as a list of strings. - */ - void execute(String cmdline, List inputs = []) { - resetOutput() - - if (cmdline != "exit") { - exitCode = null - } - - process.outputStream << cmdline << "\n" - process.outputStream.flush() - - if (cmdline != "exit") { - for (input in inputs) { - process.outputStream << input << "\n" - } - process.outputStream << EXIT_CODE_CMD << "\n" - process.outputStream.flush() - } - - def start = System.currentTimeMillis() - while (cmdline != "exit") { - Thread.sleep 100 - - synchronized (outputLock) { - // Remove all the extraneous text that's not related to the - // command's output. This includes the command string itself, - // the 'echo' command to display the command's exit code, and - // the exit code line. - removeFromOutput(cmdline + "\n") - removeFromOutput(PROMPT + EXIT_CODE_CMD + "\n") - - def str = processOutput.toString() - def m = EXIT_CODE_PATTERN.matcher(str) - if (m) { - exitCode = m[0][1] - - // Remove this exit code line from the output. - commandOutput = m.replaceAll('') - break - } - - // If the command times out, we should break out of the loop and - // display whatever output has already been produced. - if (System.currentTimeMillis() - start > timeout) { - commandOutput = "ALERT! Command timed out. Last output was:\n\n${processOutput}" - break - } - } - } - } - - /** - * Returns the exit code of the last command that was executed. - */ - int getStatus() { - if (!exitCode) throw new IllegalStateException("Did you run execute() before getting the status?") - return exitCode.toInteger() - } - - /** - * Returns the text output (both stdout and stderr) of the last command - * that was executed. - */ - String getOutput() { - return commandOutput - } - - /** - * Clears the saved command output. - */ - void resetOutput() { - synchronized (outputLock) { - processOutput = new StringBuilder() - } - } - - private void consumeProcessStream(final InputStream stream) { - char[] buffer = new char[256] - Thread.start { - def reader = new InputStreamReader(stream) - def charsRead = 0 - while (charsRead != -1) { - charsRead = reader.read(buffer, 0, 256) - if (charsRead > 0) { - synchronized (outputLock) { - processOutput.append(buffer, 0, charsRead) - } - } - } - } - } - - private void removeFromOutput(String line) { - synchronized (outputLock) { - def pos = processOutput.indexOf(line) - if (pos != -1) { - processOutput.delete(pos, pos + line.size() - 1) - } - } - } -} diff --git a/src/test/groovy/openapphack/env/OpenAppHackEnvBuilder.groovy b/src/test/groovy/openapphack/env/OpenAppHackEnvBuilder.groovy deleted file mode 100644 index 521606a..0000000 --- a/src/test/groovy/openapphack/env/OpenAppHackEnvBuilder.groovy +++ /dev/null @@ -1,194 +0,0 @@ -package openapphack.env - -import openapphack.stubs.CurlStub - -class OpenAppHackBashEnvBuilder { - - final TEST_SCRIPT_BUILD_DIR = "build/testScripts" as File - - //mandatory fields - private final File baseFolder - - //optional fields with sensible defaults - CurlStub curlStub - List candidates = ['openapphack', 'panickervinod'] - List availableCandidates = candidates - boolean onlineMode = true - boolean forcedOfflineMode = false - String broadcast = "This is a LIVE broadcast!" - String service = "http://localhost:8080" - String broadcastService = "http://localhost:8080" - String brokerService = "http://localhost:8080" - String jdkHome = "/path/to/my/jdk" - String httpProxy - String versionToken - - Map config = [ - openapphack_auto_answer:'false' - ] - - File openapphackDir, openapphackBinDir, openapphackVarDir, openapphackSrcDir, openapphackEtcDir, openapphackExtDir, openapphackArchivesDir, openapphackTmpDir - - static OpenAppHackBashEnvBuilder create(File baseFolder){ - new OpenAppHackBashEnvBuilder(baseFolder) - } - - private OpenAppHackBashEnvBuilder(File baseFolder){ - this.baseFolder = baseFolder - } - - OpenAppHackBashEnvBuilder withCurlStub(CurlStub curlStub){ - this.curlStub = curlStub - this - } - - OpenAppHackBashEnvBuilder withCandidates(List candidates){ - this.candidates = candidates - this - } - - OpenAppHackBashEnvBuilder withAvailableCandidates(List candidates){ - this.availableCandidates = candidates - this - } - - OpenAppHackBashEnvBuilder withBroadcast(String broadcast){ - this.broadcast = broadcast - this - } - - OpenAppHackBashEnvBuilder withConfiguration(String key, String value){ - config.put key, value - this - } - - OpenAppHackBashEnvBuilder withOnlineMode(boolean onlineMode){ - this.onlineMode = onlineMode - this - } - - OpenAppHackBashEnvBuilder withForcedOfflineMode(boolean forcedOfflineMode){ - this.forcedOfflineMode = forcedOfflineMode - this - } - - OpenAppHackBashEnvBuilder withService(String service){ - this.service = service - this - } - - OpenAppHackBashEnvBuilder withBroadcastService(String broadcastService){ - this.broadcastService = broadcastService - this - } - - OpenAppHackBashEnvBuilder withBrokerService(String brokerService){ - this.brokerService = brokerService - this - } - - OpenAppHackBashEnvBuilder withJdkHome(String jdkHome){ - this.jdkHome = jdkHome - this - } - - OpenAppHackBashEnvBuilder withHttpProxy(String httpProxy){ - this.httpProxy = httpProxy - this - } - - OpenAppHackBashEnvBuilder withVersionToken(String version){ - this.versionToken = version - this - } - - BashEnv build() { - openapphackDir = prepareDirectory(baseFolder, ".openapphack") - openapphackBinDir = prepareDirectory(openapphackDir, "bin") - openapphackVarDir = prepareDirectory(openapphackDir, "var") - openapphackSrcDir = prepareDirectory(openapphackDir, "src") - openapphackEtcDir = prepareDirectory(openapphackDir, "etc") - openapphackExtDir = prepareDirectory(openapphackDir, "ext") - openapphackArchivesDir = prepareDirectory(openapphackDir, "archives") - openapphackTmpDir = prepareDirectory(openapphackDir, "tmp") - - initializeCandidates(openapphackDir, candidates) - initializeAvailableCandidates(openapphackVarDir, availableCandidates) - initializeBroadcast(openapphackVarDir, broadcast) - initializeConfiguration(openapphackEtcDir, config) - initializeVersionToken(openapphackVarDir, versionToken) - - primeInitScript(openapphackBinDir) - primeModuleScripts(openapphackSrcDir) - - def env = [ - OPENAPPHACK_DIR: openapphackDir.absolutePath, - OPENAPPHACK_ONLINE: "$onlineMode", - OPENAPPHACK_FORCE_OFFLINE: "$forcedOfflineMode", - OPENAPPHACK_SERVICE: service, - OPENAPPHACK_BROADCAST_SERVICE: broadcastService, - OPENAPPHACK_BROKER_SERVICE: brokerService, - JAVA_HOME: jdkHome - ] - - if(httpProxy) { - env.put("http_proxy", httpProxy) - } - - new BashEnv(baseFolder.absolutePath, env) - } - - private prepareDirectory(File target, String directoryName) { - def directory = new File(target, directoryName) - directory.mkdirs() - directory - } - - private initializeVersionToken(File folder, String version) { - if(version) { - new File(folder, "version") << version - } - } - - - private initializeCandidates(File folder, List candidates) { - candidates.each { candidate -> - new File(folder, candidate).mkdirs() - } - } - - private initializeAvailableCandidates(File folder, List candidates){ - new File(folder, "candidates") << candidates.join(",") - } - - private initializeBroadcast(File targetFolder, String broadcast) { - new File(targetFolder, "broadcast") << broadcast - } - - private initializeConfiguration(File targetFolder, Map config){ - def configFile = new File(targetFolder, "config") - config.each { key, value -> - configFile << "$key=$value\n" - } - } - - private primeInitScript(File targetFolder) { - def sourceInitScript = new File(TEST_SCRIPT_BUILD_DIR, 'app-init.sh') - - if (!sourceInitScript.exists()) - throw new IllegalStateException("app-init.sh has not been prepared for consumption.") - - def destInitScript = new File(targetFolder, "app-init.sh") - destInitScript << sourceInitScript.text - destInitScript - } - - private primeModuleScripts(File targetFolder){ - for (f in TEST_SCRIPT_BUILD_DIR.listFiles()){ - if(!(f.name in ['selfupdate.sh', 'install.sh', 'app-init.sh'])){ - new File(targetFolder, f.name) << f.text - } - } - } - -} diff --git a/src/test/groovy/openapphack/specs/BootstrapSpec.groovy b/src/test/groovy/openapphack/specs/BootstrapSpec.groovy deleted file mode 100644 index 64851e8..0000000 --- a/src/test/groovy/openapphack/specs/BootstrapSpec.groovy +++ /dev/null @@ -1,144 +0,0 @@ -package openapphack.specs - -import openapphack.env.BashEnv -import openapphack.stubs.CurlStub -import openapphack.env.OpenAppHackBashEnvBuilder -import spock.lang.Specification - -import static openapphack.utils.TestUtils.prepareBaseDir - -class BootstrapSpec extends Specification { - - CurlStub curlStub - BashEnv bash - - File openapphackBaseDir - String openapphackBaseEnv - String bootstrap - String versionToken - - void setup(){ - openapphackBaseDir = prepareBaseDir() - openapphackBaseEnv = openapphackBaseDir.absolutePath - bootstrap = "${openapphackBaseDir.absolutePath}/.openapphack/bin/app-init.sh" - versionToken = "${openapphackBaseDir.absolutePath}/.openapphack/var/version" - curlStub = CurlStub.prepareIn(new File(openapphackBaseDir, "bin")) - } - - void "should store version token if not exists"() { - - given: 'a working openapphack installation without version token' - def versionFile = new File(versionToken) - curlStub.primeWith("http://localhost:8080/app/version", "echo x.y.b").build() - bash = OpenAppHackBashEnvBuilder - .create(openapphackBaseDir) - .withCurlStub(curlStub) - .build() - bash.start() - - when: 'bootstrap the system' - bash.execute("source $bootstrap") - - then: - versionFile.exists() - } - - void "should not query server if token is found"() { - given: 'a working openapphack installation with version token' - def versionFile = new File(versionToken) - bash = OpenAppHackBashEnvBuilder - .create(openapphackBaseDir) - .withCurlStub(curlStub) - .withVersionToken("x.y.z") - .build() - bash.start() - - when: 'bootstrap the system' - bash.execute("source $bootstrap") - - then: - versionFile.exists() - versionFile.text.contains("x.y.z") - } - - void "should query server for version and refresh if token is older than a day"() { - given: 'a working openapphack installation with expired version token' - def versionFile = new File(versionToken) - curlStub.primeWith("http://localhost:8080/app/version", "echo x.y.b").build() - bash = OpenAppHackBashEnvBuilder - .create(openapphackBaseDir) - .withCurlStub(curlStub) - .withVersionToken("x.y.a") - .build() - def twoDaysAgoInMillis = System.currentTimeMillis() - 172800000 - versionFile.setLastModified(twoDaysAgoInMillis) - bash.start() - - when: 'bootstrap the system' - bash.execute("source $bootstrap") - - then: - versionFile.exists() - versionFile.text.contains("x.y.b") - } - - void "should ignore version if api is offline"(){ - given: 'a working openapphack installation with api down' - def openapphackVersion = "x.y.z" - def versionFile = new File(versionToken) - curlStub.primeWith("http://localhost:8080/app/version", "echo ''").build() - bash = OpenAppHackBashEnvBuilder - .create(openapphackBaseDir) - .withCurlStub(curlStub) - .withVersionToken(openapphackVersion) - .build() - bash.start() - - when: 'bootstrap the system' - bash.execute("source $bootstrap") - - then: - versionFile.text.contains(openapphackVersion) - } - - void "should not go offline if curl times out"(){ - given: 'a working openapphack installation with api down' - curlStub.primeWith("http://localhost:8080/app/version", "echo ''").build() - bash = OpenAppHackBashEnvBuilder - .create(openapphackBaseDir) - .withCurlStub(curlStub) - .build() - bash.start() - - when: 'bootstrap the system' - bash.execute("source $bootstrap") - - then: - ! bash.output.contains("OPENAPPHACK can't reach the internet so going offline.") - } - - void "should ignore version if api returns garbage"(){ - given: 'a working openapphack installation with garbled api' - def openapphackVersion = "x.y.z" - def versionFile = new File(versionToken) - curlStub.primeWith("http://localhost:8080/app/version", "echo 'sorry'").build() - bash = OpenAppHackBashEnvBuilder - .create(openapphackBaseDir) - .withCurlStub(curlStub) - .withVersionToken(openapphackVersion) - .build() - bash.start() - - when: 'bootstrap the system' - bash.execute("source $bootstrap") - - then: - versionFile.text.contains openapphackVersion - } - - void cleanup(){ - println bash.output - bash.stop() - assert openapphackBaseDir.deleteDir() - } -} diff --git a/src/test/groovy/openapphack/stubs/CurlStub.groovy b/src/test/groovy/openapphack/stubs/CurlStub.groovy deleted file mode 100644 index 22ea0fd..0000000 --- a/src/test/groovy/openapphack/stubs/CurlStub.groovy +++ /dev/null @@ -1,34 +0,0 @@ -package openapphack.stubs - -class CurlStub { - - private File file - private commands = [:] - - static CurlStub prepareIn(File folder) { - folder.mkdirs() - - def file = new File(folder, "curl") - file.createNewFile() - file.write "#!/bin/bash\n" - file.executable = true - - new CurlStub(file:file) - } - - CurlStub primeWith(String request, String snippet) { - commands.put request, snippet - this - } - - void build(){ - commands.each { request, snippet -> - //use second arg because we use curl with -s - file << 'if [[ "$2" == "' - file << "$request" - file << '" ]]; then\n' - file << " $snippet\n" - file << 'fi\n' - } - } -} diff --git a/src/test/groovy/openapphack/stubs/WebServiceStub.groovy b/src/test/groovy/openapphack/stubs/WebServiceStub.groovy deleted file mode 100644 index 5328e8d..0000000 --- a/src/test/groovy/openapphack/stubs/WebServiceStub.groovy +++ /dev/null @@ -1,37 +0,0 @@ -package openapphack.stubs - -import static com.github.tomakehurst.wiremock.client.WireMock.* - -class WebServiceStub { - - static primeEndpoint(String endpoint, String body) { - stubFor(get(urlEqualTo(endpoint)).willReturn( - aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/plain") - .withBody(body))) - } - - static primeDownloadFor(String host, String candidate, String version) { - stubFor(get(urlEqualTo("/download/${candidate}/${version}/platform/Linux")).willReturn( - aResponse() - .withHeader("Location", "${host}/${candidate}-${version}.zip") - .withStatus(302))) - - def binary = "${candidate}-${version}.zip" - stubFor(get(urlEqualTo("/$binary")).willReturn( - aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/zip") - .withBodyFile(binary))) - } - - static primeSelfupdate() { - stubFor(get(urlEqualTo("/selfupdate")).willReturn( - aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/plain") - .withBodyFile("selfupdate.sh"))) - } - -} diff --git a/src/test/groovy/openapphack/utils/TestUtils.groovy b/src/test/groovy/openapphack/utils/TestUtils.groovy deleted file mode 100644 index fb4be87..0000000 --- a/src/test/groovy/openapphack/utils/TestUtils.groovy +++ /dev/null @@ -1,14 +0,0 @@ -package openapphack.utils - - -class TestUtils { - - static final DEFAULT_BASE_DIR = "/tmp/app-test" - - static File prepareBaseDir() { - def counter = "${(Math.random() * 10000).toInteger()}".padLeft(4, "0") - def baseDir = "$DEFAULT_BASE_DIR/app-$counter" as File - baseDir.mkdirs() - baseDir - } -} diff --git a/src/test/jmeter/OPENAPPHACK.jmx b/src/test/jmeter/OPENAPPHACK.jmx deleted file mode 100644 index 40007f1..0000000 --- a/src/test/jmeter/OPENAPPHACK.jmx +++ /dev/null @@ -1,441 +0,0 @@ - - - - - - false - false - - - - - - - - continue - - false - -1 - - 1 - 1 - 1382782760000 - 1382782760000 - false - - - - - - 0 - 100000 - 1 - counter - 00000 - true - - - - - - host - localhost - = - - - port - 8080 - = - - - - - - , - - candidates.csv - false - true - shareMode.thread - false - candidate,version - - - - - - - ${host} - ${port} - - - - - /alive - GET - false - false - true - false - Java - false - - - - - - OK - - Assertion.response_data - false - 2 - - - - - - - - ${host} - ${port} - - - - - /candidates - GET - false - false - true - false - Java - false - - - - - - groovy - panickervinod - griffon - gradle - - Assertion.response_data - false - 2 - - - - - - - - ${host} - ${port} - - - - - /candidates/${candidate}/${version}/validate - GET - false - false - true - false - Java - false - - - - - - valid - - Assertion.response_data - false - 8 - - - - - - - - ${host} - ${port} - - - - - /api/version - GET - false - false - true - false - Java - false - - - - - - 1.0.0 - - - Assertion.response_data - false - 2 - - - - - - - - ${host} - ${port} - - - - - /candidates/${candidate}/default - GET - false - false - true - false - Java - false - - - - - - ${version} - - Assertion.response_data - false - 2 - - - - - - - - false - Linux - = - true - platform - - - false - ${version} - = - true - current - - - false - ${version},local${counter} - = - true - installed - - - - ${host} - ${port} - - - - - /candidates/${candidate}/list - GET - false - false - true - false - Java - false - - - - - - Available - - - Assertion.response_data - false - 2 - - - - - - - - ${host} - ${port} - - - - - /api/broadcast - GET - false - false - true - false - Java - false - - - - - - Report issues - - Assertion.response_data - false - 2 - - - - - - - - ${host} - ${port} - - - - - /candidates/${candidate} - GET - false - false - true - false - Java - false - - - - - - ${version} - - Assertion.response_data - false - 2 - - - - - - - - ${host} - ${port} - - - - - /candidates/${candidate}/${version}/download - GET - false - false - true - false - Java - false - - - - - - 302 - - Assertion.response_code - false - 8 - - - - - false - - saveConfig - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - false - false - false - false - false - 0 - true - - - - - - - false - - saveConfig - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - false - false - false - false - false - 0 - true - - - - - - - 250 - - - - - - diff --git a/src/test/jmeter/candidates.csv b/src/test/jmeter/candidates.csv deleted file mode 100644 index aeffabf..0000000 --- a/src/test/jmeter/candidates.csv +++ /dev/null @@ -1,2 +0,0 @@ -panickervinod,master -openapphack,master diff --git a/src/test/resources/__files/selfupdate.sh b/src/test/resources/__files/selfupdate.sh deleted file mode 100644 index bfa8646..0000000 --- a/src/test/resources/__files/selfupdate.sh +++ /dev/null @@ -1,51 +0,0 @@ - - -echo "" -echo "Updating openapphack..." - -OPENAPPHACK_VERSION="x.y.z" - -openapphack_bin_folder="${OPENAPPHACK_DIR}/bin" -openapphack_stage_folder="${OPENAPPHACK_DIR}/tmp/stage" -openapphack_src_folder="${OPENAPPHACK_DIR}/src" - -echo "Purge existing scripts..." -rm -rf "${openapphack_bin_folder}" -rm -rf "${openapphack_src_folder}" - -echo "Refresh directory structure..." -mkdir -p "${OPENAPPHACK_DIR}/bin" -mkdir -p "${OPENAPPHACK_DIR}/ext" -mkdir -p "${OPENAPPHACK_DIR}/etc" -mkdir -p "${OPENAPPHACK_DIR}/src" -mkdir -p "${OPENAPPHACK_DIR}/var" -mkdir -p "${OPENAPPHACK_DIR}/tmp" -mkdir -p "${OPENAPPHACK_DIR}/vm" -mkdir -p "${OPENAPPHACK_DIR}/.vms" - -# drop version token -echo "$OPENAPPHACK_VERSION" > "${OPENAPPHACK_DIR}/var/version" - -echo "Prime the config file..." -openapphack_config_file="${OPENAPPHACK_DIR}/etc/config" -touch "${openapphack_config_file}" - -echo "Extract script archive..." - -echo "Unziping scripts to: ${openapphack_stage_folder}" - -echo "Moving app-init file to bin folder..." - -echo "Move remaining module scripts to src folder: ${openapphack_src_folder}" - -echo "Clean up staging folder..." - -echo "" -echo "" -echo "Successfully upgraded OpenAppHack CLI." -echo "" -echo "Please open a new terminal, or run the following in the existing one:" -echo "" -echo " source \"${OPENAPPHACK_DIR}/bin/app-init.sh\"" -echo "" -echo "" diff --git a/src/test/resources/openapphack_application.js b/src/test/resources/openapphack_application.js deleted file mode 100644 index aebfa7e..0000000 --- a/src/test/resources/openapphack_application.js +++ /dev/null @@ -1 +0,0 @@ -{ "_id" : "528887f05e75a57eee081491", "alive" : "OK" } diff --git a/src/test/resources/openapphack_broadcast.js b/src/test/resources/openapphack_broadcast.js deleted file mode 100644 index 7cb5e06..0000000 --- a/src/test/resources/openapphack_broadcast.js +++ /dev/null @@ -1 +0,0 @@ -{ "_id" : 1, "text" : "This is a LIVE Broadcast!" } diff --git a/src/test/resources/openapphack_candidates.js b/src/test/resources/openapphack_candidates.js deleted file mode 100644 index 4315278..0000000 --- a/src/test/resources/openapphack_candidates.js +++ /dev/null @@ -1,30 +0,0 @@ -[{ - "_id" : "530d9e23f0085665c6ad009c", - "candidate" : "openapphack", - "default" : "master", - "versions" : [ - { - "version" : "master", - "url" : "http://localhost:8080/openapphack-master.zip" - } - ] -}, -{ - "_id" : "530d9e23f0085665c6ad009d", - "candidate" : "panickervinod", - "default" : "master", - "versions" : [ - { - "version" : "master", - "url" : "http://localhost:8080/panickervinod-master.zip" - }, - { - "version" : "0.0.0", - "url" : "http://localhost:8080/panickervinod-0.0.0.zip" - }, - { - "version" : "0.0.1", - "url" : "http://localhost:8080/panickervinod-0.0.1.zip" - } - ] -}] diff --git a/src/test/steps/openapphack/broadcast_steps.groovy b/src/test/steps/openapphack/broadcast_steps.groovy deleted file mode 100644 index 0f2e5b8..0000000 --- a/src/test/steps/openapphack/broadcast_steps.groovy +++ /dev/null @@ -1,19 +0,0 @@ -package openapphack - -import static cucumber.api.groovy.EN.And -import static openapphack.stubs.WebServiceStub.primeEndpoint - -And(~'^no prior Broadcast was received$') { -> - broadcastFile.delete() - broadcastIdFile.delete() -} - -And(~'^a new Broadcast "(.*)" with id "(.*)" is available$') { String broadcast, String id -> - primeEndpoint("/broadcast/latest/id", id) - primeEndpoint("/broadcast/latest", broadcast) -} - -And(~'^a prior Broadcast "(.*)" with id "(.*)" was issued$') { String broadcast, String id -> - broadcastIdFile.write id - broadcastFile.write broadcast -} diff --git a/src/test/steps/openapphack/command_line_interop_steps.groovy b/src/test/steps/openapphack/command_line_interop_steps.groovy deleted file mode 100644 index 52c35d7..0000000 --- a/src/test/steps/openapphack/command_line_interop_steps.groovy +++ /dev/null @@ -1,33 +0,0 @@ -package openapphack - -import static cucumber.api.groovy.EN.* - -And(~'^I enter \"([^\"]*)\"$') { String command -> - bash.execute(command) - result = bash.output -} - -And(~'^I enter "([^"]*)" and answer "([^"]*)"$') { String command, String answer -> - bash.execute(command, [answer]) - result = bash.output -} - -And(~'^I see \"([^\"]*)\"$') { String output -> - assert result.contains(output) -} - -And(~'^I do not see "([^"]*)"$') { String output -> - assert ! result.contains(output) -} - -And(~'^I see only \"([^\"]*)\"$') { String output -> - assert result?.replaceAll("\\n", "") == output -} - -And(~'^I see the current openapphack version$') {-> - assert result.contains("OpenAppHack") -} - -And(~'^I see a single occurrence of \"([^\"]*)\"$') { String occurrence -> - assert result.count(occurrence) == 1 -} \ No newline at end of file diff --git a/src/test/steps/openapphack/env.groovy b/src/test/steps/openapphack/env.groovy deleted file mode 100644 index b5a73ab..0000000 --- a/src/test/steps/openapphack/env.groovy +++ /dev/null @@ -1,70 +0,0 @@ -package openapphack - -import com.github.tomakehurst.wiremock.WireMockServer -import com.github.tomakehurst.wiremock.client.WireMock - -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig -import static cucumber.api.groovy.Hooks.After -import static cucumber.api.groovy.Hooks.Before - -HTTP_PROXY = System.getProperty("httpProxy") ?: "" - -FAKE_JDK_PATH = "/path/to/my/openjdk" -SERVICE_UP_HOST="localhost" -SERVICE_UP_PORT=8080 -SERVICE_UP_URL = "http://$SERVICE_UP_HOST:$SERVICE_UP_PORT" -SERVICE_DOWN_URL = "http://localhost:0" - -counter = "${(Math.random() * 10000).toInteger()}".padLeft(4, "0") - -localOpenapphackCandidate = "/tmp/openapphack-core" as File - -openapphackVersion = "x.y.z" -openapphackVersionOutdated = "x.y.y" - -openapphackBaseEnv = "/tmp/app-$counter" -openapphackBaseDir = openapphackBaseEnv as File - -openapphackDirEnv = "$openapphackBaseEnv/.openapphack" -openapphackDir = openapphackDirEnv as File -binDir = "${openapphackDirEnv}/bin" as File -srcDir = "${openapphackDirEnv}/src" as File -varDir = "${openapphackDirEnv}/var" as File -etcDir = "${openapphackDirEnv}/etc" as File -extDir = "${openapphackDirEnv}/ext" as File -vmsDir = "${openapphackDirEnv}/.vms" as File -vmDir = "${openapphackDirEnv}/vm" as File -archiveDir = "${openapphackDirEnv}/archives" as File -tmpDir = "${openapphackDir}/tmp" as File - -broadcastFile = new File(varDir, "broadcast") -broadcastIdFile = new File(varDir, "broadcast_id") -candidatesFile = new File(varDir, "candidates") -versionTokenFile = new File(varDir, "version") -initScript = new File(binDir, "app-init.sh") - -bash = null - -if(!binding.hasVariable("wireMock")) { - wireMock = new WireMockServer(wireMockConfig().port(SERVICE_UP_PORT)) - wireMock.start() - WireMock.configureFor(SERVICE_UP_HOST, SERVICE_UP_PORT) -} - -Before(){ - WireMock.reset() - cleanUp() -} - -private cleanUp(){ - openapphackBaseDir.deleteDir() - localOpenapphackCandidate.deleteDir() -} - -After(){ scenario -> - def output = bash?.output - if (output) { - scenario.write("\nOutput: \n${output}") - } - bash?.stop() -} diff --git a/src/test/steps/openapphack/flush_steps.groovy b/src/test/steps/openapphack/flush_steps.groovy deleted file mode 100644 index 4301ae4..0000000 --- a/src/test/steps/openapphack/flush_steps.groovy +++ /dev/null @@ -1,49 +0,0 @@ -package openapphack - -import static cucumber.api.groovy.EN.* - -And(~'^the candidate "([^"]*)" is known locally$') { String candidate -> - assert candidatesFile.text.contains(candidate) -} - -And(~'^no candidates are know locally$') {-> - assert ! candidatesFile.exists() -} - -And(~'^no broadcast message can be found$') {-> - assert ! (broadcastFile.exists() && broadcastIdFile.exists()) -} - -And(~'^the archive "([^"]*)" has been cached$') { String archive -> - new File(archiveDir, archive).createNewFile() -} - -And(~'^no archives are cached$') {-> - assert ! archiveDir.listFiles() -} - -And(~'^the file "([^"]*)" in temporary storage$') { String fileName -> - new File(tmpDir, fileName).createNewFile() -} - -And(~'^no "([^"]*)" file is present in temporary storage$') { String fileName -> - assert ! new File(tmpDir, fileName).exists() -} - -And(~'^the broadcast has been flushed$') {-> - broadcastIdFile.delete() - broadcastFile.delete() -} - -And(~'^a prior version "([^"]*)" was detected$') { String version -> - assert versionTokenFile.exists() - assert versionTokenFile.text.contains(version) -} - -And(~'^no version token can be found$') {-> - assert ! versionTokenFile.exists() -} - -And(~'^the Remote Version has been flushed$') {-> - assert versionTokenFile.delete() -} \ No newline at end of file diff --git a/src/test/steps/openapphack/initialisation_steps.groovy b/src/test/steps/openapphack/initialisation_steps.groovy deleted file mode 100644 index 2414807..0000000 --- a/src/test/steps/openapphack/initialisation_steps.groovy +++ /dev/null @@ -1,130 +0,0 @@ -package openapphack - -import java.util.zip.ZipException -import java.util.zip.ZipFile - -import static cucumber.api.groovy.EN.* -import static openapphack.stubs.WebServiceStub.primeEndpoint -import static openapphack.stubs.WebServiceStub.primeSelfupdate - -And(~'^the openapphack work folder is created$') { -> - assert openapphackDir.isDirectory(), "The openapphack directory does not exist." -} - -And(~'^the "([^"]*)" folder exists in user home$') { String arg1 -> - assert openapphackDir.isDirectory(), "The openapphack directory does not exist." -} - -And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is corrupt$') { String candidate, String version -> - try { - new ZipFile(new File("src/test/resources/__files/${candidate}-${version}.zip")) - assert false, "Archive was not corrupt!" - - } catch (ZipException ze){ - //expected behaviour - } -} - -And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is removed$') { String candidate, String version -> - def archive = new File("${openapphackDir}/archives/${candidate}-${version}.zip") - assert ! archive.exists() -} - -And(~'^an initialised shell$') { -> - def initScript = "$openapphackDir/bin/app-init.sh" as File - assert initScript.exists() -} - -And(~'^I reinitialise the shell$') { -> - def initScript = "$openapphackDir/bin/app-init.sh" as File - assert initScript.exists() -} - -And(~'^the internet is reachable$') {-> - primeEndpoint("/broadcast/latest/id", "12345") - primeEndpoint("/app/version", openapphackVersion) - primeSelfupdate() - - forcedOffline = false - online = true - serviceUrlEnv = SERVICE_UP_URL - javaHome = FAKE_JDK_PATH -} - -And(~'^the internet is not reachable$') {-> - forcedOffline = false - online = false - serviceUrlEnv = SERVICE_DOWN_URL - javaHome = FAKE_JDK_PATH -} - -And(~'^offline mode is disabled with reachable internet$') {-> - primeEndpoint("/broadcast/latest", "This is a LIVE Broadcast!") - - forcedOffline = false - online = true - serviceUrlEnv = SERVICE_UP_URL - javaHome = FAKE_JDK_PATH -} - -And(~'^offline mode is enabled with reachable internet$') {-> - primeEndpoint("/broadcast/latest/id", "12345") - - forcedOffline = true - online = true - serviceUrlEnv = SERVICE_UP_URL - javaHome = FAKE_JDK_PATH -} - -And(~'^offline mode is enabled with unreachable internet$') {-> - forcedOffline = true - online = false - serviceUrlEnv = SERVICE_DOWN_URL - javaHome = FAKE_JDK_PATH -} - -And(~'^an initialised environment$') {-> - bash = env.OpenAppHackBashEnvBuilder.create(openapphackBaseDir) - .withOnlineMode(online) - .withForcedOfflineMode(forcedOffline) - .withService(serviceUrlEnv) - .withBroadcastService(serviceUrlEnv) - .withJdkHome(javaHome) - .withHttpProxy(HTTP_PROXY) - .withVersionToken(openapphackVersion) - .build() - - bash.start() - bash.execute("source $openapphackDirEnv/bin/app-init.sh") -} - -And(~'^an outdated initialised environment$') {-> - bash = env.OpenAppHackBashEnvBuilder.create(openapphackBaseDir) - .withOnlineMode(online) - .withForcedOfflineMode(forcedOffline) - .withService(serviceUrlEnv) - .withBroadcastService(serviceUrlEnv) - .withJdkHome(javaHome) - .withHttpProxy(HTTP_PROXY) - .withVersionToken(openapphackVersionOutdated) - .build() - - def twoDaysAgoInMillis = System.currentTimeMillis() - 172800000 - - def upgradeToken = "$openapphackDir/var/delay_upgrade" as File - upgradeToken.createNewFile() - upgradeToken.setLastModified(twoDaysAgoInMillis) - - def versionToken = "$openapphackDir/var/version" as File - versionToken.setLastModified(twoDaysAgoInMillis) - - def initFile = "$openapphackDir/bin/app-init.sh" as File - initFile.text = initFile.text.replace(openapphackVersion, openapphackVersionOutdated) - - bash.start() - bash.execute("source $openapphackDirEnv/bin/app-init.sh") -} - -And(~'^the system is bootstrapped$') {-> - bash.execute("source $openapphackDirEnv/bin/app-init.sh") -} diff --git a/src/test/steps/openapphack/installation_steps.groovy b/src/test/steps/openapphack/installation_steps.groovy deleted file mode 100644 index 2c7cc37..0000000 --- a/src/test/steps/openapphack/installation_steps.groovy +++ /dev/null @@ -1,104 +0,0 @@ -package openapphack - -import java.nio.file.FileSystems -import java.nio.file.Files -import java.nio.file.Path - -import static cucumber.api.groovy.EN.And - -And(~'^the candidate "([^"]*)" version "([^"]*)" is installed$') { String candidate, String version -> - def file = "${openapphackDir}/${candidate}/${version}" as File - if (!file.exists()) println bash.output - assert file.exists() -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is not installed$') { String candidate, String version -> - def directory = FileSystems.default.getPath("$openapphackDir/$candidate/$version") - if (Files.exists(directory)) println bash.output - assert ! Files.exists(directory) -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is already installed and default$') { String candidate, String version -> - def candidateVersion = prepareCandidateFolder("$openapphackDir", candidate, version) - def currentLink = FileSystems.default.getPath("$openapphackDir/$candidate/current") - Files.createSymbolicLink currentLink, candidateVersion -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is the default$') { String candidate, String version -> - def localVersion = FileSystems.default.getPath("$openapphackDir/$candidate/$version") - def currentLink = FileSystems.default.getPath("$openapphackDir/$candidate/current") - Files.createSymbolicLink currentLink, localVersion -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is already installed but not default$') { String candidate, String version -> - prepareCandidateFolder "$openapphackDir", candidate, version -} - -And(~'^I do not have a "([^"]*)" candidate installed$') { String candidate -> - def candidateDir = FileSystems.default.getPath("${openapphackDir}/${candidate}") - assert ! candidateDir.toFile().listFiles() -} - -And(~'^the candidate "([^"]*)" does not exist$') { String candidate -> - def candidateDir = "${openapphackDir}/${candidate}" as File - candidateDir.deleteDir() - assert ! candidateDir.exists() -} - -And(~'^I have a local candidate "([^"]*)" version "([^"]*)" at "([^"]*)"$') { String candidate, String version, String directory -> - prepareLocalCandidateFolder directory, candidate, version -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is linked to "([^"]*)"$') { String candidate, String version, String directory -> - def fileSystem = FileSystems.default - - def versionLocation = "$openapphackDir/$candidate/$version" - def versionFolder = fileSystem.getPath(versionLocation) - - assert Files.isSymbolicLink(versionFolder) - - def link = Files.readSymbolicLink(versionFolder).toString() - assert link == directory -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is already linked to "([^"]*)"$') { String candidate, String version, String folder -> - def fileSystem = FileSystems.default - - def candidateFolder = "$openapphackDir/$candidate" as File - candidateFolder.mkdirs() - - def link = fileSystem.getPath("$openapphackDir/$candidate/$version") - def target = prepareLocalCandidateFolder(folder, candidate, version) - - Files.createSymbolicLink(link, target) -} - -And(~'^I have configured "([^"]*)" to "([^"]*)"$') { String configName, String flag -> - def configFile = new File("$openapphackDir/etc/config") - configFile.write "${configName}=${flag}" -} - -private prepareCandidateFolder(String baseDir, String candidate, String version) { - def directory = "$baseDir/$candidate/$version" - prepareCandidateBinFolder directory, candidate, version -} - -private prepareLocalCandidateFolder(String baseDir, String candidate, String version){ - prepareCandidateBinFolder baseDir, candidate, version -} - -private prepareCandidateBinFolder(String folder, String candidate, String version) { - def fileSystem = FileSystems.default - - def binFolderPath = fileSystem.getPath("$folder/bin") - Files.createDirectories binFolderPath - prepareCandidateExecutable binFolderPath, candidate, version - - return fileSystem.getPath("$folder") -} - -private prepareCandidateExecutable(Path binFolder, String candidate, String version) { - def candidateFile = new File("$binFolder/$candidate") - candidateFile.write "echo ${candidate.capitalize()} Version: ${version}" - candidateFile.executable = true -} \ No newline at end of file diff --git a/src/test/steps/openapphack/remote_candidate_steps.groovy b/src/test/steps/openapphack/remote_candidate_steps.groovy deleted file mode 100644 index e69de29..0000000 diff --git a/src/test/steps/openapphack/selfupdate_steps.groovy b/src/test/steps/openapphack/selfupdate_steps.groovy deleted file mode 100644 index 4e90787..0000000 --- a/src/test/steps/openapphack/selfupdate_steps.groovy +++ /dev/null @@ -1,73 +0,0 @@ -package openapphack - -import static cucumber.api.groovy.EN.And - -And(~'^the configuration file has been primed with "([^"]*)"$') { String content -> - def configFile = "$openapphackDir/etc/config" as File - configFile << content -} - -And(~'^the configuration file has not been primed$') { -> - def configFile = "$openapphackDir/etc/config" as File - if (configFile.exists()) { - configFile.delete() - } -} - -And(~'^the configuration file is present$') { -> - def configFile = "$openapphackDir/etc/config" as File - assert configFile.exists() -} - -And(~'^the configuration file contains "([^"]*)"$') { String content -> - def configFile = "$openapphackDir/etc/config" as File - assert configFile.text.contains(content) -} - -And(~'^the configuration file does not contain "([^"]*)"$') { String content -> - def configFile = "$openapphackDir/etc/config" as File - assert !configFile.text.contains(content) -} - -And(~'^a configuration file in the extensions folder$') { -> - def configFile = "$openapphackDir/ext/config" as File - configFile.text = "" -} - -And(~'^the configuration is not present in the extensions folder$') { -> - def configFile = "$openapphackDir/ext/config" as File - assert !configFile.exists() -} - -And(~'^the configuration file is present in the etc folder$') { -> - def configFile = "$openapphackDir/etc/config" as File - assert configFile.exists() -} - -And(~'^the openapphack init script is placed in the bin folder$') { -> - assert new File("$openapphackDir/bin", "app-init.sh").exists() -} - -And(~'^the openapphack module scripts are placed in the src folder$') { -> - assert new File("$openapphackDir/src", "app-common.sh").exists() - assert new File("$openapphackDir/src", "app-main.sh").exists() - assert new File("$openapphackDir/src", "app-broadcast.sh").exists() - assert new File("$openapphackDir/src", "app-current.sh").exists() - assert new File("$openapphackDir/src", "app-default.sh").exists() - assert new File("$openapphackDir/src", "app-install.sh").exists() - assert new File("$openapphackDir/src", "app-list.sh").exists() - assert new File("$openapphackDir/src", "app-selfupdate.sh").exists() - assert new File("$openapphackDir/src", "app-uninstall.sh").exists() - assert new File("$openapphackDir/src", "app-use.sh").exists() - assert new File("$openapphackDir/src", "app-version.sh").exists() - assert new File("$openapphackDir/src", "app-help.sh").exists() -} - -And(~'^the staging folder is cleaned up$') { -> - assert !new File("$openapphackDir/tmp/stage").exists() -} - -And(~'^an empty configuration file$') { -> - def configFile = "$openapphackDir/ext/config" as File - configFile.text = "" -} \ No newline at end of file diff --git a/src/test/steps/openapphack/stub_steps.groovy b/src/test/steps/openapphack/stub_steps.groovy deleted file mode 100644 index b35cf47..0000000 --- a/src/test/steps/openapphack/stub_steps.groovy +++ /dev/null @@ -1,32 +0,0 @@ -import static cucumber.api.groovy.EN.And -import static openapphack.stubs.WebServiceStub.* - -And(~'^the default "([^"]*)" candidate is "([^"]*)"$') { String candidate, String version -> - primeEndpoint("/candidates/${candidate}/default", version) - primeDownloadFor(SERVICE_UP_URL, candidate, version) -} - -And(~'^an available selfupdate$') { -> - primeEndpoint("/selfupdate", 'echo "Successfully upgraded OpenAppHack CLI."') -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download$') { String candidate, String version -> - primeEndpoint("/candidates/${candidate}/${version}", "valid") - primeDownloadFor(SERVICE_UP_URL, candidate, version) -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is not available for download$') { String candidate, String version -> - primeEndpoint("/candidates/${candidate}/${version}", "invalid") -} - -And(~'^a "([^"]*)" list view is available for consumption$') { String candidate -> - primeEndpoint("/candidates/${candidate}/list?platform=Linux¤t=&installed=", "Available ${candidate.capitalize()} Versions") -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is a valid candidate version$') { String candidate, String version -> - primeEndpoint("/candidates/${candidate}/${version}", "valid") -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is not a valid candidate version$') { String candidate, String version -> - primeEndpoint("/candidates/${candidate}/${version}", "invalid") -} \ No newline at end of file diff --git a/src/test/steps/openapphack/use_steps.groovy b/src/test/steps/openapphack/use_steps.groovy deleted file mode 100644 index 218b1bb..0000000 --- a/src/test/steps/openapphack/use_steps.groovy +++ /dev/null @@ -1,45 +0,0 @@ -package openapphack - -import java.nio.file.* - -import static cucumber.api.groovy.EN.* - -And(~'^the candidate "([^"]*)" version "([^"]*)" is in use$') { String candidate, String version -> - def directory = FileSystems.default.getPath("$openapphackDir/$candidate/$version") - def current = FileSystems.default.getPath("$openapphackDir/$candidate/current") - def symlinkFile = current.toFile() - if(!symlinkFile.exists()){ - assert Files.createSymbolicLink(current, directory) - } -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" is not in use$') { String candidate, String version -> - def directory = FileSystems.default.getPath("$openapphackDir/$candidate/$version") - def current = FileSystems.default.getPath("$openapphackDir/$candidate/current") - def symlinkFile = current.toFile() - if(symlinkFile.exists()){ - assert ! Files.isSameFile(current, directory) - } -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" should be in use$') { String candidate, String version -> - bash.execute("$candidate --version") - assert bash.output.contains(version) -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" should be the default$') { String candidate, String version -> - def directory = FileSystems.default.getPath("$openapphackDir/$candidate/$version") - def current = FileSystems.default.getPath("$openapphackDir/$candidate/current") - assert Files.isSameFile(current, directory) -} - -And(~'^the candidate "([^"]*)" version "([^"]*)" should not be the default$') { String candidate, String version -> - def directory = FileSystems.default.getPath("$openapphackDir/$candidate/$version") - def current = FileSystems.default.getPath("$openapphackDir/$candidate/current") - assert (!Files.isSymbolicLink(current) || (Files.isSymbolicLink(current) && !Files.isSameFile(current, directory))) -} - -And(~'^the candidate "([^"]*)" is no longer selected$') { String candidate -> - def symlink = new File("$openapphackDir/$candidate/current") - assert ! symlink.exists() -} diff --git a/test/testapp.sh b/test/testapp.sh new file mode 100755 index 0000000..9dd7340 --- /dev/null +++ b/test/testapp.sh @@ -0,0 +1 @@ +echo ${0%/*/*/*} diff --git a/tools/generators b/tools/generators new file mode 160000 index 0000000..7d81526 --- /dev/null +++ b/tools/generators @@ -0,0 +1 @@ +Subproject commit 7d81526cf38e1bed69aa1334c4f0b4ea84b20b1e