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.
This commit is contained in:
Allie Jones 2015-10-26 12:16:26 -04:00 committed by Tim Abbott
parent 46e267f4dc
commit 4de0325a9d
8 changed files with 34 additions and 20 deletions

1
.gitignore vendored
View File

@ -33,3 +33,4 @@ static/third/gemoji/
static/third/zxcvbn/ static/third/zxcvbn/
tools/emoji_dump/bitmaps/ tools/emoji_dump/bitmaps/
tools/emoji_dump/*.ttx tools/emoji_dump/*.ttx
node_modules

View File

@ -1,3 +1,5 @@
before_install:
- nvm install 0.10
install: install:
- tools/travis/setup-$TEST_SUITE - tools/travis/setup-$TEST_SUITE
cache: cache:

View File

@ -2,7 +2,7 @@ var _ = require('third/underscore/underscore.js');
var MessageListView = require('js/message_list_view.js'); var MessageListView = require('js/message_list_view.js');
add_dependencies({ add_dependencies({
$: 'jquery', $: 'jQuery',
XDate: 'third/xdate/xdate.dev.js', XDate: 'third/xdate/xdate.dev.js',
util: 'js/util.js' util: 'js/util.js'
}); });

View File

@ -16,7 +16,7 @@ set_global('unread', {});
var stream_list = require('js/stream_list.js'); var stream_list = require('js/stream_list.js');
global.$ = require('jquery'); global.$ = require('jQuery');
$.fn.expectOne = function () { $.fn.expectOne = function () {
assert(this.length === 1); assert(this.length === 1);
return this; return this;

View File

@ -3,7 +3,7 @@ add_dependencies({
templates: 'js/templates' templates: 'js/templates'
}); });
global.$ = require('jquery'); global.$ = require('jQuery');
var _ = global._; var _ = global._;
// When writing these tests, the following command might be helpful: // When writing these tests, the following command might be helpful:

21
package.json Normal file
View File

@ -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"
}
}

View File

@ -35,23 +35,12 @@ APT_DEPENDENCIES = {
"supervisor", "supervisor",
"git", "git",
"npm", "npm",
"node-jquery",
"yui-compressor", "yui-compressor",
"puppet", # Used by lint-all "puppet", # Used by lint-all
"gettext", # Used by makemessages i18n "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" VENV_PATH="/srv/zulip-venv"
ZULIP_PATH="/srv/zulip" ZULIP_PATH="/srv/zulip"
@ -163,13 +152,11 @@ def main():
with sh.sudo: with sh.sudo:
sh.cp(REPO_STOPWORDS_PATH, TSEARCH_STOPWORDS_PATH, **LOUD) sh.cp(REPO_STOPWORDS_PATH, TSEARCH_STOPWORDS_PATH, **LOUD)
# Add additional node packages for test-js-with-node. # npm install and management commands expect to be run from the root of the project.
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.
os.chdir(ZULIP_PATH) os.chdir(ZULIP_PATH)
sh.npm.install(**LOUD)
os.system("tools/download-zxcvbn") os.system("tools/download-zxcvbn")
os.system("tools/emoji_dump/build_emoji") os.system("tools/emoji_dump/build_emoji")
os.system("generate_secrets.py -d") os.system("generate_secrets.py -d")

View File

@ -25,7 +25,10 @@ os.chdir(settings.DEPLOY_ROOT)
# Redirect child processes' output to a log file (most recent run only). # Redirect child processes' output to a log file (most recent run only).
fp = open('update-prod-static.log', 'w') 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'] subprocess.check_call(['python', 'tools/minify-js']
+ (['--prev-deploy', prev_deploy] if prev_deploy else []), + (['--prev-deploy', prev_deploy] if prev_deploy else []),
stdout=fp, stderr=fp) stdout=fp, stderr=fp)