diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2018-05-24 12:06:58 -0700 |
---|---|---|
committer | Gunnar Mills <gmills@us.ibm.com> | 2018-05-25 09:27:02 -0500 |
commit | 7d6e62998fac2d905d17c1dbececb403a9ab8bdb (patch) | |
tree | b2bf135aa53bf441c50918e89327a5f2e86a25f9 /gulp_tasks | |
parent | b3d48d425e8b673071c6369ca0ea639fcb8a5af4 (diff) | |
download | phosphor-webui-7d6e62998fac2d905d17c1dbececb403a9ab8bdb.tar.gz phosphor-webui-7d6e62998fac2d905d17c1dbececb403a9ab8bdb.zip |
Add format-code.sh to run special clang verify
The phosphor-webui repo requires only certain directories
be verified with clang-format. This script utilizes the
override capabilities of the format-code.sh CI process
to handle this.
Change-Id: Icb759a7d94d2b007fa88261dacc39913b1076a0a
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'gulp_tasks')
-rw-r--r-- | gulp_tasks/checkstyle.js | 37 | ||||
-rw-r--r-- | gulp_tasks/distribution.js | 55 | ||||
-rw-r--r-- | gulp_tasks/minifyvendors.js | 38 | ||||
-rw-r--r-- | gulp_tasks/server.js | 26 | ||||
-rw-r--r-- | gulp_tasks/webapp.js | 158 |
5 files changed, 139 insertions, 175 deletions
diff --git a/gulp_tasks/checkstyle.js b/gulp_tasks/checkstyle.js index bd76a8b..0826352 100644 --- a/gulp_tasks/checkstyle.js +++ b/gulp_tasks/checkstyle.js @@ -3,29 +3,28 @@ 'use strict'; -var options = require('../gulp-options.js'), - gulp = require('gulp'), - clean = require('gulp-clean'), - eslint = require('gulp-eslint'); +var options = require('../gulp-options.js'), gulp = require('gulp'), + clean = require('gulp-clean'), eslint = require('gulp-eslint'); -var runSequence = require('run-sequence'), - fs = require('fs'); +var runSequence = require('run-sequence'), fs = require('fs'); -gulp.task('checkstyle:clean', function () { - return gulp - .src([options.targetFolderPath + '/eslint-report-checkstyle.xml'], {'read': false}) - .pipe(clean({'force': true})); +gulp.task('checkstyle:clean', function() { + return gulp + .src( + [options.targetFolderPath + '/eslint-report-checkstyle.xml'], + {'read': false}) + .pipe(clean({'force': true})); }); -gulp.task('checkstyle:eslint', function () { - return gulp - .src([options.srcFolderPath + '/**/*.js', options.excludePath]) - .pipe(eslint({'useEslintrc': true})) - .pipe(eslint.format('checkstyle', function (output) { - fs.writeFileSync(options.targetFolderPath + '/eslint-report-checkstyle.xml', output); - })); +gulp.task('checkstyle:eslint', function() { + return gulp.src([options.srcFolderPath + '/**/*.js', options.excludePath]) + .pipe(eslint({'useEslintrc': true})) + .pipe(eslint.format('checkstyle', function(output) { + fs.writeFileSync( + options.targetFolderPath + '/eslint-report-checkstyle.xml', output); + })); }); -module.exports = function (callback) { - return runSequence('checkstyle:clean', 'checkstyle:eslint', callback); +module.exports = function(callback) { + return runSequence('checkstyle:clean', 'checkstyle:eslint', callback); }; diff --git a/gulp_tasks/distribution.js b/gulp_tasks/distribution.js index ec5aac0..c732eab 100644 --- a/gulp_tasks/distribution.js +++ b/gulp_tasks/distribution.js @@ -3,43 +3,40 @@ 'use strict'; -var options = require('../gulp-options.js'), - gulp = require('gulp'), - clean = require('gulp-clean'), - webapp = require('./webapp.js'), +var options = require('../gulp-options.js'), gulp = require('gulp'), + clean = require('gulp-clean'), webapp = require('./webapp.js'), imagemin = require('gulp-imagemin'); var runSequence = require('run-sequence'); -gulp.task('webapp', function (callback) { - return webapp(callback); +gulp.task('webapp', function(callback) { + return webapp(callback); }); -gulp.task('distribution:clean', function () { - return gulp - .src([options.dirname + '/dist'], { 'read': false }) - .pipe(clean({'force': true})); +gulp.task('distribution:clean', function() { + return gulp.src([options.dirname + '/dist'], {'read': false}).pipe(clean({ + 'force': true + })); }); -gulp.task('distribution:copy', function () { - return gulp - .src(['**/*'], { 'cwd': options.targetFolderPath + '/webapp' }) - .pipe(gulp.dest(options.dirname + '/dist')); +gulp.task('distribution:copy', function() { + return gulp.src(['**/*'], {'cwd': options.targetFolderPath + '/webapp'}) + .pipe(gulp.dest(options.dirname + '/dist')); }); -gulp.task('imagemin', () => - gulp.src([options.dirname + '/app/assets/images/*']) - .pipe(imagemin({ - optimizationLevel: 3, - progressive: true, - interlaced: false, - svgoPlugins: [{ - removeViewBox: false - }] - })) - .pipe(gulp.dest('dist/assets/images')) -); - -module.exports = function (callback) { - return runSequence('distribution:clean', 'webapp', 'distribution:copy', 'imagemin', callback); +gulp.task( + 'imagemin', + () => gulp.src([options.dirname + '/app/assets/images/*']) + .pipe(imagemin({ + optimizationLevel: 3, + progressive: true, + interlaced: false, + svgoPlugins: [{removeViewBox: false}] + })) + .pipe(gulp.dest('dist/assets/images'))); + +module.exports = function(callback) { + return runSequence( + 'distribution:clean', 'webapp', 'distribution:copy', 'imagemin', + callback); }; diff --git a/gulp_tasks/minifyvendors.js b/gulp_tasks/minifyvendors.js index 2819402..8c429a3 100644 --- a/gulp_tasks/minifyvendors.js +++ b/gulp_tasks/minifyvendors.js @@ -1,42 +1,32 @@ - /*eslint-env node */ /*global require: true, module: true */ 'use strict'; -var options = require('../gulp-options.js'), - gulp = require('gulp'), +var options = require('../gulp-options.js'), gulp = require('gulp'), // Base dependencies - clean = require('gulp-clean'), - rename = require('gulp-rename'), + clean = require('gulp-clean'), rename = require('gulp-rename'), // Classical gulp dependencies uglify = require('gulp-uglify'); var runSequence = require('run-sequence'); -gulp.task('minifyvendorjs:clean', function () { +gulp.task('minifyvendorjs:clean', function() { return gulp.src(options.bowerFolderPath + '/**/*.min.js', {read: false}) - .pipe(clean()); + .pipe(clean()); }); -gulp.task('minifyvendorjs:minify', function () { - return gulp - .src(options.bowerFolderPath + '/**/*.js') - .pipe(uglify({ - preserveComments: 'false' - })) - .pipe(rename({suffix: '.min'})) - .pipe(gulp.dest(function(file) { - return file.base; - })) +gulp.task('minifyvendorjs:minify', function() { + return gulp.src(options.bowerFolderPath + '/**/*.js') + .pipe(uglify({preserveComments: 'false'})) + .pipe(rename({suffix: '.min'})) + .pipe(gulp.dest(function(file) { + return file.base; + })); }); -module.exports = function (callback) { - return runSequence( - 'minifyvendorjs:clean', - 'minifyvendorjs:minify', - callback - ); -};
\ No newline at end of file +module.exports = function(callback) { + return runSequence('minifyvendorjs:clean', 'minifyvendorjs:minify', callback); +}; diff --git a/gulp_tasks/server.js b/gulp_tasks/server.js index b965786..49fc013 100644 --- a/gulp_tasks/server.js +++ b/gulp_tasks/server.js @@ -1,32 +1,28 @@ -var options = require('../gulp-options.js'), - gulp = require('gulp'), +var options = require('../gulp-options.js'), gulp = require('gulp'), connect = require('gulp-connect'), distribution = require('./distribution.js'); var runSequence = require('run-sequence'); -gulp.task('distribution', function (callback) { - return distribution(callback); +gulp.task('distribution', function(callback) { + return distribution(callback); }); gulp.task('connect', function() { - connect.server({ - root: 'dist', - livereload: true - }); + connect.server({root: 'dist', livereload: true}); }); gulp.task('livereload', function() { - gulp.src(['./dist/**/*.html','./dist/**/*.js','./dist/**/*.css']) - .pipe(connect.reload()); + gulp.src(['./dist/**/*.html', './dist/**/*.js', './dist/**/*.css']) + .pipe(connect.reload()); }); -gulp.task('watch', function () { - gulp.watch('./app/**/*', function(callback){ +gulp.task('watch', function() { + gulp.watch('./app/**/*', function(callback) { return runSequence('distribution', 'livereload'); }); }); -module.exports = function (callback) { - return runSequence('connect', 'watch', callback); -};
\ No newline at end of file +module.exports = function(callback) { + return runSequence('connect', 'watch', callback); +}; diff --git a/gulp_tasks/webapp.js b/gulp_tasks/webapp.js index e514543..edeaff8 100644 --- a/gulp_tasks/webapp.js +++ b/gulp_tasks/webapp.js @@ -3,12 +3,10 @@ 'use strict'; -var options = require('../gulp-options.js'), - gulp = require('gulp'), +var options = require('../gulp-options.js'), gulp = require('gulp'), // Base dependencies - clean = require('gulp-clean'), - rename = require('gulp-rename'), + clean = require('gulp-clean'), rename = require('gulp-rename'), util = require('gulp-util'), // Angular gulp dependencies @@ -17,115 +15,99 @@ var options = require('../gulp-options.js'), ngConstant = require('gulp-ng-constant'), // Classical gulp dependencies - stripDebug = require('gulp-strip-debug'), - uglify = require('gulp-uglify'), - sass = require('gulp-sass'), - cleanCss = require('gulp-clean-css'), - rev = require('gulp-rev'), - revReplace = require('gulp-rev-replace'), - gulpIf = require('gulp-if'), - useref = require('gulp-useref'), + stripDebug = require('gulp-strip-debug'), uglify = require('gulp-uglify'), + sass = require('gulp-sass'), cleanCss = require('gulp-clean-css'), + rev = require('gulp-rev'), revReplace = require('gulp-rev-replace'), + gulpIf = require('gulp-if'), useref = require('gulp-useref'), jsoncombine = require('gulp-jsoncombine'), htmlParser = require('gulp-htmlparser'); -var runSequence = require('run-sequence'), - es = require('event-stream'); +var runSequence = require('run-sequence'), es = require('event-stream'); -gulp.task('webapp:clean', function () { - return gulp - .src([options.targetFolderPath + '/webapp', options.dirname + '/.temp'], { 'read': false }) - .pipe(clean({'force': true})); +gulp.task('webapp:clean', function() { + return gulp + .src( + [options.targetFolderPath + '/webapp', options.dirname + '/.temp'], + {'read': false}) + .pipe(clean({'force': true})); }); -gulp.task('webapp:sasscompile', function () { - return gulp - .src('app/styles/index.scss') - .pipe(sass.sync().on('error', util.log)) - .pipe(gulp.dest(options.srcFolderPath + '/styles')) +gulp.task('webapp:sasscompile', function() { + return gulp.src('app/styles/index.scss') + .pipe(sass.sync().on('error', util.log)) + .pipe(gulp.dest(options.srcFolderPath + '/styles')); }); // ----- To .temp from app -gulp.task('webapp:copyjs', function () { - return gulp.src(options.srcFolderPath + '/**/*.js') - .pipe(ngAnnotate()) // Check angular dependencies injection - .pipe(stripDebug()) // Remove all logs - .pipe(uglify({ 'mangle': false })) - .pipe(gulp.dest(options.dirname + '/.temp')); +gulp.task('webapp:copyjs', function() { + return gulp.src(options.srcFolderPath + '/**/*.js') + .pipe(ngAnnotate()) // Check angular dependencies injection + .pipe(stripDebug()) // Remove all logs + .pipe(uglify({'mangle': false})) + .pipe(gulp.dest(options.dirname + '/.temp')); }); -gulp.task('webapp:copyothers', function () { - return gulp.src(['**/*', '!**/*.js', '!**/*.css', '!**/*.scss'], { 'cwd': options.srcFolderPath }) // All except JS files - .pipe(gulp.dest(options.tempFolderPath)); +gulp.task('webapp:copyothers', function() { + return gulp + .src( + ['**/*', '!**/*.js', '!**/*.css', '!**/*.scss'], + {'cwd': options.srcFolderPath}) // All except JS files + .pipe(gulp.dest(options.tempFolderPath)); }); -gulp.task('webapp:copycss', function () { - return gulp - .src('app/styles/index.css') - .pipe(cleanCss()) - .pipe(gulp.dest(options.tempFolderPath + '/styles')); +gulp.task('webapp:copycss', function() { + return gulp.src('app/styles/index.css') + .pipe(cleanCss()) + .pipe(gulp.dest(options.tempFolderPath + '/styles')); }); -gulp.task('webapp:constants', function () { - return gulp - .src('environment-constants.json') - .pipe(ngConstant({ - 'name': 'app.constants', - 'deps': false - })) - .pipe(rename('environment-constants.js')) - .pipe(gulp.dest(options.tempFolderPath + '/constants')); +gulp.task('webapp:constants', function() { + return gulp.src('environment-constants.json') + .pipe(ngConstant({'name': 'app.constants', 'deps': false})) + .pipe(rename('environment-constants.js')) + .pipe(gulp.dest(options.tempFolderPath + '/constants')); }); // ----- To target/webapp from .temp and bower_components -gulp.task('webapp:template', function () { - return gulp.src([options.srcFolderPath + '/**/*.html', '!' + options.srcFolderPath + '/index.html']) - .pipe(ngTemplateCache('templates.js', { - 'module': 'app.templates', - 'standalone': true - })) - .pipe(gulp.dest(options.tempFolderPath)); +gulp.task('webapp:template', function() { + return gulp + .src([ + options.srcFolderPath + '/**/*.html', + '!' + options.srcFolderPath + '/index.html' + ]) + .pipe(ngTemplateCache( + 'templates.js', {'module': 'app.templates', 'standalone': true})) + .pipe(gulp.dest(options.tempFolderPath)); }); -gulp.task('webapp:useref', function () { - var tasks = ['index.html'].map(function (indexPage) { - var assets = useref.assets({ }); +gulp.task('webapp:useref', function() { + var tasks = ['index.html'].map(function(indexPage) { + var assets = useref.assets({}); - return gulp.src(options.tempFolderPath + '/' + indexPage) - .pipe(assets) - .pipe(assets.restore()) - .pipe(useref()) - .pipe(revReplace()) // Force useref to apply the 'rev' method - .pipe(gulp.dest(options.targetFolderPath + '/webapp')); - }); + return gulp.src(options.tempFolderPath + '/' + indexPage) + .pipe(assets) + .pipe(assets.restore()) + .pipe(useref()) + .pipe(revReplace()) // Force useref to apply the 'rev' method + .pipe(gulp.dest(options.targetFolderPath + '/webapp')); + }); - return es.concat.apply(null, tasks); + return es.concat.apply(null, tasks); }); -gulp.task('webapp:copyresources', function () { - return gulp.src(['**/*.*', '!**/*.js', '!**/*.css', '!**/*.html', '!**/*.log'], { 'cwd': options.tempFolderPath }) - .pipe(gulp.dest(options.targetFolderPath + '/webapp')); +gulp.task('webapp:copyresources', function() { + return gulp + .src( + ['**/*.*', '!**/*.js', '!**/*.css', '!**/*.html', '!**/*.log'], + {'cwd': options.tempFolderPath}) + .pipe(gulp.dest(options.targetFolderPath + '/webapp')); }); -module.exports = function (callback) { - return runSequence( - 'webapp:clean', - 'webapp:sasscompile', - [ - 'webapp:copyjs', - 'webapp:copycss', - 'webapp:copyothers' - ], - [ - 'webapp:constants', - 'webapp:template' - ], - [ - 'webapp:useref' - ], - [ - 'webapp:copyresources' - ], - callback - ); +module.exports = function(callback) { + return runSequence( + 'webapp:clean', 'webapp:sasscompile', + ['webapp:copyjs', 'webapp:copycss', 'webapp:copyothers'], + ['webapp:constants', 'webapp:template'], ['webapp:useref'], + ['webapp:copyresources'], callback); }; |