Commit 7bc5484d by Paul Hocker

added new command;

parent 7baf3ef8
Version 0.5
Version 1.0
- complete rewrite of tool
- nifty new ascii art logo
- better git support
- using yapsy for module and command plugins
Version 0.3
- bug fixes
Version 0.1
- first release
\ No newline at end of file
- first release
# Copyright 2016, SpockerDotNet LLC
__version__ = '0.6.1'
__version__ = '0.7.0'
__copyright__ = 'Copyright 2016-2017, SpockerDotNet LLC'
__logo__ = '''
......
......@@ -23,23 +23,33 @@ def _copy_module(project, module):
def _install_main(project):
install = True
logging.log(99, 'Installing Project [{0}]'.format(project.name))
# do NOT install if the project path already exists
if os.path.exists(project.project_path):
logging.debug('- project folder already present')
if project.args.force:
logging.debug('- using the force to remove the project folder')
helper.clean_folder(project.project_path)
else:
raise Exception('Project Path Already Exists at [{0}] -- Try Using the --force'.format(project.project_path))
# create repository
logging.debug('- ignoring presence of existing project folder, skipping main project install')
install = False
# create the repository
logging.debug('- check to see if the repository exists at [{0}]'.format(project.repository_path))
if not os.path.exists(project.repository_path):
os.makedirs(project.repository_path)
logging.debug('- new repositor created at [{0}]'.format(project.repository_path))
# create project
logging.debug('- check to see if the project exists at [{0}]'.format(project.project_path))
if not os.path.exists(project.project_path):
os.makedirs(project.project_path)
_install_module(project, project.main)
# create the project if we need to
if install:
logging.debug('- check to see if the project exists at [{0}]'.format(project.project_path))
if not os.path.exists(project.project_path):
os.makedirs(project.project_path)
_install_module(project, project.main)
def _install_modules(project):
......
import logging
import argparse
import os
import umodules.helper as helper
from umodules.command import ICommand
class Install(ICommand):
def create_project(project, project_path):
def run(self, project):
# check for file in base template folder
# create unity project
logging.debug("- creating unity project folder [{0}]".format(project_path))
os.makedirs(project_path)
os.makedirs(project_path + '/Assets')
os.makedirs(project_path + '/Assets/' + project.args.name)
os.makedirs(project_path + '/Assets/' + project.args.name + 'Work')
os.makedirs(project_path + '/Assets/' + project.args.name + 'Test')
# check for file in base template folder
try:
filename = project.args.template + ".yml"
template_path = os.path.abspath(project.home_path + "/templates/" + filename)
try:
template_path = os.path.abspath(project.options['template_path'] + filename)
logging.debug("- looking for project template [{0}]".format(template_path))
if not os.path.exists(template_path):
# check for file in config template folder
template_path = os.path.abspath(project.home_path + "/templates/" + filename)
logging.debug("- looking for project template [{0}]".format(template_path))
if not os.path.exists(template_path):
logging.debug("- unable to locate the project template [{0}]".format(template_path))
raise Exception("uModules Template [{0}] was not Found.".format(filename))
logging.debug("- found project template [{0}]".format(template_path))
# copy and replace project name
newfile = project.args.name + ".yml"
newpath = "./" + newfile
f1 = open(template_path, 'r')
f2 = open(newpath, 'w')
for line in f1:
line = line.replace('$project_name$', project.args.name)
line = line.replace('$project_name:lower$', project.args.name.lower())
f2.write(line)
f2.close()
f1.close()
# check for gitignore template
filename = "gitignore"
template_path = os.path.abspath(project.options['template_path'] + filename)
logging.debug("- looking for project template [{0}]".format(template_path))
if not os.path.exists(template_path):
# check for file in config template folder
template_path = os.path.abspath(project.home_path + "/templates/" + filename)
logging.debug("- looking for project template [{0}]".format(template_path))
if not os.path.exists(template_path):
# check for file in config template folder
template_path = os.path.abspath(project.options['template_path'] + filename)
logging.debug("- looking for project template [{0}]".format(template_path))
if not os.path.exists(template_path):
logging.debug("- unable to locate the project template [{0}]".format(template_path))
raise Exception("uModules Template [{0}] was not Found.".format(filename))
# copy and replace project name
newfile = project.args.name + ".yml"
newpath = "./" + newfile
f1 = open(template_path, 'r')
f2 = open(newpath, 'w')
for line in f1:
line = line.replace('$project_name$', project.args.name)
line = line.replace('$project_name:lower$', project.args.name.lower())
f2.write(line)
f2.close()
f1.close()
except Exception as e:
raise e
logging.debug("- unable to locate the project template [{0}]".format(template_path))
raise Exception("uModules Template [{0}] was not Found.".format(filename))
logging.debug("- found project template [{0}]".format(template_path))
# copy and replace project name
newfile = project_path + "/.gitignore"
newpath = "./" + newfile
f1 = open(template_path, 'r')
f2 = open(newpath, 'w')
for line in f1:
line = line.replace('$project_name$', project.args.name)
line = line.replace('$project_name:lower$', project.args.name.lower())
f2.write(line)
f2.close()
f1.close()
except Exception as e:
raise e
class Install(ICommand):
def run(self, project):
project_path = "./" + project.args.name
# check if the project path is already there
if os.path.exists(project_path):
if not project.args.force:
raise Exception("Project [{0}] already exists, use the --force to overwrite".format(project.args.name))
else:
logging.debug("- using the force to overwrite existing project")
helper.clean_folder(project_path)
create_project(project, project_path)
def build(self, subparser):
super().build(subparser)
......
......@@ -17,10 +17,10 @@ from distutils.file_util import copy_file
def import_package(project, src, dest):
logging.debug('- importing unity package from {0} into {1}'.format(src, dest))
#cmd = '{0} -createProject {1} -importPackage \"{2}\" -quit -batchmode -nographics'\
# .format(build_unity_command(project.unity_path), dest, src)
cmd = '{0} -createProject {1} -importPackage \"{2}\" '\
cmd = '{0} -createProject {1} -importPackage \"{2}\" -quit -batchmode -nographics'\
.format(build_unity_command(project.unity_path), dest, src)
#cmd = '{0} -createProject {1} -importPackage \"{2}\" '\
# .format(build_unity_command(project.unity_path), dest, src)
try:
run_command(cmd)
except Exception as e:
......
# general information
project: $project_name$
project_path: .
unity_path: /path/to/unity
unity_packages_path: ./assets
unity_path: $unity_path$
unity_packages_path: $asset_path$
default_type: git
# main project
......
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
# Autogenerated solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
# Unity3D generated meta files
*.pidb.meta
# Unity3D Generated File On Crash Reports
sysinfo.txt
# Builds
*.apk
*.unitypackage
# OS Generated
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Ignore everything in Assets except for our Project Folder
Assets/*
!Assets/$project_name$*
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment