diff --git a/.gitignore b/.gitignore index d1f06eee..a0518ce7 100644 --- a/.gitignore +++ b/.gitignore @@ -103,9 +103,11 @@ dwsync.xml # ------------------------------------------------------------------------------ assets/bower/ assets/dist/ -bower_components/ assets/public/css/*.css +assets/public/css/maps/ assets/public/bower/ +assets/public/fonts/font-awesome/ +bower_components/ .bower-cache/ .bower-registry/ .bower-tmp/ diff --git a/app/views/layout.jade b/app/views/layout.jade index 70a9875f..b9f0d489 100644 --- a/app/views/layout.jade +++ b/app/views/layout.jade @@ -10,6 +10,9 @@ html.no-js meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1') meta(name='description', content='This rapid MVP was built with Eskimo.') meta(name='viewport', content='width=device-width, initial-scale=1') + if settings.server.env !== 'production' + meta(name='robots' content='noindex') + meta(name='googlebot' content='noindex') block stylesheets link(rel='stylesheet', href='/css/style.css') diff --git a/bin/eskimo.js b/bin/eskimo.js index fd47040f..462f10c5 100755 --- a/bin/eskimo.js +++ b/bin/eskimo.js @@ -20,6 +20,8 @@ var pluralize = require('pluralize'); _.pluralize = pluralize.plural; _.singularize = pluralize.singular; +var Chance = require('chance'); + var multiline = require('multiline'); var async = require('async'); var fs = require('fs'); @@ -157,7 +159,6 @@ function create(dirname) { }, 'Readme.md': function createReadmeFile(callback) { - var readmePath = path.resolve(path.join(dirname, 'Readme.md')); fs.readFile(path.join(templates, 'Readme.md'), 'utf8', function(err, data) { @@ -174,6 +175,27 @@ function create(dirname) { }); + }, + + + 'config.js': function createConfigFile(callback) { + + var configPath = path.resolve(path.join(dirname, 'boot', 'config.js')); + + fs.readFile(path.join(templates, 'boot', 'config.js'), 'utf8', function(err, data) { + + if (err) { + return callback(err); + } + + data = _.template(data)({ + name: path.basename(dirname), + chance: new Chance() + }); + + fs.writeFile(configPath, data, callback); + + }); }, diff --git a/boot/local.js b/boot/local.js index ff55f4f9..efc9f9a4 100644 --- a/boot/local.js +++ b/boot/local.js @@ -22,6 +22,12 @@ exports = module.exports = function() { pass: 'abc123' } } + }, + // less: { + // enabled: false // disable less middleware, if you use gulp watch + // }, + liveReload: { + port: 35729 } }; }; diff --git a/etc/init/02-middleware.js b/etc/init/02-middleware.js index 4a2fe8be..4be6f327 100644 --- a/etc/init/02-middleware.js +++ b/etc/init/02-middleware.js @@ -23,8 +23,10 @@ exports = module.exports = function(IoC, logger, settings, policies) { if (settings.server.env === 'development') { - // less middleware - app.use(lessMiddleware(settings.less.path, settings.less.options)); + if (settings.less.enabled) { + // less middleware + app.use(lessMiddleware(settings.less.path, settings.less.options)); + } // jade-amd templates app.use(settings.jade.amd.path, jadeAmd.jadeAmdMiddleware(settings.jade.amd.options)); diff --git a/etc/init/03-sessions.js b/etc/init/03-sessions.js index 83991f94..9684d014 100644 --- a/etc/init/03-sessions.js +++ b/etc/init/03-sessions.js @@ -28,7 +28,7 @@ exports = module.exports = function(IoC, settings, sessions, User, policies) { // support live reload // (note this must come after sessions) // - if (settings.server.env === 'development') + if (settings.server.env === 'development' && settings.liveReload) app.all(policies.notApiRouteRegexp, connectLiveReload(settings.liveReload)); // add support for authentication diff --git a/gulpfile.js b/gulpfile.js index bba1a44b..a84d18c1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -25,6 +25,7 @@ var override = require('gulp-rev-css-url'); var filter = require('gulp-filter'); var livereload = require('tiny-lr')(); var nodemon = require('gulp-nodemon'); +var autoprefixer = require('gulp-autoprefixer'); //var bowerJSON = require('./bower.json'); //var googlecdn = require('gulp-google-cdn'); @@ -64,12 +65,19 @@ gulp.task('jshint', function() { .pipe(jshint.reporter(stylish)); }); + gulp.task('less', function() { return gulp .src([ './assets/public/css/style.less' ]) - .pipe(less().on('error', logger.error)) + .pipe(sourcemaps.init()) + .pipe(less().on('error', logger.error)) + .pipe(autoprefixer({ + // browsers: ['last 2 versions'], + cascade: true, + remove: true + })) .pipe(sourcemaps.write('./maps')) .pipe(gulp.dest('./assets/public/css')); }); diff --git a/package.json b/package.json index 0213d356..7fcb412e 100644 --- a/package.json +++ b/package.json @@ -43,11 +43,13 @@ "homepage": "https://github.com/niftylettuce/eskimo", "dependencies": { "async": "^0.9.0", + "autoprefixer-core": "^5.1.5", "basic-auth": "^1.0.0", "body-parser": "^1.3.0", "bootable": "^0.2.3", "bootable-environment": "^0.2.0", "chalk": "^0.5.1", + "chance": "^0.7.3", "commander": "^2.2.0", "compression": "^1.0.6", "connect": "^3.1.1", @@ -102,6 +104,7 @@ "cookie": "^0.1.2", "del": "^0.1.3", "gulp": "^3.8.8", + "gulp-autoprefixer": "^2.1.0", "gulp-bower": "0.0.6", "gulp-csso": "^0.2.9", "gulp-exit": "0.0.2", diff --git a/boot/config.js b/templates/boot/config.js similarity index 65% rename from boot/config.js rename to templates/boot/config.js index d5e37bff..c2315126 100644 --- a/boot/config.js +++ b/templates/boot/config.js @@ -2,6 +2,7 @@ // # config var path = require('path'); +var autoprefixer = require('autoprefixer-core'); var parentDir = path.join(__dirname, '..'); var appDir = path.join(parentDir, 'app'); @@ -17,7 +18,7 @@ var maxAge = 24 * 60 * 60 * 1000; exports = module.exports = function() { - return { + var config = { defaults: { basicAuth: { @@ -82,8 +83,8 @@ exports = module.exports = function() { messageFormat: 'text' }, session: { - secret: 'igloo-change-me', - key: 'igloo', + secret: '<%= chance.string({length: 130}) %>', + key: '<%= _.slugify(name) %>', cookie: { maxAge: maxAge }, @@ -108,7 +109,7 @@ exports = module.exports = function() { options: {} } }, - cookieParser: 'igloo-change-me', + cookieParser: '<%= chance.string({length: 130}) %>', csrf: { enabled: true, options: { @@ -147,9 +148,15 @@ exports = module.exports = function() { slack: false }, less: { + enabled: true, path: publicDir, options: { - force: true + force: true, + postprocess: { + css: function(css, req) { + return autoprefixer.process(css).css; + } + } } }, jade: { @@ -157,9 +164,6 @@ exports = module.exports = function() { path: '/js/tmpl/', options: {} } - }, - liveReload: { - port: 35729 } }, @@ -169,8 +173,12 @@ exports = module.exports = function() { env: 'test', port: 5000 }, + mongo: { + dbname: '<%= _.slugify(name) %>_test', + db: '<%= _.slugify(name) %>_test' // keep for winston logger + }, redis: { - prefix: 'igloo_test' + prefix: '<%= _.slugify(name) %>_test', }, logger: { 'console': false, @@ -180,14 +188,14 @@ exports = module.exports = function() { development: { cache: true, - url: 'http://localhost:3000', + url: 'http://<%= _.slugify(name) %>-dev.clevertech.biz', server: { env: 'development', port: 3000, }, mongo: { - dbname: 'igloo-development', - db: 'igloo-development' // keep for winston logger + dbname: '<%= _.slugify(name) %>_development', + db: '<%= _.slugify(name) %>_development' // keep for winston logger }, knex: { debug: true, @@ -195,17 +203,76 @@ exports = module.exports = function() { host: '127.0.0.1', user: 'root', password: '', - database: 'igloo_development' + database: '<%= _.slugify(name) %>_development' } }, redis: { - prefix: 'igloo-development' + prefix: '<%= _.slugify(name) %>_development' + } + }, + + staging: { + cache: true, + url: 'http://<%= _.slugify(name) %>-stag.clevertech.biz', + password: { + minStrength: 1, + limitAttempts: true + }, + views: { + dir: path.join(assetsDir, 'dist'), + }, + publicDir: path.join(assetsDir, 'dist'), + showStack: false, + updateNotifier: { + enabled: false, + }, + server: { + env: 'staging', + port: 3080, + cluster: true + }, + mongo: { + dbname: '<%= _.slugify(name) %>_staging', + db: '<%= _.slugify(name) %>_staging' // keep for winston logger + }, + knex: { + connection: { + host: '127.0.0.1', + user: 'root', + password: '', + database: '<%= _.slugify(name) %>_staging' + } + }, + redis: { + prefix: '<%= _.slugify(name) %>_staging' + }, + output: { + colorize: false + }, + logger: { + 'console': true, + requests: true, + mongo: false, + file: false + /* + // + file: { + filename: '/var/log/igloo.log', + // TODO: maxsize + // TODO: maxFiles + timestamp: true + } + */ + }, + s3: { + bucket: 'requidity-stag' } }, production: { cache: true, - url: 'http://localhost:3080', + // FIXME + url: 'http://<%= _.slugify(name) %>-prod.clevertech.biz', password: { minStrength: 1, limitAttempts: true @@ -224,19 +291,19 @@ exports = module.exports = function() { cluster: true }, mongo: { - dbname: 'igloo-production', - db: 'igloo-production' // keep for winston logger + dbname: '<%= _.slugify(name) %>_production', + db: '<%= _.slugify(name) %>_production' // keep for winston logger }, knex: { connection: { host: '127.0.0.1', user: 'root', password: '', - database: 'igloo_production' + database: '<%= _.slugify(name) %>_production' } }, redis: { - prefix: 'igloo_production' + prefix: '<%= _.slugify(name) %>_production' }, output: { colorize: false @@ -260,6 +327,8 @@ exports = module.exports = function() { }; + return config; + }; exports['@singleton'] = true;