This repository has been archived by the owner on Oct 1, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
310 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"extends": "kellyirc", | ||
"parser": "babel-eslint", | ||
"cache": true, | ||
"env": { | ||
"node": true, | ||
"es6": true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
const fs = require('fs'); | ||
const execSync = require('child_process').execSync; | ||
|
||
export const getPaths = () => JSON.parse(fs.readFileSync('./package.json')).gulp; | ||
export const currentTag = () => execSync('git describe --abbrev=0').toString().trim(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
const _ = require('lodash'); | ||
|
||
const gulp = require('gulp'); | ||
const filter = require('gulp-filter'); | ||
const ghPages = require('gulp-gh-pages'); | ||
|
||
const browserSync = require('browser-sync').create(); | ||
|
||
const getPaths = require('./_common').getPaths; | ||
|
||
gulp.task('deploy', () => { | ||
const paths = getPaths(); | ||
return gulp.src(`${paths.dist}/**/*`, { base: paths.dist }) | ||
.pipe(filter((file) => { | ||
return !_.contains(file.path, 'node_modules') && !_.contains(file.path, 'nw') && !_.contains(file.path, 'package'); | ||
})) | ||
.pipe(ghPages()); | ||
}); | ||
|
||
gulp.task('reload', () => { | ||
browserSync.reload(); | ||
}); | ||
|
||
gulp.task('connect', ['build:all'], () => { | ||
browserSync.init({ | ||
port: 8000, | ||
server: { | ||
baseDir: './dist' | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
const gulp = require('gulp'); | ||
const del = require('del'); | ||
const vinylPaths = require('vinyl-paths'); | ||
|
||
const getPaths = require('./_common').getPaths; | ||
|
||
gulp.task('clean:libcss', () => gulp.src(getPaths().dist+'/css/lib.min.css').pipe(vinylPaths(del))); | ||
|
||
gulp.task('clean:libjs', () => gulp.src(getPaths().dist+'/js/lib.min.js').pipe(vinylPaths(del))); | ||
|
||
gulp.task('clean:css', () => gulp.src(getPaths().dist+'/css/main.min.css').pipe(vinylPaths(del))); | ||
|
||
gulp.task('clean:js', () => gulp.src(getPaths().dist+'/js/main.min.js').pipe(vinylPaths(del))); | ||
|
||
gulp.task('clean:all', ['clean:libcss', 'clean:libjs', 'clean:css', 'clean:js']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
|
||
const gulp = require('gulp'); | ||
const util = require('gulp-util'); | ||
const concat = require('gulp-concat'); | ||
const minifyCss = require('gulp-minify-css'); | ||
const ngAnnotate = require('gulp-ng-annotate'); | ||
const sourcemaps = require('gulp-sourcemaps'); | ||
const sass = require('gulp-sass'); | ||
const autoprefixer = require('gulp-autoprefixer'); | ||
const gulpif = require('gulp-if'); | ||
const rename = require('gulp-rename'); | ||
const jade = require('gulp-jade'); | ||
|
||
const source = require('vinyl-source-stream'); | ||
|
||
const browserify = require('browserify'); | ||
const babelify = require('babelify'); | ||
const errorify = require('errorify'); | ||
const watchify = require('watchify'); | ||
|
||
const getPaths = require('./_common').getPaths; | ||
|
||
gulp.task('compile:libcss', ['clean:libcss'], () => { | ||
return gulp.src(getPaths().libcss) | ||
.pipe(concat('lib.min.css')) | ||
.pipe(minifyCss({ | ||
keepSpecialComments: false, | ||
removeEmpty: true | ||
})) | ||
.pipe(gulp.dest(getPaths().dist + 'css')) | ||
.on('error', util.log); | ||
}); | ||
|
||
gulp.task('compile:libjs', ['clean:libjs'], () => { | ||
return gulp.src(getPaths().libjs) | ||
.pipe(concat('lib.min.js')) | ||
.pipe(gulp.dest(getPaths().dist + 'js')) | ||
.on('error', util.log); | ||
}); | ||
|
||
let bundler = null; | ||
|
||
gulp.task('compile:js', ['eslint', 'clean:js'], () => { | ||
|
||
const bundlee = function() { | ||
return bundler | ||
.bundle() | ||
.pipe(source('js/main.min.js')) | ||
.pipe(ngAnnotate()) | ||
.pipe(gulp.dest(getPaths().dist)) | ||
.on('error', util.log); | ||
}; | ||
|
||
if(global.watching && bundler) return bundlee(); | ||
|
||
bundler = browserify({ | ||
cache: {}, packageCache: {}, fullPaths: true, | ||
entries: [getPaths().entry], | ||
debug: global.watching | ||
}) | ||
.transform(babelify); | ||
|
||
if(global.watching) { | ||
bundler.plugin(errorify); | ||
} | ||
|
||
if (global.watching) { | ||
bundler = watchify(bundler); | ||
bundler.on('update', bundlee); | ||
} | ||
|
||
return bundlee(); | ||
}); | ||
|
||
gulp.task('compile:sass', ['clean:css'], () => { | ||
return gulp.src(getPaths().sass) | ||
.pipe(sourcemaps.init()) | ||
.pipe(sass().on('error', sass.logError)) | ||
.pipe(concat('css/main.css')) | ||
.pipe(autoprefixer({ | ||
browsers: ['last 2 versions'], | ||
cascade: false | ||
})) | ||
.pipe(gulpif(!global.watching, minifyCss({ | ||
keepSpecialComments: false, | ||
removeEmpty: true | ||
}))) | ||
.pipe(rename({ suffix: '.min' })) | ||
.pipe(sourcemaps.write()) | ||
.pipe(gulp.dest(getPaths().dist)) | ||
.on('error', util.log); | ||
}); | ||
|
||
gulp.task('compile:jade', () => { | ||
return gulp.src(getPaths().jade) | ||
.pipe(concat('index.html')) | ||
.pipe(jade({ | ||
pretty: global.watching | ||
})) | ||
.pipe(gulp.dest(getPaths().dist)) | ||
.on('error', util.log); | ||
}); | ||
|
||
gulp.task('build:lib', ['compile:libjs', 'compile:libcss']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
const gulp = require('gulp'); | ||
const util = require('gulp-util'); | ||
|
||
const getPaths = require('./_common').getPaths; | ||
|
||
gulp.task('copy:dist', () => { | ||
return gulp.src(getPaths().favicon) | ||
.pipe(gulp.dest(getPaths().dist)) | ||
.on('error', util.log); | ||
}); | ||
|
||
gulp.task('copy:nw', () => { | ||
return gulp.src(['./package.json', 'nw-setup/**/*']) | ||
.pipe(gulp.dest(getPaths().dist)) | ||
.on('error', util.log); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
const gulp = require('gulp'); | ||
const eslint = require('gulp-eslint'); | ||
|
||
const getPaths = require('./_common').getPaths; | ||
|
||
gulp.task('eslint', () => { | ||
return gulp.src(getPaths().js) | ||
.pipe(eslint({ useEslintrc: true, cache: true })) | ||
.pipe(eslint.format()) | ||
.pipe(eslint.failOnError()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
const gulp = require('gulp'); | ||
const mocha = require('gulp-mocha'); | ||
|
||
const getPaths = require('./_common').getPaths; | ||
|
||
gulp.task('test', function() { | ||
const paths = getPaths(); | ||
|
||
gulp.src(paths.testjs) | ||
.pipe(mocha()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
const gulp = require('gulp'); | ||
const fs = require('fs'); | ||
const git = require('gulp-git'); | ||
const bump = require('gulp-bump'); | ||
const filter = require('gulp-filter'); | ||
const tagVersion = require('gulp-tag-version'); | ||
|
||
const runSequence = require('run-sequence'); | ||
const changelog = require('conventional-changelog'); | ||
|
||
const currentTag = require('./_common').currentTag; | ||
|
||
const versionSources = ['./bower.json', './package.json']; | ||
|
||
const versionStream = (type) => { | ||
return gulp.src(versionSources) | ||
.pipe(bump({ type: type })) | ||
.pipe(gulp.dest('./')) | ||
.pipe(filter('package.json')) | ||
.pipe(tagVersion({ prefix: '' })); | ||
}; | ||
|
||
const commitStream = (type) => { | ||
const tag = currentTag(); | ||
return gulp.src(versionSources.concat('CHANGELOG.md')) | ||
.pipe(git.commit(`chore(version): release ${type} version ${tag}`, function() { | ||
git.push(); | ||
git.push('origin', 'master', { args: '--tags' }); | ||
})); | ||
}; | ||
|
||
const pushStream = () => { | ||
git.push(); | ||
git.push('origin', 'master', { args: '--tags' }); | ||
}; | ||
|
||
gulp.task('generate:changelog', () => { | ||
return changelog({ | ||
releaseCount: 0, | ||
preset: 'angular' | ||
}) | ||
.pipe(fs.createWriteStream('CHANGELOG.md')); | ||
}); | ||
|
||
gulp.task('bump:patch:tag', () => versionStream('patch')); | ||
gulp.task('bump:minor:tag', () => versionStream('minor')); | ||
gulp.task('bump:major:tag', () => versionStream('major')); | ||
|
||
gulp.task('bump:patch:commit', () => runSequence('bump:patch:tag', 'generate:changelog', () => commitStream('patch') && pushStream())); | ||
gulp.task('bump:minor:commit', () => runSequence('bump:minor:tag', 'generate:changelog', () => commitStream('minor') && pushStream())); | ||
gulp.task('bump:major:commit', () => runSequence('bump:major:tag', 'generate:changelog', () => commitStream('major') && pushStream())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
const gulp = require('gulp'); | ||
const runSequence = require('run-sequence'); | ||
|
||
const getPaths = require('./_common').getPaths; | ||
|
||
gulp.task('watch:sass', () => { | ||
global.watching = true; | ||
return gulp.watch(getPaths().sass, () => { runSequence('compile:sass', 'reload'); }); | ||
}); | ||
|
||
gulp.task('watch:jade', () => { | ||
global.watching = true; | ||
return gulp.watch(getPaths().jade, () => { runSequence('compile:jade', 'reload'); }); | ||
}); | ||
|
||
gulp.task('watch:js', () => { | ||
global.watching = true; | ||
return gulp.watch(getPaths().js, () => { runSequence('compile:js', 'reload'); }); | ||
}); | ||
|
||
gulp.task('watch:package', () => { | ||
global.watching = true; | ||
return gulp.watch('package.json', () => { runSequence('compile:libjs', 'compile:libcss', 'reload'); }); | ||
}); | ||
|
||
gulp.task('watch:all', ['watch:package', 'watch:sass', 'watch:jade', 'watch:js']); |
Oops, something went wrong.