Packaging process bundled as Gulp task
Bundling a ready to use plugin ZIP has been automated into a Gulp task. After executing unit tests and code sniffer, only the relevant files are bundled.
This commit is contained in:
parent
3206da2861
commit
2e7883bc62
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
composer.lock
|
||||
/vendor/
|
||||
/node_modules/
|
||||
/dist/
|
||||
.idea
|
||||
|
61
Gulpfile.js
Normal file
61
Gulpfile.js
Normal file
@ -0,0 +1,61 @@
|
||||
var gulp = require('gulp');
|
||||
var clean = require('gulp-clean');
|
||||
var copy = require('gulp-copy');
|
||||
var zip = require('gulp-zip');
|
||||
var composer = require('gulp-composer');
|
||||
var phpunit = require('gulp-phpunit');
|
||||
var exec = require('child_process').exec;
|
||||
var phpcs = require('gulp-phpcs');
|
||||
var config = require('./package.json');
|
||||
|
||||
// Clean the target directory.
|
||||
gulp.task('clean', function () {
|
||||
console.log('Cleaning up target directory ...');
|
||||
return gulp.src('dist', {read: false})
|
||||
.pipe(clean());
|
||||
});
|
||||
|
||||
// Prepare composer.
|
||||
gulp.task('compose', function () {
|
||||
console.log('Preparing Composer ...');
|
||||
return composer('install');
|
||||
});
|
||||
|
||||
// Execute unit tests.
|
||||
gulp.task('test', ['compose'], function () {
|
||||
console.log('Running PHPUnit tests ...');
|
||||
return gulp.src('phpunit.xml')
|
||||
.pipe(phpunit('./vendor/bin/phpunit', {debug: false}));
|
||||
});
|
||||
|
||||
// Execute PHP Code Sniffer.
|
||||
gulp.task('test-cs', function (cb) {
|
||||
return exec('./vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs', function (err, stdout, stderr) {
|
||||
console.log(stdout);
|
||||
console.log(stderr);
|
||||
if (null === err) {
|
||||
console.log('Running PHP Code Sniffer tests ...');
|
||||
gulp.src(['statify-blacklist.php', 'inc/**/*.php'])
|
||||
.pipe(phpcs({bin: './vendor/bin/phpcs', standard: 'phpcs.xml'}))
|
||||
.pipe(phpcs.reporter('log'));
|
||||
}
|
||||
cb(err);
|
||||
});
|
||||
});
|
||||
|
||||
// Bundle files as required for plugin distribution..
|
||||
gulp.task('bundle', ['clean'], function () {
|
||||
console.log('Collecting files for package dist/' + config.name + config.version + ' ...');
|
||||
return gulp.src(['**/*.php', '!test/**', '!vendor/**', 'README.md', 'LICENSE.md'], {base: './'})
|
||||
.pipe(copy('./dist/' + config.name + '.' + config.version));
|
||||
});
|
||||
|
||||
// Create a ZIP package of the relevant files for plugin distribution.
|
||||
gulp.task('package', ['bundle'], function () {
|
||||
console.log('Building package dist/' + config.name + config.version + '.zip ...');
|
||||
return gulp.src('./dist/' + config.name + '.' + config.version + '/**')
|
||||
.pipe(zip(config.name + '.' + config.version + '.zip'))
|
||||
.pipe(gulp.dest('./dist'));
|
||||
});
|
||||
|
||||
gulp.task('default', ['clean', 'compose', 'test', 'test-cs', 'bundle', 'package']);
|
@ -83,6 +83,7 @@ Because of this, an IP blacklist can only be applied while processing the reques
|
||||
|
||||
### Work in Progress ###
|
||||
* Relicensed to GPLv2 or later
|
||||
* Fix problem with faulty IPv6 netmask in IP blacklist
|
||||
* Minor changes for WP Coding Standard
|
||||
|
||||
### 1.4.0 / 10.06.2017 ###
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "stklcode/statify-blacklist",
|
||||
"version": "1.4.1-dev",
|
||||
"description": "A blacklist extension for the famous Statify WordPress plugin",
|
||||
"keywords": [
|
||||
"wordpress",
|
||||
@ -23,6 +24,6 @@
|
||||
"require-dev": {
|
||||
"php": ">=5.5",
|
||||
"phpunit/phpunit": "*",
|
||||
"wp-coding-standards/wpcs": "~0.6.0"
|
||||
"wp-coding-standards/wpcs": "~0.11.0"
|
||||
}
|
||||
}
|
||||
|
17
package.json
Normal file
17
package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "statify-blacklist",
|
||||
"version": "1.4.1-dev",
|
||||
"description": "A blacklist extension for the famous Statify WordPress plugin",
|
||||
"author": "Stefan Kalscheuer",
|
||||
"license": "GPLv2 or later",
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-clean": "^0.3.2",
|
||||
"gulp-copy": "^1.0.0",
|
||||
"gulp-zip": "^4.0.0",
|
||||
"gulp-composer": "^0.4.0",
|
||||
"gulp-phpunit": "^0.23.0",
|
||||
"gulp-phpcs": "^2.0.0",
|
||||
"child_process": "^1.0.2"
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="StatifyBlacklist">
|
||||
<description>Derived from WordPress</description>
|
||||
<description>Derived from WordPress Coding Standard</description>
|
||||
|
||||
<rule ref="WordPress">
|
||||
<!-- Type hint checks mess up PHP 7 checks, while this plugin has compatibility level 5.5 and above. -->
|
||||
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
|
@ -2,8 +2,7 @@
|
||||
<phpunit bootstrap="./vendor/autoload.php">
|
||||
<testsuites>
|
||||
<testsuite name="Statify Blacklist TestSuite">
|
||||
<directory>./test</directory>
|
||||
<directory suffix="-test.php">./test/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
</phpunit>
|
||||
</phpunit>
|
||||
|
@ -7,11 +7,10 @@
|
||||
* @license GPL-2.0+
|
||||
*
|
||||
* @wordpress-plugin
|
||||
*
|
||||
* Plugin Name: Statify Blacklist
|
||||
* Plugin URI: https://de.wordpress.org/plugins/statify-blacklist/
|
||||
* Description: Extension for the Statify plugin to add a customizable blacklists.
|
||||
* Version: 1.4.0
|
||||
* Version: 1.4.1-dev
|
||||
* Author: Stefan Kalscheuer (@stklcode)
|
||||
* Author URI: https://www.stklcode.de
|
||||
* Plugin URI: https://wordpress.org/plugins/statify-blacklist
|
||||
|
@ -39,12 +39,12 @@ require_once( 'inc/statifyblacklist-admin.class.php' );
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
class StatifyBlacklistTest extends PHPUnit\Framework\TestCase {
|
||||
class StatifyBlacklist_Test extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Test simple referer filter.
|
||||
*/
|
||||
public function testRefererFilter() {
|
||||
public function test_referer_filter() {
|
||||
// Prepare Options: 2 blacklisted domains, disabled.
|
||||
StatifyBlacklist::$_options = array(
|
||||
'referer' => array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user