mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-02-16 11:27:00 +01:00
feat(build): Wiredep task for grunt and gulp (#1402)
* Fix(grunt): remove redundant grunt task loading remove explicit grunt task loading for `grunt-protactor-coverage` as `load-grunt-tasks` handles it * Feat(grunt): add wiredep task for grunt Automatically update bower dependencies. * Fix(grunt-wiredep):Remove trailing comma from assets Remove trailing comma from assets configuration generated by wiredep * Fix(gulp): Remove trailing comma from asset files Remove trailing comma from asset configurations generated by wiredep * Fix(npm): use tilde ranges * Fix(gulp): use wiredep instead of gulp-wiredep Fixes #1398 * Fix(grunt): use wiredep instead of grunt-wiredep * Fix(lint): suppress eslint errors in asset files Fixes #1402
This commit is contained in:
@@ -1,24 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint comma-dangle:[0, "only-multiline"] */
|
||||
|
||||
module.exports = {
|
||||
client: {
|
||||
lib: {
|
||||
css: [
|
||||
// bower:css
|
||||
'public/lib/bootstrap/dist/css/bootstrap.css',
|
||||
'public/lib/bootstrap/dist/css/bootstrap-theme.css'
|
||||
'public/lib/bootstrap/dist/css/bootstrap-theme.css',
|
||||
// endbower
|
||||
],
|
||||
js: [
|
||||
// bower:js
|
||||
'public/lib/angular/angular.js',
|
||||
'public/lib/angular-resource/angular-resource.js',
|
||||
'public/lib/angular-animate/angular-animate.js',
|
||||
'public/lib/angular-messages/angular-messages.js',
|
||||
'public/lib/angular-ui-router/release/angular-ui-router.js',
|
||||
'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
|
||||
'public/lib/angular-file-upload/dist/angular-file-upload.js',
|
||||
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js'
|
||||
'public/lib/angular-file-upload/dist/angular-file-upload.min.js',
|
||||
'public/lib/angular-messages/angular-messages.js',
|
||||
'public/lib/angular-mocks/angular-mocks.js',
|
||||
'public/lib/angular-resource/angular-resource.js',
|
||||
'public/lib/angular-ui-router/release/angular-ui-router.js',
|
||||
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
|
||||
// endbower
|
||||
],
|
||||
tests: ['public/lib/angular-mocks/angular-mocks.js']
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint comma-dangle:[0, "only-multiline"] */
|
||||
|
||||
module.exports = {
|
||||
client: {
|
||||
lib: {
|
||||
css: [
|
||||
// bower:css
|
||||
'public/lib/bootstrap/dist/css/bootstrap.min.css',
|
||||
'public/lib/bootstrap/dist/css/bootstrap-theme.min.css'
|
||||
'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
|
||||
// endbower
|
||||
],
|
||||
js: [
|
||||
// bower:js
|
||||
'public/lib/angular/angular.min.js',
|
||||
'public/lib/angular-resource/angular-resource.min.js',
|
||||
'public/lib/angular-animate/angular-animate.min.js',
|
||||
'public/lib/angular-messages/angular-messages.min.js',
|
||||
'public/lib/angular-ui-router/release/angular-ui-router.min.js',
|
||||
'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js',
|
||||
'public/lib/angular-file-upload/dist/angular-file-upload.min.js',
|
||||
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js'
|
||||
'public/lib/angular-messages/angular-messages.min.js',
|
||||
'public/lib/angular-mocks/angular-mocks.js',
|
||||
'public/lib/angular-resource/angular-resource.min.js',
|
||||
'public/lib/angular-ui-router/release/angular-ui-router.min.js',
|
||||
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
|
||||
// endbower
|
||||
]
|
||||
},
|
||||
|
||||
41
gruntfile.js
41
gruntfile.js
@@ -8,7 +8,8 @@ var _ = require('lodash'),
|
||||
testAssets = require('./config/assets/test'),
|
||||
testConfig = require('./config/env/test'),
|
||||
fs = require('fs'),
|
||||
path = require('path');
|
||||
path = require('path'),
|
||||
wiredep = require('wiredep');
|
||||
|
||||
module.exports = function (grunt) {
|
||||
// Project Configuration
|
||||
@@ -74,6 +75,34 @@ module.exports = function (grunt) {
|
||||
}
|
||||
}
|
||||
},
|
||||
wiredep: {
|
||||
fileTypes: {
|
||||
src: 'config/assets/default.js',
|
||||
ignorePath: '../../',
|
||||
js: {
|
||||
replace: {
|
||||
css: function (filePath) {
|
||||
var minFilePath = filePath.replace('.css', '.min.css');
|
||||
var fullPath = path.join(process.cwd(), minFilePath);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
return '\'' + filePath + '\',';
|
||||
} else {
|
||||
return '\'' + minFilePath + '\',';
|
||||
}
|
||||
},
|
||||
js: function (filePath) {
|
||||
var minFilePath = filePath.replace('.js', '.min.js');
|
||||
var fullPath = path.join(process.cwd(), minFilePath);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
return '\'' + filePath + '\',';
|
||||
} else {
|
||||
return '\'' + minFilePath + '\',';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
nodemon: {
|
||||
dev: {
|
||||
script: 'server.js',
|
||||
@@ -228,7 +257,6 @@ module.exports = function (grunt) {
|
||||
|
||||
// Load NPM tasks
|
||||
require('load-grunt-tasks')(grunt);
|
||||
grunt.loadNpmTasks('grunt-protractor-coverage');
|
||||
|
||||
// Make sure upload directory exists
|
||||
grunt.task.registerTask('mkdir:upload', 'Task that makes sure upload directory exists.', function () {
|
||||
@@ -288,8 +316,15 @@ module.exports = function (grunt) {
|
||||
// Lint CSS and JavaScript files.
|
||||
grunt.registerTask('lint', ['sass', 'less', 'eslint', 'csslint']);
|
||||
|
||||
grunt.registerMultiTask('wiredep', 'Inject Bower dependencies.', function () {
|
||||
this.requiresConfig(['wiredep', this.target, 'src']);
|
||||
|
||||
var options = this.options(this.data);
|
||||
wiredep(options);
|
||||
});
|
||||
|
||||
// Lint project files and minify them into two production files.
|
||||
grunt.registerTask('build', ['env:dev', 'lint', 'ngAnnotate', 'uglify', 'cssmin']);
|
||||
grunt.registerTask('build', ['env:dev', 'wiredep', 'lint', 'ngAnnotate', 'uglify', 'cssmin']);
|
||||
|
||||
// Run the project tests
|
||||
grunt.registerTask('test', ['env:test', 'lint', 'mkdir:upload', 'copy:localConfig', 'server', 'mochaTest', 'karma:unit', 'protractor']);
|
||||
|
||||
@@ -17,6 +17,7 @@ var _ = require('lodash'),
|
||||
}
|
||||
}),
|
||||
pngquant = require('imagemin-pngquant'),
|
||||
wiredep = require('wiredep').stream,
|
||||
path = require('path'),
|
||||
endOfLine = require('os').EOL,
|
||||
protractor = require('gulp-protractor').protractor,
|
||||
@@ -199,7 +200,7 @@ gulp.task('imagemin', function () {
|
||||
// wiredep task to default
|
||||
gulp.task('wiredep', function () {
|
||||
return gulp.src('config/assets/default.js')
|
||||
.pipe(plugins.wiredep({
|
||||
.pipe(wiredep({
|
||||
ignorePath: '../../'
|
||||
}))
|
||||
.pipe(gulp.dest('config/assets/'));
|
||||
@@ -208,7 +209,7 @@ gulp.task('wiredep', function () {
|
||||
// wiredep task to production
|
||||
gulp.task('wiredep:prod', function () {
|
||||
return gulp.src('config/assets/production.js')
|
||||
.pipe(plugins.wiredep({
|
||||
.pipe(wiredep({
|
||||
ignorePath: '../../',
|
||||
fileTypes: {
|
||||
js: {
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
"glob": "~7.0.0",
|
||||
"grunt": "~1.0.1",
|
||||
"grunt-cli": "~1.2.0",
|
||||
"gulp-wiredep": "~0.0.0",
|
||||
"helmet": "~1.3.0",
|
||||
"jasmine-core": "~2.4.1",
|
||||
"lodash": "~4.6.1",
|
||||
@@ -76,7 +75,8 @@
|
||||
"socket.io": "~1.4.5",
|
||||
"swig": "~1.4.2",
|
||||
"validator": "~5.1.0",
|
||||
"winston": "^2.2.0"
|
||||
"winston": "^2.2.0",
|
||||
"wiredep": "~4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coveralls": "~2.11.6",
|
||||
|
||||
Reference in New Issue
Block a user