Grunt → Gulp
This commit is contained in:
parent
0977259d6b
commit
1194e32a2d
|
@ -1,2 +1,3 @@
|
|||
node_modules
|
||||
bower_components
|
||||
prepared
|
||||
archive.zip
|
||||
|
|
115
Gruntfile.js
115
Gruntfile.js
|
@ -1,115 +0,0 @@
|
|||
module.exports = function(grunt) {
|
||||
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
grunt.initConfig({
|
||||
bump: {
|
||||
options: {
|
||||
files: ['package.json', 'bower.json'],
|
||||
commitFiles: ['package.json', 'bower.json'],
|
||||
pushTo: 'origin'
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
prepare: {
|
||||
files: [{
|
||||
src: [
|
||||
'**',
|
||||
'!node_modules/**',
|
||||
'!bower_components/**',
|
||||
'!CONTRIBUTING.md',
|
||||
'!Gruntfile.js',
|
||||
'!LICENSE.md',
|
||||
'!README.md',
|
||||
'!bower.json',
|
||||
'!package.json'
|
||||
],
|
||||
dest: 'temp/pres/'
|
||||
},{
|
||||
expand: true,
|
||||
cwd: 'node_modules/shower-core/',
|
||||
src: [
|
||||
'**',
|
||||
'!package.json',
|
||||
'!README.md'
|
||||
],
|
||||
dest: 'temp/pres/shower/'
|
||||
},{
|
||||
expand: true,
|
||||
cwd: 'node_modules/shower-ribbon/',
|
||||
src: [
|
||||
'**',
|
||||
'!package.json',
|
||||
'!README.md'
|
||||
],
|
||||
dest: 'temp/pres/shower/themes/ribbon/'
|
||||
},{
|
||||
expand: true,
|
||||
cwd: 'node_modules/shower-material/',
|
||||
src: [
|
||||
'**',
|
||||
'!package.json',
|
||||
'!README.md'
|
||||
],
|
||||
dest: 'temp/pres/shower/themes/material/'
|
||||
}]
|
||||
}
|
||||
},
|
||||
replace: {
|
||||
core: {
|
||||
src: 'temp/pres/index.html',
|
||||
overwrite: true,
|
||||
replacements: [{
|
||||
from: /(node_modules|bower_components)\/shower-core/g,
|
||||
to: 'shower'
|
||||
},{
|
||||
from: /(node_modules|bower_components)\/shower-(ribbon|material)/g,
|
||||
to: 'shower/themes/$2'
|
||||
}]
|
||||
},
|
||||
themes: {
|
||||
src: 'temp/pres/shower/themes/*/index.html',
|
||||
overwrite: true,
|
||||
replacements: [{
|
||||
from: '../shower-core', to: '../..'
|
||||
}]
|
||||
}
|
||||
},
|
||||
'gh-pages': {
|
||||
options: {
|
||||
base: 'temp/pres',
|
||||
clone: 'temp/clone'
|
||||
},
|
||||
src: ['**']
|
||||
},
|
||||
compress: {
|
||||
shower: {
|
||||
options: {
|
||||
archive: 'archive.zip'
|
||||
},
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: 'temp/pres/',
|
||||
src: '**',
|
||||
dest: '.'
|
||||
}]
|
||||
}
|
||||
},
|
||||
clean: ['temp']
|
||||
});
|
||||
|
||||
grunt.registerTask('publish', [
|
||||
'copy',
|
||||
'replace',
|
||||
'gh-pages',
|
||||
'clean'
|
||||
]);
|
||||
|
||||
grunt.registerTask('archive', [
|
||||
'copy',
|
||||
'replace',
|
||||
'compress',
|
||||
'clean'
|
||||
]);
|
||||
|
||||
};
|
|
@ -0,0 +1,101 @@
|
|||
const del = require('del');
|
||||
const fs = require('fs');
|
||||
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');
|
||||
const pages = require('gulp-gh-pages');
|
||||
|
||||
gulp.task('prepare', () => {
|
||||
|
||||
const shower = gulp.src([
|
||||
'**',
|
||||
'!node_modules{,/**}',
|
||||
'!CONTRIBUTING.md',
|
||||
'!LICENSE.md',
|
||||
'!README.md',
|
||||
'!gulpfile.js',
|
||||
'!package.json'
|
||||
])
|
||||
.pipe(replace(
|
||||
/(<link rel="stylesheet" href=")(node_modules\/shower-ribbon\/)(styles\/screen-16x10.css">)/g,
|
||||
'$1shower/themes/ribbon/$3', { skipBinary: true }
|
||||
))
|
||||
.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', () => {
|
||||
return gulp.src('prepared/**')
|
||||
.pipe(pages())
|
||||
});
|
||||
|
||||
gulp.task('archive', (callback) => {
|
||||
sequence(
|
||||
'prepare',
|
||||
'zip',
|
||||
'clean', callback
|
||||
)
|
||||
});
|
||||
|
||||
gulp.task('publish', (callback) => {
|
||||
sequence(
|
||||
'prepare',
|
||||
'upload',
|
||||
'clean', callback
|
||||
)
|
||||
});
|
||||
|
||||
gulp.task('clean', () => {
|
||||
return del('prepared/**');
|
||||
});
|
||||
|
||||
gulp.task('default', ['prepare']);
|
18
package.json
18
package.json
|
@ -26,13 +26,15 @@
|
|||
"shower-ribbon": "^2.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-bump": "0.7.0",
|
||||
"grunt-contrib-clean": "^1.0.0",
|
||||
"grunt-contrib-compress": "^1.1.1",
|
||||
"grunt-contrib-copy": "^1.0.0",
|
||||
"grunt-gh-pages": "^1.0.0",
|
||||
"grunt-text-replace": "^0.4.0",
|
||||
"load-grunt-tasks": "^3.4.1"
|
||||
"del": "^2.2.0",
|
||||
"fs": "0.0.2",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-gh-pages": "^0.5.4",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-replace": "^0.5.4",
|
||||
"gulp-rsync": "0.0.5",
|
||||
"gulp-zip": "^3.2.0",
|
||||
"merge-stream": "^1.0.0",
|
||||
"run-sequence": "^1.1.5"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue