Skip to content

Commit 0a8eabd

Browse files
author
Kelin Chauhan
committed
Added project files and wp-cli command
1 parent f29005c commit 0a8eabd

File tree

7 files changed

+435
-2
lines changed

7 files changed

+435
-2
lines changed

.travis.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
sudo: required
2+
3+
language: node_js
4+
node_js:
5+
- "0.10"
6+
7+
8+
before_install:
9+
- rm -rf ~/.gnupg
10+
11+
12+
before_script:
13+
- export PLUGIN_DIR=$(pwd)
14+
- ls -l
15+
- sudo rm -rf /etc/mysql/
16+
- sudo apt-get -qq purge mysql* graphviz*
17+
- sudo apt-get -qq autoremove
18+
- sudo apt-get update
19+
- sudo bash -c 'echo -e "[user]\n\tname = abc\n\temail = [email protected]" > /home/travis/.gitconfig'
20+
- sudo wget -qO ee rt.cx/ee && sudo bash ee
21+
- source /etc/bash_completion.d/ee_auto.rc
22+
- sudo ee -v
23+
- sudo lsb_release -a
24+
- sudo ee site create wp.localtest.me --wpfc --user=ADMINUSER [email protected] --pass=ADMINPASS
25+
- sudo chmod 777 -R /var/www
26+
- sudo nginx -t
27+
- sudo service nginx reload
28+
- cd /var/www/wp.localtest.me/htdocs/wp-content/plugins/ && ls
29+
- wp --allow-root plugin deactivate w3-total-cache
30+
- wp --allow-root plugin delete nginx-helper
31+
- mkdir nginx-helper
32+
- cd $PLUGIN_DIR
33+
- cp -Rf * /var/www/wp.localtest.me/htdocs/wp-content/plugins/nginx-helper/
34+
- cd /var/www/wp.localtest.me/htdocs/
35+
- wp plugin activate --all
36+
- cd $PLUGIN_DIR
37+
- cd tests/functional/
38+
- npm install -g nightwatch
39+
- npm install
40+
41+
script:
42+
- nightwatch

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "rtcamp/nginx-helper",
3+
"description": "Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.",
4+
"keywords": ["wordpress", "plugin", "nginx", "nginx-helper", "fastcgi", "redis-cache", "redis", "cache"],
5+
"homepage": "https://rtcamp.com/nginx-helper/",
6+
"license": "GPL-2.0+",
7+
"authors": [{
8+
"name": "rtCamp",
9+
"email": "[email protected]",
10+
"homepage": "https://rtcamp.com"
11+
}],
12+
"minimum-stability": "dev",
13+
"prefer-stable": true,
14+
"type": "wordpress-plugin",
15+
"support": {
16+
"issues": "https://github.com/rtCamp/nginx-helper/issues",
17+
"forum": "https://wordpress.org/support/plugin/nginx-helper",
18+
"wiki": "https://github.com/rtCamp/nginx-helper/wiki",
19+
"source": "https://github.com/rtCamp/nginx-helper/"
20+
},
21+
"require": {
22+
"php": ">=5.3.2",
23+
"composer/installers": "^1.0"
24+
},
25+
"require-dev": {
26+
"wpreadme2markdown/wpreadme2markdown": "*"
27+
}
28+
}

composer.lock

Lines changed: 200 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#! /bin/bash
2+
# A modification of Dean Clatworthy's deploy script as found here: https://github.com/deanc/wordpress-plugin-git-svn
3+
# The difference is that this script lives in the plugin's git repo & doesn't require an existing SVN repo.
4+
5+
# main config
6+
PLUGINSLUG="nginx-helper"
7+
MAINFILE="nginx-helper.php" # this should be the name of your main php file in the wordpress plugin
8+
#SVNUSER="rtcamp" # your svn username
9+
10+
11+
##### YOU CAN STOP EDITING HERE #####
12+
CURRENTDIR=`pwd`
13+
14+
# git config
15+
GITPATH="$CURRENTDIR/" # this file should be in the base of your git repository
16+
17+
# svn config
18+
SVNPATH="/tmp/$PLUGINSLUG" # path to a temp SVN repo. No trailing slash required and don't add trunk.
19+
SVNURL="https://plugins.svn.wordpress.org/$PLUGINSLUG/" # Remote SVN repo on wordpress.org, with no trailing slash
20+
21+
# Detect svn username based on url
22+
SVNUSER=$(cat ~/.subversion/auth/svn.simple/* | grep -A4 $(echo $SVNURL | awk -F// '{print $2}' | cut -d'/' -f1) | tail -n1)
23+
if [ -z "$SVNUSER" ]
24+
then
25+
SVNUSER="chandrapatel"
26+
fi
27+
28+
29+
# Let's begin...
30+
echo ".........................................."
31+
echo
32+
echo "Preparing to deploy WordPress plugin"
33+
echo
34+
echo ".........................................."
35+
echo
36+
37+
# Check version in readme.txt is the same as plugin file
38+
NEWVERSION1=`grep "^Stable tag" $GITPATH/readme.txt | awk -F' ' '{print $3}'`
39+
echo "readme version: $NEWVERSION1"
40+
#NEWVERSION2=`grep "^Version" $GITPATH/$MAINFILE | awk -F' ' '{print $2}'`
41+
NEWVERSION2=`grep -i "Version" $GITPATH/$MAINFILE | head -n1 | awk -F':' '{print $2}' | awk -F' ' '{print $1}'`
42+
echo "$MAINFILE version: $NEWVERSION2"
43+
44+
if [ "$NEWVERSION1" != "$NEWVERSION2" ]; then echo "Versions don't match. Exiting...."; exit 1; fi
45+
46+
echo "Versions match in readme.txt and PHP file. Let's proceed..."
47+
48+
cd $GITPATH
49+
bash readme.sh $SVNURL
50+
git add README.md
51+
echo -e "Enter a commit message for this new version: \c"
52+
read COMMITMSG
53+
git commit -am "$COMMITMSG"
54+
55+
echo "Tagging new version in git"
56+
git tag -a "$NEWVERSION1" -m "Tagging version $NEWVERSION1"
57+
58+
echo "Pushing latest commit to origin, with tags"
59+
git push origin master
60+
git push origin master --tags
61+
62+
echo
63+
echo "Creating local copy of SVN repo ..."
64+
svn co $SVNURL $SVNPATH
65+
66+
echo "Exporting the HEAD of master from git to the trunk of SVN"
67+
git checkout-index -a -f --prefix=$SVNPATH/trunk/
68+
69+
echo "Ignoring github specific files and deployment script"
70+
svn propset svn:ignore "deploy.sh
71+
readme.sh
72+
README.md
73+
.git
74+
.gitattributes
75+
.gitignore
76+
tests
77+
map.conf
78+
nginx.log" "$SVNPATH/trunk/"
79+
80+
echo "Changing directory to SVN and committing to trunk"
81+
cd $SVNPATH/trunk/
82+
# Add all new files that are not set to be ignored
83+
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
84+
svn commit --username=$SVNUSER -m "$COMMITMSG"
85+
86+
echo "Creating new SVN tag & committing it"
87+
cd $SVNPATH
88+
svn copy trunk/ tags/$NEWVERSION1/
89+
cd $SVNPATH/tags/$NEWVERSION1
90+
svn commit --username=$SVNUSER -m "Tagging version $NEWVERSION1"
91+
92+
echo "Removing temporary directory $SVNPATH"
93+
rm -fr $SVNPATH/
94+
95+
echo "*** FIN ***"

nginx-helper.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,18 @@ function deactivate_nginx_helper() {
8181
* @since 2.0.0
8282
*/
8383
function run_nginx_helper() {
84-
global $nginx_helper;
85-
84+
global $nginx_helper;
85+
8686
$nginx_helper = new Nginx_Helper();
8787
$nginx_helper->run();
8888

89+
// Load WP-CLI command.
90+
if ( defined( 'WP_CLI' ) && WP_CLI ) {
91+
92+
require_once plugin_dir_path( __FILE__ ) . 'wp-cli.php';
93+
\WP_CLI::add_command( 'nginx-helper', 'Nginx_Helper_WP_CLI_Command' );
94+
95+
}
96+
8997
}
9098
run_nginx_helper();

0 commit comments

Comments
 (0)