2016-03-23 23:53:37 +03:00
|
|
|
const del = require('del');
|
|
|
|
const gulp = require('gulp');
|
|
|
|
const merge = require('merge-stream');
|
|
|
|
const rename = require('gulp-rename');
|
|
|
|
const replace = require('gulp-replace');
|
|
|
|
const rsync = require('gulp-rsync');
|
|
|
|
const sequence = require('run-sequence');
|
|
|
|
const zip = require('gulp-zip');
|
2018-05-21 12:56:22 +03:00
|
|
|
const ghpages = require('gh-pages');
|
2017-07-19 20:48:56 +03:00
|
|
|
const browserSync = require('browser-sync').create();
|
2016-03-23 23:53:37 +03:00
|
|
|
|
|
|
|
gulp.task('prepare', () => {
|
|
|
|
|
|
|
|
const shower = gulp.src([
|
|
|
|
'**',
|
2016-08-12 22:18:44 +03:00
|
|
|
'!docs{,/**}',
|
2016-03-23 23:53:37 +03:00
|
|
|
'!node_modules{,/**}',
|
2016-04-03 20:47:04 +03:00
|
|
|
'!prepared{,/**}',
|
2016-03-23 23:53:37 +03:00
|
|
|
'!CONTRIBUTING.md',
|
|
|
|
'!LICENSE.md',
|
|
|
|
'!README.md',
|
|
|
|
'!gulpfile.js',
|
2017-07-20 15:57:54 +03:00
|
|
|
'!package.json',
|
|
|
|
'!package-lock.json'
|
2016-03-23 23:53:37 +03:00
|
|
|
])
|
|
|
|
.pipe(replace(
|
2016-08-12 22:18:32 +03:00
|
|
|
/(<link rel="stylesheet" href=")(node_modules\/shower-)([^\/]*)\/(.*\.css">)/g,
|
|
|
|
'$1shower/themes/$3/$4', { skipBinary: true }
|
2016-03-23 23:53:37 +03:00
|
|
|
))
|
|
|
|
.pipe(replace(
|
|
|
|
/(<script src=")(node_modules\/shower-core\/)(shower.min.js"><\/script>)/g,
|
|
|
|
'$1shower/$3', { skipBinary: true }
|
|
|
|
));
|
|
|
|
|
|
|
|
const core = gulp.src([
|
|
|
|
'shower.min.js'
|
|
|
|
], {
|
|
|
|
cwd: 'node_modules/shower-core'
|
|
|
|
})
|
|
|
|
.pipe(rename( (path) => {
|
|
|
|
path.dirname = 'shower/' + path.dirname;
|
|
|
|
}));
|
|
|
|
|
|
|
|
const material = gulp.src([
|
|
|
|
'**', '!package.json'
|
|
|
|
], {
|
|
|
|
cwd: 'node_modules/shower-material'
|
|
|
|
})
|
|
|
|
.pipe(rename( (path) => {
|
|
|
|
path.dirname = 'shower/themes/material/' + path.dirname;
|
|
|
|
}))
|
|
|
|
|
|
|
|
const ribbon = gulp.src([
|
|
|
|
'**', '!package.json'
|
|
|
|
], {
|
|
|
|
cwd: 'node_modules/shower-ribbon'
|
|
|
|
})
|
|
|
|
.pipe(rename( (path) => {
|
|
|
|
path.dirname = 'shower/themes/ribbon/' + path.dirname;
|
|
|
|
}));
|
|
|
|
|
|
|
|
const themes = merge(material, ribbon)
|
|
|
|
.pipe(replace(
|
|
|
|
/(<script src=")(\/shower-core\/)(shower.min.js"><\/script>)/,
|
|
|
|
'$1../../$3', { skipBinary: true }
|
|
|
|
));
|
|
|
|
|
|
|
|
return merge(shower, core, themes)
|
|
|
|
.pipe(gulp.dest('prepared'));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('zip', () => {
|
|
|
|
return gulp.src('prepared/**')
|
|
|
|
.pipe(zip('archive.zip'))
|
|
|
|
.pipe(gulp.dest('.'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('upload', () => {
|
2018-05-21 12:56:22 +03:00
|
|
|
return ghpages.publish('prepared')
|
2016-03-23 23:53:37 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('archive', (callback) => {
|
|
|
|
sequence(
|
|
|
|
'prepare',
|
|
|
|
'zip',
|
|
|
|
'clean', callback
|
|
|
|
)
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('publish', (callback) => {
|
|
|
|
sequence(
|
|
|
|
'prepare',
|
|
|
|
'upload',
|
|
|
|
'clean', callback
|
|
|
|
)
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('clean', () => {
|
2018-05-21 12:58:27 +03:00
|
|
|
return del('prepared/**');
|
2016-03-23 23:53:37 +03:00
|
|
|
});
|
|
|
|
|
2017-07-19 20:48:56 +03:00
|
|
|
gulp.task('serve', () => {
|
|
|
|
browserSync.init({
|
|
|
|
ui: false,
|
|
|
|
notify: false,
|
|
|
|
port: 3000,
|
|
|
|
server: {
|
|
|
|
baseDir: '.'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
gulp.watch('index.html').on('change', () => {
|
|
|
|
browserSync.reload();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('default', ['serve']);
|