Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

Commit

Permalink
chore(*): add dev server with live reload and first demo page
Browse files Browse the repository at this point in the history
  • Loading branch information
philippd committed Mar 19, 2014
1 parent c74d230 commit ee7e20a
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,6 +2,7 @@
node_modules
bower_components
dist
demo/js
npm-debug.log
*.iml
.idea
57 changes: 48 additions & 9 deletions Gruntfile.js
Expand Up @@ -12,19 +12,19 @@ module.exports = function (grunt) {

meta: {
banner: '/**\n * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * <%= pkg.homepage %>\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' +
' * License: <%= pkg.license %>\n */\n'
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * <%= pkg.homepage %>\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' +
' * License: <%= pkg.license %>\n */\n'
},

build_dir: 'dist',

files: {

core: [
'src/model-validation-module.js',
'src/core/controller-demo.js'
'src/model-validation.js',
'src/core/demo-controller.js'
],

test: ['src/**/*.spec.js']
Expand Down Expand Up @@ -62,7 +62,7 @@ module.exports = function (grunt) {
},

core: {
src: ['src/model-validation.prefix', '<%= files.core %>', 'src/model-validation.suffix'],
src: ['js.prefix', '<%= files.core %>', 'js.suffix'],
dest: '<%= build_dir %>/angular-model-validation.js'
}

Expand Down Expand Up @@ -94,6 +94,38 @@ module.exports = function (grunt) {
singleRun: true,
browsers: ['Firefox']
}
},

copy: {

demo: {
files: [{
src: '*.js',
dest: 'demo/js/',
cwd: 'dist/',
expand: true
}]
}
},

watch: {
livereload: {
options: {
livereload: true
},
files: ['src/**/*.js'],
tasks: ['concat:core', 'concat:banner', 'uglify:core', 'copy:demo']
}
},

express: {
server: {
options: {
port: 3005,
bases: '.',
server: __dirname + '/server.js'
}
}
}
});

Expand All @@ -114,6 +146,13 @@ module.exports = function (grunt) {
]);

// For development purpose.
grunt.registerTask('dev', ['jshint', 'karma:unit', 'concat', 'watch:livereload']);
grunt.registerTask('server', ['express', 'express-keepalive']);
grunt.registerTask('dev', [
'build',
'copy:demo',
'watch:livereload'
]);
grunt.registerTask('server', [
'express',
'express-keepalive'
]);
};
16 changes: 16 additions & 0 deletions demo/demo-1.html
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
</head>
<body ng-app="nca.model-validation">

<div ng-controller="TestController">

</div>

<script src="/bower_components/angular/angular.js"></script>
<script src="js/angular-model-validation.js"></script>
<script src="http://localhost:35729/livereload.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions js.prefix
@@ -0,0 +1 @@
(function (window, document) {
File renamed without changes.
4 changes: 1 addition & 3 deletions karma.conf.js
@@ -1,5 +1,3 @@
// Karma configuration

module.exports = function (config) {
config.set({

Expand All @@ -10,7 +8,7 @@ module.exports = function (config) {
files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'src/model-validation-module.js',
'src/model-validation.js',
'src/**/*.js',
'src/**/*.spec.js'
],
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -24,6 +24,7 @@
"karma-phantomjs-launcher": "~0.1.2",
"grunt": "~0.4.4",
"grunt-karma": "~0.8.2",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.4.0",
Expand Down
20 changes: 20 additions & 0 deletions server.js
@@ -0,0 +1,20 @@
var express = require('express');

var app = express()
var server = require('http').createServer(app);

app.configure(function () {
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.errorHandler());
app.use(express.static(__dirname));
app.use(app.router);
});

module.exports = server;

// Override: Provide an "use" used by grunt-express.
module.exports.use = function () {
app.use.apply(app, arguments);
};
File renamed without changes.
@@ -1,6 +1,6 @@
'use strict';

describe('TestController', function () {
describe('DemoController', function () {
it('should do something', function () {
expect(true).toBe(true);
});
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion src/model-validation.prefix

This file was deleted.

File renamed without changes.

0 comments on commit ee7e20a

Please sign in to comment.