├── .gitignore ├── CHANGELOG.md ├── README.md ├── bin └── mg2-builder ├── build.xml ├── build ├── config │ ├── artifact.excludes │ └── default.properties ├── phpscripts │ ├── Magento │ │ └── EnsureConfiguration.php │ ├── Server │ │ ├── SetServerProperties.php │ │ └── setAvailableServers.php │ ├── Util │ │ ├── CustomHookTask.php │ │ ├── ExecuteTargetTask.php │ │ └── PasswordTask.php │ └── lib │ │ └── SpycLib.php ├── shellscripts │ └── inputpassword.sh └── xmlscripts │ ├── artifact.xml │ ├── database.xml │ ├── install.xml │ ├── magento.xml │ ├── release.xml │ ├── server.xml │ ├── sync.xml │ ├── tests-setup.xml │ ├── update.xml │ └── util.xml ├── composer.json ├── composer.lock ├── config.sample ├── mg2-builder │ ├── build.properties │ ├── magento │ │ ├── config.yaml │ │ ├── env.php.template │ │ └── install-config-mysql.php.template │ ├── server │ │ └── config.yaml │ └── vhost │ │ ├── apache.local.conf │ │ └── nginx.local.conf └── project.properties └── docs └── images └── youtube └── playlist.png /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_STORE 3 | /bin/* 4 | !bin/mg2-builder 5 | /vendor -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) 5 | and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). 6 | 7 | ## [2.1.4] - 13-08-2018 8 | ### Fixed 9 | - Target to set `core_config_data` settings now also works properly on Magento versions `<=2.1` 10 | 11 | ## [2.1.3] - 22-06-2018 12 | 13 | ### Added 14 | - Allow `project.name` provision 15 | 16 | ## [2.1.2] - 22-06-2018 17 | 18 | ### Added 19 | - `magento:install` and `magento:setup:upgrade` are executed in `--no-interaction` mode, when possible. 20 | 21 | ## [2.1] - 8-05-2018 22 | 23 | ### Changed 24 | - `EnsureConfiguration` has been updated to use out of the box magento `config:set` available on versions >=2.2 25 | - `config.yaml` file has a different format now according to previous commented change. See [Sample config.yaml](config.sample/mg2-builder/magento/config.yaml) 26 | 27 | ## [2.0] - 14-12-2017 28 | ### Added 29 | - New `artifact:transfer` to build and transfer artifacts. Uses config propagation features in `Magento >= 2.2` 30 | - New `tests-setup:install` to create integration test DB and settings without the need to install magento. 31 | - New `config/project.properties` to be able to share configurations with [magento2-deployment-tool](https://github.com/staempfli/magento2-deployment-tool) 32 | 33 | ### Changed 34 | - `config/mg2-builder/project.properties` moved to `config/mg2-builder/build.properties` 35 | - Dependency should now be installed in `required` instead of `required-dev`. Needed to be able to use the new `artifact:transfer` feature. 36 | - `release.deploy.server.command` updated to also set `-Dbuild.project.type` option. 37 | 38 | ### Removed 39 | - `config/mg2-builder/project.properties` moved to `config/project.properties` 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magento 2 Builder tool 2 | [![Project Status: Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development.](http://www.repostatus.org/badges/latest/abandoned.svg)](http://www.repostatus.org/#abandoned) 3 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a9fdcbb6b4b542ee992888eda876ad51)](https://www.codacy.com/app/Staempfli/magento2-builder-tool?utm_source=github.com&utm_medium=referral&utm_content=staempfli/magento2-builder-tool&utm_campaign=Badge_Grade) 4 | [![Maintainability](https://api.codeclimate.com/v1/badges/1574c4018d8d90520572/maintainability)](https://codeclimate.com/github/staempfli/magento2-builder-tool/maintainability) 5 | 6 | Tool to automatically build Magento2 projects and sync data from remote servers. 7 | 8 | #### Local environments: 9 | * Set up local environment (DB, config, Server) 10 | * Install project's real data (Sync from Server) 11 | 12 | #### CI / Build Environments: 13 | * Prepare DB and configurations for executing tests. 14 | * Build and transfer artifacts ready to be deployed on a server. 15 | 16 | ## Installation 17 | 18 | ``` 19 | composer require "staempfli/magento2-builder-tool":"~2.0" 20 | ``` 21 | 22 | ## Demo 23 | 24 | 25 | Magento2 Builder Playlist 26 | 27 | 28 | ## Introduction 29 | 30 | `magento2-builder-tool` is a tool to setup local environments for your Magento2 projects by executing one command. No Docker, no Vagrant needed but it is also compatible inside those virtualised setups. Database, Apache/Nginx configuration and everything else are created automatically for each project. You can even use `sync` mode to get server data copied locally. 31 | 32 | This tool is also meant for `CI` or `Build` environments to automate the step of creating the artifact. 33 | 34 | What this tool does for you: 35 | 36 | ### LOCAL Environment 37 | 38 | ``` 39 | 1. Create Magento Database 40 | 2. Create Integration Test Database 41 | 3. Magento Install 42 | 4. Sync Data From Server 43 | 5. Update core_config_data for your environment 44 | 6. setup:upgrade 45 | 7. clean cache 46 | 8. Setup Apache/Nginx configuration 47 | ``` 48 | Only manual step is to edit your `/etc/hosts`. If you want to automate that too, see [DnsMasq on MAC](#dnsMasq-on-mac) 49 | 50 | ### CI / Build Environment 51 | 52 | ``` 53 | - Create DB for integration tests 54 | - Builds and transfer artifact that can be directly deployed on a server 55 | ``` 56 | 57 | ## Setup 58 | 59 | ### Config Folder 60 | 61 | ``` 62 | cp -r /staempfli/magento2-builder-tool/config.sample/ config 63 | ``` 64 | 65 | * Set the project languages and other configuration into `config/project.properties` or `config/mg2-builder/build.properties` 66 | * Set the project custom `core_config_data` on `config/mg2-builder/magento/config.yaml` 67 | * Set the project servers settings on `config/mg2-builder/server/config.yaml` 68 | 69 | **NOTE:** You only need to replace parameters between `<>` with your corresponding values. All other placehoders like `${}` or `{{}}` will be automatically replaced during the tool execution 70 | 71 | ### Create logs folder 72 | 73 | ``` 74 | mkdir logs 75 | vim logs/.gitignore 76 | # Ignore everything in this directory 77 | * 78 | # Except this file 79 | !.gitignore 80 | ``` 81 | 82 | ### Custom Properties 83 | 84 | You can customise all properties according to your needs: 85 | 86 | * Properties added in `config/mg2-builder/build.properties` and `config/project.properties` have higher priority and will overwrite default ones 87 | * Check all properties that can be customised here: 88 | * [build/config/default.properties](build/config/default.properties) 89 | 90 | ## LOCAL Environaments 91 | ### Usage 92 | 93 | * List available targets: 94 | 95 | * `bin/mg2-builder -l` 96 | 97 | * Project install: 98 | 99 | * `bin/mg2-builder install` 100 | 101 | * Sync data from server: 102 | 103 | * `bin/mg2-builder sync` 104 | 105 | ### TIPS 106 | 107 | #### Local settings 108 | 109 | If you do not want to input over and over again the properties required, you can setup your default environment parameters as follows: 110 | 111 | 1. Create folder `_conf` at one level higher than your project root. 112 | 113 | 2. Add a new file `environment.properties` inside that folder. 114 | 115 | 3. Inside this file you can specify your environment properties as follows: 116 | 117 | ``` 118 | project.environment= (usually Local) 119 | database.admin.username= 120 | environment.server.type= (apache, nginx or none) 121 | environment.vhosts.dir= 122 | ``` 123 | 124 | #### SSH without password 125 | 126 | To skip entering the ssh password every time, you can use `ssh-copy-id` to automatically set the public-private keys on the server. 127 | Simply execute: 128 | 129 | ``` 130 | ssh-copy-id user@server-domain 131 | ``` 132 | 133 | #### DnsMasq on MAC 134 | 135 | On `OS X` you can even skip the manual step of editing the `etc/hosts` by using `dnsmasq`. You can configure it to automatically load all `*.dev` or `*.lo` urls (`*.local` does not work). 136 | 137 | * [Never Touch Your Local /etc/hosts File in OS X Again](http://alanthing.com/blog/2012/04/24/never-touch-your-local-etchosts-file-os-x-again/) 138 | 139 | **NOTE**: When adding a new `dnsmasq`, you need to reload the `dnsmasq daemon`: 140 | 141 | ``` 142 | sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist 143 | sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist 144 | ``` 145 | 146 | ## CI / Build Environments 147 | ### Usage 148 | 149 | * Create DB and settings for integration tests: 150 | 151 | * `bin/mg2-builder tests-setup:install` 152 | 153 | * Create and transfer built artifact: 154 | 155 | * `bin/mg2-builder artifact:transfer [-Dartifact.name, -Duse.server.properties]` 156 | 157 | 158 | ## Custom scripts 159 | 160 | If you need additional scripts to build your projects, you can add them here: 161 | 162 | * `config/mg2-builder/xmlscripts/custom.xml` 163 | 164 | You can also define targets that will be automatically executed during the build process. 165 | This tool contains `customHooks` that can be listened to dispatch other targets. 166 | You can set inside `config/mg2-builder/project.properties` the targets to be executed by these hooks: 167 | 168 | ``` 169 | vim config/mg2-builder/xmlscripts/custom.xml 170 | before-magento-install = 171 | after-sync = 172 | after-tests-setup-integration = 173 | after-util-db-clean = 174 | ``` 175 | 176 | ## Disclaimer 177 | 178 | In order to use sync functionalities, `n98-magenrun2` must be available on the remote server. The easiest way is to add it as part as your project dependencies: 179 | 180 | ``` 181 | composer require "n98/magerun2":"^1.4" 182 | ``` 183 | 184 | If you install `n98-magerun2` in your server in another way, be sure to configure the parameter `sync.bin.n98-magerun2` accordingly: 185 | 186 | * [build/config/default.properties#L26](build/config/default.properties#L26) 187 | 188 | ## Troubleshooting 189 | 190 | #### Set null config values on magento version 2.2.x 191 | 192 | * **Problem**: [PR #15216](https://github.com/magento/magento2/pull/15216) 193 | * **Solution**: Apply patch directly in your project using composer 194 | 195 | ``` 196 | "require": { 197 | "cweagans/composer-patches": "^1.0" 198 | }, 199 | "extra": { 200 | "patches": { 201 | "magento/module-config": { 202 | "Make possible to set null values using config:set command": "https://stash.staempfli.com/projects/MAG/repos/magento2-patches/raw/patches/2.2.x/config-set-null-value/version-2.2.0.patch" 203 | } 204 | }, 205 | "composer-exit-on-patch-failure": true 206 | } 207 | ``` 208 | **NOTE**: use `version-2.2.0.patch` for magento `>=2.2.0 <=2.2.3` and `version-2.2.4.patch` for magento `>=2.2.4` 209 | 210 | #### MySQL server has gone away 211 | 212 | * **Problem**: `MySQL` crashes sometime when creating, importing or updating the Magento database. 213 | 214 | * **Solution**: Add following configuration in your `.my.cnf` 215 | * Gist: [.my.conf](https://gist.github.com/jalogut/f507f13b27f7a63d936edd58fad5e121) 216 | 217 | * **How to restart mysql**: Kill MySQL process, start MySQL and try again: 218 | 219 | 1. `killall -9 mysqld` 220 | 2. `mysql.server start` or `mysql.server restart` 221 | 3. Try again: `mg2-builder install` 222 | 223 | ## Prerequisites 224 | 225 | - PHP >= 7.0.* 226 | - Mysql >= 5.7.* 227 | 228 | ## ChangeLog 229 | 230 | [CHANGELOG.md](CHANGELOG.md) 231 | 232 | ## Developers 233 | 234 | * [Juan Alonso](https://github.com/jalogut) 235 | 236 | Licence 237 | ------- 238 | [GNU General Public License, version 3 (GPLv3)](http://opensource.org/licenses/gpl-3.0) 239 | 240 | Copyright 241 | --------- 242 | (c) 2017 Staempfli AG 243 | -------------------------------------------------------------------------------- /bin/mg2-builder: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCE="${BASH_SOURCE[0]}" 4 | while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink 5 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 6 | SOURCE="$(readlink "$SOURCE")" 7 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located 8 | done 9 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )/../" 10 | 11 | $DIR/../../phing/phing/bin/phing -f $DIR/build.xml "$@" 12 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /build/config/artifact.excludes: -------------------------------------------------------------------------------- 1 | cache 2 | page_cache 3 | _cache 4 | pub/media 5 | env.php 6 | tests 7 | Test 8 | Tests 9 | var/log 10 | logs 11 | magento2-builder-tool 12 | bin/mg2-builder 13 | .git 14 | .gitattributes 15 | .gitignore 16 | .gitmodules -------------------------------------------------------------------------------- /build/config/default.properties: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------ 2 | # General Project Information 3 | #------------------------------------------------------------------------------------------ 4 | magento.dir=magento 5 | logs.dir=logs 6 | project.environment.valid=local,igr 7 | project.environment.install.alowed=local 8 | 9 | #------------------------------------------------------------------------------------------ 10 | # Configuration Files 11 | #------------------------------------------------------------------------------------------ 12 | magento.config.filename=config/mg2-builder/magento/config.yaml 13 | servers.config.filename=config/mg2-builder/servers/config.yaml 14 | template.envphp=config/mg2-builder/magento/env.php.template 15 | template.integration.mysql=config/mg2-builder/magento/install-config-mysql.php.template 16 | template.apache.local=config/mg2-builder/vhost/apache.local.conf 17 | template.nginx.local=config/mg2-builder/vhost/nginx.local.conf 18 | env.install.date.config='install' => array ('date' => '${build.timestamp}',), 19 | 20 | #------------------------------------------------------------------------------------------ 21 | # Binaries Settings 22 | #------------------------------------------------------------------------------------------ 23 | bin.n98-magerun2=${phing.dir}/../../n98/magerun2/bin/n98-magerun2 --root-dir=${magento.dir} 24 | bin.magento=${magento.dir}/bin/magento 25 | 26 | #------------------------------------------------------------------------------------------ 27 | # Sync Settings 28 | #------------------------------------------------------------------------------------------ 29 | sync.bin.n98-magerun2=bin/n98-magerun2 --root-dir=${magento.dir} 30 | sync.dump.filename=${project.name}_${remote.environment}_latest.sql.gz 31 | # strip tables for database sync (https://github.com/netz98/n98-magerun/wiki/Stripped-Database-Dumps) 32 | sync.dump.strips=@stripped 33 | sync.media.dir=${magento.dir}/pub/media 34 | sync.media.excludes=--exclude='cache' --exclude='js' --exclude='css' --exclude='tmp' 35 | 36 | #------------------------------------------------------------------------------------------ 37 | # Database Settings 38 | #------------------------------------------------------------------------------------------ 39 | database.host=localhost 40 | database.connection.type=default 41 | setup.upgrade.keep.generated=1 42 | 43 | #------------------------------------------------------------------------------------------ 44 | # Installation Settings 45 | #------------------------------------------------------------------------------------------ 46 | magento.admin.frontname=admin 47 | install.admin.username=admin 48 | install.admin.firstname=admin 49 | install.admin.lastname=default 50 | install.admin.password=staempfli2017 51 | install.admin.email=magento@staempfli.com 52 | install.locale=en_US 53 | install.currency=CHF 54 | install.timezone=Europe/Zurich 55 | magento.setup.install.extra.params= 56 | 57 | #------------------------------------------------------------------------------------------ 58 | # Release Settings 59 | #------------------------------------------------------------------------------------------ 60 | deploy.build.type=default 61 | release.deploy.server.command=mg2-deployer release -Drelease.version=${release.version} -Dbuild.project.type=${deploy.build.type} 62 | 63 | #------------------------------------------------------------------------------------------ 64 | # Artifact Settings 65 | #------------------------------------------------------------------------------------------ 66 | artifact.dir=/tmp 67 | artifact.remote.transfer.dir=tmp-downloads 68 | 69 | command.artifact.build=composer install --no-dev --prefer-dist --optimize-autoloader 70 | artifact.excludesfile=${phing.dir}/build/config/artifact.excludes 71 | command.artifact.package=tar --exclude-from=${artifact.excludesfile} -czf ${artifact.filename} . 72 | command.artifact.transfer=scp -P ${server.ssh.port} ${artifact.filename} ${server.ssh.deployUsername}@${server.ssh.host}:${artifact.remote.transfer.dir} 73 | 74 | #------------------------------------------------------------------------------------------ 75 | # Magento File Generation Settings 76 | #------------------------------------------------------------------------------------------ 77 | # Space-separated list of modules to disable during release 78 | module.disable.list= 79 | 80 | # Space-separated list of languages 81 | static-content.languages=en_US 82 | 83 | command.static-content.deploy.options=--exclude-theme=Magento/blank 84 | command.permissions=find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; && find var vendor pub/static pub/media app/etc -type d -exec chmod g+w {} \; && chmod u+x bin/magento 85 | 86 | -------------------------------------------------------------------------------- /build/phpscripts/Magento/EnsureConfiguration.php: -------------------------------------------------------------------------------- 1 | getProject()->getProperty('magento.config.filename'); 24 | $environment = strtoupper($this->getProject()->getProperty('project.environment')); 25 | 26 | if (!$environment) { 27 | throw new BuildException("Environment is not defined"); 28 | } 29 | 30 | $allConfig = SpycLib::YAMLLoad($configFilename); 31 | if (!isset($allConfig[$environment])) { 32 | throw new BuildException(sprintf('No core config data defined for environment: %s', $environment)); 33 | } 34 | 35 | $config = $allConfig[$environment]; 36 | $this->setConfigValues($config); 37 | } 38 | 39 | /** 40 | * Set Core Config Values 41 | * - Format array: array(path => array(scope => array(scope_id => value))) 42 | * 43 | * @param array $config 44 | * @throws BuildException 45 | */ 46 | private function setConfigValues(array $config) 47 | { 48 | foreach ($config as $path => $pathData) { 49 | foreach ($pathData as $scope => $scopeData) { 50 | if ('default' == $scope) { 51 | $this->executeConfigSetCommand($path, $scopeData); 52 | continue; 53 | } 54 | foreach ($scopeData as $scopeCode => $value) { 55 | $this->executeConfigSetCommand($path, $value, $scope, $scopeCode); 56 | } 57 | } 58 | } 59 | } 60 | 61 | /** 62 | * @SuppressWarnings(PHPMD.UnusedLocalVariable) 63 | */ 64 | private function executeConfigSetCommand($path, $value, $scope = false, $scopeCode = false) 65 | { 66 | $value = $this->getProject()->replaceProperties($value); 67 | $command = $this->getConfigSetCommand($path, $value); 68 | if ($scope && $scopeCode) { 69 | $command = $command . " " . $this->getConfigSetScopeParams($scope, $scopeCode); 70 | } 71 | $this->log($command, Project::MSG_INFO); 72 | exec($command, $output, $return); 73 | if ($return) { 74 | $message = sprintf('Error executing command: %s', $command); 75 | $this->log($message, Project::MSG_ERR); 76 | throw new BuildException($message); 77 | } 78 | } 79 | 80 | private function getConfigSetCommand($path, $value) 81 | { 82 | if ($this->isMagentoConfigSetAvailable()) { 83 | $magentoBin = $this->getProject()->getProperty('bin.magento'); 84 | return "{$magentoBin} config:set --lock {$path} {$value}"; 85 | } 86 | $magerunBin = $this->getProject()->getProperty('bin.n98-magerun2'); 87 | return "{$magerunBin} config:set {$path} {$value}"; 88 | } 89 | 90 | private function getConfigSetScopeParams($scope, $scopeCode) 91 | { 92 | if ($this->isMagentoConfigSetAvailable()) { 93 | return "--scope={$scope} --scope-code={$scopeCode}"; 94 | } 95 | return "--scope={$scope} --scope-id={$scopeCode}"; 96 | } 97 | 98 | /** 99 | * @SuppressWarnings(PHPMD.UnusedLocalVariable) 100 | */ 101 | private function isMagentoConfigSetAvailable(): bool 102 | { 103 | if (null === $this->magentoConfigSetCommandAvailable) { 104 | $magentoBin = $this->getProject()->getProperty('bin.magento'); 105 | exec("{$magentoBin} config:set --help 2> /dev/null", $output, $return); 106 | $this->magentoConfigSetCommandAvailable = ($return) ? false : true; 107 | } 108 | return $this->magentoConfigSetCommandAvailable; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /build/phpscripts/Server/SetServerProperties.php: -------------------------------------------------------------------------------- 1 | getProject()->getProperty('servers.config.filename'); 22 | $remoteEnvironment = strtoupper($this->getProject()->getProperty('remote.environment')); 23 | 24 | if (!$remoteEnvironment) { 25 | throw new BuildException("Remote Environment is not defined"); 26 | } 27 | 28 | $serversConfig = SpycLib::YAMLLoad($configFilename); 29 | if (!isset($serversConfig[$remoteEnvironment])) { 30 | throw new BuildException(sprintf('Not ssh configuration defined for server: %s', $remoteEnvironment)); 31 | } 32 | 33 | $config = $serversConfig[$remoteEnvironment]; 34 | foreach ($config as $param => $value) { 35 | $this->getProject()->setNewProperty('server.ssh.' . $param, $value); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /build/phpscripts/Server/setAvailableServers.php: -------------------------------------------------------------------------------- 1 | getProject()->getProperty('servers.config.filename'); 22 | 23 | if (file_exists($configFilename)) { 24 | $serversConfig = SpycLib::YAMLLoad($configFilename); 25 | if (count($serversConfig) > 0) { 26 | $availableServers = implode(',', array_keys($serversConfig)); 27 | $this->getProject()->setProperty('servers.available', strtolower($availableServers)); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /build/phpscripts/Util/CustomHookTask.php: -------------------------------------------------------------------------------- 1 | _hook = $hook; 20 | } 21 | 22 | /** 23 | * Main 24 | */ 25 | public function main() 26 | { 27 | $callbacks = explode(',', $this->getProject()->getProperty($this->_hook)); 28 | 29 | foreach ($callbacks as $callback) { 30 | if ($callback) { 31 | try { 32 | $message = sprintf('Executing target %s from %s', $callback, $this->_hook); 33 | $this->log($message); 34 | $this->getProject()->executeTarget($callback); 35 | } catch (BuildException $ex) { 36 | $message = sprintf( 37 | 'Failed to execute target %s as called in %s. Reason: %s', $callback, $this->_hook, 38 | $ex->getMessage() 39 | ); 40 | $this->log($message, Project::MSG_ERR); 41 | } 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /build/phpscripts/Util/ExecuteTargetTask.php: -------------------------------------------------------------------------------- 1 | target = $target; 26 | } 27 | 28 | /** 29 | * Main 30 | */ 31 | public function main() 32 | { 33 | $message = sprintf('Executing target %s', $this->target); 34 | $this->log($message); 35 | $this->getProject()->executeTarget($this->target); 36 | } 37 | } -------------------------------------------------------------------------------- /build/phpscripts/Util/PasswordTask.php: -------------------------------------------------------------------------------- 1 | _passwordLength = $passwordLength; 25 | } 26 | 27 | /** 28 | * @param string $outputPropertyName 29 | */ 30 | public function setOutputPropertyName($outputPropertyName) 31 | { 32 | $this->_outputPropertyName = $outputPropertyName; 33 | } 34 | 35 | public function init() 36 | { 37 | if (!$this->_passwordLength) { 38 | $this->_passwordLength = 12; 39 | } 40 | } 41 | 42 | public function main() 43 | { 44 | $this->getProject()->setProperty( 45 | $this->_outputPropertyName, 46 | $this->_generateRandomPassword($this->_passwordLength)); 47 | } 48 | 49 | /** 50 | * generates a random password to be used as database password etc. 51 | * 52 | * @param int desired length of password (default 16) 53 | * 54 | * @return string 55 | */ 56 | protected function _generateRandomPassword($length = 0) 57 | { 58 | $validChars = '0123456789abcdefghijklmnopqrstuvwABCDEFGHIJKLMNOPQRSTUVW'; 59 | $i = 0; 60 | $password = ''; 61 | 62 | while ($i < $length) { 63 | $num = mt_rand() % strlen($validChars); 64 | $password .= substr($validChars, $num, 1); 65 | $i++; 66 | } 67 | 68 | return $password; 69 | } 70 | } -------------------------------------------------------------------------------- /build/phpscripts/lib/SpycLib.php: -------------------------------------------------------------------------------- 1 | 6 | * @author Chris Wanstrath 7 | * @link http://code.google.com/p/spyc/ 8 | * @copyright Copyright 2005-2006 Chris Wanstrath, 2006-2011 Vlad Andersen 9 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 10 | * @package SpycLib 11 | */ 12 | 13 | if (!function_exists('spyc_load')) { 14 | /** 15 | * Parses YAML to array. 16 | * @param string $string YAML string. 17 | * @return array 18 | */ 19 | function spyc_load ($string) { 20 | return SpycLib::YAMLLoadString($string); 21 | } 22 | } 23 | 24 | if (!function_exists('spyc_load_file')) { 25 | /** 26 | * Parses YAML to array. 27 | * @param string $file Path to YAML file. 28 | * @return array 29 | */ 30 | function spyc_load_file ($file) { 31 | return SpycLib::YAMLLoad($file); 32 | } 33 | } 34 | 35 | if (!function_exists('spyc_dump')) { 36 | /** 37 | * Dumps array to YAML. 38 | * @param array $data Array. 39 | * @return string 40 | */ 41 | function spyc_dump ($data) { 42 | return SpycLib::YAMLDump($data, false, false, true); 43 | } 44 | } 45 | 46 | /** 47 | * The Simple PHP YAML Class. 48 | * 49 | * This class can be used to read a YAML file and convert its contents 50 | * into a PHP array. It currently supports a very limited subsection of 51 | * the YAML spec. 52 | * 53 | * Usage: 54 | * 55 | * $SpycLib = new SpycLib; 56 | * $array = $SpycLib->load($file); 57 | * 58 | * or: 59 | * 60 | * $array = SpycLib::YAMLLoad($file); 61 | * 62 | * or: 63 | * 64 | * $array = spyc_load_file($file); 65 | * 66 | * @package SpycLib 67 | */ 68 | class SpycLib { 69 | 70 | // SETTINGS 71 | 72 | const REMPTY = "\0\0\0\0\0"; 73 | 74 | /** 75 | * Setting this to true will force YAMLDump to enclose any string value in 76 | * quotes. False by default. 77 | * 78 | * @var bool 79 | */ 80 | public $setting_dump_force_quotes = false; 81 | 82 | /** 83 | * Setting this to true will forse YAMLLoad to use syck_load function when 84 | * possible. False by default. 85 | * @var bool 86 | */ 87 | public $setting_use_syck_is_possible = false; 88 | 89 | 90 | 91 | /**#@+ 92 | * @access private 93 | * @var mixed 94 | */ 95 | private $_dumpIndent; 96 | private $_dumpWordWrap; 97 | private $_containsGroupAnchor = false; 98 | private $_containsGroupAlias = false; 99 | private $path; 100 | private $result; 101 | private $LiteralPlaceHolder = '___YAML_Literal_Block___'; 102 | private $SavedGroups = array(); 103 | private $indent; 104 | /** 105 | * Path modifier that should be applied after adding current element. 106 | * @var array 107 | */ 108 | private $delayedPath = array(); 109 | 110 | /**#@+ 111 | * @access public 112 | * @var mixed 113 | */ 114 | public $_nodeId; 115 | 116 | /** 117 | * Load a valid YAML string to SpycLib. 118 | * @param string $input 119 | * @return array 120 | */ 121 | public function load ($input) { 122 | return $this->__loadString($input); 123 | } 124 | 125 | /** 126 | * Load a valid YAML file to SpycLib. 127 | * @param string $file 128 | * @return array 129 | */ 130 | public function loadFile ($file) { 131 | return $this->__load($file); 132 | } 133 | 134 | /** 135 | * Load YAML into a PHP array statically 136 | * 137 | * The load method, when supplied with a YAML stream (string or file), 138 | * will do its best to convert YAML in a file into a PHP array. Pretty 139 | * simple. 140 | * Usage: 141 | * 142 | * $array = SpycLib::YAMLLoad('lucky.yaml'); 143 | * print_r($array); 144 | * 145 | * @access public 146 | * @return array 147 | * @param string $input Path of YAML file or string containing YAML 148 | */ 149 | public static function YAMLLoad($input) { 150 | $Spyc = new SpycLib; 151 | return $Spyc->__load($input); 152 | } 153 | 154 | /** 155 | * Load a string of YAML into a PHP array statically 156 | * 157 | * The load method, when supplied with a YAML string, will do its best 158 | * to convert YAML in a string into a PHP array. Pretty simple. 159 | * 160 | * Note: use this function if you don't want files from the file system 161 | * loaded and processed as YAML. This is of interest to people concerned 162 | * about security whose input is from a string. 163 | * 164 | * Usage: 165 | * 166 | * $array = SpycLib::YAMLLoadString("---\n0: hello world\n"); 167 | * print_r($array); 168 | * 169 | * @access public 170 | * @return array 171 | * @param string $input String containing YAML 172 | */ 173 | public static function YAMLLoadString($input) { 174 | $Spyc = new SpycLib; 175 | return $Spyc->__loadString($input); 176 | } 177 | 178 | /** 179 | * Dump YAML from PHP array statically 180 | * 181 | * The dump method, when supplied with an array, will do its best 182 | * to convert the array into friendly YAML. Pretty simple. Feel free to 183 | * save the returned string as nothing.yaml and pass it around. 184 | * 185 | * Oh, and you can decide how big the indent is and what the wordwrap 186 | * for folding is. Pretty cool -- just pass in 'false' for either if 187 | * you want to use the default. 188 | * 189 | * Indent's default is 2 spaces, wordwrap's default is 40 characters. And 190 | * you can turn off wordwrap by passing in 0. 191 | * 192 | * @access public 193 | * @return string 194 | * @param array $array PHP array 195 | * @param int $indent Pass in false to use the default, which is 2 196 | * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) 197 | * @param int $no_opening_dashes Do not start YAML file with "---\n" 198 | */ 199 | public static function YAMLDump($array, $indent = false, $wordwrap = false, $no_opening_dashes = false) { 200 | $spyc = new SpycLib; 201 | return $spyc->dump($array, $indent, $wordwrap, $no_opening_dashes); 202 | } 203 | 204 | 205 | /** 206 | * Dump PHP array to YAML 207 | * 208 | * The dump method, when supplied with an array, will do its best 209 | * to convert the array into friendly YAML. Pretty simple. Feel free to 210 | * save the returned string as tasteful.yaml and pass it around. 211 | * 212 | * Oh, and you can decide how big the indent is and what the wordwrap 213 | * for folding is. Pretty cool -- just pass in 'false' for either if 214 | * you want to use the default. 215 | * 216 | * Indent's default is 2 spaces, wordwrap's default is 40 characters. And 217 | * you can turn off wordwrap by passing in 0. 218 | * 219 | * @access public 220 | * @return string 221 | * @param array $array PHP array 222 | * @param int $indent Pass in false to use the default, which is 2 223 | * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) 224 | */ 225 | public function dump($array,$indent = false,$wordwrap = false, $no_opening_dashes = false) { 226 | // Dumps to some very clean YAML. We'll have to add some more features 227 | // and options soon. And better support for folding. 228 | 229 | // New features and options. 230 | if ($indent === false or !is_numeric($indent)) { 231 | $this->_dumpIndent = 2; 232 | } else { 233 | $this->_dumpIndent = $indent; 234 | } 235 | 236 | if ($wordwrap === false or !is_numeric($wordwrap)) { 237 | $this->_dumpWordWrap = 40; 238 | } else { 239 | $this->_dumpWordWrap = $wordwrap; 240 | } 241 | 242 | // New YAML document 243 | $string = ""; 244 | if (!$no_opening_dashes) $string = "---\n"; 245 | 246 | // Start at the base of the array and move through it. 247 | if ($array) { 248 | $array = (array)$array; 249 | $previous_key = -1; 250 | foreach ($array as $key => $value) { 251 | if (!isset($first_key)) $first_key = $key; 252 | $string .= $this->_yamlize($key,$value,0,$previous_key, $first_key, $array); 253 | $previous_key = $key; 254 | } 255 | } 256 | return $string; 257 | } 258 | 259 | /** 260 | * Attempts to convert a key / value array item to YAML 261 | * @access private 262 | * @return string 263 | * @param $key The name of the key 264 | * @param $value The value of the item 265 | * @param $indent The indent of the current node 266 | */ 267 | private function _yamlize($key,$value,$indent, $previous_key = -1, $first_key = 0, $source_array = null) { 268 | if (is_array($value)) { 269 | if (empty ($value)) 270 | return $this->_dumpNode($key, array(), $indent, $previous_key, $first_key, $source_array); 271 | // It has children. What to do? 272 | // Make it the right kind of item 273 | $string = $this->_dumpNode($key, self::REMPTY, $indent, $previous_key, $first_key, $source_array); 274 | // Add the indent 275 | $indent += $this->_dumpIndent; 276 | // Yamlize the array 277 | $string .= $this->_yamlizeArray($value,$indent); 278 | } elseif (!is_array($value)) { 279 | // It doesn't have children. Yip. 280 | $string = $this->_dumpNode($key, $value, $indent, $previous_key, $first_key, $source_array); 281 | } 282 | return $string; 283 | } 284 | 285 | /** 286 | * Attempts to convert an array to YAML 287 | * @access private 288 | * @return string 289 | * @param $array The array you want to convert 290 | * @param $indent The indent of the current level 291 | */ 292 | private function _yamlizeArray($array,$indent) { 293 | if (is_array($array)) { 294 | $string = ''; 295 | $previous_key = -1; 296 | foreach ($array as $key => $value) { 297 | if (!isset($first_key)) $first_key = $key; 298 | $string .= $this->_yamlize($key, $value, $indent, $previous_key, $first_key, $array); 299 | $previous_key = $key; 300 | } 301 | return $string; 302 | } else { 303 | return false; 304 | } 305 | } 306 | 307 | /** 308 | * Returns YAML from a key and a value 309 | * @access private 310 | * @return string 311 | * @param $key The name of the key 312 | * @param $value The value of the item 313 | * @param $indent The indent of the current node 314 | */ 315 | private function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key = 0, $source_array = null) { 316 | // do some folding here, for blocks 317 | if (is_string ($value) && ((strpos($value,"\n") !== false || strpos($value,": ") !== false || strpos($value,"- ") !== false || 318 | strpos($value,"*") !== false || strpos($value,"#") !== false || strpos($value,"<") !== false || strpos($value,">") !== false || strpos ($value, ' ') !== false || 319 | strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || strpos($value,"&") !== false || strpos($value, "'") !== false || strpos($value, "!") === 0 || 320 | substr ($value, -1, 1) == ':') 321 | ) { 322 | $value = $this->_doLiteralBlock($value,$indent); 323 | } else { 324 | $value = $this->_doFolding($value,$indent); 325 | } 326 | 327 | if ($value === array()) $value = '[ ]'; 328 | if ($value === "") $value = '""'; 329 | if (self::isTranslationWord($value)) { 330 | $value = $this->_doLiteralBlock($value, $indent); 331 | } 332 | if (trim ($value) != $value) 333 | $value = $this->_doLiteralBlock($value,$indent); 334 | 335 | if (is_bool($value)) { 336 | $value = $value ? "true" : "false"; 337 | } 338 | 339 | if ($value === null) $value = 'null'; 340 | if ($value === "'" . self::REMPTY . "'") $value = null; 341 | 342 | $spaces = str_repeat(' ',$indent); 343 | 344 | //if (is_int($key) && $key - 1 == $previous_key && $first_key===0) { 345 | if (is_array ($source_array) && array_keys($source_array) === range(0, count($source_array) - 1)) { 346 | // It's a sequence 347 | $string = $spaces.'- '.$value."\n"; 348 | } else { 349 | // if ($first_key===0) throw new Exception('Keys are all screwy. The first one was zero, now it\'s "'. $key .'"'); 350 | // It's mapped 351 | if (strpos($key, ":") !== false || strpos($key, "#") !== false) { $key = '"' . $key . '"'; } 352 | $string = rtrim ($spaces.$key.': '.$value)."\n"; 353 | } 354 | return $string; 355 | } 356 | 357 | /** 358 | * Creates a literal block for dumping 359 | * @access private 360 | * @return string 361 | * @param $value 362 | * @param $indent int The value of the indent 363 | */ 364 | private function _doLiteralBlock($value,$indent) { 365 | if ($value === "\n") return '\n'; 366 | if (strpos($value, "\n") === false && strpos($value, "'") === false) { 367 | return sprintf ("'%s'", $value); 368 | } 369 | if (strpos($value, "\n") === false && strpos($value, '"') === false) { 370 | return sprintf ('"%s"', $value); 371 | } 372 | $exploded = explode("\n",$value); 373 | $newValue = '|'; 374 | $indent += $this->_dumpIndent; 375 | $spaces = str_repeat(' ',$indent); 376 | foreach ($exploded as $line) { 377 | $newValue .= "\n" . $spaces . ($line); 378 | } 379 | return $newValue; 380 | } 381 | 382 | /** 383 | * Folds a string of text, if necessary 384 | * @access private 385 | * @return string 386 | * @param $value The string you wish to fold 387 | */ 388 | private function _doFolding($value,$indent) { 389 | // Don't do anything if wordwrap is set to 0 390 | 391 | if ($this->_dumpWordWrap !== 0 && is_string ($value) && strlen($value) > $this->_dumpWordWrap) { 392 | $indent += $this->_dumpIndent; 393 | $indent = str_repeat(' ',$indent); 394 | $wrapped = wordwrap($value,$this->_dumpWordWrap,"\n$indent"); 395 | $value = ">\n".$indent.$wrapped; 396 | } else { 397 | if ($this->setting_dump_force_quotes && is_string ($value) && $value !== self::REMPTY) 398 | $value = '"' . $value . '"'; 399 | if (is_numeric($value) && is_string($value)) 400 | $value = '"' . $value . '"'; 401 | } 402 | 403 | 404 | return $value; 405 | } 406 | 407 | private function isTrueWord($value) { 408 | $words = self::getTranslations(array('true', 'on', 'yes', 'y')); 409 | return in_array($value, $words, true); 410 | } 411 | 412 | private function isFalseWord($value) { 413 | $words = self::getTranslations(array('false', 'off', 'no', 'n')); 414 | return in_array($value, $words, true); 415 | } 416 | 417 | private function isNullWord($value) { 418 | $words = self::getTranslations(array('null', '~')); 419 | return in_array($value, $words, true); 420 | } 421 | 422 | private function isTranslationWord($value) { 423 | return ( 424 | self::isTrueWord($value) || 425 | self::isFalseWord($value) || 426 | self::isNullWord($value) 427 | ); 428 | } 429 | 430 | /** 431 | * Coerce a string into a native type 432 | * Reference: http://yaml.org/type/bool.html 433 | * TODO: Use only words from the YAML spec. 434 | * @access private 435 | * @param $value The value to coerce 436 | */ 437 | private function coerceValue(&$value) { 438 | if (self::isTrueWord($value)) { 439 | $value = true; 440 | } else if (self::isFalseWord($value)) { 441 | $value = false; 442 | } else if (self::isNullWord($value)) { 443 | $value = null; 444 | } 445 | } 446 | 447 | /** 448 | * Given a set of words, perform the appropriate translations on them to 449 | * match the YAML 1.1 specification for type coercing. 450 | * @param $words The words to translate 451 | * @access private 452 | */ 453 | private static function getTranslations(array $words) { 454 | $result = array(); 455 | foreach ($words as $i) { 456 | $result = array_merge($result, array(ucfirst($i), strtoupper($i), strtolower($i))); 457 | } 458 | return $result; 459 | } 460 | 461 | // LOADING FUNCTIONS 462 | 463 | private function __load($input) { 464 | $Source = $this->loadFromSource($input); 465 | return $this->loadWithSource($Source); 466 | } 467 | 468 | private function __loadString($input) { 469 | $Source = $this->loadFromString($input); 470 | return $this->loadWithSource($Source); 471 | } 472 | 473 | private function loadWithSource($Source) { 474 | if (empty ($Source)) return array(); 475 | if ($this->setting_use_syck_is_possible && function_exists ('syck_load')) { 476 | $array = syck_load (implode ("\n", $Source)); 477 | return is_array($array) ? $array : array(); 478 | } 479 | 480 | $this->path = array(); 481 | $this->result = array(); 482 | 483 | $cnt = count($Source); 484 | for ($i = 0; $i < $cnt; $i++) { 485 | $line = $Source[$i]; 486 | 487 | $this->indent = strlen($line) - strlen(ltrim($line)); 488 | $tempPath = $this->getParentPathByIndent($this->indent); 489 | $line = self::stripIndent($line, $this->indent); 490 | if (self::isComment($line)) continue; 491 | if (self::isEmpty($line)) continue; 492 | $this->path = $tempPath; 493 | 494 | $literalBlockStyle = self::startsLiteralBlock($line); 495 | if ($literalBlockStyle) { 496 | $line = rtrim ($line, $literalBlockStyle . " \n"); 497 | $literalBlock = ''; 498 | $line .= ' '.$this->LiteralPlaceHolder; 499 | $literal_block_indent = strlen($Source[$i+1]) - strlen(ltrim($Source[$i+1])); 500 | while (++$i < $cnt && $this->literalBlockContinues($Source[$i], $this->indent)) { 501 | $literalBlock = $this->addLiteralLine($literalBlock, $Source[$i], $literalBlockStyle, $literal_block_indent); 502 | } 503 | $i--; 504 | } 505 | 506 | // Strip out comments 507 | if (strpos ($line, '#')) { 508 | $line = preg_replace('/\s*#([^"\']+)$/','',$line); 509 | } 510 | 511 | while (++$i < $cnt && self::greedilyNeedNextLine($line)) { 512 | $line = rtrim ($line, " \n\t\r") . ' ' . ltrim ($Source[$i], " \t"); 513 | } 514 | $i--; 515 | 516 | $lineArray = $this->_parseLine($line); 517 | 518 | if ($literalBlockStyle) 519 | $lineArray = $this->revertLiteralPlaceHolder ($lineArray, $literalBlock); 520 | 521 | $this->addArray($lineArray, $this->indent); 522 | 523 | foreach ($this->delayedPath as $indent => $delayedPath) 524 | $this->path[$indent] = $delayedPath; 525 | 526 | $this->delayedPath = array(); 527 | 528 | } 529 | return $this->result; 530 | } 531 | 532 | private function loadFromSource ($input) { 533 | if (!empty($input) && strpos($input, "\n") === false && file_exists($input)) 534 | $input = file_get_contents($input); 535 | 536 | return $this->loadFromString($input); 537 | } 538 | 539 | private function loadFromString ($input) { 540 | $lines = explode("\n",$input); 541 | foreach ($lines as $k => $_) { 542 | $lines[$k] = rtrim ($_, "\r"); 543 | } 544 | return $lines; 545 | } 546 | 547 | /** 548 | * Parses YAML code and returns an array for a node 549 | * @access private 550 | * @return array 551 | * @param string $line A line from the YAML file 552 | */ 553 | private function _parseLine($line) { 554 | if (!$line) return array(); 555 | $line = trim($line); 556 | if (!$line) return array(); 557 | 558 | $array = array(); 559 | 560 | $group = $this->nodeContainsGroup($line); 561 | if ($group) { 562 | $this->addGroup($line, $group); 563 | $line = $this->stripGroup ($line, $group); 564 | } 565 | 566 | if ($this->startsMappedSequence($line)) 567 | return $this->returnMappedSequence($line); 568 | 569 | if ($this->startsMappedValue($line)) 570 | return $this->returnMappedValue($line); 571 | 572 | if ($this->isArrayElement($line)) 573 | return $this->returnArrayElement($line); 574 | 575 | if ($this->isPlainArray($line)) 576 | return $this->returnPlainArray($line); 577 | 578 | 579 | return $this->returnKeyValuePair($line); 580 | 581 | } 582 | 583 | /** 584 | * Finds the type of the passed value, returns the value as the new type. 585 | * @access private 586 | * @param string $value 587 | * @return mixed 588 | */ 589 | private function _toType($value) { 590 | if ($value === '') return ""; 591 | $first_character = $value[0]; 592 | $last_character = substr($value, -1, 1); 593 | 594 | $is_quoted = false; 595 | do { 596 | if (!$value) break; 597 | if ($first_character != '"' && $first_character != "'") break; 598 | if ($last_character != '"' && $last_character != "'") break; 599 | $is_quoted = true; 600 | } while (0); 601 | 602 | if ($is_quoted) { 603 | $value = str_replace('\n', "\n", $value); 604 | return strtr(substr ($value, 1, -1), array ('\\"' => '"', '\'\'' => '\'', '\\\'' => '\'')); 605 | } 606 | 607 | if (strpos($value, ' #') !== false && !$is_quoted) 608 | $value = preg_replace('/\s+#(.+)$/','',$value); 609 | 610 | if ($first_character == '[' && $last_character == ']') { 611 | // Take out strings sequences and mappings 612 | $innerValue = trim(substr ($value, 1, -1)); 613 | if ($innerValue === '') return array(); 614 | $explode = $this->_inlineEscape($innerValue); 615 | // Propagate value array 616 | $value = array(); 617 | foreach ($explode as $v) { 618 | $value[] = $this->_toType($v); 619 | } 620 | return $value; 621 | } 622 | 623 | if (strpos($value,': ')!==false && $first_character != '{') { 624 | $array = explode(': ',$value); 625 | $key = trim($array[0]); 626 | array_shift($array); 627 | $value = trim(implode(': ',$array)); 628 | $value = $this->_toType($value); 629 | return array($key => $value); 630 | } 631 | 632 | if ($first_character == '{' && $last_character == '}') { 633 | $innerValue = trim(substr ($value, 1, -1)); 634 | if ($innerValue === '') return array(); 635 | // Inline Mapping 636 | // Take out strings sequences and mappings 637 | $explode = $this->_inlineEscape($innerValue); 638 | // Propagate value array 639 | $array = array(); 640 | foreach ($explode as $v) { 641 | $SubArr = $this->_toType($v); 642 | if (empty($SubArr)) continue; 643 | if (is_array ($SubArr)) { 644 | $array[key($SubArr)] = $SubArr[key($SubArr)]; continue; 645 | } 646 | $array[] = $SubArr; 647 | } 648 | return $array; 649 | } 650 | 651 | if ($value == 'null' || $value == 'NULL' || $value == 'Null' || $value == '' || $value == '~') { 652 | return null; 653 | } 654 | 655 | if ( is_numeric($value) && preg_match ('/^(-|)[1-9]+[0-9]*$/', $value) ){ 656 | $intvalue = (int)$value; 657 | if ($intvalue != PHP_INT_MAX) 658 | $value = $intvalue; 659 | return $value; 660 | } 661 | 662 | if (is_numeric($value) && preg_match('/^0[xX][0-9a-fA-F]+$/', $value)) { 663 | // Hexadecimal value. 664 | return hexdec($value); 665 | } 666 | 667 | $this->coerceValue($value); 668 | 669 | if (is_numeric($value)) { 670 | if ($value === '0') return 0; 671 | if (rtrim ($value, 0) === $value) 672 | $value = (float)$value; 673 | return $value; 674 | } 675 | 676 | return $value; 677 | } 678 | 679 | /** 680 | * Used in inlines to check for more inlines or quoted strings 681 | * @access private 682 | * @return array 683 | */ 684 | private function _inlineEscape($inline) { 685 | // There's gotta be a cleaner way to do this... 686 | // While pure sequences seem to be nesting just fine, 687 | // pure mappings and mappings with sequences inside can't go very 688 | // deep. This needs to be fixed. 689 | 690 | $seqs = array(); 691 | $maps = array(); 692 | $saved_strings = array(); 693 | $saved_empties = array(); 694 | 695 | // Check for empty strings 696 | $regex = '/("")|(\'\')/'; 697 | if (preg_match_all($regex,$inline,$strings)) { 698 | $saved_empties = $strings[0]; 699 | $inline = preg_replace($regex,'YAMLEmpty',$inline); 700 | } 701 | unset($regex); 702 | 703 | // Check for strings 704 | $regex = '/(?:(")|(?:\'))((?(1)[^"]+|[^\']+))(?(1)"|\')/'; 705 | if (preg_match_all($regex,$inline,$strings)) { 706 | $saved_strings = $strings[0]; 707 | $inline = preg_replace($regex,'YAMLString',$inline); 708 | } 709 | unset($regex); 710 | 711 | // echo $inline; 712 | 713 | $i = 0; 714 | do { 715 | 716 | // Check for sequences 717 | while (preg_match('/\[([^{}\[\]]+)\]/U',$inline,$matchseqs)) { 718 | $seqs[] = $matchseqs[0]; 719 | $inline = preg_replace('/\[([^{}\[\]]+)\]/U', ('YAMLSeq' . (count($seqs) - 1) . 's'), $inline, 1); 720 | } 721 | 722 | // Check for mappings 723 | while (preg_match('/{([^\[\]{}]+)}/U',$inline,$matchmaps)) { 724 | $maps[] = $matchmaps[0]; 725 | $inline = preg_replace('/{([^\[\]{}]+)}/U', ('YAMLMap' . (count($maps) - 1) . 's'), $inline, 1); 726 | } 727 | 728 | if ($i++ >= 10) break; 729 | 730 | } while (strpos ($inline, '[') !== false || strpos ($inline, '{') !== false); 731 | 732 | $explode = explode(',',$inline); 733 | $explode = array_map('trim', $explode); 734 | $stringi = 0; $i = 0; 735 | 736 | while (1) { 737 | 738 | // Re-add the sequences 739 | if (!empty($seqs)) { 740 | foreach ($explode as $key => $value) { 741 | if (strpos($value,'YAMLSeq') !== false) { 742 | foreach ($seqs as $seqk => $seq) { 743 | $explode[$key] = str_replace(('YAMLSeq'.$seqk.'s'),$seq,$value); 744 | $value = $explode[$key]; 745 | } 746 | } 747 | } 748 | } 749 | 750 | // Re-add the mappings 751 | if (!empty($maps)) { 752 | foreach ($explode as $key => $value) { 753 | if (strpos($value,'YAMLMap') !== false) { 754 | foreach ($maps as $mapk => $map) { 755 | $explode[$key] = str_replace(('YAMLMap'.$mapk.'s'), $map, $value); 756 | $value = $explode[$key]; 757 | } 758 | } 759 | } 760 | } 761 | 762 | 763 | // Re-add the strings 764 | if (!empty($saved_strings)) { 765 | foreach ($explode as $key => $value) { 766 | while (strpos($value,'YAMLString') !== false) { 767 | $explode[$key] = preg_replace('/YAMLString/',$saved_strings[$stringi],$value, 1); 768 | unset($saved_strings[$stringi]); 769 | ++$stringi; 770 | $value = $explode[$key]; 771 | } 772 | } 773 | } 774 | 775 | 776 | // Re-add the empties 777 | if (!empty($saved_empties)) { 778 | foreach ($explode as $key => $value) { 779 | while (strpos($value,'YAMLEmpty') !== false) { 780 | $explode[$key] = preg_replace('/YAMLEmpty/', '', $value, 1); 781 | $value = $explode[$key]; 782 | } 783 | } 784 | } 785 | 786 | $finished = true; 787 | foreach ($explode as $key => $value) { 788 | if (strpos($value,'YAMLSeq') !== false) { 789 | $finished = false; break; 790 | } 791 | if (strpos($value,'YAMLMap') !== false) { 792 | $finished = false; break; 793 | } 794 | if (strpos($value,'YAMLString') !== false) { 795 | $finished = false; break; 796 | } 797 | if (strpos($value,'YAMLEmpty') !== false) { 798 | $finished = false; break; 799 | } 800 | } 801 | if ($finished) break; 802 | 803 | $i++; 804 | if ($i > 10) 805 | break; // Prevent infinite loops. 806 | } 807 | 808 | 809 | return $explode; 810 | } 811 | 812 | private function literalBlockContinues ($line, $lineIndent) { 813 | if (!trim($line)) return true; 814 | if (strlen($line) - strlen(ltrim($line)) > $lineIndent) return true; 815 | return false; 816 | } 817 | 818 | private function referenceContentsByAlias ($alias) { 819 | do { 820 | if (!isset($this->SavedGroups[$alias])) { echo "Bad group name: $alias."; break; } 821 | $groupPath = $this->SavedGroups[$alias]; 822 | $value = $this->result; 823 | foreach ($groupPath as $k) { 824 | $value = $value[$k]; 825 | } 826 | } while (false); 827 | return $value; 828 | } 829 | 830 | private function addArrayInline ($array, $indent) { 831 | $CommonGroupPath = $this->path; 832 | if (empty ($array)) return false; 833 | 834 | foreach ($array as $k => $_) { 835 | $this->addArray(array($k => $_), $indent); 836 | $this->path = $CommonGroupPath; 837 | } 838 | return true; 839 | } 840 | 841 | private function addArray ($incoming_data, $incoming_indent) { 842 | 843 | // print_r ($incoming_data); 844 | 845 | if (count ($incoming_data) > 1) 846 | return $this->addArrayInline ($incoming_data, $incoming_indent); 847 | 848 | $key = key ($incoming_data); 849 | $value = isset($incoming_data[$key]) ? $incoming_data[$key] : null; 850 | if ($key === '__!YAMLZero') $key = '0'; 851 | 852 | if ($incoming_indent == 0 && !$this->_containsGroupAlias && !$this->_containsGroupAnchor) { // Shortcut for root-level values. 853 | if ($key || $key === '' || $key === '0') { 854 | $this->result[$key] = $value; 855 | } else { 856 | $this->result[] = $value; end ($this->result); $key = key ($this->result); 857 | } 858 | $this->path[$incoming_indent] = $key; 859 | return; 860 | } 861 | 862 | 863 | 864 | $history = array(); 865 | // Unfolding inner array tree. 866 | $history[] = $_arr = $this->result; 867 | foreach ($this->path as $k) { 868 | $history[] = $_arr = $_arr[$k]; 869 | } 870 | 871 | if ($this->_containsGroupAlias) { 872 | $value = $this->referenceContentsByAlias($this->_containsGroupAlias); 873 | $this->_containsGroupAlias = false; 874 | } 875 | 876 | 877 | // Adding string or numeric key to the innermost level or $this->arr. 878 | if (is_string($key) && $key == '<<') { 879 | if (!is_array ($_arr)) { $_arr = array (); } 880 | 881 | $_arr = array_merge ($_arr, $value); 882 | } else if ($key || $key === '' || $key === '0') { 883 | if (!is_array ($_arr)) 884 | $_arr = array ($key=>$value); 885 | else 886 | $_arr[$key] = $value; 887 | } else { 888 | if (!is_array ($_arr)) { $_arr = array ($value); $key = 0; } 889 | else { $_arr[] = $value; end ($_arr); $key = key ($_arr); } 890 | } 891 | 892 | $reverse_path = array_reverse($this->path); 893 | $reverse_history = array_reverse ($history); 894 | $reverse_history[0] = $_arr; 895 | $cnt = count($reverse_history) - 1; 896 | for ($i = 0; $i < $cnt; $i++) { 897 | $reverse_history[$i+1][$reverse_path[$i]] = $reverse_history[$i]; 898 | } 899 | $this->result = $reverse_history[$cnt]; 900 | 901 | $this->path[$incoming_indent] = $key; 902 | 903 | if ($this->_containsGroupAnchor) { 904 | $this->SavedGroups[$this->_containsGroupAnchor] = $this->path; 905 | if (is_array ($value)) { 906 | $k = key ($value); 907 | if (!is_int ($k)) { 908 | $this->SavedGroups[$this->_containsGroupAnchor][$incoming_indent + 2] = $k; 909 | } 910 | } 911 | $this->_containsGroupAnchor = false; 912 | } 913 | 914 | } 915 | 916 | private static function startsLiteralBlock ($line) { 917 | $lastChar = substr (trim($line), -1); 918 | if ($lastChar != '>' && $lastChar != '|') return false; 919 | if ($lastChar == '|') return $lastChar; 920 | // HTML tags should not be counted as literal blocks. 921 | if (preg_match ('#<.*?>$#', $line)) return false; 922 | return $lastChar; 923 | } 924 | 925 | private static function greedilyNeedNextLine($line) { 926 | $line = trim ($line); 927 | if (!strlen($line)) return false; 928 | if (substr ($line, -1, 1) == ']') return false; 929 | if ($line[0] == '[') return true; 930 | if (preg_match ('#^[^:]+?:\s*\[#', $line)) return true; 931 | return false; 932 | } 933 | 934 | private function addLiteralLine ($literalBlock, $line, $literalBlockStyle, $indent = -1) { 935 | $line = self::stripIndent($line, $indent); 936 | if ($literalBlockStyle !== '|') { 937 | $line = self::stripIndent($line); 938 | } 939 | $line = rtrim ($line, "\r\n\t ") . "\n"; 940 | if ($literalBlockStyle == '|') { 941 | return $literalBlock . $line; 942 | } 943 | if (strlen($line) == 0) 944 | return rtrim($literalBlock, ' ') . "\n"; 945 | if ($line == "\n" && $literalBlockStyle == '>') { 946 | return rtrim ($literalBlock, " \t") . "\n"; 947 | } 948 | if ($line != "\n") 949 | $line = trim ($line, "\r\n ") . " "; 950 | return $literalBlock . $line; 951 | } 952 | 953 | function revertLiteralPlaceHolder ($lineArray, $literalBlock) { 954 | foreach ($lineArray as $k => $_) { 955 | if (is_array($_)) 956 | $lineArray[$k] = $this->revertLiteralPlaceHolder ($_, $literalBlock); 957 | else if (substr($_, -1 * strlen ($this->LiteralPlaceHolder)) == $this->LiteralPlaceHolder) 958 | $lineArray[$k] = rtrim ($literalBlock, " \r\n"); 959 | } 960 | return $lineArray; 961 | } 962 | 963 | private static function stripIndent ($line, $indent = -1) { 964 | if ($indent == -1) $indent = strlen($line) - strlen(ltrim($line)); 965 | return substr ($line, $indent); 966 | } 967 | 968 | private function getParentPathByIndent ($indent) { 969 | if ($indent == 0) return array(); 970 | $linePath = $this->path; 971 | do { 972 | end($linePath); $lastIndentInParentPath = key($linePath); 973 | if ($indent <= $lastIndentInParentPath) array_pop ($linePath); 974 | } while ($indent <= $lastIndentInParentPath); 975 | return $linePath; 976 | } 977 | 978 | 979 | private function clearBiggerPathValues ($indent) { 980 | 981 | 982 | if ($indent == 0) $this->path = array(); 983 | if (empty ($this->path)) return true; 984 | 985 | foreach ($this->path as $k => $_) { 986 | if ($k > $indent) unset ($this->path[$k]); 987 | } 988 | 989 | return true; 990 | } 991 | 992 | 993 | private static function isComment ($line) { 994 | if (!$line) return false; 995 | if ($line[0] == '#') return true; 996 | if (trim($line, " \r\n\t") == '---') return true; 997 | return false; 998 | } 999 | 1000 | private static function isEmpty ($line) { 1001 | return (trim ($line) === ''); 1002 | } 1003 | 1004 | 1005 | private function isArrayElement ($line) { 1006 | if (!$line || !is_scalar($line)) return false; 1007 | if (substr($line, 0, 2) != '- ') return false; 1008 | if (strlen ($line) > 3) 1009 | if (substr($line,0,3) == '---') return false; 1010 | 1011 | return true; 1012 | } 1013 | 1014 | private function isHashElement ($line) { 1015 | return strpos($line, ':'); 1016 | } 1017 | 1018 | private function isLiteral ($line) { 1019 | if ($this->isArrayElement($line)) return false; 1020 | if ($this->isHashElement($line)) return false; 1021 | return true; 1022 | } 1023 | 1024 | 1025 | private static function unquote ($value) { 1026 | if (!$value) return $value; 1027 | if (!is_string($value)) return $value; 1028 | if ($value[0] == '\'') return trim ($value, '\''); 1029 | if ($value[0] == '"') return trim ($value, '"'); 1030 | return $value; 1031 | } 1032 | 1033 | private function startsMappedSequence ($line) { 1034 | return (substr($line, 0, 2) == '- ' && substr ($line, -1, 1) == ':'); 1035 | } 1036 | 1037 | private function returnMappedSequence ($line) { 1038 | $array = array(); 1039 | $key = self::unquote(trim(substr($line,1,-1))); 1040 | $array[$key] = array(); 1041 | $this->delayedPath = array(strpos ($line, $key) + $this->indent => $key); 1042 | return array($array); 1043 | } 1044 | 1045 | private function checkKeysInValue($value) { 1046 | if (strchr('[{"\'', $value[0]) === false) { 1047 | if (strchr($value, ': ') !== false) { 1048 | throw new Exception('Too many keys: '.$value); 1049 | } 1050 | } 1051 | } 1052 | 1053 | private function returnMappedValue ($line) { 1054 | $this->checkKeysInValue($line); 1055 | $array = array(); 1056 | $key = self::unquote (trim(substr($line,0,-1))); 1057 | $array[$key] = ''; 1058 | return $array; 1059 | } 1060 | 1061 | private function startsMappedValue ($line) { 1062 | return (substr ($line, -1, 1) == ':'); 1063 | } 1064 | 1065 | private function isPlainArray ($line) { 1066 | return ($line[0] == '[' && substr ($line, -1, 1) == ']'); 1067 | } 1068 | 1069 | private function returnPlainArray ($line) { 1070 | return $this->_toType($line); 1071 | } 1072 | 1073 | private function returnKeyValuePair ($line) { 1074 | $array = array(); 1075 | $key = ''; 1076 | if (strpos ($line, ': ')) { 1077 | // It's a key/value pair most likely 1078 | // If the key is in double quotes pull it out 1079 | if (($line[0] == '"' || $line[0] == "'") && preg_match('/^(["\'](.*)["\'](\s)*:)/',$line,$matches)) { 1080 | $value = trim(str_replace($matches[1],'',$line)); 1081 | $key = $matches[2]; 1082 | } else { 1083 | // Do some guesswork as to the key and the value 1084 | $explode = explode(': ', $line); 1085 | $key = trim(array_shift($explode)); 1086 | $value = trim(implode(': ', $explode)); 1087 | $this->checkKeysInValue($value); 1088 | } 1089 | // Set the type of the value. Int, string, etc 1090 | $value = $this->_toType($value); 1091 | if ($key === '0') $key = '__!YAMLZero'; 1092 | $array[$key] = $value; 1093 | } else { 1094 | $array = array ($line); 1095 | } 1096 | return $array; 1097 | 1098 | } 1099 | 1100 | 1101 | private function returnArrayElement ($line) { 1102 | if (strlen($line) <= 1) return array(array()); // Weird %) 1103 | $array = array(); 1104 | $value = trim(substr($line,1)); 1105 | $value = $this->_toType($value); 1106 | if ($this->isArrayElement($value)) { 1107 | $value = $this->returnArrayElement($value); 1108 | } 1109 | $array[] = $value; 1110 | return $array; 1111 | } 1112 | 1113 | 1114 | private function nodeContainsGroup ($line) { 1115 | $symbolsForReference = 'A-z0-9_\-'; 1116 | if (strpos($line, '&') === false && strpos($line, '*') === false) return false; // Please die fast ;-) 1117 | if ($line[0] == '&' && preg_match('/^(&['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1]; 1118 | if ($line[0] == '*' && preg_match('/^(\*['.$symbolsForReference.']+)/', $line, $matches)) return $matches[1]; 1119 | if (preg_match('/(&['.$symbolsForReference.']+)$/', $line, $matches)) return $matches[1]; 1120 | if (preg_match('/(\*['.$symbolsForReference.']+$)/', $line, $matches)) return $matches[1]; 1121 | if (preg_match ('#^\s*<<\s*:\s*(\*[^\s]+).*$#', $line, $matches)) return $matches[1]; 1122 | return false; 1123 | 1124 | } 1125 | 1126 | private function addGroup ($line, $group) { 1127 | if ($group[0] == '&') $this->_containsGroupAnchor = substr ($group, 1); 1128 | if ($group[0] == '*') $this->_containsGroupAlias = substr ($group, 1); 1129 | //print_r ($this->path); 1130 | } 1131 | 1132 | private function stripGroup ($line, $group) { 1133 | $line = trim(str_replace($group, '', $line)); 1134 | return $line; 1135 | } 1136 | } 1137 | 1138 | // Enable use of SpycLib from command line 1139 | // The syntax is the following: php SpycLib.php spyc.yaml 1140 | 1141 | do { 1142 | if (PHP_SAPI != 'cli') break; 1143 | if (empty ($_SERVER['argc']) || $_SERVER['argc'] < 2) break; 1144 | if (empty ($_SERVER['PHP_SELF']) || FALSE === strpos ($_SERVER['PHP_SELF'], 'SpycLib.php') ) break; 1145 | $file = $argv[1]; 1146 | echo json_encode (spyc_load_file ($file)); 1147 | } while (0); 1148 | -------------------------------------------------------------------------------- /build/shellscripts/inputpassword.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | read -s -p "" password && echo "$password"; -------------------------------------------------------------------------------- /build/xmlscripts/artifact.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 | 29 | 30 | 31 | 48 | 49 | 59 | 60 | 69 | 70 | 84 | 85 | 96 | 97 | 110 | 111 | 118 | 119 | -------------------------------------------------------------------------------- /build/xmlscripts/database.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 55 | 56 | 69 | 70 | 80 | 81 | 91 | 92 | 138 | 139 | -------------------------------------------------------------------------------- /build/xmlscripts/install.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 44 | 45 | 63 | 64 | 95 | 96 | 109 | 110 | 161 | 162 | -------------------------------------------------------------------------------- /build/xmlscripts/magento.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 30 | 31 | 44 | 45 | 97 | 98 | 104 | 105 | 134 | 135 | 160 | 161 | -------------------------------------------------------------------------------- /build/xmlscripts/release.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /build/xmlscripts/server.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 | 23 | 31 | 32 | 58 | 59 | -------------------------------------------------------------------------------- /build/xmlscripts/sync.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 41 | 42 | 61 | 62 | 79 | 80 | 91 | 92 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /build/xmlscripts/tests-setup.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 25 | 26 | 39 | 40 | 48 | 49 | 66 | 67 | 76 | 77 | 85 | 86 | -------------------------------------------------------------------------------- /build/xmlscripts/update.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /build/xmlscripts/util.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 32 | 33 | 47 | 48 | 61 | 62 | 85 | 86 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "staempfli/magento2-builder-tool", 3 | "description": "Staempfli AG Magento2 Builder Tool", 4 | "keywords": ["magento2", "tool", "build", "development", "environment", "sync"], 5 | "license": [ 6 | "GPL-3.0-only" 7 | ], 8 | "authors": [ 9 | { 10 | "name": "Juan Alonso", 11 | "email": "juan.alonso@staempfli.com" 12 | } 13 | ], 14 | "config": { 15 | "bin-dir": "bin" 16 | }, 17 | "bin": ["bin/mg2-builder"], 18 | "require": { 19 | "phing/phing": "2.*" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /config.sample/mg2-builder/build.properties: -------------------------------------------------------------------------------- 1 | # Use this file to set specific properties for the build. 2 | # You can overwrite the build/default.properties just setting a new value here -------------------------------------------------------------------------------- /config.sample/mg2-builder/magento/config.yaml: -------------------------------------------------------------------------------- 1 | LOCAL: 2 | # Disable merge static files 3 | dev/js/merge_files: 4 | default: 0 5 | dev/css/merge_css_files: 6 | default: 0 7 | # Disable Varnish 8 | system/full_page_cache/caching_application: 9 | default: 1 10 | # SSL Configuration 11 | web/secure/use_in_frontend: 12 | default: 0 13 | web/secure/use_in_adminhtml: 14 | default: 0 15 | web/secure/enable_hsts: 16 | default: 0 17 | web/secure/enable_upgrade_insecure: 18 | default: 0 19 | web/secure/base_link_url: 20 | default: "{{secure_base_url}}" 21 | web/unsecure/base_link_url: 22 | default: "{{unsecure_base_url}}" 23 | # Store urls 24 | web/unsecure/base_url: 25 | default: "http://${project.name}.lo/" 26 | # websites: 27 | # de: "http://${project.name}-de.lo/" 28 | web/secure/base_url: 29 | default: "http://${project.name}.lo/" 30 | # websites: 31 | # de: "http://${project.name}-de.lo/" 32 | 33 | IGR: 34 | # Disable Varnish 35 | system/full_page_cache/caching_application: 36 | default: 1 37 | # SSL Configuration 38 | web/secure/use_in_frontend: 39 | default: 0 40 | web/secure/use_in_adminhtml: 41 | default: 0 42 | web/secure/enable_hsts: 43 | default: 0 44 | web/secure/enable_upgrade_insecure: 45 | default: 0 46 | web/secure/base_link_url: 47 | default: "{{secure_base_url}}" 48 | web/unsecure/base_link_url: 49 | default: "{{unsecure_base_url}}" 50 | # Store urls 51 | web/unsecure/base_url: 52 | default: "https:///" 53 | # websites: 54 | # de: "https://${project.name}-de.lo/" 55 | web/secure/base_url: 56 | default: "https:///" 57 | # websites: 58 | # de: "https://${project.name}-de.lo/" 59 | -------------------------------------------------------------------------------- /config.sample/mg2-builder/magento/env.php.template: -------------------------------------------------------------------------------- 1 | 4 | array ( 5 | 'frontName' => '{{ADMIN_FRONTNAME}}', 6 | ), 7 | 'crypt' => 8 | array ( 9 | 'key' => '{{ENCRYPTION_KEY}}', 10 | ), 11 | 'session' => 12 | array ( 13 | 'save' => 'files', 14 | ), 15 | 'db' => 16 | array ( 17 | 'table_prefix' => '', 18 | 'connection' => 19 | array ( 20 | 'default' => 21 | array ( 22 | 'host' => '{{DATABASE_HOST}}', 23 | 'dbname' => '{{DATABASE_NAME}}', 24 | 'username' => '{{DATABASE_USER}}', 25 | 'password' => '{{DATABASE_PASS}}', 26 | 'active' => '1', 27 | ), 28 | ), 29 | ), 30 | 'resource' => 31 | array ( 32 | 'default_setup' => 33 | array ( 34 | 'connection' => 'default', 35 | ), 36 | ), 37 | 'x-frame-options' => 'SAMEORIGIN', 38 | 'MAGE_MODE' => 'developer', 39 | 'cache_types' => 40 | array ( 41 | 'config' => 1, 42 | 'layout' => 1, 43 | 'block_html' => 1, 44 | 'collections' => 1, 45 | 'reflection' => 1, 46 | 'db_ddl' => 1, 47 | 'eav' => 1, 48 | 'config_integration' => 1, 49 | 'config_integration_api' => 1, 50 | 'full_page' => 1, 51 | 'translate' => 1, 52 | 'config_webservice' => 1, 53 | ), 54 | {{INSTALL_DATE}} 55 | ); 56 | -------------------------------------------------------------------------------- /config.sample/mg2-builder/magento/install-config-mysql.php.template: -------------------------------------------------------------------------------- 1 | '{{INTEGRATION_DB_HOST}}', 5 | 'db-user' => '{{INTEGRATION_DB_USER}}', 6 | 'db-password' => '{{INTEGRATION_DB_PASS}}', 7 | 'db-name' => '{{INTEGRATION_DB_NAME}}', 8 | 'db-prefix' => '', 9 | 'backend-frontname' => 'backend', 10 | 'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, 11 | 'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD, 12 | 'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL, 13 | 'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME, 14 | 'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME, 15 | ]; 16 | -------------------------------------------------------------------------------- /config.sample/mg2-builder/server/config.yaml: -------------------------------------------------------------------------------- 1 | DEV: 2 | host: example.server.host 3 | port: 22 4 | rootDir: /home//public_html 5 | deployUsername: 6 | 7 | IGR: 8 | host: example.server.host 9 | port: 22 10 | rootDir: /home//public_html 11 | deployUsername: 12 | 13 | PRD: 14 | host: example.server.host 15 | port: 22 16 | rootDir: /home//public_html 17 | deployUsername: 18 | 19 | -------------------------------------------------------------------------------- /config.sample/mg2-builder/vhost/apache.local.conf: -------------------------------------------------------------------------------- 1 | 2 | DocumentRoot "{{DOCUMENT_ROOT}}" 3 | ServerName {{SERVER_NAME}}.lo 4 | 5 | Options Indexes FollowSymLinks MultiViews 6 | AllowOverride All 7 | Order allow,deny 8 | Allow from all 9 | Require all granted 10 | 11 | ErrorLog "{{LOGS_DIR}}/error_log" 12 | CustomLog "{{LOGS_DIR}}/access_log" common 13 | -------------------------------------------------------------------------------- /config.sample/mg2-builder/vhost/nginx.local.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name {{SERVER_NAME}}.lo; 4 | 5 | # document root 6 | set $MAGE_ROOT {{DOCUMENT_ROOT}}; 7 |     set $MAGE_MODE developer; 8 | 9 | # access and error logging 10 | access_log {{LOGS_DIR}}/access.log; 11 | error_log {{LOGS_DIR}}/error.log; 12 | 13 | # Set default website 14 | set $websiteCode base; 15 | set $websiteType website; 16 | 17 | #----------------------------- 18 | root $MAGE_ROOT/pub; 19 | 20 | index index.php; 21 | autoindex off; 22 | charset off; 23 | 24 | add_header 'X-Content-Type-Options' 'nosniff'; 25 | add_header 'X-XSS-Protection' '1; mode=block'; 26 | 27 | location ~ \.php$ { 28 | fastcgi_param MAGE_RUN_CODE $websiteCode; 29 | fastcgi_param MAGE_RUN_TYPE $websiteType; 30 | } 31 | 32 | location /setup { 33 | root $MAGE_ROOT; 34 | location ~ ^/setup/index.php { 35 | fastcgi_pass unix:{{USER_HOME}}/.phpbrew/var/php.sock; 36 | fastcgi_index index.php; 37 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 38 | include fastcgi_params; 39 | } 40 | 41 | location ~ ^/setup/(?!pub/). { 42 | deny all; 43 | } 44 | 45 | location ~ ^/setup/pub/ { 46 | add_header X-Frame-Options "SAMEORIGIN"; 47 | } 48 | } 49 | 50 | location /update { 51 | root $MAGE_ROOT; 52 | 53 | location ~ ^/update/index.php { 54 | fastcgi_split_path_info ^(/update/index.php)(/.+)$; 55 | fastcgi_pass unix:{{USER_HOME}}/.phpbrew/var/php.sock; 56 | fastcgi_index index.php; 57 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 58 | fastcgi_param PATH_INFO $fastcgi_path_info; 59 | include fastcgi_params; 60 | } 61 | 62 | # deny everything but index.php 63 | location ~ ^/update/(?!pub/). { 64 | deny all; 65 | } 66 | 67 | location ~ ^/update/pub/ { 68 | add_header X-Frame-Options "SAMEORIGIN"; 69 | } 70 | } 71 | 72 | location / { 73 | try_files $uri $uri/ /index.php?$args; 74 | } 75 | 76 | location /pub { 77 | location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) { 78 | deny all; 79 | } 80 | alias $MAGE_ROOT/pub; 81 | add_header X-Frame-Options "SAMEORIGIN"; 82 | } 83 | 84 | location /static/ { 85 | if ($MAGE_MODE = "production") { 86 | expires max; 87 | } 88 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { 89 | add_header Cache-Control "public"; 90 | add_header X-Frame-Options "SAMEORIGIN"; 91 | expires +1y; 92 | 93 | if (!-f $request_filename) { 94 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 95 | } 96 | } 97 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { 98 | add_header Cache-Control "no-store"; 99 | add_header X-Frame-Options "SAMEORIGIN"; 100 | expires off; 101 | 102 | if (!-f $request_filename) { 103 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 104 | } 105 | } 106 | if (!-f $request_filename) { 107 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 108 | } 109 | add_header X-Frame-Options "SAMEORIGIN"; 110 | } 111 | 112 | location /media/ { 113 | try_files $uri $uri/ /get.php?$args; 114 | 115 | location ~ ^/media/theme_customization/.*\.xml { 116 | deny all; 117 | } 118 | 119 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { 120 | add_header Cache-Control "public"; 121 | add_header X-Frame-Options "SAMEORIGIN"; 122 | expires +1y; 123 | try_files $uri $uri/ /get.php?$args; 124 | } 125 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { 126 | add_header Cache-Control "no-store"; 127 | add_header X-Frame-Options "SAMEORIGIN"; 128 | expires off; 129 | try_files $uri $uri/ /get.php?$args; 130 | } 131 | add_header X-Frame-Options "SAMEORIGIN"; 132 | } 133 | 134 | location /media/customer/ { 135 | deny all; 136 | } 137 | 138 | location /media/downloadable/ { 139 | deny all; 140 | } 141 | 142 | location /media/import/ { 143 | deny all; 144 | } 145 | 146 | location ~ cron\.php { 147 | deny all; 148 | } 149 | 150 | location ~ (index|get|static|report|404|503)\.php$ { 151 | try_files $uri =404; 152 | fastcgi_pass unix:{{USER_HOME}}/.phpbrew/var/php.sock; 153 | 154 | fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; 155 | fastcgi_param PHP_VALUE "memory_limit=256M \n max_execution_time=600"; 156 | fastcgi_read_timeout 600s; 157 | fastcgi_connect_timeout 600s; 158 | fastcgi_param MAGE_MODE $MAGE_MODE; 159 | 160 | fastcgi_index index.php; 161 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 162 | include fastcgi_params; 163 | } 164 | #----------------------------- 165 | } -------------------------------------------------------------------------------- /config.sample/project.properties: -------------------------------------------------------------------------------- 1 | # Use this file to set specific properties for the project. 2 | # You can overwrite the build/default.properties just setting a new value here 3 | 4 | # ---- Static Content Settings ---- 5 | #static-content.languages=en_US 6 | #command.static-content.deploy.options=--exclude-theme=Magento/blank -------------------------------------------------------------------------------- /docs/images/youtube/playlist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/staempfli/magento2-builder-tool/3e2d5e3adcdbd9890323aa955367063be674dba4/docs/images/youtube/playlist.png --------------------------------------------------------------------------------