Skip to content

Instantly share code, notes, and snippets.

/pw

Created April 6, 2014 05:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/10001724 to your computer and use it in GitHub Desktop.
Save anonymous/10001724 to your computer and use it in GitHub Desktop.
Processwire Commander
#!/usr/bin/python
"""
/*
* Processwire Commander
*
* Creates new Processwire Projects
* Version 1.0.0
* April 2014
* ----------------------------------------------------------------------------
*
* "THE BEER-WARE LICENSE" (Revision 42):
* <camilo@cervezapps.cl> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return Camilo Castro. (CLSource)
* ----------------------------------------------------------------------------
*/
"""
import os,sys
import subprocess
# Subprocess Call with /dev/null for silence
def call(command):
with open(os.devnull, "w") as fnull:
result = subprocess.call(command, stdout = fnull, stderr = fnull)
# Get Project Name
try:
name = sys.argv[1]
except:
name = "ProcessWire"
# Check for help command
if name == 'help':
print
print "Creates a new Processwire Project"
print "Requires git and internet connection"
print
print "Usage: pw <name> <branch> <version>"
print
print 'Defaults: "Processwire" "master" "2.4.0"'
print
print "Branches: master dev"
print
print """Versions Available:
2.2.4
2.2.5
2.2.8
2.2.9
2.2.9.final
2.3.0
2.3.1
2.4.0 (lastest)
"""
print "Made with love by CLSource <camilo@cervezapps.cl>"
print
sys.exit(0)
# Get Project PW Branch
try:
branch = sys.argv[2]
except:
branch = "master"
# Get Project PW Version
try:
version = sys.argv[3]
except:
version = "lastest"
# Get the lastest pw
# Show the output
subprocess.call(["git", "clone", "https://github.com/ryancramerdesign/ProcessWire.git"])
# Rename the directory
print "Renaming"
call(["mv", "ProcessWire", name])
# Go inside
path = "./%s" % (name)
os.chdir(path)
# Checkout to branch
print "Checkout to Branch and Version"
if version != "lastest":
call(["git", "checkout","-b", branch, version])
else:
call(["git", "checkout", branch])
# Remove ProcessWire Git History
print "Cleaning"
call(["rm", "-rf", ".git"])
# Create a Clean Git VCS
print "Init Git"
call(["git", "init"])
call(["git", "add", "."])
call(["git", "commit", "-m", "Initial PW Setup"])
# Go back
os.chdir("../")
print
print "%s Setup Complete" % (name)
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment