UNPKG

product-admin

Version:

EA admin screens

155 lines (134 loc) 4.12 kB
"use strict"; const gulp = require("gulp"); const nodemon = require('gulp-nodemon'); const sass = require('gulp-sass'); const del = require('del'); const eslint = require('gulp-eslint'); const bump = require('gulp-bump'); const args = require('yargs').argv; const shell = require('gulp-shell') const runSequence = require('run-sequence'); /** * STYLES */ gulp.task('sass', function() { return gulp.src('src-client/styles/*.scss') .pipe(sass({ includePaths: [ 'src-client/bower_components', '../product-admin/src-client/bower_components' ] })) .pipe(sass().on('error', sass.logError)) .pipe(gulp.dest('src-client/styles')); }); /** * LINTING */ gulp.task('lint', () => { return gulp.src([ './**/*.js', '!./node_modules/**', '!./dist/**', '!./**/bower_components/**' ]) .pipe(eslint()) .pipe(eslint.format()) .pipe(eslint.failAfterError()); }); /** * SERVER */ // start our server and listen for changes gulp.task('server', server); gulp.task("clean", () => { del.sync(['./dist']); }); gulp.task("build-client", () => { return gulp.src([ 'src-client/bower_components/**', //TODO: we probably don't need everything in bower_components. 'src-client/**/*.css', 'src-client/**/*.html', '!src-client/**/*.spec.*', 'src-client/**/*.js', 'src-client/index.html', 'src-client/element.html', 'src-client/resources/**/*' ], { base: './src-client' }) .pipe(gulp.dest('dist/public')); }); gulp.task("build-server", () => { return gulp.src([ "src-server/**" ], { base: "./src-server" }) .pipe(gulp.dest("dist/")); }); gulp.task("watch", () => { gulp.run("server"); gulp.watch(["src-client/**/*"], ["build-client"]); }); gulp.task('bumpBowerNpm', () => { /// <summary> /// It bumps revisions /// Usage: /// 1. gulp bump : bumps the package.json and bower.json to the next minor revision. /// i.e. from 0.1.1 to 0.1.2 /// 2. gulp bump --version 1.1.1 : bumps/sets the package.json and bower.json to the /// specified revision. /// 3. gulp bump --type major : bumps 1.0.0 /// gulp bump --type minor : bumps 0.1.0 /// gulp bump --type patch : bumps 0.0.2 /// gulp bump --type prerelease : bumps 0.0.1-2 /// </summary> var type = args.type; var version = args.version; var msg = "" var options = {}; if (version) { options.version = version; msg += ' to ' + version; } else { options.type = type; msg += ' for a ' + type; } return gulp .src(['package.json', 'bower.json']) .pipe(bump(options)) .pipe(gulp.dest('./')); }); gulp.task('pushBumpAdd', shell.task([ 'git add package.json bower.json', ])); gulp.task('pushBumpCommit', shell.task([ 'git commit -n -m "bumping version"' ])); gulp.task('pushBumpForReal', shell.task([ 'git push' ])); gulp.task("bump", function(done){; runSequence( "bumpBowerNpm", "pushBumpAdd", "pushBumpCommit", "pushBumpForReal", function(){ console.log("done bumping!"); done(); } ); }); // Run this sequentially rather than in parallel // If server is included in the task-array, it could run before `build` finishes // Causing an error. Do you want that? gulp.task("default", ["build"], server); gulp.task("build", ["clean", "sass", "build-client", "build-server"]); gulp.task("dist", ["clean", "sass", "build-client", "build-server"]); function server() { return nodemon({ script: 'dist/app.js', watch: ["src-server/**/*"], ext: 'js' }).on('restart', () => { gulp.src('dist/app.js') }); }