From 3025f9e3cc3c7a5dd238207f9b37bac34b4fe1fa Mon Sep 17 00:00:00 2001 From: everyx Date: Mon, 20 Mar 2017 23:24:24 +0800 Subject: [PATCH] add gulp support, fix #6 --- .gitignore | 7 +++++-- build.sh | 22 ---------------------- composer.json | 15 --------------- gulpfile.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 12 ++++++++++++ 5 files changed, 63 insertions(+), 39 deletions(-) delete mode 100755 build.sh delete mode 100644 composer.json create mode 100644 gulpfile.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore index a7e8081..3c46de5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ -*.zip -*.gz \ No newline at end of file +# Do not index node.js modules that are used for building +node_modules + +# Do not index releases +release \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100755 index d5ff460..0000000 --- a/build.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -author='Mibew' - -tmp_dir='/tmp' -working_dir=`echo $PWD` - -target_dir="$tmp_dir/$author/Mibew/Plugin/OperatorStatus" -mkdir -p $target_dir - -shopt -s extglob -cp -R !(*.sh) $target_dir -shopt -u extglob - -version=`cat Plugin.php|grep -Po "(?<=return ')(\d.){2}\d{1}"` - -cd $tmp_dir - -tar -czvf $working_dir/mibew-operator-status-plugin.$version.tar.gz $author -zip -r $working_dir/mibew-operator-status-plugin.$version.zip $author - -rm -rf $plugin_root_dir diff --git a/composer.json b/composer.json deleted file mode 100644 index e3b9690..0000000 --- a/composer.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "Mibew/mibew-operator-status-plugin", - "description": "An operator status plugin for Mibew 2.0.", - "license": "MIT", - "authors": [ - { - "name": "everyx", - "email": "lunt.luo@gmail.com" - } - ], - "autoload": { - "psr-0": {"Mibew\\Mibew\\Plugin\\OperatorStatus\\": ""} - }, - "target-dir": "Mibew/Mibew/Plugin/OperatorStatus" -} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..77e5832 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,46 @@ +var eventStream = require('event-stream'), + gulp = require('gulp'), + chmod = require('gulp-chmod'), + zip = require('gulp-zip'), + tar = require('gulp-tar'), + gzip = require('gulp-gzip'), + rename = require('gulp-rename'); + +gulp.task('prepare-release', function() { + var version = require('./package.json').version; + + return eventStream.merge( + getSources() + .pipe(zip('mibew-operator-status-plugin-' + version + '.zip')), + getSources() + .pipe(tar('mibew-operator-status-plugin-' + version + '.tar')) + .pipe(gzip()) + ) + .pipe(chmod(0644)) + .pipe(gulp.dest('release')); +}); + +// Builds and packs plugins sources +gulp.task('default', ['prepare-release'], function() { + // The "default" task is just an alias for "prepare-release" task. +}); + +/** + * Returns files stream with the plugin sources. + * + * @returns {Object} Stream with VinylFS files. + */ +var getSources = function() { + return gulp.src([ + 'Controller/*', + 'LICENSE', + 'Plugin.php', + 'README.md', + 'routing.yml' + ], + {base: './'} + ) + .pipe(rename(function(path) { + path.dirname = 'Mibew/Mibew/Plugin/OperatorStatus/' + path.dirname; + })); +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..efd7bfb --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "version": "0.3.0", + "devDependencies": { + "event-stream": "~3.3.1", + "gulp": "^3.9.1", + "gulp-chmod": "~1.2.0", + "gulp-gzip": "~1.1.0", + "gulp-rename": "~1.2.2", + "gulp-tar": "~1.4.0", + "gulp-zip": "~3.0.2" + } +}