From 4de0325a9d332809046d58b5b40e335971237030 Mon Sep 17 00:00:00 2001 From: Allie Jones Date: Mon, 26 Oct 2015 12:16:26 -0400 Subject: [PATCH] Install node dependencies using npm. The node packages 'jQuery' and 'jquery' are different--'jQuery' is the legacy support package that is needed for Zulip so the require statements in the tests were updated. Travis uses node 4.0 by default and we are using 0.10, so the command to install the correct version had to be added to the .travis.yml file. --- .gitignore | 1 + .travis.yml | 2 ++ .../node_tests/message_list_view.js | 2 +- frontend_tests/node_tests/stream_list.js | 2 +- frontend_tests/node_tests/templates.js | 2 +- package.json | 21 +++++++++++++++++++ provision.py | 19 +++-------------- tools/update-prod-static | 5 ++++- 8 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 76029a04f2..d6e4a18103 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ static/third/gemoji/ static/third/zxcvbn/ tools/emoji_dump/bitmaps/ tools/emoji_dump/*.ttx +node_modules diff --git a/.travis.yml b/.travis.yml index 071a6c2375..12357c5fa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +before_install: + - nvm install 0.10 install: - tools/travis/setup-$TEST_SUITE cache: diff --git a/frontend_tests/node_tests/message_list_view.js b/frontend_tests/node_tests/message_list_view.js index c0c8615fed..ebf869056e 100644 --- a/frontend_tests/node_tests/message_list_view.js +++ b/frontend_tests/node_tests/message_list_view.js @@ -2,7 +2,7 @@ var _ = require('third/underscore/underscore.js'); var MessageListView = require('js/message_list_view.js'); add_dependencies({ - $: 'jquery', + $: 'jQuery', XDate: 'third/xdate/xdate.dev.js', util: 'js/util.js' }); diff --git a/frontend_tests/node_tests/stream_list.js b/frontend_tests/node_tests/stream_list.js index c99f778fba..e2eee874a6 100644 --- a/frontend_tests/node_tests/stream_list.js +++ b/frontend_tests/node_tests/stream_list.js @@ -16,7 +16,7 @@ set_global('unread', {}); var stream_list = require('js/stream_list.js'); -global.$ = require('jquery'); +global.$ = require('jQuery'); $.fn.expectOne = function () { assert(this.length === 1); return this; diff --git a/frontend_tests/node_tests/templates.js b/frontend_tests/node_tests/templates.js index 00628e0714..a6b644aa7e 100644 --- a/frontend_tests/node_tests/templates.js +++ b/frontend_tests/node_tests/templates.js @@ -3,7 +3,7 @@ add_dependencies({ templates: 'js/templates' }); -global.$ = require('jquery'); +global.$ = require('jQuery'); var _ = global._; // When writing these tests, the following command might be helpful: diff --git a/package.json b/package.json new file mode 100644 index 0000000000..804cd3d83d --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "zulip", + "version": "0.0.0", + "license": "Apache-2.0", + "description": "", + "main": "", + "dependencies": {}, + "devDependencies": { + "jQuery": "1.7.4", + "jsdom": "0.5.7", + "xmlhttprequest": "1.5.0", + "nwmatcher": "1.3.6", + "htmlparser2": "3.8.3", + "cssstyle": "0.2.29" + }, + "scripts": {}, + "repository": { + "type": "git", + "url": "https://github.com/zulip/zulip.git" + } +} diff --git a/provision.py b/provision.py index e2ac1d0f1b..ea70e45478 100644 --- a/provision.py +++ b/provision.py @@ -35,23 +35,12 @@ APT_DEPENDENCIES = { "supervisor", "git", "npm", - "node-jquery", "yui-compressor", "puppet", # Used by lint-all "gettext", # Used by makemessages i18n ] } -# TODO: backport node-{cssstyle,htmlparser2,nwmatcher} to trusty, -# so we can eliminate npm (above) and this section. -NPM_DEPENDENCIES = { - "trusty": [ - "cssstyle", - "htmlparser2", - "nwmatcher", - ] -} - VENV_PATH="/srv/zulip-venv" ZULIP_PATH="/srv/zulip" @@ -163,13 +152,11 @@ def main(): with sh.sudo: sh.cp(REPO_STOPWORDS_PATH, TSEARCH_STOPWORDS_PATH, **LOUD) - # Add additional node packages for test-js-with-node. - with sh.sudo: - sh.npm.install(*NPM_DEPENDENCIES["trusty"], g=True, prefix="/usr", **LOUD) - - # Management commands expect to be run from the root of the project. + # npm install and management commands expect to be run from the root of the project. os.chdir(ZULIP_PATH) + sh.npm.install(**LOUD) + os.system("tools/download-zxcvbn") os.system("tools/emoji_dump/build_emoji") os.system("generate_secrets.py -d") diff --git a/tools/update-prod-static b/tools/update-prod-static index ec4a58ccff..0e990db901 100755 --- a/tools/update-prod-static +++ b/tools/update-prod-static @@ -25,7 +25,10 @@ os.chdir(settings.DEPLOY_ROOT) # Redirect child processes' output to a log file (most recent run only). fp = open('update-prod-static.log', 'w') -# Compile Handlebars templates and minify JavaScripts. +# Install node packages +subprocess.check_call(['npm', 'install'], stdout=fp, stderr=fp); + +# Compile Handlebars templates and minify JavaScript. subprocess.check_call(['python', 'tools/minify-js'] + (['--prev-deploy', prev_deploy] if prev_deploy else []), stdout=fp, stderr=fp)