2017-02-09 01:52:37 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const gulp = require('gulp')
|
|
|
|
const watch = require('gulp-watch')
|
|
|
|
const merge = require('merge-stream')
|
|
|
|
const babel = require('gulp-babel')
|
|
|
|
const uglify = require('gulp-uglify')
|
|
|
|
const concat = require('gulp-concat')
|
|
|
|
const nodemon = require('gulp-nodemon')
|
|
|
|
const plumber = require('gulp-plumber')
|
|
|
|
const zip = require('gulp-zip')
|
|
|
|
const tar = require('gulp-tar')
|
|
|
|
const gzip = require('gulp-gzip')
|
|
|
|
const sass = require('gulp-sass')
|
|
|
|
const cleanCSS = require('gulp-clean-css')
|
|
|
|
const include = require('gulp-include')
|
|
|
|
const run = require('run-sequence')
|
2016-08-17 00:56:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Paths
|
|
|
|
*
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
const paths = {
|
|
|
|
scripts: {
|
|
|
|
combine: [
|
|
|
|
'./node_modules/socket.io-client/dist/socket.io.min.js',
|
2017-03-27 02:07:40 +00:00
|
|
|
'./node_modules/jquery/dist/jquery.min.js', // done
|
2017-02-09 01:52:37 +00:00
|
|
|
'./node_modules/vue/dist/vue.min.js',
|
2017-03-25 21:03:09 +00:00
|
|
|
'./node_modules/vee-validate/dist/vee-validate.min.js',
|
2017-03-05 04:20:22 +00:00
|
|
|
'./node_modules/axios/dist/axios.min.js',
|
2017-02-09 01:52:37 +00:00
|
|
|
'./node_modules/jquery-smooth-scroll/jquery.smooth-scroll.min.js',
|
|
|
|
'./node_modules/jquery-simple-upload/simpleUpload.min.js',
|
|
|
|
'./node_modules/jquery-contextmenu/dist/jquery.contextMenu.min.js',
|
2017-03-27 02:07:40 +00:00
|
|
|
'./node_modules/sticky-js/dist/sticky.min.js', // done
|
2017-02-09 01:52:37 +00:00
|
|
|
'./node_modules/simplemde/dist/simplemde.min.js',
|
|
|
|
'./node_modules/ace-builds/src-min-noconflict/ace.js',
|
|
|
|
'./node_modules/ace-builds/src-min-noconflict/ext-modelist.js',
|
|
|
|
'./node_modules/ace-builds/src-min-noconflict/mode-markdown.js',
|
|
|
|
'./node_modules/ace-builds/src-min-noconflict/theme-tomorrow_night.js',
|
|
|
|
'./node_modules/filesize.js/dist/filesize.min.js',
|
2017-03-27 02:07:40 +00:00
|
|
|
'./node_modules/lodash/lodash.min.js' // done
|
2017-02-09 01:52:37 +00:00
|
|
|
],
|
|
|
|
ace: [
|
|
|
|
'./node_modules/ace-builds/src-min-noconflict/mode-*.js',
|
|
|
|
'!./node_modules/ace-builds/src-min-noconflict/mode-markdown.js'
|
|
|
|
],
|
|
|
|
compile: [
|
|
|
|
'./client/js/*.js'
|
|
|
|
],
|
|
|
|
watch: [
|
|
|
|
'./client/js/**/*.js'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
css: {
|
|
|
|
combine: [
|
|
|
|
'./node_modules/highlight.js/styles/tomorrow.css',
|
|
|
|
'./node_modules/simplemde/dist/simplemde.min.css'
|
|
|
|
],
|
|
|
|
compile: [
|
|
|
|
'./client/scss/*.scss'
|
|
|
|
],
|
|
|
|
includes: [
|
|
|
|
'./node_modules/requarks-core' //! MUST BE LAST
|
|
|
|
],
|
|
|
|
watch: [
|
|
|
|
'./client/scss/**/*.scss',
|
|
|
|
'../core/core-client/scss/**/*.scss'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
fonts: [
|
|
|
|
'../node_modules/requarks-core/core-client/fonts/**/*' //! MUST BE LAST
|
|
|
|
],
|
|
|
|
deploy: [
|
|
|
|
'./**/*',
|
|
|
|
'!client/js', '!client/js/**',
|
|
|
|
'!client/scss', '!client/scss/**',
|
2017-02-14 20:27:08 +00:00
|
|
|
'!coverage', '!coverage/**',
|
2017-02-09 01:52:37 +00:00
|
|
|
'!data', '!data/**',
|
2017-02-14 20:27:08 +00:00
|
|
|
'!dist', '!dist/**',
|
|
|
|
'!node_modules', '!node_modules/**',
|
|
|
|
'!npm', '!npm/**',
|
2017-02-09 01:52:37 +00:00
|
|
|
'!repo', '!repo/**',
|
2017-02-14 20:27:08 +00:00
|
|
|
'!test', '!test/**',
|
|
|
|
'!gulpfile.js', '!config.yml'
|
2017-02-09 01:52:37 +00:00
|
|
|
]
|
|
|
|
}
|
2016-08-17 00:56:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TASK - Starts server in development mode
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('server', ['scripts', 'css', 'fonts'], function () {
|
|
|
|
nodemon({
|
|
|
|
script: './server',
|
|
|
|
ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'],
|
|
|
|
ext: 'js json',
|
|
|
|
env: { 'NODE_ENV': 'development' }
|
|
|
|
})
|
|
|
|
})
|
2017-02-26 23:06:20 +00:00
|
|
|
gulp.task('configure', ['scripts', 'css', 'fonts'], function () {
|
|
|
|
nodemon({
|
|
|
|
exec: 'node wiki configure',
|
|
|
|
ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'],
|
|
|
|
ext: 'js json',
|
|
|
|
env: { 'NODE_ENV': 'development' }
|
|
|
|
})
|
|
|
|
})
|
2016-08-17 00:56:55 +00:00
|
|
|
|
2016-08-18 03:52:23 +00:00
|
|
|
/**
|
|
|
|
* TASK - Process all scripts processes
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('scripts', ['scripts-libs', 'scripts-app'])
|
2016-08-18 03:52:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TASK - Combine js libraries
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('scripts-libs', function () {
|
|
|
|
return merge(
|
2016-08-18 03:52:23 +00:00
|
|
|
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.src(paths.scripts.combine)
|
|
|
|
.pipe(concat('libs.js', {newLine: ';\n'}))
|
|
|
|
.pipe(uglify({ mangle: false }))
|
|
|
|
.pipe(gulp.dest('./assets/js')),
|
2016-09-11 02:53:21 +00:00
|
|
|
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.src(paths.scripts.ace)
|
|
|
|
.pipe(gulp.dest('./assets/js/ace'))
|
2016-09-11 02:53:21 +00:00
|
|
|
|
2017-02-09 01:52:37 +00:00
|
|
|
)
|
|
|
|
})
|
2016-08-18 03:52:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TASK - Combine, make compatible and compress js app scripts
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('scripts-app', function () {
|
|
|
|
return gulp.src(paths.scripts.compile)
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(include({ extensions: 'js' }))
|
|
|
|
.pipe(babel())
|
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(plumber.stop())
|
|
|
|
.pipe(gulp.dest('./assets/js'))
|
|
|
|
})
|
2016-08-18 03:52:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TASK - Process all css processes
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('css', ['css-libs', 'css-app'])
|
2016-08-18 03:52:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TASK - Combine css libraries
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('css-libs', function () {
|
|
|
|
return gulp.src(paths.css.combine)
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(concat('libs.css'))
|
|
|
|
.pipe(cleanCSS({ keepSpecialComments: 0 }))
|
|
|
|
.pipe(plumber.stop())
|
|
|
|
.pipe(gulp.dest('./assets/css'))
|
|
|
|
})
|
2016-08-18 03:52:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TASK - Combine app css
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('css-app', function () {
|
|
|
|
return gulp.src(paths.css.compile)
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(sass.sync({ includePaths: paths.css.includes }))
|
|
|
|
.pipe(cleanCSS({ keepSpecialComments: 0 }))
|
|
|
|
.pipe(plumber.stop())
|
|
|
|
.pipe(gulp.dest('./assets/css'))
|
|
|
|
})
|
2016-08-18 03:52:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TASK - Copy web fonts
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('fonts', function () {
|
|
|
|
return gulp.src(paths.fonts)
|
|
|
|
.pipe(gulp.dest('./assets/fonts'))
|
|
|
|
})
|
2016-08-18 03:52:23 +00:00
|
|
|
|
2016-08-17 00:56:55 +00:00
|
|
|
/**
|
|
|
|
* TASK - Start dev watchers
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('watch', function () {
|
|
|
|
return merge(
|
|
|
|
watch(paths.scripts.watch, {base: './'}, function () { return gulp.start('scripts-app') }),
|
|
|
|
watch(paths.css.watch, {base: './'}, function () { return gulp.start('css-app') })
|
|
|
|
)
|
|
|
|
})
|
2016-08-17 00:56:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TASK - Starts development server with watchers
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('default', ['watch', 'server'])
|
2017-02-26 23:06:20 +00:00
|
|
|
gulp.task('default-configure', ['watch', 'configure'])
|
2016-11-23 03:06:59 +00:00
|
|
|
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('dev', function () {
|
|
|
|
paths.css.includes.pop()
|
|
|
|
paths.css.includes.push('../core')
|
2016-11-23 03:06:59 +00:00
|
|
|
|
2017-02-09 01:52:37 +00:00
|
|
|
paths.fonts.pop()
|
|
|
|
paths.fonts.push('../core/core-client/fonts/**/*')
|
2016-11-23 03:06:59 +00:00
|
|
|
|
2017-02-09 01:52:37 +00:00
|
|
|
return run('default')
|
|
|
|
})
|
2016-11-23 03:06:59 +00:00
|
|
|
|
2017-02-26 23:06:20 +00:00
|
|
|
gulp.task('dev-configure', function () {
|
|
|
|
paths.css.includes.pop()
|
|
|
|
paths.css.includes.push('../core')
|
|
|
|
|
|
|
|
paths.fonts.pop()
|
|
|
|
paths.fonts.push('../core/core-client/fonts/**/*')
|
|
|
|
|
|
|
|
return run('default-configure')
|
|
|
|
})
|
|
|
|
|
2016-08-17 00:56:55 +00:00
|
|
|
/**
|
|
|
|
* TASK - Creates deployment packages
|
|
|
|
*/
|
2017-02-09 01:52:37 +00:00
|
|
|
gulp.task('deploy', ['scripts', 'css', 'fonts'], function () {
|
|
|
|
var zipStream = gulp.src(paths.deploy)
|
|
|
|
.pipe(zip('wiki-js.zip'))
|
|
|
|
.pipe(gulp.dest('dist'))
|
|
|
|
|
|
|
|
var targzStream = gulp.src(paths.deploy)
|
|
|
|
.pipe(tar('wiki-js.tar'))
|
|
|
|
.pipe(gzip())
|
|
|
|
.pipe(gulp.dest('dist'))
|
|
|
|
|
|
|
|
return merge(zipStream, targzStream)
|
|
|
|
})
|