diff --git a/.travis.yml b/.travis.yml index 109ae11..79c97c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,3 @@ language: node_js node_js: - '0.12' -branches: - only: - - master - - stable - - beta -deploy: - provider: heroku - api_key: - secure: WYfyx56/Ep8Itxilnpk8MPSokCLO3z7aN7MMhlhbCoS6u0a4p3zNAkpkFC0BJ50Nqt1aONhgQ0LAdIyckzE9SnaEUvJl7xM0fKLf+F9lQnjyKlo6katKKjGwjp/IH8YY1NTrRAvHPvN/hQQg56xJNEtUCtSEk4pWhRAmBXByAefUMYwrBCT7OsEYyVjEJvrvS/FbzNk6Oxg/45058g0qJocR3SDHgCh6SlDv1jV1kMKcglY1sfZt+rjCvPdZMt5Nyf0Ru/JQ8+GuoNM7tE4O0bMha3lPru+QCsgRpUsVfwUN0gE526dcfF/i3fRNzQ+42MvP7c1mZ8zT+ZpB2pA6B9akZpHFf5BNJQTF0wWcObRoAbUpH4vcJ8o/drPNEnGrUxzqNnL5GKFHJv7RRPci8D647OI3geVBsFFyrEql1hS6Tj0qlblC39ym5VNLIf9MraTQ3KH7F9EQXAhPvTRcucDL4ugbpE6j4b47I4l/2seH4WfKEKMQWh+2uzx0swto4SuZrnzyO2EJxWTnIVaUu3czwwFdsU+m66i2MQXC35wW5faIDTxDBeTcbbDJobF5NyOuW40Y115DWoPf2Aj2EbNQiAEMYpxBJ9uJ7RYjtDx2Dd3zNvArvir+Cd21POga1HOe3Jup+UnJoLvaQbhcGTN+ilLtD35J+hlv21iu4sM= - app: shriming - on: - repo: shriming/chat diff --git a/config/env/config.js b/config/env/config.js index a591f6d..3f2e7a4 100644 --- a/config/env/config.js +++ b/config/env/config.js @@ -2,7 +2,67 @@ var _ = require('lodash'); var config = { dev: 'development', - prod: 'production' + prod: 'production', + + /*************************************************************************** + * Set the bin path for executing plugins * + ***************************************************************************/ + bin: './node_modules/.bin/', + + /*************************************************************************** + * Set the directory for db files * + ***************************************************************************/ + directoryForDb: './db', + + /*************************************************************************** + * Set the entry point to app * + ***************************************************************************/ + appScript: 'app.js', + + /*************************************************************************** + * Set the src paths to files * + ***************************************************************************/ + src: { + libs: [ + 'frontend/libs/sails.io.js/dist/sails.io.js', + 'frontend/libs/eventemitter2/lib/eventemitter2.js' + ], + server: ['./config', './api'], + css: ['frontend/**/*.styl', + '!frontend/static/**/*', + '!frontend/*.bundles/**/*', + '!frontend/libs/**/*', + '!frontend/static/**/*' + ], + js: ['frontend/**/*.js', + '!frontend/static/**/*', + '!frontend/*.bundles/**/*' + ], + images: ['frontend/**/*.{png,jpg,gif,svg,ico}', + '!frontend/static/*', + '!frontend/*.bundles/*' + ], + bemhtmlTemplates: ['frontend/**/*.bemhtml', + '!frontend/static/**/*', + '!frontend/*.bundles/**/*' + ], + bemtreeTemplates: ['frontend/**/*.bemtree', + '!frontend/static/**/*', + '!frontend/*.bundles/**/*' + ], + }, + + /*************************************************************************** + * Set the dest paths to files * + ***************************************************************************/ + dest: { + mergedCss: 'frontend/desktop.bundles/merged/_merged.css', + finalCss: 'frontend/static/css', + mergedJs: 'frontend/desktop.bundles/merged/_merged.js', + finalJs: 'frontend/static/js', + images: 'frontend/static/images', + libs: 'frontend/static/js' + } }; process.env.PORT = process.env.PORT || 3000; @@ -11,10 +71,8 @@ config.port = process.env.PORT; process.env.BROWSER_SYNC_PORT = process.env.BROWSER_SYNC_PORT || 8090; config.browserSyncPort = process.env.BROWSER_SYNC_PORT; -process.env.NODE_ENV = process.env.NODE_ENV || config.dev; -config.env = process.env.NODE_ENV; - -console.log(process); +process.env.YENV = process.env.YENV || config.dev; +config.env = process.env.YENV; var envConfig; // require could error out if diff --git a/config/env/development.js b/config/env/development.js index db0798c..8fc32ce 100644 --- a/config/env/development.js +++ b/config/env/development.js @@ -11,63 +11,8 @@ */ module.exports = { - /*************************************************************************** - * Set the bin path for executing plugins * - ***************************************************************************/ - bin: './node_modules/.bin/', - - /*************************************************************************** - * Set the directory for db files * - ***************************************************************************/ - directoryForDb: './db', - /*************************************************************************** * Set the logging in production environment to 'debug' * ***************************************************************************/ - logLevel: 'debug', - - /*************************************************************************** - * Set the entry point to app * - ***************************************************************************/ - appScript: 'app.js', - - /*************************************************************************** - * Set the src paths to files * - ***************************************************************************/ - src: { - server: ['./config', './api'], - css: ['frontend/**/*.styl', - '!frontend/static/**/*', - '!frontend/*.bundles/**/*', - '!frontend/libs/**/*', - '!frontend/static/**/*' - ], - js: ['frontend/**/*.js', - '!frontend/static/**/*', - '!frontend/*.bundles/**/*' - ], - images: ['frontend/**/*.{png,jpg,gif,svg,ico}', - '!frontend/static/*', - '!frontend/*.bundles/*' - ], - bemhtmlTemplates: ['frontend/**/*.bemhtml', - '!frontend/static/**/*', - '!frontend/*.bundles/**/*' - ], - bemtreeTemplates: ['frontend/**/*.bemtree', - '!frontend/static/**/*', - '!frontend/*.bundles/**/*' - ], - }, - - /*************************************************************************** - * Set the dest paths to files * - ***************************************************************************/ - dest: { - mergedCss: 'frontend/desktop.bundles/merged/_merged.css', - finalCss: 'frontend/static/css', - mergedJs: 'frontend/desktop.bundles/merged/_merged.js', - finalJs: 'frontend/static/js', - images: 'frontend/static/images' - } + logLevel: 'debug' }; diff --git a/frontend/.enb/make.js b/frontend/.enb/make.js index 9a64133..0928002 100644 --- a/frontend/.enb/make.js +++ b/frontend/.enb/make.js @@ -45,7 +45,6 @@ if(!fs.existsSync('frontend/desktop.bundles/merged')) { } module.exports = function (config) { - config.includeConfig('enb-bem-specs'); config.module('enb-bem-specs').createConfigurator('specs').configure({ @@ -56,7 +55,6 @@ module.exports = function (config) { }); config.nodes('*.bundles/*', function (nodeConfig) { - var addTechs = [ // essential (begin) // config levels @@ -181,7 +179,7 @@ module.exports = function (config) { ], [ tech.borschik, - { sourceTarget : '?.css', destTarget : '_?.css', tech : 'cleancss', freeze : true, minify : true } + { sourceTarget : '?.css', destTarget : '_?.css', freeze : true, minify : false } ] ]); }); @@ -214,9 +212,8 @@ function getLevels(config) { { path : 'libs/bem-components/desktop.blocks', check : false }, { path : 'libs/bem-components/design/common.blocks', check : false }, { path : 'libs/bem-components/design/desktop.blocks', check : false }, - { path : 'libs.blocks', check : true }, - { path : 'common.blocks', check : true }, - { path : 'desktop.blocks', check : true } + { path : 'desktop.blocks', check : true }, + { path : 'common.blocks', check : true } ]; } diff --git a/frontend/common.blocks/page/page.bemhtml b/frontend/common.blocks/page/page.bemhtml index bd99803..ebdc4b3 100644 --- a/frontend/common.blocks/page/page.bemhtml +++ b/frontend/common.blocks/page/page.bemhtml @@ -7,7 +7,7 @@ block('page')( process.env.BROWSER_SYNC_PORT + '/browser-sync/browser-sync-client.2.9.11.js'; - if(process.env.NODE_ENV === 'development') { + if(process.env.YENV === 'development') { content.push({ elem : 'js', url : url diff --git a/frontend/libs.blocks/emoji-lib/_type/emoji-lib_type_twemoji.deps.js b/frontend/desktop.blocks/emoji-lib/_type/emoji-lib_type_twemoji.deps.js similarity index 100% rename from frontend/libs.blocks/emoji-lib/_type/emoji-lib_type_twemoji.deps.js rename to frontend/desktop.blocks/emoji-lib/_type/emoji-lib_type_twemoji.deps.js diff --git a/frontend/libs.blocks/emoji-lib/_type/emoji-lib_type_twemoji.js b/frontend/desktop.blocks/emoji-lib/_type/emoji-lib_type_twemoji.js similarity index 100% rename from frontend/libs.blocks/emoji-lib/_type/emoji-lib_type_twemoji.js rename to frontend/desktop.blocks/emoji-lib/_type/emoji-lib_type_twemoji.js diff --git a/frontend/libs.blocks/eventemitter2/eventemitter2.deps.js b/frontend/desktop.blocks/eventemitter2/eventemitter2.deps.js similarity index 100% rename from frontend/libs.blocks/eventemitter2/eventemitter2.deps.js rename to frontend/desktop.blocks/eventemitter2/eventemitter2.deps.js diff --git a/frontend/libs.blocks/eventemitter2/eventemitter2.js b/frontend/desktop.blocks/eventemitter2/eventemitter2.js similarity index 100% rename from frontend/libs.blocks/eventemitter2/eventemitter2.js rename to frontend/desktop.blocks/eventemitter2/eventemitter2.js diff --git a/frontend/libs.blocks/jquery/__textcomplete/jquery__textcomplete.deps.js b/frontend/desktop.blocks/jquery/__textcomplete/jquery__textcomplete.deps.js similarity index 100% rename from frontend/libs.blocks/jquery/__textcomplete/jquery__textcomplete.deps.js rename to frontend/desktop.blocks/jquery/__textcomplete/jquery__textcomplete.deps.js diff --git a/frontend/libs.blocks/jquery/__textcomplete/jquery__textcomplete.js b/frontend/desktop.blocks/jquery/__textcomplete/jquery__textcomplete.js similarity index 100% rename from frontend/libs.blocks/jquery/__textcomplete/jquery__textcomplete.js rename to frontend/desktop.blocks/jquery/__textcomplete/jquery__textcomplete.js diff --git a/frontend/libs.blocks/socket-io/__config/socket-io__config.js b/frontend/desktop.blocks/socket-io/__config/socket-io__config.js similarity index 99% rename from frontend/libs.blocks/socket-io/__config/socket-io__config.js rename to frontend/desktop.blocks/socket-io/__config/socket-io__config.js index 897fad3..332ae75 100644 --- a/frontend/libs.blocks/socket-io/__config/socket-io__config.js +++ b/frontend/desktop.blocks/socket-io/__config/socket-io__config.js @@ -4,7 +4,6 @@ */ modules.define('socket-io__config', function(provide){ - provide(/** @exports */{ /** * URL for loading socket.io if it does not exist. @@ -15,5 +14,4 @@ modules.define('socket-io__config', function(provide){ connectOptions : {}, url : '/static/js/sails.io.js' }); - }); diff --git a/frontend/libs.blocks/socket-io/socket-io.deps.js b/frontend/desktop.blocks/socket-io/socket-io.deps.js similarity index 100% rename from frontend/libs.blocks/socket-io/socket-io.deps.js rename to frontend/desktop.blocks/socket-io/socket-io.deps.js diff --git a/frontend/libs.blocks/socket-io/socket-io.js b/frontend/desktop.blocks/socket-io/socket-io.js similarity index 70% rename from frontend/libs.blocks/socket-io/socket-io.js rename to frontend/desktop.blocks/socket-io/socket-io.js index 2789a1a..b7b909e 100644 --- a/frontend/libs.blocks/socket-io/socket-io.js +++ b/frontend/desktop.blocks/socket-io/socket-io.js @@ -11,6 +11,7 @@ modules.define( /* global io */ function doProvide(preserveGlobal){ + console.log('preserveGlobal', preserveGlobal); /** * @exports * @type Function @@ -19,5 +20,9 @@ modules.define( provide(preserveGlobal? io : io); } - typeof io !== 'undefined'? doProvide(true) : loader(cfg.url, doProvide); + if (typeof io !== 'undefined') { + doProvide(true); + } else { + loader(cfg.url, doProvide); + } }); diff --git a/frontend/libs.blocks/toastr/toastr.css b/frontend/desktop.blocks/toastr/toastr.css similarity index 100% rename from frontend/libs.blocks/toastr/toastr.css rename to frontend/desktop.blocks/toastr/toastr.css diff --git a/frontend/libs.blocks/toastr/toastr.deps.js b/frontend/desktop.blocks/toastr/toastr.deps.js similarity index 100% rename from frontend/libs.blocks/toastr/toastr.deps.js rename to frontend/desktop.blocks/toastr/toastr.deps.js diff --git a/frontend/libs.blocks/toastr/toastr.js b/frontend/desktop.blocks/toastr/toastr.js similarity index 100% rename from frontend/libs.blocks/toastr/toastr.js rename to frontend/desktop.blocks/toastr/toastr.js diff --git a/frontend/libs.blocks/libs/libs.deps.js b/frontend/libs.blocks/libs/libs.deps.js deleted file mode 100644 index 66be89c..0000000 --- a/frontend/libs.blocks/libs/libs.deps.js +++ /dev/null @@ -1,6 +0,0 @@ -({ - mustDeps : [ - { block : 'socket-io' } - ], - shouldDeps : [] -}); diff --git a/frontend/static/js/sails.io.js b/frontend/static/js/sails.io.js index d34fed6..820d794 100644 --- a/frontend/static/js/sails.io.js +++ b/frontend/static/js/sails.io.js @@ -422,7 +422,7 @@ var parts=["source","protocol","authority","userInfo","user","password","host"," // If target hostname is different than actual hostname, we'll consider this cross-origin. - var hasSameHostname = targetAfterProtocol.search(window.location.hostname) !== 0; + var hasSameHostname = targetAfterProtocol.search(window.location.hostname) === 0; if (!hasSameHostname) { return true; } diff --git a/gulpfile.js b/gulpfile.js index 32a16e7..8f120da 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,6 +7,8 @@ var flatten = require('gulp-flatten'); var runSequence = require('run-sequence'); var browserSync = require('browser-sync').create(); var stylint = require('gulp-stylint'); +var minifyCss = require('gulp-minify-css'); +var gulpif = require('gulp-if'); var config = require('./config/env/config'); /*************************************************************************** @@ -35,6 +37,10 @@ gulp.task('nodemon-restart', function(){ /*************************************************************************** * Copy tasks * ***************************************************************************/ +gulp.task('copy-libs', function(){ + return gulp.src(config.src.libs) + .pipe(gulp.dest(config.dest.libs)); +}); gulp.task('copy-images', function(){ return gulp.src(config.src.images) @@ -46,6 +52,7 @@ gulp.task('copy-css', function(){ return gulp.src(config.dest.mergedCss) .pipe(replace(/(url\([',"]?(.*[\/]{1})?(.*\.(png|jpg|gif|svg))[',"]?\))/g, 'url("../images/$3")')) .pipe(flatten()) + .pipe(gulpif(config.env === 'production', minifyCss())) .pipe(gulp.dest(config.dest.finalCss)); }); @@ -55,7 +62,7 @@ gulp.task('copy-js', function(){ .pipe(gulp.dest(config.dest.finalJs)); }); -gulp.task('copy-files', ['copy-js', 'copy-css', 'copy-images']); +gulp.task('copy-files', ['copy-libs', 'copy-js', 'copy-css', 'copy-images']); /*************************************************************************** * Mongo tasks * @@ -122,10 +129,6 @@ gulp.task('browser-reload', function(){ * Other tasks * ***************************************************************************/ -gulp.task('run-app', shell.task([ - 'node app.js --prod' -])); - gulp.task('watch', function(){ gulp.watch(config.src.images, function(){ runSequence('copy-images', 'browser-reload'); @@ -145,7 +148,7 @@ gulp.task('watch', function(){ gulp.watch(config.src.js, function(){ runSequence('jslint', 'enb-no-cache', 'copy-js', 'browser-reload'); - }); + }); }); /*************************************************************************** @@ -156,8 +159,4 @@ gulp.task('dev', function(){ runSequence('lint', 'enb-no-cache', 'copy-files', 'server', 'browser-sync', 'watch'); }); -gulp.task('prod', function(){ - runSequence('enb-no-cache', 'copy-files', 'run-app'); -}); - gulp.task('default', ['mongo', 'dev']); diff --git a/package.json b/package.json index f57ce07..ee4a270 100644 --- a/package.json +++ b/package.json @@ -29,18 +29,17 @@ "dependencies": { "bcryptjs": "^2.1.0", "bem-environ": "^1.4.0", - "borschik-tech-cleancss": "^2.0.1", "bower": "^1.3.9", "browser-sync": "^2.9.3", "connect-mongo": "^0.8.2", - "ejs": "~0.8.4", "enb": "0.17.0", "enb-autoprefixer": "^0.1.1", "enb-bem": "0.1.0-beta2", "enb-bem-specs": "^0.6.0", "enb-bemxjst": "^1.3.2", - "enb-borschik": "^1.1.1", + "enb-borschik": "2.1.0", "enb-diverse-js": "^0.1.0", + "enb-bem-techs": "^2.0.1", "enb-magic-factory": "^0.4.4", "enb-modules": "^0.2.0", "enb-stylus": "1.1.2", @@ -49,6 +48,9 @@ "gulp-flatten": "^0.2.0", "gulp-replace-path": "^0.4.0", "gulp-shell": "^0.4.3", + "gulp-minify-css": "^1.2.1", + "gulp-if": "^2.0.0", + "gulp-stylint": "^2.0.0", "html": "0.0.7", "lodash": "^3.10.1", "nodemon": "^1.5.1", @@ -79,12 +81,8 @@ "bem": "^0.10.1", "bower-npm-install": "^0.5.9", "csscomb": "^3.1.8", - "enb-bem-techs": "^2.0.1", "faker": "^2.1.2", "git-hooks": "^1.0.0", - "grunt": "^0.4.5", - "gulp-jshint": "^1.11.2", - "gulp-stylint": "^2.0.0", "jscs": "^1.11.2", "jscs-bem": "^0.2.0", "jshint": "2.6.0",