Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[BUGFIX] Added missing files from last revert.

  • Loading branch information...
commit d333b185b95cc1394d66142d764488649e817e6a 1 parent 166b95b
@cmuench cmuench authored
Showing with 840 additions and 121 deletions.
  1. +0 −4 .travis.yml
  2. +19 −0 autocompletion/phpstorm/filetypes/n98_magerun script files.xml
  3. +21 −12 changes.txt
  4. +6 −5 composer.json
  5. +135 −81 composer.lock
  6. +114 −1 config.yaml
  7. BIN  n98-magerun.phar
  8. +28 −0 readme.rst
  9. +43 −0 src/N98/Magento/Command/ComposerWrapper/EventSubscriber.php
  10. +35 −8 src/N98/Magento/Command/Installer/InstallCommand.php
  11. +2 −0  src/N98/Magento/Command/PHPUnit/TestCase.php
  12. +25 −0 src/N98/Magento/Command/Script/Repository/AbstractRepositoryCommand.php
  13. +48 −0 src/N98/Magento/Command/Script/Repository/ListCommand.php
  14. +57 −0 src/N98/Magento/Command/Script/Repository/RunCommand.php
  15. +107 −0 src/N98/Magento/Command/Script/Repository/ScriptLoader.php
  16. +18 −2 src/N98/Magento/Command/ScriptCommand.php
  17. +44 −0 src/N98/Magento/EventSubscriber.php
  18. +13 −7 src/N98/Util/Console/Helper/MagentoHelper.php
  19. +5 −1 tests/N98/Magento/ApplicationTest.php
  20. +50 −0 tests/N98/Magento/Command/Composer/InitCommandTest.php
  21. +31 −0 tests/N98/Magento/Command/Script/Repository/ListCommandTest.php
  22. +32 −0 tests/N98/Magento/Command/Script/Repository/RunCommandTest.php
  23. +2 −0  tests/N98/Magento/Command/Script/Repository/_scripts/bar.magerun
  24. +2 −0  tests/N98/Magento/Command/Script/Repository/_scripts/foo.magerun
  25. +3 −0  tests/N98/Magento/Command/Script/Repository/_scripts/hello-world.magerun
View
4 .travis.yml
@@ -16,10 +16,6 @@ php:
- 5.4
- 5.5
-matrix:
- allow_failures:
- - php: 5.5
-
before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install --dev --prefer-source
View
19 autocompletion/phpstorm/filetypes/n98_magerun script files.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<filetype binary="false" default_extension="" description="n98-magerun script files" name="n98-magerun script files">
+ <highlighting>
+ <options>
+ <option name="LINE_COMMENT" value="#" />
+ <option name="COMMENT_START" value="" />
+ <option name="COMMENT_END" value="" />
+ <option name="HEX_PREFIX" value="" />
+ <option name="NUM_POSTFIXES" value="" />
+ </options>
+ <keywords keywords="admin:notifications;admin:user:change-password;admin:user:create;admin:user:list;cache:clean;cache:disable;cache:enable;cache:flush;cache:list;cms:banner:toggle;cms:page:publish;config:delete;config:dump;config:get;config:search;config:set;customer:change-password;customer:create;customer:create:dummy;customer:info;customer:list;db:console;db:create;db:drop;db:dump;db:import;db:info;db:query;design:demo-notice;dev:class:lookup;dev:console;dev:ide:phpstorm:meta;dev:log;dev:log:db;dev:log:size;dev:module:create;dev:module:dependencies:from;dev:module:dependencies:on;dev:module:list;dev:module:observer:list;dev:module:rewrite:conflicts;dev:module:rewrite:list;dev:profiler;dev:report:count;dev:setup:script:attribute;dev:symlinks;dev:template-hints;dev:template-hints-blocks;dev:theme:duplicates;dev:theme:list;dev:translate:admin;dev:translate:shop;ecomdev:fixture:csv;ecomdev:fixture:sql;extension:download;extension:install;extension:list;extension:upgrade;help;index:list;index:reindex;index:reindex:all;install;list;local-config:generate;magerun:command:create;magerun:module:create;open-browser;script;self-update;shell;sys:check;sys:cron:history;sys:cron:list;sys:cron:run;sys:info;sys:maintenance;sys:setup:compare-versions;sys:setup:run;sys:store:config:base-url:list;sys:store:list;sys:url:list;sys:website:list;tmp:remove;uml:generate;uninstall" ignore_case="false" />
+ <keywords3 keywords="$" />
+ <keywords4 keywords="!" />
+ </highlighting>
+ <extensionMap>
+ <mapping ext="magerun" />
+ </extensionMap>
+</filetype>
+
View
33 changes.txt
@@ -1,6 +1,7 @@
**************
RECENT CHANGES
**************
+
======
1.77.1
======
@@ -8,6 +9,26 @@ RECENT CHANGES
* Bugfix for project configuration loader
======
+1.77.0
+======
+
+* New commands to embedded composer:
+ - composer:init
+ - composer:install
+ - composer:require
+ - composer:update
+ - composer:validate
+ - composer:search
+ - composer:diagnose
+* New script repository commands (by Christian Münch)
+* Enhanced Folder Detection (by Alexander Menk)
+* Ability to add helpers by config - Issue #204 (by Christian Münch)
+* Moved command registration out to dist config.
+* Added new script variables
+* Updated Symfony dependencies
+* Support for Symfony Console Events / Added Event Dispatcher
+
+======
1.76.0
======
@@ -17,18 +38,6 @@ RECENT CHANGES
* Fixed issue #197 - Doesn't run when /tmp/magento/var exists and database is not created / tables missing
* Fixed issue #199 - Error with dev:module:rewrite:conflicts
-======
-1.75.0
-======
-
-* Updated dependencies
-* Issue #47 - Warning if running as root
-* Issue #55 - Multi-reindex
-* Issue #171 - open-browser: admin backend
-* Issue #116 - Added "report_compared_product_index" and "report_viewed_*" tables to "log" group
-* Fixed issue #164 - dev:ide:phpstorm:meta debug mode isn't enough verbose to detect where the problem is
-* Fixed issue #187 - Cache flush is not compatible with older versions of Enterprise
-
-----------------------------------------
SEE FULL CHANGELOG: http://bit.ly/10IDU1H
-----------------------------------------
View
11 composer.json
@@ -9,11 +9,12 @@
"keywords": ["magento", "installer", "cli"],
"require": {
"php": ">=5.3.3",
- "symfony/console": "2.3.3",
- "symfony/finder": "2.3.3",
- "symfony/yaml": "2.3.3",
- "symfony/process": "2.3.3",
- "symfony/validator": "2.3.3",
+ "symfony/console": "2.3.4",
+ "symfony/event-dispatcher": "2.3.4",
+ "symfony/finder": "2.3.4",
+ "symfony/yaml": "2.3.4",
+ "symfony/process": "2.3.4",
+ "symfony/validator": "2.3.4",
"n98/junit-xml": "dev-master",
"fzaninotto/faker": "1.2.0",
"composer/composer": "dev-master",
View
216 composer.lock
@@ -3,7 +3,7 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
- "hash": "87be351c1d959c3a10bc33e29dea97c8",
+ "hash": "9dcbaa09f2739e07db5e84bd041aef4f",
"packages": [
{
"name": "composer/composer",
@@ -11,12 +11,12 @@
"source": {
"type": "git",
"url": "https://github.com/composer/composer.git",
- "reference": "1a50f74c4c900d7bc9215f28045242e1ce0af4c0"
+ "reference": "72919e04b0dfdedf160ca49c0da88bd782d7ac99"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/composer/zipball/1a50f74c4c900d7bc9215f28045242e1ce0af4c0",
- "reference": "1a50f74c4c900d7bc9215f28045242e1ce0af4c0",
+ "url": "https://api.github.com/repos/composer/composer/zipball/72919e04b0dfdedf160ca49c0da88bd782d7ac99",
+ "reference": "72919e04b0dfdedf160ca49c0da88bd782d7ac99",
"shasum": ""
},
"require": {
@@ -72,7 +72,7 @@
"dependency",
"package"
],
- "time": "2013-08-16 16:24:01"
+ "time": "2013-08-31 13:55:12"
},
{
"name": "fzaninotto/faker",
@@ -80,12 +80,12 @@
"source": {
"type": "git",
"url": "https://github.com/fzaninotto/Faker.git",
- "reference": "v1.2.0"
+ "reference": "4ad4bc4b5c8d3c0f3cf55d2fedc2f65b313ec62f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/v1.2.0",
- "reference": "v1.2.0",
+ "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/4ad4bc4b5c8d3c0f3cf55d2fedc2f65b313ec62f",
+ "reference": "4ad4bc4b5c8d3c0f3cf55d2fedc2f65b313ec62f",
"shasum": ""
},
"require": {
@@ -94,7 +94,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.1.x-dev"
+ "dev-master": "1.2.x-dev"
}
},
"autoload": {
@@ -118,20 +118,20 @@
"faker",
"fixtures"
],
- "time": "2013-06-09 17:55:57"
+ "time": "2013-06-09 18:05:57"
},
{
"name": "justinrainbow/json-schema",
"version": "1.1.0",
"source": {
"type": "git",
- "url": "git://github.com/justinrainbow/json-schema.git",
- "reference": "v1.1.0"
+ "url": "https://github.com/justinrainbow/json-schema.git",
+ "reference": "05ff6d8d79fe3ad190b0663d80d3f9deee79416c"
},
"dist": {
"type": "zip",
- "url": "https://github.com/justinrainbow/json-schema/archive/v1.1.0.zip",
- "reference": "v1.1.0",
+ "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/05ff6d8d79fe3ad190b0663d80d3f9deee79416c",
+ "reference": "05ff6d8d79fe3ad190b0663d80d3f9deee79416c",
"shasum": ""
},
"require": {
@@ -181,16 +181,16 @@
"source": {
"type": "git",
"url": "https://github.com/cmuench/junit-xml.git",
- "reference": "6381433a39498dc22bec60cebdb2576a9d2327b0"
+ "reference": "7bb6c7cd746bc18dab2b7a302db12e87da34530e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/cmuench/junit-xml/zipball/6381433a39498dc22bec60cebdb2576a9d2327b0",
- "reference": "6381433a39498dc22bec60cebdb2576a9d2327b0",
+ "url": "https://api.github.com/repos/cmuench/junit-xml/zipball/7bb6c7cd746bc18dab2b7a302db12e87da34530e",
+ "reference": "7bb6c7cd746bc18dab2b7a302db12e87da34530e",
"shasum": ""
},
"require-dev": {
- "phpunit/phpunit": "3.7.19"
+ "phpunit/phpunit": "3.7.24"
},
"type": "library",
"autoload": {
@@ -209,20 +209,20 @@
}
],
"description": "JUnit XML Document generation library",
- "time": "2013-04-12 08:03:36"
+ "time": "2013-08-22 12:49:41"
},
{
"name": "seld/jsonlint",
"version": "1.1.1",
"source": {
"type": "git",
- "url": "http://github.com/Seldaek/jsonlint",
- "reference": "1.1.1"
+ "url": "https://github.com/Seldaek/jsonlint.git",
+ "reference": "2b5b57008ec93148fa46110d42c7a201a6677fe0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/1.1.1",
- "reference": "1.1.1",
+ "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/2b5b57008ec93148fa46110d42c7a201a6677fe0",
+ "reference": "2b5b57008ec93148fa46110d42c7a201a6677fe0",
"shasum": ""
},
"require": {
@@ -260,17 +260,17 @@
},
{
"name": "symfony/console",
- "version": "v2.3.3",
+ "version": "v2.3.4",
"target-dir": "Symfony/Component/Console",
"source": {
"type": "git",
"url": "https://github.com/symfony/Console.git",
- "reference": "v2.3.3"
+ "reference": "db78f8ff7fc9e28d25ff9a0bf6ddf9f0e35fbbe3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/Console/zipball/v2.3.3",
- "reference": "v2.3.3",
+ "url": "https://api.github.com/repos/symfony/Console/zipball/db78f8ff7fc9e28d25ff9a0bf6ddf9f0e35fbbe3",
+ "reference": "db78f8ff7fc9e28d25ff9a0bf6ddf9f0e35fbbe3",
"shasum": ""
},
"require": {
@@ -309,21 +309,75 @@
],
"description": "Symfony Console Component",
"homepage": "http://symfony.com",
+ "time": "2013-08-17 16:34:49"
+ },
+ {
+ "name": "symfony/event-dispatcher",
+ "version": "v2.3.4",
+ "target-dir": "Symfony/Component/EventDispatcher",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/EventDispatcher.git",
+ "reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/41c9826457c65fa3cf746f214985b7ca9cba42f8",
+ "reference": "41c9826457c65fa3cf746f214985b7ca9cba42f8",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "symfony/dependency-injection": "~2.0"
+ },
+ "suggest": {
+ "symfony/dependency-injection": "",
+ "symfony/http-kernel": ""
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.3-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\EventDispatcher\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony EventDispatcher Component",
+ "homepage": "http://symfony.com",
"time": "2013-07-21 12:12:18"
},
{
"name": "symfony/finder",
- "version": "v2.3.3",
+ "version": "v2.3.4",
"target-dir": "Symfony/Component/Finder",
"source": {
"type": "git",
"url": "https://github.com/symfony/Finder.git",
- "reference": "v2.3.3"
+ "reference": "4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.3.3",
- "reference": "v2.3.3",
+ "url": "https://api.github.com/repos/symfony/Finder/zipball/4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1",
+ "reference": "4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1",
"shasum": ""
},
"require": {
@@ -356,21 +410,21 @@
],
"description": "Symfony Finder Component",
"homepage": "http://symfony.com",
- "time": "2013-07-21 12:12:18"
+ "time": "2013-08-13 20:18:00"
},
{
"name": "symfony/process",
- "version": "v2.3.3",
+ "version": "v2.3.4",
"target-dir": "Symfony/Component/Process",
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
- "reference": "v2.3.3"
+ "reference": "1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/Process/zipball/v2.3.3",
- "reference": "v2.3.3",
+ "url": "https://api.github.com/repos/symfony/Process/zipball/1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b",
+ "reference": "1e91553e1cedd0b8fb1da6ea4f89b02e21713d5b",
"shasum": ""
},
"require": {
@@ -403,21 +457,21 @@
],
"description": "Symfony Process Component",
"homepage": "http://symfony.com",
- "time": "2013-08-02 21:51:01"
+ "time": "2013-08-22 06:42:25"
},
{
"name": "symfony/translation",
- "version": "v2.3.3",
+ "version": "v2.3.4",
"target-dir": "Symfony/Component/Translation",
"source": {
"type": "git",
"url": "https://github.com/symfony/Translation.git",
- "reference": "v2.3.3"
+ "reference": "65f888291f0896ad492f9abc6dc05c998373aded"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/Translation/zipball/v2.3.3",
- "reference": "v2.3.3",
+ "url": "https://api.github.com/repos/symfony/Translation/zipball/65f888291f0896ad492f9abc6dc05c998373aded",
+ "reference": "65f888291f0896ad492f9abc6dc05c998373aded",
"shasum": ""
},
"require": {
@@ -458,21 +512,21 @@
],
"description": "Symfony Translation Component",
"homepage": "http://symfony.com",
- "time": "2013-08-02 20:53:38"
+ "time": "2013-08-26 05:49:51"
},
{
"name": "symfony/validator",
- "version": "v2.3.3",
+ "version": "v2.3.4",
"target-dir": "Symfony/Component/Validator",
"source": {
"type": "git",
"url": "https://github.com/symfony/Validator.git",
- "reference": "v2.3.3"
+ "reference": "8f6f6be47fb8e1179cd225b1f949630e26221e42"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/Validator/zipball/v2.3.3",
- "reference": "v2.3.3",
+ "url": "https://api.github.com/repos/symfony/Validator/zipball/8f6f6be47fb8e1179cd225b1f949630e26221e42",
+ "reference": "8f6f6be47fb8e1179cd225b1f949630e26221e42",
"shasum": ""
},
"require": {
@@ -519,21 +573,21 @@
],
"description": "Symfony Validator Component",
"homepage": "http://symfony.com",
- "time": "2013-08-06 05:59:49"
+ "time": "2013-08-24 15:26:22"
},
{
"name": "symfony/yaml",
- "version": "v2.3.3",
+ "version": "v2.3.4",
"target-dir": "Symfony/Component/Yaml",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
- "reference": "v2.3.3"
+ "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.3.3",
- "reference": "v2.3.3",
+ "url": "https://api.github.com/repos/symfony/Yaml/zipball/5a279f1b5f5e1045a6c432354d9ea727ff3a9847",
+ "reference": "5a279f1b5f5e1045a6c432354d9ea727ff3a9847",
"shasum": ""
},
"require": {
@@ -566,7 +620,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "http://symfony.com",
- "time": "2013-07-21 12:12:18"
+ "time": "2013-08-24 15:26:22"
},
{
"name": "twig/twig",
@@ -574,12 +628,12 @@
"source": {
"type": "git",
"url": "https://github.com/fabpot/Twig.git",
- "reference": "v1.13.2"
+ "reference": "6d6a1009427d1f398c9d40904147bf9f723d5755"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/fabpot/Twig/zipball/v1.13.2",
- "reference": "v1.13.2",
+ "url": "https://api.github.com/repos/fabpot/Twig/zipball/6d6a1009427d1f398c9d40904147bf9f723d5755",
+ "reference": "6d6a1009427d1f398c9d40904147bf9f723d5755",
"shasum": ""
},
"require": {
@@ -625,12 +679,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "1.2.12"
+ "reference": "0e9958c459d675fb497d8dc5001c91d335734e48"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.12",
- "reference": "1.2.12",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0e9958c459d675fb497d8dc5001c91d335734e48",
+ "reference": "0e9958c459d675fb497d8dc5001c91d335734e48",
"shasum": ""
},
"require": {
@@ -685,13 +739,13 @@
"version": "1.3.3",
"source": {
"type": "git",
- "url": "git://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "1.3.3"
+ "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
+ "reference": "16a78140ed2fc01b945cfa539665fadc6a038029"
},
"dist": {
"type": "zip",
- "url": "https://github.com/sebastianbergmann/php-file-iterator/zipball/1.3.3",
- "reference": "1.3.3",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/16a78140ed2fc01b945cfa539665fadc6a038029",
+ "reference": "16a78140ed2fc01b945cfa539665fadc6a038029",
"shasum": ""
},
"require": {
@@ -723,20 +777,20 @@
"filesystem",
"iterator"
],
- "time": "2012-10-11 04:44:38"
+ "time": "2012-10-11 11:44:38"
},
{
"name": "phpunit/php-text-template",
"version": "1.1.4",
"source": {
"type": "git",
- "url": "git://github.com/sebastianbergmann/php-text-template.git",
- "reference": "1.1.4"
+ "url": "https://github.com/sebastianbergmann/php-text-template.git",
+ "reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23"
},
"dist": {
"type": "zip",
- "url": "https://github.com/sebastianbergmann/php-text-template/zipball/1.1.4",
- "reference": "1.1.4",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5180896f51c5b3648ac946b05f9ec02be78a0b23",
+ "reference": "5180896f51c5b3648ac946b05f9ec02be78a0b23",
"shasum": ""
},
"require": {
@@ -767,7 +821,7 @@
"keywords": [
"template"
],
- "time": "2012-10-31 11:15:28"
+ "time": "2012-10-31 18:15:28"
},
{
"name": "phpunit/php-timer",
@@ -775,12 +829,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
- "reference": "1.0.5"
+ "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1.0.5",
- "reference": "1.0.5",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
+ "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
"shasum": ""
},
"require": {
@@ -819,12 +873,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
- "reference": "1.2.0"
+ "reference": "31babf400e5b5868573bf49a000a3519d3978233"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1.2.0",
- "reference": "1.2.0",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/31babf400e5b5868573bf49a000a3519d3978233",
+ "reference": "31babf400e5b5868573bf49a000a3519d3978233",
"shasum": ""
},
"require": {
@@ -869,12 +923,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "3.7.24"
+ "reference": "af7b77ccb5c64458bdfca95665d29558d1df7d08"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.24",
- "reference": "3.7.24",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/af7b77ccb5c64458bdfca95665d29558d1df7d08",
+ "reference": "af7b77ccb5c64458bdfca95665d29558d1df7d08",
"shasum": ""
},
"require": {
@@ -942,13 +996,13 @@
"version": "1.2.3",
"source": {
"type": "git",
- "url": "git://github.com/sebastianbergmann/phpunit-mock-objects.git",
- "reference": "1.2.3"
+ "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
+ "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875"
},
"dist": {
"type": "zip",
- "url": "https://github.com/sebastianbergmann/phpunit-mock-objects/archive/1.2.3.zip",
- "reference": "1.2.3",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875",
+ "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875",
"shasum": ""
},
"require": {
View
115 config.yaml
@@ -5,8 +5,121 @@ plugin:
folders:
- /usr/local/share/n98-magerun/modules
+helpers:
+ parameter: N98\Util\Console\Helper\ParameterHelper
+ table: N98\Util\Console\Helper\TableHelper
+ dialog: Composer\Command\Helper\DialogHelper
+
+script:
+ folders:
+ - /usr/local/share/n98-magerun/scripts
+
+detect:
+ subFolders:
+ - web
+ - www
+ - htdocs
+ - public
+ - pub
+ - webroot
+ - web-root
+ - wwwroot
+
+event:
+ subscriber:
+ - N98\Magento\EventSubscriber
+ - N98\Magento\Command\ComposerWrapper\EventSubscriber
+
commands:
- customCommands: []
+ customCommands:
+ - N98\Magento\Command\Admin\DisableNotificationsCommand
+ - N98\Magento\Command\Admin\User\ChangePasswordCommand
+ - N98\Magento\Command\Admin\User\CreateUserCommand
+ - N98\Magento\Command\Admin\User\ListCommand
+ - N98\Magento\Command\Cache\CleanCommand
+ - N98\Magento\Command\Cache\DisableCommand
+ - N98\Magento\Command\Cache\EnableCommand
+ - N98\Magento\Command\Cache\FlushCommand
+ - N98\Magento\Command\Cache\ListCommand
+ - N98\Magento\Command\Cms\Banner\ToggleCommand
+ - N98\Magento\Command\Cms\Page\PublishCommand
+ - N98\Magento\Command\Config\DeleteCommand
+ - N98\Magento\Command\Config\DumpCommand
+ - N98\Magento\Command\Config\GetCommand
+ - N98\Magento\Command\Config\SetCommand
+ - N98\Magento\Command\Config\SearchCommand
+ - N98\Magento\Command\Customer\ChangePasswordCommand
+ - N98\Magento\Command\Customer\CreateCommand
+ - N98\Magento\Command\Customer\CreateDummyCommand
+ - N98\Magento\Command\Customer\InfoCommand
+ - N98\Magento\Command\Customer\ListCommand
+ - N98\Magento\Command\Database\ConsoleCommand
+ - N98\Magento\Command\Database\CreateCommand
+ - N98\Magento\Command\Database\DropCommand
+ - N98\Magento\Command\Database\DumpCommand
+ - N98\Magento\Command\Database\ImportCommand
+ - N98\Magento\Command\Database\InfoCommand
+ - N98\Magento\Command\Database\QueryCommand
+ - N98\Magento\Command\Design\DemoNoticeCommand
+ - N98\Magento\Command\Developer\Ide\PhpStorm\MetaCommand
+ - N98\Magento\Command\Developer\Setup\Script\AttributeCommand
+ - N98\Magento\Command\Developer\ConsoleCommand
+ - N98\Magento\Command\Developer\Log\DbCommand
+ - N98\Magento\Command\Developer\Log\LogCommand
+ - N98\Magento\Command\Developer\Log\SizeCommand
+ - N98\Magento\Command\Developer\Module\CreateCommand
+ - N98\Magento\Command\Developer\Module\ListCommand
+ - N98\Magento\Command\Developer\Module\Observer\ListCommand
+ - N98\Magento\Command\Developer\Module\Rewrite\ConflictsCommand
+ - N98\Magento\Command\Developer\Module\Rewrite\ListCommand
+ - N98\Magento\Command\Developer\Module\Dependencies\OnCommand
+ - N98\Magento\Command\Developer\Module\Dependencies\FromCommand
+ - N98\Magento\Command\Developer\ProfilerCommand
+ - N98\Magento\Command\Developer\Report\CountCommand
+ - N98\Magento\Command\Developer\ClassLookupCommand
+ - N98\Magento\Command\Developer\SymlinksCommand
+ - N98\Magento\Command\Developer\TemplateHintsBlocksCommand
+ - N98\Magento\Command\Developer\TemplateHintsCommand
+ - N98\Magento\Command\Developer\Theme\DuplicatesCommand
+ - N98\Magento\Command\Developer\Theme\ListCommand
+ - N98\Magento\Command\Developer\TranslateInlineAdminCommand
+ - N98\Magento\Command\Developer\TranslateInlineShopCommand
+ - N98\Magento\Command\Indexer\ListCommand
+ - N98\Magento\Command\Indexer\ReindexAllCommand
+ - N98\Magento\Command\Indexer\ReindexCommand
+ - N98\Magento\Command\Installer\InstallCommand
+ - N98\Magento\Command\Installer\UninstallCommand
+ - N98\Magento\Command\LocalConfig\GenerateCommand
+ - N98\Magento\Command\MagentoConnect\DownloadExtensionCommand
+ - N98\Magento\Command\MagentoConnect\InstallExtensionCommand
+ - N98\Magento\Command\MagentoConnect\ListExtensionsCommand
+ - N98\Magento\Command\MagentoConnect\UpgradeExtensionCommand
+ - N98\Magento\Command\OpenBrowserCommand
+ - N98\Magento\Command\ScriptCommand
+ - N98\Magento\Command\Script\Repository\ListCommand
+ - N98\Magento\Command\Script\Repository\RunCommand
+ - N98\Magento\Command\SelfUpdateCommand
+ - N98\Magento\Command\ShellCommand
+ - N98\Magento\Command\System\CheckCommand
+ - N98\Magento\Command\System\Cron\HistoryCommand
+ - N98\Magento\Command\System\Cron\ListCommand
+ - N98\Magento\Command\System\Cron\RunCommand
+ - N98\Magento\Command\System\InfoCommand
+ - N98\Magento\Command\System\MaintenanceCommand
+ - N98\Magento\Command\System\Setup\CompareVersionsCommand
+ - N98\Magento\Command\System\Setup\RunCommand
+ - N98\Magento\Command\System\Store\Config\BaseUrlListCommand
+ - N98\Magento\Command\System\Store\ListCommand
+ - N98\Magento\Command\System\Url\ListCommand
+ - N98\Magento\Command\System\Website\ListCommand
+ - "composer:init": Composer\Command\InitCommand
+ - "composer:install": Composer\Command\InstallCommand
+ - "composer:require": Composer\Command\RequireCommand
+ - "composer:update": Composer\Command\UpdateCommand
+ - "composer:validate": Composer\Command\ValidateCommand
+ - "composer:search": Composer\Command\SearchCommand
+ - "composer:diagnose": Composer\Command\DiagnoseCommand
+
aliases: []
N98\Magento\Command\Installer\InstallCommand:
View
BIN  n98-magerun.phar
Binary file not shown
View
28 readme.rst
@@ -16,6 +16,9 @@ Build Status
.. image:: https://www.versioneye.com/user/projects/51236c8b294edc00020064c5/badge.png
:target: https://www.versioneye.com/user/projects/51236c8b294edc00020064c5
+.. image:: https://poser.pugx.org/n98/magerun/v/stable.png
+ :target: https://packagist.org/packages/n98/magerun
+
**Development Branch**
.. image:: https://travis-ci.org/netz98/n98-magerun.png?branch=develop
@@ -1167,6 +1170,31 @@ Pre-defined variables:
* ${magento.edition} -> Magento Edition -> Community or Enterprise
* ${magerun.version} -> Magerun version i.e. 1.66.0
* ${php.version} -> PHP Version
+* ${script.file} -> Current script file path
+* ${script.dir} -> Current script file dir
+
+n98-magerun Script Repository
+"""""""""""""""""""""""""""""
+You can organize your scripts in a repository.
+Simply place a script in folder */usr/local/share/n98-magerun/scripts* or in your home dir
+in folder *<HOME>/.n98-magerun/scripts*.
+
+Scripts must have the file extension *.magerun*.
+
+After that you can list all scripts with the *script:repo:list* command.
+The first line of the script can contain a comment (line prefixed with #) which will be displayed as description.
+
+.. code-block:: sh
+
+ $ n98-magerun.phar script:repo:list
+
+If you want to execute a script from repository this can be done by *script:repo:run* command.
+
+.. code-block:: sh
+
+ $ n98-magerun.phar script:repo:run [script]
+
+Script argument is optional. If you don't specify any you can select one from a list.
Autocompletion
--------------
View
43 src/N98/Magento/Command/ComposerWrapper/EventSubscriber.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace N98\Magento\Command\ComposerWrapper;
+
+use Composer\Factory;
+use Composer\IO\ConsoleIO;
+use Symfony\Component\Console\Event\ConsoleEvent;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+class EventSubscriber implements EventSubscriberInterface
+{
+ /**
+ * Returns an array of event names this subscriber wants to listen to.
+ *
+ * @return array The event names to listen to
+ *
+ * @api
+ */
+ public static function getSubscribedEvents()
+ {
+ return array('console.command' => 'registerComposer');
+ }
+
+ /**
+ * @param ConsoleEvent $event
+ */
+ public function registerComposer(ConsoleEvent $event)
+ {
+ /*
+ * Inject composer object in composer commands
+ */
+ $command = $event->getCommand();
+ if (strstr(get_class($command), 'Composer\\Command\\')) {
+ $io = new ConsoleIO($event->getInput(), $event->getOutput(), $command->getHelperSet());
+ $magentoRootFolder = $command->getApplication()->getMagentoRootFolder();
+ $configFile = $magentoRootFolder . '/composer.json';
+ $composer = Factory::create($io, $configFile);
+ chdir($magentoRootFolder);
+ $command->setComposer($composer);
+ $command->setIO($io);
+ }
+ }
+}
View
43 src/N98/Magento/Command/Installer/InstallCommand.php
@@ -77,6 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->downloadMagento($input, $output);
$this->createDatabase($input, $output);
$this->installSampleData($input, $output);
+ $this->removeEmptyFolders();
$this->setDirectoryPermissions($output);
$this->installMagento($input, $output, $this->config['installationFolder']);
}
@@ -278,23 +279,24 @@ protected function installSampleData(InputInterface $input, OutputInterface $out
$installSampleData = ($input->getOption('installSampleData') !== null) ? $this->_parseBoolOption($input->getOption('installSampleData')) : $dialog->askConfirmation($output, '<question>Install sample data?</question> <comment>[y]</comment>: ');
if ($installSampleData) {
+ $filesystem = new Filesystem();
+
foreach ($this->commandConfig['demo-data-packages'] as $demoPackageData) {
if ($demoPackageData['name'] == $extra['sample-data']) {
$package = $this->downloadByComposerConfig(
$input,
$output,
$demoPackageData,
- $this->config['installationFolder'],
+ $this->config['installationFolder'] . '/_temp_demo_data',
false
);
$this->_fixComposerExtractionBug();
$expandedFolder = $this->config['installationFolder']
- . DIRECTORY_SEPARATOR
- . str_replace(array('.tar.gz', '.tar.bz2', '.zip'), '', basename($package->getDistUrl()));
+ . '/_temp_demo_data/'
+ . str_replace(array('.tar.gz', '.tar.bz2', '.zip'), '', basename($package->getDistUrl()));
if (is_dir($expandedFolder)) {
- $filesystem = new Filesystem();
$filesystem->recursiveCopy(
$expandedFolder,
$this->config['installationFolder']
@@ -302,8 +304,13 @@ protected function installSampleData(InputInterface $input, OutputInterface $out
$filesystem->recursiveRemoveDirectory($expandedFolder);
}
+ // Remove empty folder
+ if (is_dir($this->config['installationFolder'] . '/vendor/composer')) {
+ $filesystem->recursiveRemoveDirectory($this->config['installationFolder'] . '/vendor/composer');
+ }
+
// Install sample data
- $sampleDataSqlFile = glob($this->config['installationFolder'] . DIRECTORY_SEPARATOR . 'magento_*sample_data*sql');
+ $sampleDataSqlFile = glob($this->config['installationFolder'] . '/_temp_demo_data/magento_*sample_data*sql');
$db = $this->config['db']; /* @var $db \PDO */
if (isset($sampleDataSqlFile[0])) {
$os = new OperatingSystem();
@@ -329,15 +336,20 @@ protected function installSampleData(InputInterface $input, OutputInterface $out
}
}
}
+
+ if (is_dir($this->config['installationFolder'] . '/_temp_demo_data')) {
+ $filesystem->recursiveRemoveDirectory($this->config['installationFolder'] . '/_temp_demo_data');
+ }
}
}
protected function _fixComposerExtractionBug()
{
- $mediaFolder = $this->config['installationFolder'] . DIRECTORY_SEPARATOR . 'media';
- $wrongFolder = $mediaFolder . DIRECTORY_SEPARATOR . 'media';
+ $filesystem = new Filesystem();
+
+ $mediaFolder = $this->config['installationFolder'] . '/media';
+ $wrongFolder = $this->config['installationFolder'] . '/_temp_demo_data/media';
if (is_dir($wrongFolder)) {
- $filesystem = new Filesystem();
$filesystem->recursiveCopy(
$wrongFolder,
$mediaFolder
@@ -347,6 +359,21 @@ protected function _fixComposerExtractionBug()
}
/**
+ * Remove empty composer extraction folder
+ */
+ protected function removeEmptyFolders()
+ {
+ if (is_dir(getcwd() . '/vendor')) {
+ $finder = new Finder();
+ $finder->files()->depth(3)->in(getcwd() . '/vendor');
+ if ($finder->count() == 0) {
+ $filesystem = new Filesystem();
+ $filesystem->recursiveRemoveDirectory(getcwd() . '/vendor');
+ }
+ }
+ }
+
+ /**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return array
View
2  src/N98/Magento/Command/PHPUnit/TestCase.php
@@ -29,6 +29,8 @@ public function getApplication()
'N98\Magento\Application',
array('getMagentoRootFolder')
);
+ $loader = require __DIR__ . '/../../../../../vendor/autoload.php';
+ $this->application->setAutoloader($loader);
$this->application->expects($this->any())->method('getMagentoRootFolder')->will($this->returnValue($root));
$this->application->init();
$this->application->initMagento();
View
25 src/N98/Magento/Command/Script/Repository/AbstractRepositoryCommand.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace N98\Magento\Command\Script\Repository;
+
+use N98\Magento\Command\AbstractMagentoCommand;
+
+class AbstractRepositoryCommand extends AbstractMagentoCommand
+{
+ /**
+ * Extension of n98-magerun scripts
+ */
+ const MAGERUN_EXTENSION = '.magerun';
+
+ /**
+ * @return array
+ */
+ protected function getScripts()
+ {
+ $config = $this->getApplication()->getConfig();
+ $loader = new ScriptLoader($config['script']['folders']);
+ $files = $loader->getFiles();
+
+ return $files;
+ }
+}
View
48 src/N98/Magento/Command/Script/Repository/ListCommand.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace N98\Magento\Command\Script\Repository;
+
+use N98\Magento\Command\AbstractMagentoCommand;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\StringInput;
+use Symfony\Component\Console\Shell;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class ListCommand extends AbstractRepositoryCommand
+{
+ protected function configure()
+ {
+ $this
+ ->setName('script:repo:list')
+ ->setDescription('Lists all scripts in repository')
+ ;
+ }
+
+ /**
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ *
+ * @return int|null|void
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $files = $this->getScripts();
+ if (count($files) > 0) {
+ $table = array();
+ foreach ($files as $file) {
+ $table[] = array(
+ substr($file['fileinfo']->getFilename(), 0, -strlen(self::MAGERUN_EXTENSION)),
+ $file['location'],
+ $file['description'],
+ );
+ }
+ $this->getHelper('table')
+ ->setHeaders(array('Script', 'Location', 'Description'))
+ ->setRows($table)
+ ->render($output);
+ } else {
+ $output->writeln('<info>no script file found</info>');
+ }
+ }
+}
View
57 src/N98/Magento/Command/Script/Repository/RunCommand.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace N98\Magento\Command\Script\Repository;
+
+use N98\Magento\Command\AbstractMagentoCommand;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\StringInput;
+use Symfony\Component\Console\Shell;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class RunCommand extends AbstractRepositoryCommand
+{
+ protected function configure()
+ {
+ $this
+ ->setName('script:repo:run')
+ ->addArgument('script', InputArgument::OPTIONAL, 'Name of script in repository')
+ ->setDescription('Run script from repository')
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $files = $this->getScripts();
+ if ($input->getArgument('script') == null) {
+ $question = array();
+ $i = 0;
+ foreach ($files as $file) {
+ $files[$i] = $file;
+ $question[] = '<comment>[' . ($i + 1) . ']</comment> ' . $file['fileinfo']->getFilename() . PHP_EOL;
+ $i++;
+ }
+ $question[] = '<question>Please select a script file: </question>';
+ $selectedFile = $this->getHelper('dialog')->askAndValidate($output, $question, function($typeInput) use ($files) {
+ if (!isset($files[$typeInput - 1])) {
+ throw new \InvalidArgumentException('Invalid file');
+ }
+
+ return $files[$typeInput - 1]['fileinfo']->getPathname();
+ });
+ } else {
+ $script = $input->getArgument('script');
+ if (substr($script, -strlen(self::MAGERUN_EXTENSION)) !== self::MAGERUN_EXTENSION) {
+ $script .= self::MAGERUN_EXTENSION;
+ }
+
+ if (!isset($files[$script])) {
+ throw new \InvalidArgumentException('Invalid script');
+ }
+ $selectedFile = $files[$script]['fileinfo']->getPathname();
+ }
+
+ $input = new StringInput('script ' . escapeshellarg($selectedFile));
+ $this->getApplication()->run($input, $output);
+ }
+}
View
107 src/N98/Magento/Command/Script/Repository/ScriptLoader.php
@@ -0,0 +1,107 @@
+<?php
+
+namespace N98\Magento\Command\Script\Repository;
+
+use Symfony\Component\Finder\Finder;
+use Symfony\Component\Finder\SplFileInfo;
+
+class ScriptLoader
+{
+ /**
+ * @var array
+ */
+ protected $_scriptFiles = array();
+
+ /**
+ * @var string
+ */
+ protected $_homeScriptFolder = '';
+
+ /**
+ * @var array
+ */
+ protected $_scriptFolders = array();
+
+ /**
+ * @param array $scriptFolders
+ */
+ public function __construct(array $scriptFolders)
+ {
+ $this->_homeScriptFolder = getenv('HOME') . '/.n98-magerun/scripts';
+ $this->_scriptFolders = $scriptFolders;
+ $this->_scriptFolders[] = $this->_homeScriptFolder;
+ foreach ($this->_scriptFolders as $key => $scriptFolder) {
+ if (!is_dir($scriptFolder)) {
+ unset($this->_scriptFolders[$key]);
+ }
+ }
+
+ $this->findScripts();
+ }
+
+ protected function findScripts()
+ {
+ $finder = Finder::create()
+ ->files()
+ ->followLinks(true)
+ ->ignoreUnreadableDirs(true)
+ ->name('*.magerun')
+ ->in($this->_scriptFolders);
+
+ $this->_scriptFiles = array();
+ foreach ($finder as $file) { /* @var $file SplFileInfo */
+ $this->_scriptFiles[$file->getFilename()] = array(
+ 'fileinfo' => $file,
+ 'description' => $this->_readFirstLineOfFile($file->getPathname()),
+ 'location' => $this->_getLocation($file->getPathname()),
+ );
+ }
+
+ ksort($this->_scriptFiles);
+ }
+
+ /**
+ * Reads the first line. If it's a comment return it.
+ *
+ * @param $file
+ *
+ * @return string
+ */
+ protected function _readFirstLineOfFile($file)
+ {
+ $f = @fopen($file, 'r');
+ if (!$f) {
+ return '';
+ }
+ $line = trim(fgets($f));
+ fclose($f);
+
+ if (isset($line[0]) && $line[0] != '#') {
+ return '';
+ }
+
+ return trim(substr($line, 1));
+ }
+
+ /**
+ * @param string $pathname
+ *
+ * @return string
+ */
+ protected function _getLocation($pathname)
+ {
+ if (dirname($pathname) == $this->_homeScriptFolder) {
+ return 'personal';
+ }
+
+ return 'system';
+ }
+
+ /**
+ * @return array
+ */
+ public function getFiles()
+ {
+ return $this->_scriptFiles;
+ }
+}
View
20 src/N98/Magento/Command/ScriptCommand.php
@@ -16,6 +16,11 @@ class ScriptCommand extends AbstractMagentoCommand
*/
protected $scriptVars = array();
+ /**
+ * @var string
+ */
+ protected $_scriptFilename = '';
+
protected function configure()
{
$this
@@ -27,7 +32,8 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
- $script = $this->_getContent($input->getArgument('filename'));
+ $this->_scriptFilename = $input->getArgument('filename');
+ $script = $this->_getContent($this->_scriptFilename);
$commands = explode("\n", $script);
foreach ($commands as $commandString) {
@@ -36,7 +42,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
continue;
}
$firstChar = substr($commandString, 0, 1);
- $this->initScriptVars();
switch ($firstChar) {
@@ -119,6 +124,15 @@ protected function runMagerunCommand(InputInterface $input, OutputInterface $out
protected function _prepareShellCommand($commandString)
{
$commandString = ltrim($commandString, '!');
+
+ // @TODO find a better place
+ if (strstr($commandString, '${magento.root}')
+ || strstr($commandString, '${magento.version}')
+ || strstr($commandString, '${magento.edition}')
+ ) {
+ $this->initMagento();
+ }
+ $this->initScriptVars();
$commandString = $this->_replaceScriptVars($commandString);
return $commandString;
@@ -134,6 +148,8 @@ protected function initScriptVars()
$this->scriptVars['${php.version}'] = substr(phpversion(), 0, strpos(phpversion(), '-'));
$this->scriptVars['${magerun.version}'] = $this->getApplication()->getVersion();
+ $this->scriptVars['${script.file}'] = $this->_scriptFilename;
+ $this->scriptVars['${script.dir}'] = dirname($this->_scriptFilename);
}
/**
View
44 src/N98/Magento/EventSubscriber.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace N98\Magento;
+
+use N98\Util\OperatingSystem;
+use Symfony\Component\Console\Event\ConsoleEvent;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+class EventSubscriber implements EventSubscriberInterface
+{
+ const WARNING_ROOT_USER = '<error>It\'s not recommended to run n98-magerun as root user</error>';
+
+ /**
+ * Returns an array of event names this subscriber wants to listen to.
+ *
+ * @return array The event names to listen to
+ *
+ * @api
+ */
+ public static function getSubscribedEvents()
+ {
+ return array('console.run.before' => 'checkRunningAsRootUser');
+ }
+
+ /**
+ * Display a warning if a running n98-magerun as root user
+ *
+ * @param ConsoleEvent $event
+ * @return void
+ */
+ public function checkRunningAsRootUser(ConsoleEvent $event)
+ {
+ $output = $event->getOutput();
+ if (OperatingSystem::isLinux() || OperatingSystem::isMacOs()) {
+ if (function_exists('posix_getuid')) {
+ if (posix_getuid() === 0) {
+ $output->writeln('');
+ $output->writeln(self::WARNING_ROOT_USER);
+ $output->writeln('');
+ }
+ }
+ }
+ }
+}
View
20 src/N98/Util/Console/Helper/MagentoHelper.php
@@ -38,19 +38,25 @@ public function getName()
* Start Magento detection
*
* @param string $folder
- */
- public function detect($folder)
+ * @param array $subFolders Sub-folders to check
+ */
+ public function detect($folder, $subFolders = array())
{
$folders = $this->splitPathFolders($folder);
$folders = $this->checkModman($folders);
+ $folders = array_merge($folders, $subFolders);
foreach (array_reverse($folders) as $searchFolder) {
+ if (!is_dir($searchFolder)) {
+ continue;
+ }
if ($this->_search($searchFolder)) {
- break;
+ break;
}
}
}
+
/**
* @return string
*/
@@ -123,10 +129,10 @@ protected function checkModman($folders)
$baseFolderContent = trim(file_get_contents($searchFolder . DIRECTORY_SEPARATOR . '.basedir'));
if (!empty($baseFolderContent)) {
$modmanBaseFolder = $searchFolder
- . DIRECTORY_SEPARATOR
- . '..'
- . DIRECTORY_SEPARATOR
- . trim($baseFolderContent);
+ . DIRECTORY_SEPARATOR
+ . '..'
+ . DIRECTORY_SEPARATOR
+ . trim($baseFolderContent);
array_push($folders, $modmanBaseFolder);
}
}
View
6 tests/N98/Magento/ApplicationTest.php
@@ -2,11 +2,13 @@
namespace N98\Magento;
+use N98\Util\ArrayFunctions;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Tester\CommandTester;
use N98\Magento\Command\PHPUnit\TestCase;
use N98\Magento\Application;
+use Symfony\Component\Yaml\Yaml;
class ApplicationTest extends TestCase
{
@@ -27,6 +29,8 @@ public function testExecute()
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('N98', $prefixes);
+ $distConfigArray = Yaml::parse(file_get_contents(__DIR__ . '/../../../config.yaml'));
+
$configArray = array(
'autoloaders' => array(
'N98MagerunTest' => __DIR__ . '/_ApplicationTestSrc',
@@ -44,7 +48,7 @@ public function testExecute()
);
$application->setAutoExit(false);
- $application->init($configArray);
+ $application->init(ArrayFunctions::mergeArrays($distConfigArray, $configArray));
$application->run(new StringInput('list'), new NullOutput());
// Check if autoloaders, commands and aliases are registered
View
50 tests/N98/Magento/Command/Composer/InitCommandTest.php
@@ -0,0 +1,50 @@
+<?php
+
+/*
+ * This file is part of Composer.
+ *
+ * (c) Nils Adermann <naderman@naderman.de>
+ * Jordi Boggiano <j.boggiano@seld.be>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Test\Command;
+
+use Composer\Command\InitCommand;
+use N98\Magento\Command\PHPUnit\TestCase;
+use Symfony\Component\Console\Tester\CommandTester;
+
+class InitCommandTest extends TestCase
+{
+ public function testParseValidAuthorString()
+ {
+ $command = new InitCommand();
+ $author = $command->parseAuthorString('John Smith <john@example.com>');
+ $this->assertEquals('John Smith', $author['name']);
+ $this->assertEquals('john@example.com', $author['email']);
+ }
+
+ public function testParseValidUtf8AuthorString()
+ {
+ $command = new InitCommand();
+ $author = $command->parseAuthorString('Matti Meikäläinen <matti@example.com>');
+ $this->assertEquals('Matti Meikäläinen', $author['name']);
+ $this->assertEquals('matti@example.com', $author['email']);
+ }
+
+ public function testParseEmptyAuthorString()
+ {
+ $command = new InitCommand();
+ $this->setExpectedException('InvalidArgumentException');
+ $command->parseAuthorString('');
+ }
+
+ public function testParseAuthorStringWithInvalidEmail()
+ {
+ $command = new InitCommand();
+ $this->setExpectedException('InvalidArgumentException');
+ $command->parseAuthorString('John Smith <john>');
+ }
+}
View
31 tests/N98/Magento/Command/Script/Repository/ListCommandTest.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace N98\Magento\Command\Script\Repository;
+
+use Symfony\Component\Console\Tester\CommandTester;
+use N98\Magento\Command\PHPUnit\TestCase;
+
+class ListCommandTest extends TestCase
+{
+ public function testExecute()
+ {
+ $application = $this->getApplication();
+ $config = $application->getConfig();
+ $config['script']['folders'][] = __DIR__ . '/_scripts';
+ $application->setConfig($config);
+
+ $application->add(new RunCommand());
+ $command = $this->getApplication()->find('script:repo:list');
+
+ $commandTester = new CommandTester($command);
+ $commandTester->execute(
+ array(
+ 'command' => $command->getName(),
+ )
+ );
+
+ $this->assertContains('Cache Flush Command Test (Hello World)', $commandTester->getDisplay());
+ $this->assertContains('Foo command', $commandTester->getDisplay());
+ $this->assertContains('Bar command', $commandTester->getDisplay());
+ }
+}
View
32 tests/N98/Magento/Command/Script/Repository/RunCommandTest.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace N98\Magento\Command\Script\Repository;
+
+use Symfony\Component\Console\Tester\CommandTester;
+use N98\Magento\Command\PHPUnit\TestCase;
+
+class RunCommandTest extends TestCase
+{
+ public function testExecute()
+ {
+ $application = $this->getApplication();
+ $config = $application->getConfig();
+ $config['script']['folders'][] = __DIR__ . '/_scripts';
+ $application->setConfig($config);
+
+ $application->add(new RunCommand());
+ $command = $this->getApplication()->find('script:repo:run');
+
+ $commandTester = new CommandTester($command);
+ $commandTester->execute(
+ array(
+ 'command' => $command->getName(),
+ 'script' => 'hello-world',
+ )
+ );
+
+ // Runs sys:info -> Check for any output
+ $this->assertContains('Vendors (core)', $commandTester->getDisplay());
+ $this->assertContains(__DIR__ . '/_scripts/hello-world.magerun', $commandTester->getDisplay());
+ }
+}
View
2  tests/N98/Magento/Command/Script/Repository/_scripts/bar.magerun
@@ -0,0 +1,2 @@
+# Bar command
+sys:info
View
2  tests/N98/Magento/Command/Script/Repository/_scripts/foo.magerun
@@ -0,0 +1,2 @@
+# Foo command
+sys:info
View
3  tests/N98/Magento/Command/Script/Repository/_scripts/hello-world.magerun
@@ -0,0 +1,3 @@
+# Cache Flush Command Test (Hello World)
+sys:info
+! echo "${script.file}"
Please sign in to comment.
Something went wrong with that request. Please try again.