Skip to content
This repository was archived by the owner on May 25, 2019. It is now read-only.

Commit cc98697

Browse files
committed
chore(grunt): update all about the grunt
1 parent a144e2f commit cc98697

File tree

6 files changed

+58
-64
lines changed

6 files changed

+58
-64
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
bower_components/
22
node_modules/
33
out/
4+
dist/

.jshintrc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"immed": true,
3+
"newcap": true,
4+
"noarg": true,
5+
"noempty": true,
6+
"nonew": true,
7+
"trailing": true,
8+
"maxlen": 200,
9+
"boss": true,
10+
"eqnull": true,
11+
"expr": true,
12+
"globalstrict": true,
13+
"laxbreak": true,
14+
"loopfunc": true,
15+
"sub": true,
16+
"undef": true,
17+
"browser": true,
18+
"quotmark": true,
19+
"globals": {
20+
"module" : false,
21+
"angular" : false,
22+
"require" : false,
23+
"process" : false
24+
}
25+
}

gruntFile.js

Lines changed: 29 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
module.exports = function (grunt) {
22
'use strict';
33

4-
var _ = grunt.util._;
5-
64
require('load-grunt-tasks')(grunt);
75

86
// Default task.
97
grunt.registerTask('default', ['jshint', 'karma:unit']);
108
grunt.registerTask('serve', ['connect:continuous', 'karma:continuous', 'watch']);
11-
grunt.registerTask('build-doc', ['uglify', 'copy']);
9+
grunt.registerTask('dist', ['ngmin', 'uglify']);
1210

1311
// HACK TO ACCESS TO THE COMPONENT-PUBLISHER
1412
function fakeTargetTask(prefix){
@@ -35,19 +33,6 @@ module.exports = function (grunt) {
3533
return grunt.util._.extend(options, customOptions, travisOptions);
3634
};
3735

38-
var js_dependencies =[
39-
'<%= bower %>/angular-ui-bootstrap-bower/ui-bootstrap-tpls.min.js',
40-
'<%= bower %>/codemirror/lib/codemirror.js',
41-
'<%= bower %>/codemirror/mode/scheme/scheme.js',
42-
'<%= bower %>/codemirror/mode/javascript/javascript.js',
43-
'<%= bower %>/codemirror/mode/xml/xml.js',
44-
];
45-
46-
var css_dependencies = [
47-
'<%= bower %>/codemirror/lib/codemirror.css',
48-
'<%= bower %>/codemirror/theme/twilight.css'
49-
];
50-
5136
// Project configuration.
5237
grunt.initConfig({
5338
bower: 'bower_components',
@@ -60,26 +45,24 @@ module.exports = function (grunt) {
6045
' * @link <%= pkg.homepage %>',
6146
' * @license <%= pkg.license %>',
6247
' */',
63-
''].join('\n'),
64-
view : {
65-
humaName : 'UI CodeMirror',
66-
repoName : 'ui-codemirror',
67-
demoHTML : grunt.file.read('demo/demo.html'),
68-
demoJS : grunt.file.read('demo/demo.js'),
69-
css: css_dependencies.concat(['assets/css/demo.css']),
70-
js : js_dependencies.concat(['build/ui-codemirror.min.js'])
71-
}
48+
''].join('\n')
7249
},
50+
7351
watch: {
52+
src: {
53+
files: ['src/*'],
54+
tasks: ['jshint', 'karma:unit:run', 'dist', 'build:gh-pages']
55+
},
7456
test: {
75-
files: ['<%= meta.view.repoName %>.js', 'test/*.js'],
57+
files: ['test/*.js'],
7658
tasks: ['jshint', 'karma:unit:run']
7759
},
7860
demo: {
79-
files: ['demo/*', '<%= meta.view.repoName %>.js'],
80-
tasks: ['uglify', 'copy']
61+
files: ['demo/*'],
62+
tasks: ['build:gh-pages']
8163
}
8264
},
65+
8366
karma: {
8467
unit: testConfig('test/karma.conf.js'),
8568
server: {configFile: 'test/karma.conf.js'},
@@ -88,58 +71,41 @@ module.exports = function (grunt) {
8871

8972
connect: {
9073
options: {
91-
base : '<%= dist %>',
74+
base : 'out/built/gh-pages',
9275
port: grunt.option('port') || '8000',
9376
hostname: grunt.option('host') || 'localhost',
94-
open : true
77+
open: 'http://<%= connect.options.hostname %>:<%= connect.options.port %>',
78+
livereload: grunt.option('port') || '8000'
9579
},
9680
server: { options: { keepalive: true } },
9781
continuous: { options: { keepalive: false } }
9882
},
9983

10084
jshint:{
101-
all:['<%= meta.view.repoName %>.js', 'gruntFile.js','test/*.js', 'demo/*.js'],
102-
options:{
103-
curly:true,
104-
eqeqeq:true,
105-
immed:true,
106-
latedef:true,
107-
newcap:true,
108-
noarg:true,
109-
sub:true,
110-
boss:true,
111-
eqnull:true,
112-
globals:{}
113-
}
85+
files:['src/*.js', 'demo/**/*.js', 'gruntFile.js'],
86+
options: { jshintrc: '.jshintrc' }
11487
},
88+
11589
uglify: {
11690
options: {banner: '<%= meta.banner %>'},
11791
build: {
118-
files: {
119-
'<%= dist %>/build/<%= meta.view.repoName %>.min.js': ['<%= meta.view.repoName %>.js']
120-
}
92+
expand: true,
93+
cwd: 'dist',
94+
src: ['*.js'],
95+
ext: '.min.js',
96+
dest: 'dist'
12197
}
12298
},
123-
copy: {
99+
100+
ngmin: {
124101
main: {
125-
files: [
126-
{src: ['<%= meta.view.repoName %>.js'], dest: '<%= dist %>/build/<%= meta.view.repoName %>.js', filter: 'isFile'}
127-
]
128-
},
129-
template : {
130-
options : {processContent : function(content){
131-
return grunt.template.process(content);
132-
}},
133-
files: [
134-
{src: ['<%= dist %>/.tmpl/index.tmpl'], dest: '<%= dist %>/index.html'},
135-
{src: ['demo/demo.css'], dest: '<%= dist %>/assets/css/demo.css'}
136-
]
137-
.concat(
138-
_.map(js_dependencies.concat(css_dependencies), function (f) {
139-
return {src: [f], dest: '<%= dist %>/' + f, filter: 'isFile'};
140-
}))
102+
expand: true,
103+
cwd: 'src',
104+
src: ['*.js'],
105+
dest: 'dist'
141106
}
142107
},
108+
143109
changelog: {
144110
options: {
145111
dest: 'CHANGELOG.md'

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
"devDependencies": {
1111
"component-publisher": "douglasduteil/component-publisher",
1212
"grunt": "~0.4.2",
13+
"grunt-contrib-connect": "~0.5.0",
1314
"grunt-contrib-copy": "~0.4.1",
1415
"grunt-contrib-jshint": "~0.7.2",
1516
"grunt-contrib-uglify": "~0.2.7",
1617
"grunt-contrib-watch": "~0.5.3",
1718
"grunt-conventional-changelog": "~1.0.0",
1819
"grunt-karma": "~0.6.2",
20+
"grunt-ngmin": "0.0.3",
1921
"karma": "~0.10.8",
2022
"karma-chrome-launcher": "~0.1.1",
2123
"karma-coffee-preprocessor": "~0.1.1",
File renamed without changes.

test/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function(config) {
1717
'bower_components/angular/angular.js',
1818
'bower_components/angular-mocks/angular-mocks.js',
1919
'bower_components/codemirror/lib/codemirror.js',
20-
'ui-codemirror.js',
20+
'src/ui-codemirror.js',
2121
'test/*.spec.js'
2222
],
2323

0 commit comments

Comments
 (0)