Skip to content

Commit

Permalink
Merged branch feature/#5-communities into feature/#5-communities
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Zazo committed Mar 10, 2016
2 parents 7d98dff + 1e4cb15 commit ff28d79
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 12 deletions.
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: node_js
node_js:
- "4.2"
- "4.3"
before_script:
- mv .env_test .env
services:
- "mongodb"
env:
- CXX=g++-4.8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
notifications:
slack: evr-arch-europe:1UCLAzIauC94wHuy2W2VLD1F
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# keystonejs-portal

[![Build Status](https://travis-ci.org/everisARQ/keystonejs-portal.svg?branch=master)](https://travis-ci.org/everisARQ/keystonejs-portal)

## PRE-REQUISITES
- mongodb

Expand Down
17 changes: 15 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var shell = require('gulp-shell');
var open = require('gulp-open');
var sass = require('gulp-sass');
var jasmine = require('gulp-jasmine');
var util = require('gulp-util');
var runSequence = require('run-sequence');

var paths = {
Expand Down Expand Up @@ -51,9 +52,21 @@ gulp.task('start', 'Run keystonejs-portal.', shell.task('node keystone.js'));

gulp.task('start-dev', 'Run keystonejs-portal with nodemon watching changes in js files.', shell.task('nodemon --watch ./routes --watch ./models keystone.js'));

gulp.task('test', 'Run all project tests', ['test:routes']);
gulp.task('test', 'Run all project tests', function (done) {
runSequence(['test:routes'], function (err) {
if (err) {
var exitCode = 2;
util.log(util.colors.red('[ERROR]'), 'gulp test task failed:', util.colors.red(err));
util.log(util.colors.red('[FAIL]'), 'gulp test task failed - exiting with code', util.colors.red(exitCode));
return process.exit(exitCode);
} else {
util.log(util.colors.green('[OK]'), 'gulp test task finished without errors');
return done();
}
});
});

gulp.task('test:routes', 'Runs routes tests', function () {
gulp.task('test:routes', 'Runs routes tests', function (done) {
return gulp.src(paths.test.routes)
.pipe(jasmine({
timeout: 15000
Expand Down
37 changes: 31 additions & 6 deletions keystone.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Simulate config options from your production environment by
// customising the .env file in your project's root folder.
require('dotenv').load();

var keystone = require('keystone'),
i18n = require('i18n'),
path = require('path');
var keystone = require('keystone'),
i18n = require('i18n'),
fs = require('fs'),
FileStreamRotator = require('file-stream-rotator'),
path = require('path');

// Initialise Keystone with your project's configuration.
// See http://keystonejs.com/guide/config for available options
Expand All @@ -26,7 +27,7 @@ keystone.init({
'auto update': true,
'session': true,
'auth': true,
'user model': 'User'
'user model': 'User',

});

Expand Down Expand Up @@ -79,6 +80,22 @@ keystone.set('language options', {
// Load your project's Routes
keystone.set('routes', require('./routes'));

// HTTP LOGGER
keystone.set('logger', 'common');

var logDirectory = __dirname + '/log'
// ensure log directory exists
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory)

// create a rotating write stream
var accessLogStream = FileStreamRotator.getStream({
date_format: 'YYYYMMDD',
filename: logDirectory + '/access-%DATE%.log',
frequency: 'daily',
verbose: false
});

keystone.set('logger options', {stream: accessLogStream});

// Setup common locals for your emails. The following are required by Keystone's
// default email templates, you may remove them if you're using your own.
Expand Down Expand Up @@ -125,8 +142,16 @@ keystone.set('nav', {
'users': 'users'
});

// Start Keystone to connect to your database and initialise the web server
keystone.set('Logger options', {
level: 'info'/*,
formatter: '',
timestamp: '',
logstash: '',
json: ''*/

});

// Start Keystone to connect to your database and initialise the web server
keystone.start();

module.exports = keystone;
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"dependencies": {
"async": "^1.5.0",
"dotenv": "^1.1.0",
"file-stream-rotator": "0.0.6",
"i18n": "^0.7.0",
"keystone": "https://github.com/everisARQ/keystone.git#master",
"keystone": "file:../keystone",
"node-sass": "^3.4.2",
"node-sass-middleware": "^0.9.7",
"semver": "^5.1.0",
Expand All @@ -21,20 +22,22 @@
"gulp-open": "^1.0.0",
"gulp-sass": "^2.1.1",
"gulp-shell": "^0.5.0",
"gulp-util": "^3.0.7",
"gulp-wait": "0.0.2",
"gulp-watch": "^4.3.5",
"jasmine": "^2.4.1",
"jshint": "^2.9.1",
"jshint-stylish": "^0.1.3",
"nodemon": "^1.8.1",
"run-sequence": "^1.1.5",
"supertest": "^1.2.0"
},
"engines": {
"node": "^4.2.0",
"node": "^4.3.0",
"npm": "^2.14.0"
},
"scripts": {
"preinstall": "npm install semver && node -e \"require('./utils/startup-check.js').nodeVersion()\"",
"preinstall": "./preinstall.sh",
"start": "node keystone.js",
"start-dev": "nodemon --watch ./routes --watch ./models keystone.js",
"test": "gulp test"
Expand Down
10 changes: 10 additions & 0 deletions preinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
file="./node_modules/keystone"

if [ -d "$file" ]
then
echo "pre-install validations run"
npm install semver && node -e "require('./node_modules/keystone/lib/archjs/utils/startup-check.js').nodeVersion(require('path').resolve('./package.json'))"
else
echo "First install. Doesn't execute validations"
fi
3 changes: 3 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var keystone = require('keystone'),

var importRoutes = keystone.importer(__dirname);

var logger = keystone.Logger;

// Add i18n API implementation
keystone.pre('routes', i18n.init);
keystone.set('i18n', i18n);
Expand All @@ -41,6 +43,7 @@ var routes = {
exports = module.exports = function(app) {

// Views
logger.debug('Creates principal routes.');
app.get('/', routes.views.index);
app.get('/blog/:category?', routes.views.blog);
app.get('/blog/post/:post', routes.views.post);
Expand Down
2 changes: 1 addition & 1 deletion templates/layouts/default.jade
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ html(lang="#{language}")
li
a.grey-text.text-lighten-3(href='#') Bug report
hr.hidden-lg.hidden-md
.col-md-4.text-center
.col-md-6.text-center
p.white-text.text-center SOCIAL MEDIA
a.btn-floating.btn-large.fb-bg.waves-effect.waves-light(href='#')
i.fa.fa-facebook
Expand Down
4 changes: 4 additions & 0 deletions test/helpers/keystone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var keystone = require('../../../keystone.js');

const port = process.env.TEST_PORT || 5150;
keystone.set('auto update', false);
keystone.set('port', port);

/**
Expand All @@ -11,6 +12,9 @@ keystone.set('port', port);
keystone.closeConnections = () => {
keystone.httpServer.close();
keystone.mongoose.connection.close();
keystone.app.close((err) => {
return (err) ? false : true;
});
};

module.exports = keystone;

0 comments on commit ff28d79

Please sign in to comment.