Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #170

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
12 changes: 0 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
68 changes: 63 additions & 5 deletions config/env/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
57 changes: 1 addition & 56 deletions config/env/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};
9 changes: 3 additions & 6 deletions frontend/.enb/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -56,7 +55,6 @@ module.exports = function (config) {
});

config.nodes('*.bundles/*', function (nodeConfig) {

var addTechs = [
// essential (begin)
// config levels
Expand Down Expand Up @@ -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 }
]
]);
});
Expand Down Expand Up @@ -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 }
];
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/common.blocks/page/page.bemhtml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

modules.define('socket-io__config', function(provide){

provide(/** @exports */{
/**
* URL for loading socket.io if it does not exist.
Expand All @@ -15,5 +14,4 @@ modules.define('socket-io__config', function(provide){
connectOptions : {},
url : '/static/js/sails.io.js'
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ modules.define(
/* global io */

function doProvide(preserveGlobal){
console.log('preserveGlobal', preserveGlobal);
/**
* @exports
* @type Function
Expand All @@ -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);
}
});
6 changes: 0 additions & 6 deletions frontend/libs.blocks/libs/libs.deps.js

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/static/js/sails.io.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

/***************************************************************************
Expand Down Expand Up @@ -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)
Expand All @@ -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));
});

Expand All @@ -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 *
Expand Down Expand Up @@ -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');
Expand All @@ -145,7 +148,7 @@ gulp.task('watch', function(){

gulp.watch(config.src.js, function(){
runSequence('jslint', 'enb-no-cache', 'copy-js', 'browser-reload');
});
});
});

/***************************************************************************
Expand All @@ -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']);
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down