Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit 1185f4b

Browse files
committed
verified build and refactored
1 parent c97342f commit 1185f4b

14 files changed

+231
-282
lines changed

config/csslintrc.json renamed to .csslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"text-indent": false,
3232
"unique-headings": false,
3333
"universal-selector": false,
34-
"unqualified-attributes": false,
34+
"unqualified-attributes": true,
3535
"vendor-prefix": true,
3636
"zero-units": true
3737
}

.jshintrc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"bitwise": true,
3+
"laxcomma": true,
4+
"curly": true,
5+
"eqeqeq": true,
6+
"es3": true,
7+
"forin": true,
8+
"freeze": true,
9+
"futurehostile": true,
10+
"latedef": true,
11+
"noarg": true,
12+
"nocomma": true,
13+
"nonbsp": true,
14+
"nonew": true,
15+
"notypeof": true,
16+
"singleGroups": true,
17+
"strict": true,
18+
"undef": true,
19+
"unused": true,
20+
"plusplus": true
21+
}

Gruntfile.js

+26-128
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*global module, require*/
22
(function setUp(module, require) {
3-
43
'use strict';
54

65
var banner = ['/*!',
@@ -10,145 +9,44 @@
109
' * www.opensource.org/licenses/MIT',
1110
' *',
1211
' * <%= grunt.template.today("yyyy-mm-dd") %>',
13-
' */\n\n'].join('\n')
14-
, modRewrite = require('connect-modrewrite');
12+
' */\n\n'].join('\n');
1513

1614
module.exports = function doGrunt(grunt) {
15+
var confs = require('./tasks/confs')
16+
, jscs = require('./tasks/jscs')(grunt)
17+
, csslint = require('./tasks/csslint')(grunt)
18+
, eslint = require('./tasks/eslint')(grunt)
19+
, uglify = require('./tasks/uglify')(banner, grunt)
20+
, cssmin = require('./tasks/cssmin')(banner, grunt)
21+
, connect = require('./tasks/connect')(grunt)
22+
, watch = require('./tasks/watch')(grunt)
23+
, concurrent = require('./tasks/concurrent')(grunt);
1724

1825
grunt.initConfig({
1926
'pkg': grunt.file.readJSON('package.json'),
20-
'confs': {
21-
'dist': 'dist',
22-
'config': 'config',
23-
'css': 'src/css',
24-
'js': 'src/js',
25-
'serverPort': 8000
26-
},
27-
'csslint': {
28-
'options': {
29-
'csslintrc': '<%= confs.config %>/csslintrc.json'
30-
},
31-
'strict': {
32-
'src': [
33-
'<%= confs.css %>/**/*.css'
34-
]
35-
}
36-
},
37-
'eslint': {
38-
'options': {
39-
'config': '<%= confs.config %>/eslint.json'
40-
},
41-
'target': [
42-
'Gruntfile.js',
43-
'<%= confs.js %>/**/*.js'
44-
]
45-
},
46-
'uglify': {
47-
'options': {
48-
'sourceMap': true,
49-
'sourceMapName': '<%= confs.dist %>/angular-datepicker.sourcemap.map',
50-
'preserveComments': false,
51-
'report': 'gzip',
52-
'banner': banner
53-
},
54-
'minifyTarget': {
55-
'files': {
56-
'<%= confs.dist %>/angular-datepicker.min.js': [
57-
'<%= confs.js %>/angular-datepicker.js'
58-
]
59-
}
60-
}
61-
},
62-
'cssmin': {
63-
'options': {
64-
'report': 'gzip',
65-
'banner': banner
66-
},
67-
'minifyTarget': {
68-
'files': {
69-
'<%= confs.dist %>/angular-datepicker.min.css': [
70-
'<%= confs.css %>/angular-datepicker.css'
71-
]
72-
}
73-
}
74-
},
75-
'connect': {
76-
'server': {
77-
'options': {
78-
'port': '<%= confs.serverPort %>',
79-
'base': '.',
80-
'keepalive': true,
81-
'middleware': function manageMiddlewares(connect, options) {
82-
var middlewares = []
83-
, directory = options.directory || options.base[options.base.length - 1];
84-
85-
// enable Angular's HTML5 mode
86-
middlewares.push(modRewrite(['!\\.html|\\.js|\\.svg|\\.css|\\.png|\\.gif$ /index.html [L]']));
87-
88-
if (!Array.isArray(options.base)) {
89-
options.base = [options.base];
90-
}
91-
options.base.forEach(function forEachOption(base) {
92-
// Serve static files.
93-
middlewares.push(connect.static(base));
94-
});
95-
96-
// Make directory browse-able.
97-
middlewares.push(connect.directory(directory));
98-
99-
return middlewares;
100-
}
101-
}
102-
}
103-
},
104-
'watch': {
105-
'dev': {
106-
'files': [
107-
'Gruntfile.js',
108-
'<%= confs.css %>/**/*.css',
109-
'<%= confs.js %>/**/*.js'
110-
],
111-
'tasks': [
112-
'csslint',
113-
'eslint'
114-
],
115-
'options': {
116-
'spawn': false
117-
}
118-
}
119-
},
120-
'concurrent': {
121-
'dev': {
122-
'tasks': [
123-
'connect:server',
124-
'watch:dev'
125-
],
126-
'options': {
127-
'limit': '<%= concurrent.dev.tasks.length %>',
128-
'logConcurrentOutput': true
129-
}
130-
}
131-
}
27+
'confs': confs,
28+
'jscs': jscs,
29+
'csslint': csslint,
30+
'eslint': eslint,
31+
'uglify': uglify,
32+
'cssmin': cssmin,
33+
'connect': connect,
34+
'watch': watch,
35+
'concurrent': concurrent
13236
});
13337

134-
grunt.loadNpmTasks('grunt-contrib-csslint');
135-
grunt.loadNpmTasks('grunt-eslint');
136-
grunt.loadNpmTasks('grunt-contrib-uglify');
137-
grunt.loadNpmTasks('grunt-contrib-cssmin');
138-
139-
grunt.loadNpmTasks('grunt-concurrent');
140-
grunt.loadNpmTasks('grunt-contrib-connect');
141-
grunt.loadNpmTasks('grunt-contrib-watch');
142-
14338
grunt.registerTask('default', [
144-
'csslint',
145-
'eslint',
39+
'lint',
14640
'concurrent:dev'
14741
]);
14842

149-
grunt.registerTask('prod', [
43+
grunt.registerTask('lint', [
15044
'csslint',
151-
'eslint',
45+
'eslint'
46+
]);
47+
48+
grunt.registerTask('prod', [
49+
'lint',
15250
'cssmin',
15351
'uglify'
15452
]);

config/eslint.json

-152
This file was deleted.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"grunt-contrib-cssmin": "*",
3030
"grunt-contrib-uglify": "*",
3131
"grunt-contrib-watch": "*",
32-
"grunt-eslint": "*"
32+
"grunt-eslint": "*",
33+
"grunt-jscs": "*"
3334
},
3435
"author": {
3536
"name": "Filippo Oretti",

tasks/concurrent.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*global module*/
2+
(function setUp(module) {
3+
'use strict';
4+
5+
module.exports = function exportingFunction(grunt) {
6+
7+
grunt.loadNpmTasks('grunt-concurrent');
8+
return {
9+
'dev': {
10+
'tasks': [
11+
'connect:server',
12+
'watch:dev'
13+
],
14+
'options': {
15+
'limit': '<%= concurrent.dev.tasks.length %>',
16+
'logConcurrentOutput': true
17+
}
18+
}
19+
};
20+
};
21+
}(module));

0 commit comments

Comments
 (0)