1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 02:42:17 -05:00

moved dev server to grunt connect

This commit is contained in:
Tankred Hase 2013-05-22 10:16:26 +02:00
parent 9f9cd612af
commit f5d505df49
7 changed files with 102 additions and 121 deletions

View File

@ -1,25 +1,67 @@
module.exports = function(grunt) {
'use strict';
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
dev: {
options: {
port: 8580,
base: '.',
keepalive: true
}
},
test: {
options: {
port: 8581,
base: '.'
}
},
prod: {
options: {
port: process.env.PORT || 8585,
base: './src/',
keepalive: true,
middleware: function(connect, options) {
// Return array of whatever middlewares you want
return [
function(req, res, next) {
res.setHeader('Content-Security-Policy', "default-src 'self'; script-src 'self' 'unsafe-eval'; connect-src *; object-src 'none'; style-src 'self' 'unsafe-inline'");
res.setHeader('X-Content-Security-Policy', "default-src *; script-src 'self' 'unsafe-eval'; options eval-script; object-src 'none'; style-src 'self' 'unsafe-inline'");
res.setHeader('X-WebKit-CSP', "default-src 'self'; script-src 'self' 'unsafe-eval'; connect-src *; object-src 'none'; style-src 'self' 'unsafe-inline'");
return next();
},
// Serve static files.
connect.static(options.base)];
}
}
}
},
jshint: {
all: ['Gruntfile.js', 'src/js/**/*.js']
},
qunit: {
all: {
options: {
urls: ['http://localhost:8580/unit/index.html']
urls: ['http://localhost:<%= connect.test.options.port %>/test/unit/index.html']
}
}
}
});
// Load the plugin(s)
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
// Default task(s).
grunt.registerTask('test', ['jshint', 'qunit']);
grunt.registerTask('dev', ['connect:dev']);
grunt.registerTask('test', ['jshint', 'connect:test', 'qunit']);
grunt.registerTask('prod', ['connect:prod']);
};

View File

@ -7,14 +7,15 @@
"scripts": {
"preinstall": "rm -rf node_modules/",
"postinstall": "./res/copy-deps.sh",
"test": "test/test.sh"
"test": "grunt test",
"start": "grunt prod"
},
"dependencies": {
"express": "~3.2.4",
"grunt": "~0.4.1",
"grunt-contrib-connect": "~0.3.0",
"crypto-lib": "https://github.com/whiteout-io/crypto-lib/tarball/master"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.5.3",
"grunt-contrib-qunit": "~0.2.1"
}

View File

@ -1,35 +0,0 @@
'use strict';
var express = require('express'),
port, app, dev;
port = process.env.PORT || 8585;
dev = (process.argv[2] === '--dev');
app = express();
// Server setup
app.configure(function() {
app.use(express.compress());
if (dev) {
// serve test files in development mode
console.log(' > Starting in development mode ...');
app.use(express['static'](__dirname + '/test'));
} else {
// activate content security policy for production
app.use(function(req, res, next) {
res.set('Content-Security-Policy', "default-src 'self'; script-src 'self' 'unsafe-eval'; connect-src *; object-src 'none'; style-src 'self' 'unsafe-inline'");
res.set('X-Content-Security-Policy', "default-src *; script-src 'self' 'unsafe-eval'; options eval-script; object-src 'none'; style-src 'self' 'unsafe-inline'");
res.set('X-WebKit-CSP', "default-src 'self'; script-src 'self' 'unsafe-eval'; connect-src *; object-src 'none'; style-src 'self' 'unsafe-inline'");
return next();
});
}
app.use(express['static'](__dirname + '/src'));
});
// start server
app.listen(port);
console.log(' > listening on http://localhost:' + port);

View File

@ -31,7 +31,7 @@ var RSA = function(forge, util) {
this.generateKeypair = function(keySize, callback) {
forge.rsa.generateKeyPair({
bits: keySize,
workerScript: (typeof app !== 'undefined') ? (app.config.workerPath + '/../../lib/forge/prime.worker.js') : undefined
workerScript: (typeof app !== 'undefined') ? (app.config.workerPath + '/../lib/forge/prime.worker.js') : undefined
}, function(err, newKeypair) {
if (err || !newKeypair || !newKeypair.publicKey || !newKeypair.privateKey) {
callback({

View File

@ -15,41 +15,41 @@
</script>
<!-- dependencies -->
<script src="../lib/cordova-2.5.0.js"></script>
<script src="../../src/lib/cordova-2.5.0.js"></script>
<script src="../qunit-1.11.0.js"></script>
<script src="../lib/jquery-1.8.2.min.js"></script>
<script src="../lib/underscore-1.4.4.min.js"></script>
<script src="../lib/backbone-0.9.10.min.js"></script>
<script src="../lib/lawnchair/lawnchair-git.min.js"></script>
<script src="../lib/lawnchair/lawnchair-adapter-indexed-db-git.js"></script>
<script src="../lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js"></script>
<script src="../../src/lib/jquery-1.8.2.min.js"></script>
<script src="../../src/lib/underscore-1.4.4.min.js"></script>
<script src="../../src/lib/backbone-0.9.10.min.js"></script>
<script src="../../src/lib/lawnchair/lawnchair-git.min.js"></script>
<script src="../../src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js"></script>
<script src="../../src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js"></script>
<script src="../lib/forge/forge.rsa.bundle.js"></script>
<script src="../lib/uuid.js"></script>
<script src="../../src/lib/forge/forge.rsa.bundle.js"></script>
<script src="../../src/lib/uuid.js"></script>
<script src="../js/app-config.js"></script>
<script src="../../src/js/app-config.js"></script>
<script>
app.config.workerPath = '../js';
app.config.workerPath = '../../src/js';
app.config.cloudUrl = 'http://localhost:8888';
</script>
<script src="../js/model/email-model.js"></script>
<script src="../js/model/folder-model.js"></script>
<script src="../js/model/account-model.js"></script>
<script src="../js/model/publickey-model.js"></script>
<script src="../../src/js/model/email-model.js"></script>
<script src="../../src/js/model/folder-model.js"></script>
<script src="../../src/js/model/account-model.js"></script>
<script src="../../src/js/model/publickey-model.js"></script>
<script src="../js/crypto/util.js"></script>
<script src="../js/crypto/pbkdf2.js"></script>
<script src="../js/crypto/aes-cbc.js"></script>
<script src="../js/crypto/rsa.js"></script>
<script src="../js/crypto/crypto-batch.js"></script>
<script src="../js/crypto/crypto.js"></script>
<script src="../../src/js/crypto/util.js"></script>
<script src="../../src/js/crypto/pbkdf2.js"></script>
<script src="../../src/js/crypto/aes-cbc.js"></script>
<script src="../../src/js/crypto/rsa.js"></script>
<script src="../../src/js/crypto/crypto-batch.js"></script>
<script src="../../src/js/crypto/crypto.js"></script>
<script src="../js/dao/localstorage-dao.js"></script>
<script src="../js/dao/lawnchair-dao.js"></script>
<script src="../js/dao/devicestorage.js"></script>
<script src="../js/dao/cloudstorage-dao.js"></script>
<script src="../js/dao/email-dao.js"></script>
<script src="../../src/js/dao/localstorage-dao.js"></script>
<script src="../../src/js/dao/lawnchair-dao.js"></script>
<script src="../../src/js/dao/devicestorage.js"></script>
<script src="../../src/js/dao/cloudstorage-dao.js"></script>
<script src="../../src/js/dao/email-dao.js"></script>
<!-- tests -->
<script src="cloudstorage-dao-test.js"></script>

View File

@ -1,27 +0,0 @@
#!/bin/sh
# go to root
cd `dirname $0`
cd ..
PORT=8580
# start server for integration tests
echo "--> starting test server...\n"
PORT=$PORT node server.js --dev &
# get process id
PID=$!
# wait the service to init
sleep 1
# run integration tests
echo "\n--> run tests via grunt...\n"
grunt test
# stop server for integration tests
echo "\n--> stoping test server..."
# wait for request to terminate
sleep 0.5
# kill server process
kill $PID
echo "\n--> all done!\n"

View File

@ -15,41 +15,41 @@
</script>
<!-- dependencies -->
<script src="../lib/cordova-2.5.0.js"></script>
<script src="../../src/lib/cordova-2.5.0.js"></script>
<script src="../qunit-1.11.0.js"></script>
<script src="../lib/jquery-1.8.2.min.js"></script>
<script src="../lib/underscore-1.4.4.min.js"></script>
<script src="../lib/backbone-0.9.10.min.js"></script>
<script src="../lib/lawnchair/lawnchair-git.min.js"></script>
<script src="../lib/lawnchair/lawnchair-adapter-indexed-db-git.js"></script>
<script src="../lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js"></script>
<script src="../../src/lib/jquery-1.8.2.min.js"></script>
<script src="../../src/lib/underscore-1.4.4.min.js"></script>
<script src="../../src/lib/backbone-0.9.10.min.js"></script>
<script src="../../src/lib/lawnchair/lawnchair-git.min.js"></script>
<script src="../../src/lib/lawnchair/lawnchair-adapter-indexed-db-git.js"></script>
<script src="../../src/lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js"></script>
<script src="../lib/forge/forge.rsa.bundle.js"></script>
<script src="../lib/uuid.js"></script>
<script src="../../src/lib/forge/forge.rsa.bundle.js"></script>
<script src="../../src/lib/uuid.js"></script>
<script src="../js/app-config.js"></script>
<script src="../../src/js/app-config.js"></script>
<script>
app.config.workerPath = '../js';
app.config.workerPath = '../../src/js';
app.config.cloudUrl = 'http://localhost:8888';
</script>
<script src="../js/model/email-model.js"></script>
<script src="../js/model/folder-model.js"></script>
<script src="../js/model/account-model.js"></script>
<script src="../js/model/publickey-model.js"></script>
<script src="../../src/js/model/email-model.js"></script>
<script src="../../src/js/model/folder-model.js"></script>
<script src="../../src/js/model/account-model.js"></script>
<script src="../../src/js/model/publickey-model.js"></script>
<script src="../js/crypto/util.js"></script>
<script src="../js/crypto/pbkdf2.js"></script>
<script src="../js/crypto/aes-cbc.js"></script>
<script src="../js/crypto/rsa.js"></script>
<script src="../js/crypto/crypto-batch.js"></script>
<script src="../js/crypto/crypto.js"></script>
<script src="../../src/js/crypto/util.js"></script>
<script src="../../src/js/crypto/pbkdf2.js"></script>
<script src="../../src/js/crypto/aes-cbc.js"></script>
<script src="../../src/js/crypto/rsa.js"></script>
<script src="../../src/js/crypto/crypto-batch.js"></script>
<script src="../../src/js/crypto/crypto.js"></script>
<script src="../js/dao/localstorage-dao.js"></script>
<script src="../js/dao/lawnchair-dao.js"></script>
<script src="../js/dao/devicestorage.js"></script>
<script src="../js/dao/cloudstorage-dao.js"></script>
<script src="../js/dao/email-dao.js"></script>
<script src="../../src/js/dao/localstorage-dao.js"></script>
<script src="../../src/js/dao/lawnchair-dao.js"></script>
<script src="../../src/js/dao/devicestorage.js"></script>
<script src="../../src/js/dao/cloudstorage-dao.js"></script>
<script src="../../src/js/dao/email-dao.js"></script>
<!-- tests -->
<script src="../test-data.js"></script>