From f6e9e227f8a5e3d78400845717b5008adecda71b Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 8 Aug 2013 18:19:54 +0200 Subject: [PATCH] Install npm package locally --- .gitignore | 1 + .travis.yml | 2 +- builder.php | 1 + .../Command/Developer/BowerInstall.php | 2 +- .../CLIProvider/CLIDriversServiceProvider.php | 10 ++++-- package.json | 10 ++++++ tests/js/run.sh | 33 ++++++++++++++++--- 7 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 221440c4af..56f96c7332 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ .DS_Store /vendor /plugins +/node_modules composer.phar behat.yml /datas diff --git a/.travis.yml b/.travis.yml index 967efb667b..99f857a092 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ before_script: - cp -f hudson/_GV.php config/ - node --version - npm --version - - npm install bower-canary mocha-phantomjs@">=2.0 <3.0" recess@">=1.1.0 <1.1.7" uglify-js -g + - npm install - echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then pecl install redis; fi;' diff --git a/builder.php b/builder.php index b2d646ddf1..b7e401ef47 100755 --- a/builder.php +++ b/builder.php @@ -92,6 +92,7 @@ $finder ->name('sinon') ->name('sinon-chai') ->name('js-fixtures') + ->name('node_modules') ->ignoreDotFiles(false) ->ignoreVCS(false) ->in(__DIR__); diff --git a/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php b/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php index 89c83fc28a..5d5e242543 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php +++ b/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php @@ -40,7 +40,7 @@ class BowerInstall extends Command if (!version_compare('1.0.0-alpha.1', $version, '<=')) { throw new RuntimeException(sprintf( - 'Bower version 1.0.0-alpha.1 is required (version %s provided), please install bower-canary : `npm install -g bower-canary`', $version + 'Bower version 1.0.0-alpha.1 is required (version %s provided), please install bower-canary : `npm install -g bower-canary or run npm install from root directory`', $version )); } diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php index 5094d13505..ab7220a231 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php @@ -29,15 +29,21 @@ class CLIDriversServiceProvider implements ServiceProviderInterface }); $app['driver.binary-finder'] = $app->protect(function ($name, $configName) use ($app) { + $extraDirs = array(); + + if (is_dir($app['root.path'] . '/node_modules')) { + $extraDirs[] = $app['root.path'] . '/node_modules/.bin'; + } + if (!$app['phraseanet.configuration']->isSetup()) { - return $app['executable-finder']->find($name); + return $app['executable-finder']->find($name, null, $extraDirs); } if (isset($app['phraseanet.configuration']['binaries'][$configName])) { return $app['phraseanet.configuration']['binaries'][$configName]; } - return $app['executable-finder']->find($name); + return $app['executable-finder']->find($name, null, $extraDirs); }); $app['driver.bower'] = $app->share(function (Application $app) { diff --git a/package.json b/package.json new file mode 100644 index 0000000000..7baf3e06eb --- /dev/null +++ b/package.json @@ -0,0 +1,10 @@ +{ + "name": "phraseanet", + "version": "3.9.0", + "devDependencies": { + "bower-canary": "latest", + "mocha-phantomjs": ">=2.0 <3.0", + "recess": ">=1.1.0 <1.1.7", + "uglify-js": "latest" + } +} diff --git a/tests/js/run.sh b/tests/js/run.sh index 7d768c360d..c3544c3a2a 100755 --- a/tests/js/run.sh +++ b/tests/js/run.sh @@ -2,12 +2,37 @@ BASEDIR=$(dirname $0) ROOTDIR="$BASEDIR/../.." +PHANTOMJS_BIN="" +MOCHA_PHANTOMJS_BIN="" + +if type "phantomjs" > /dev/null; then + PHANTOMJS_BIN="phantomjs" +elif type "$ROOTDIR/node_modules/.bin/phantomjs" > /dev/null; then + PHANTOMJS_BIN="$ROOTDIR/node_modules/.bin/phantomjs" +fi + +if type "mocha-phantomjs" > /dev/null; then + MOCHA_PHANTOMJS_BIN="mocha-phantomjs" +elif type "$ROOTDIR/node_modules/.bin/mocha-phantomjs" > /dev/null; then + MOCHA_PHANTOMJS_BIN="$ROOTDIR/node_modules/.bin/mocha-phantomjs" +fi + +if [ -z "$PHANTOMJS_BIN" ]; then + echo "phantomjs is required to run JS tests, see https://npmjs.org/package/phantomjs" + exit 1 +fi + +if [ -z "$MOCHA_PHANTOMJS_BIN" ]; then + echo "mocha-phantomjs is required to run JS tests, see https://npmjs.org/package/mocha-phantomjs" + exit 1 +fi + # run qunit tests -phantomjs "$ROOTDIR/www/assets/qunit/addons/phantomjs/runner.js" "$ROOTDIR/www/include/js/tests/jquery.Upload.js.html" -phantomjs "$ROOTDIR/www/assets/qunit/addons/phantomjs/runner.js" "$ROOTDIR/www/include/js/tests/jquery.Edit.js.html" -phantomjs "$ROOTDIR/www/assets/qunit/addons/phantomjs/runner.js" "$ROOTDIR/www/include/js/tests/jquery.Selection.js.html" +$PHANTOMJS_BIN "$ROOTDIR/www/assets/qunit/addons/phantomjs/runner.js" "$ROOTDIR/www/include/js/tests/jquery.Upload.js.html" +$PHANTOMJS_BIN "$ROOTDIR/www/assets/qunit/addons/phantomjs/runner.js" "$ROOTDIR/www/include/js/tests/jquery.Edit.js.html" +$PHANTOMJS_BIN "$ROOTDIR/www/assets/qunit/addons/phantomjs/runner.js" "$ROOTDIR/www/include/js/tests/jquery.Selection.js.html" # run backbone tests -mocha-phantomjs "$ROOTDIR/www/scripts/tests/index.html" +$MOCHA_PHANTOMJS_BIN "$ROOTDIR/www/scripts/tests/index.html"