Skip to content

Commit 329422f

Browse files
committed
move from supervisor to nodemon (more flexible ignore allows to ignore hmvc/*/client)
1 parent 06d0380 commit 329422f

10 files changed

Lines changed: 86 additions & 53 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ out/*
3030

3131
# Generated content
3232
public/*
33-
client/styles/sprites/*
33+
styles/sprites/*
3434

3535
# Bower stuff.
3636
bower_components/

bin/server

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env node
2-
'use strict';
32

43
const log = require('js-log')();
54
const config = require('config');

client/delegate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ function delegate(topElement, selector, eventName, handler) {
2424
topElement.addEventListener(eventName, function(event) {
2525
var found = findDelegateTarget(event, selector);
2626

27-
// currentTarget is read only, I can not overwrite it to the "found" element
27+
// .currentTarget is read only, I can not overwrite it to the "found" element
2828
// Object.create wrapper would break event.preventDefault()
2929
// so, keep in mind:
3030
// --> event.currentTarget is always the top-level (delegating) element!
3131
// use "this" to get the found target
3232

33-
event.delegateTarget = event.currentTarget; // for compat. with jQuery
33+
event.delegateTarget = this; // use instead of this in object methods
3434

3535
if (found) {
3636
handler.call(found, event);

client/modal.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function Modal() {
2+
3+
}
4+
5+
Modal.prototype.getElement = function() {
6+
if (!this.elem) this.render();
7+
return this.elem;
8+
};
9+
10+
Modal.prototype.render = function() {
11+
var elem = this.elem = document.createElement('div');
12+
elem.className = 'modal';
13+
this.contentElem = document.createElement('div');
14+
this.contentElem.className = 'modal-dialog';
15+
elem.appendChild(this.contentElem);
16+
};
17+
18+
Modal.prototype.setContent = function(html) {
19+
this.contentElem.innerHTML = html;
20+
};
21+
22+
Modal.prototype.show = function() {
23+
document.body.appendChild(this.getElement());
24+
};
25+
26+
Modal.prototype.hide = function() {
27+
this.elem.remove();
28+
};
29+
30+
31+
module.exports = Modal;

gulpfile.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const gulp = require('gulp');
77
const path = require('path');
88
const fs = require('fs');
99
const assert = require('assert');
10-
const config = require('config');
1110
const development = (process.env.NODE_ENV == 'development');
1211

1312
const jsSources = [
@@ -43,7 +42,11 @@ gulp.task('lint', ['lint-once'], wrapWatch(jsSources, 'lint'));
4342
// usage: gulp loaddb --db fixture/db
4443
gulp.task('loaddb', lazyRequireTask('./tasks/loadDb'));
4544

46-
gulp.task("supervisor", ['link-modules'], lazyRequireTask('./tasks/supervisor', { cmd: "./bin/server", watch: ["hmvc", "modules"] }));
45+
gulp.task("nodemon", ['link-modules'], lazyRequireTask('./tasks/nodemon', {
46+
script: "./bin/server",
47+
ignore: '**/client/', // ignore hmvc apps client code
48+
watch: ["hmvc", "modules"]
49+
}));
4750

4851
gulp.task("client:livereload", lazyRequireTask("./tasks/livereload", { watch: "public/**/*.*" }));
4952

@@ -95,7 +98,7 @@ gulp.task('client:minify', lazyRequireTask('./tasks/minify', {
9598
}));
9699

97100

98-
gulp.task('client:compile-css', ['client:compile-css-once'], wrapWatch(["styles/**/*.styl","styles/**/*.sprite/**"], "client:compile-css-once"));
101+
gulp.task('client:compile-css', ['client:compile-css-once'], wrapWatch(["styles/**/*.styl", "styles/**/*.sprite/**"], "client:compile-css-once"));
99102

100103

101104
gulp.task("client:browserify:clean", lazyRequireTask('./tasks/browserifyClean', { dst: './public/js'}));
@@ -107,10 +110,10 @@ gulp.task("client:browserify", ['client:browserify:clean'], lazyRequireTask('./t
107110
// compile-css and sprites are independant tasks
108111
// run both or run *-once separately
109112
gulp.task('run', [
110-
'supervisor', 'client:livereload',
113+
'nodemon', 'client:livereload',
111114
"client:sync-resources", 'client:compile-css', 'client:browserify', 'client:sync-css-images']);
112115

113116
gulp.task('tutorial:import', lazyRequireTask('tutorial/tasks/import', {
114-
root: path.join(config.projectRoot, 'javascript-tutorial'),
117+
root: 'javascript-tutorial',
115118
updateFiles: true // skip same size files
116119
}));

hmvc/auth/client/login.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var xhr = require('client/xhr');
22
var delegate = require('client/delegate');
3+
var Modal = require('client/modal');
34

45
// Run like this:
56
// login()
@@ -8,12 +9,11 @@ var delegate = require('client/delegate');
89
module.exports = function(options, authCallback) {
910
options = options || {};
1011

11-
var authModal = document.createElement('div');
12-
authModal.className = "auth-modal";
13-
14-
authModal.innerHTML = '<div class="progress large"></div>';
15-
document.body.append(authModal);
12+
var modal = new Modal();
1613

14+
modal.setContent('<div class="progress large"></div>');
15+
modal.show();
16+
/*
1717
var request = xhr({ url: '/auth/login-register-form' });
1818
request.addEventListener('success', function(event) {
1919
authModal.innerHTML = event.result;
@@ -26,7 +26,7 @@ module.exports = function(options, authCallback) {
2626
});
2727
2828
request.send();
29-
29+
*/
3030
};
3131

3232
function initAuthModal(authCallback) {
@@ -87,6 +87,7 @@ function initAuthLogin(authCallback) {
8787

8888
}
8989

90+
/*
9091
document.on('click', '[data-action-verify-email]', function(event) {
9192
event.preventDefault();
9293
var request = xhr({method: 'POST', url: '/auth/verify-email'});
@@ -97,6 +98,7 @@ document.on('click', '[data-action-verify-email]', function(event) {
9798
request.send(JSON.stringify({email: this.dataset.actionVerifyEmail}));
9899
99100
});
101+
*/
100102

101103

102104
function openAuthPopup(url) {

hmvc/tutorial/tasks/import.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const gm = require('gm');
2626
* @returns {Function}
2727
*/
2828
module.exports = function(options) {
29-
const root = options.root;
29+
const root = path.join(config.projectRoot, options.root);
3030

3131
return function(callback) {
3232

package.json

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
"private": true,
55
"scripts": {
66
"prod": "NODE_ENV=production node --harmony ./bin/server",
7-
"dev": "NODE_ENV=development supervisor --harmony --debug --ignore node_modules ./bin/server",
8-
"debug": "NODE_ENV=development supervisor --harmony --debug-brk --ignore node_modules ./bin/server",
9-
"test": "NODE_ENV=test supervisor --harmony --debug --ignore node_modules ./bin/server",
10-
"fixperms": "chown -R `id -u` . * ~/.npm ~/.node-gyp"
7+
"fixperms": "sudo chown -R `id -u` . * ~/.npm ~/.node-gyp"
118
},
129
"precommit": "NODE_ENV=development node --harmony `which gulp` pre-commit",
1310
"dependencies": {
@@ -19,7 +16,7 @@
1916
"factor-bundle": "*",
2017
"fs-extra": "*",
2118
"glob": "*",
22-
"gm": "^1.16.0",
19+
"gm": "*",
2320
"gulp-cache": "*",
2421
"gulp-concat": "*",
2522
"gulp-debug": "*",
@@ -29,23 +26,24 @@
2926
"gulp-jshint-cache": "*",
3027
"gulp-load-plugins": "*",
3128
"gulp-newer": "*",
29+
"gulp-nodemon": "^1.0.4",
3230
"gulp-notify": "*",
3331
"gulp-plumber": "*",
3432
"gulp-rimraf": "*",
3533
"gulp-stylus": "*",
3634
"gulp-util": "*",
3735
"gulp.spritesmith": "*",
38-
"humane-js": "^3.1.0",
39-
"image-size": "^0.3.2",
36+
"humane-js": "*",
37+
"image-size": "*",
4038
"imagemin": "*",
4139
"imagemin-pngcrush": "*",
4240
"imagemin-svgo": "*",
43-
"inherits": "^2.0.1",
41+
"inherits": "*",
4442
"jade": "*",
4543
"javascript-parser": "*",
4644
"jquery": "*",
4745
"js-log": "*",
48-
"juice2": "^1.3.0",
46+
"juice2": "*",
4947
"koa": "*",
5048
"koa-compose": "*",
5149
"koa-csrf": "*",
@@ -70,18 +68,19 @@
7068
"nib": "*",
7169
"nodemailer": "*",
7270
"nodemailer-ses-transport": "*",
71+
"nodemon": "^1.2.1",
7372
"passport": "*",
74-
"passport-facebook": "^1.0.3",
75-
"passport-github": "^0.1.5",
76-
"passport-google": "^0.3.0",
77-
"passport-google-oauth": "^0.1.5",
78-
"passport-google-plus": "^0.2.0",
73+
"passport-facebook": "*",
74+
"passport-github": "*",
75+
"passport-google": "*",
76+
"passport-google-oauth": "*",
77+
"passport-google-plus": "*",
7978
"passport-local": "*",
80-
"passport-vkontakte": "^0.2.1",
81-
"passport-yandex": "0.0.2",
79+
"passport-vkontakte": "*",
80+
"passport-yandex": "*",
8281
"path-to-regexp": "*",
8382
"prismjs": "git://github.com/LeaVerou/prism#gh-pages",
84-
"request": "^2.39.0",
83+
"request": "*",
8584
"stylus": "*",
8685
"svgutils": "*",
8786
"through2": "*",
@@ -92,7 +91,7 @@
9291
"yargs": "*"
9392
},
9493
"devDependencies": {
95-
"better-assert": "^1.0.1",
94+
"better-assert": "*",
9695
"browserify": "*",
9796
"clarify": "*",
9897
"co-mocha": "*",
@@ -104,16 +103,14 @@
104103
"gulp-mocha": "*",
105104
"gulp-sourcemaps": "*",
106105
"gulp-stylus-sprite": "*",
107-
"gulp-supervisor": "*",
108106
"lazypipe": "*",
109107
"mocha": "*",
110108
"node-notifier": "*",
111-
"nodemailer-stub-transport": "^0.1.4",
109+
"nodemailer-stub-transport": "*",
112110
"should": "*",
113111
"sinon": "*",
114112
"superagent": "*",
115113
"supertest": "*",
116-
"supervisor": "*",
117114
"trace": "*",
118115
"watchify": "*"
119116
},

tasks/nodemon.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const gp = require('gulp-load-plugins')();
2+
3+
module.exports = function(options) {
4+
5+
var opts = {
6+
ext: "js",
7+
nodeArgs: ['--debug', '--harmony']
8+
};
9+
10+
for (var key in options) {
11+
opts[key] = options[key];
12+
}
13+
14+
return function(callback) {
15+
gp.nodemon(opts);
16+
};
17+
};

tasks/supervisor.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)