/pw
Created
April 6, 2014 05:00
Processwire Commander
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "Creates a new Processwire Project" | |
print "Requires git and internet connection" | |
print "Usage: pw <name> <branch> <version>" | |
print 'Defaults: "Processwire" "master" "2.4.0"' | |
print "Branches: master dev" | |
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>" | |
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 "%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