# -*- coding: utf-8 -*- """ Configure the build process for the plugin dbui """ import os import re import tempfile # ............................................................................ # # JAVASCRIPT LIBRARY # JavaScript source code and compile version # paths are relative to the static directory # SENCHA_CLS = [ "plugin_extjs/packages/core/src", "plugin_extjs/classic/classic/src", "plugin_extjs/classic/classic/overrides", "plugin_dbui/src"] SENCHA_NS = "Ext" JSLIBDEBUG = "plugin_dbui/dbui-debug.js" JSLIBMIN = "plugin_dbui/dbui-min.js" # ........................................................................... # # DOCUMENTATION # output directories for documentation # paths are relative to the static directory # DOCS_DIR = "plugin_dbui/docs" JSDOC = "plugin_dbui/docs/jsduck" LATEXDOC = "plugin_dbui/docs/latex" PDFDOC = "plugin_dbui/docs/pdf" # ........................................................................... # # PLUGINS # ace, dbui, extjs and mathjax # paths are relative to the application directory # PLUGINS_FILES = {} PLUGINS_FILES["default"] = [ "controllers/plugin_%s.py", "models/plugin_%s.py", "modules/plugin_%s", "private/plugin_%s", "static/plugin_%s", "views/plugin_%s"] PLUGINS_FILES["ace"] = [ "static/plugin_ace/src-min-noconflict/ace.js", "static/plugin_ace/src-min-noconflict/mode-json.js", "static/plugin_ace/src-min-noconflict/theme-crimson_editor.js", "static/plugin_ace/src-min-noconflict/worker-json.js"] PLUGINS_FILES["dbui"] = [ "modules/plugin_dbui", "models/plugin_dbui.py", "controllers/plugin_dbui.py", "views/plugin_dbui", "static/plugin_dbui/resources/css/kde-oxygen.css", "static/plugin_dbui/resources/css/dbui.css", "static/plugin_dbui/resources/icons", "static/plugin_dbui/src", "static/plugin_dbui/locale/dbui-lang-en.js", "static/plugin_dbui/locale/dbui-lang-fr.js", "static/plugin_dbui/dbui-min.js", "static/plugin_dbui/docs"] PLUGINS_FILES["extjs"] = [ "static/plugin_extjs/build/classic/locale", "static/plugin_extjs/build/classic/theme-classic", "static/plugin_extjs/build/ext-all.js", "static/plugin_extjs/build/ext-all-debug.js", "static/plugin_extjs/classic/classic/src", "static/plugin_extjs/classic/classic/overrides", "static/plugin_extjs/packages/core/src", "static/plugin_extjs/version.properties"] PLUGINS_FILES["mathjax"] = [ "static/plugin_mathjax/fonts/HTML-CSS/TeX/woff", "static/plugin_mathjax/images", "static/plugin_mathjax/jax", "static/plugin_mathjax/extensions", "static/plugin_mathjax/MathJax.js"] # ............................................................................ # # REFERENCE FILES # - path are relative to the static repository # DBUIJS = "plugin_dbui/src/Dbui.js" def commit_release(): """Commit release CHANGELOG, VERSION and DBUIJS files """ print "\n", "."*79 print "\n\tCommit CHANGELOG, DBUIJS, VERSION, ..." if not which("git", localhost=True): error('\n\tThe application git is missing !') print '\tSkip this step.\n' return # move to the master branch git("checkout master") # Commit modified files print '\n\tgit add', DBUIJS, CHANGELOG, VERSION git("add", DBUIJS, CHANGELOG, VERSION) msg = "Start release candidate %s" % get_version() print '\tgit commit:', msg git("commit -m", msg) def get_plugin_version(plugin): """ Args: plugin (str): name of the plugin Return: str: the plugin version """ if plugin == "ace": cwd = os.getcwd() os.chdir("static/plugin_ace") with tempfile.TemporaryFile() as tmpfile: git("describe --tags", stdout=tmpfile) tmpfile.seek(0) release = tmpfile.read() release = release.replace("v", "").replace("\n", "") os.chdir(cwd) elif plugin == "dbui": filename = os.path.join("static", DBUIJS) with open(filename, "rb") as tmpfile: text = tmpfile.read() match = re.match(r"(.+ version: ')([\w._-]*)('.+)", text, re.DOTALL) release = match.group(2) elif plugin == "extjs": fn = os.path.join('static', 'plugin_extjs', 'version.properties') if not os.path.exists(fn): error("\n\tNo version file for the plugin extjs !") sys.exit(1) with open(fn, 'rb') as fi: s = fi.read() match = re.search(r"version.release=(\d+(\.\d+)*)", s) if not match: error("\n\tExt JS release number not defined !") sys.exit(1) release = match.group(1) elif plugin == "mathjax": filename = os.path.join('static', 'plugin_mathjax', 'MathJax.js') with open(filename, 'rb') as tmpfile: text = tmpfile.read() match = re.match(r'.+MathJax.version="(\d+(\.\d+)*)";', text, re.DOTALL) if not match: error("\n\tMathJax release number not defined !") sys;exit(1) release = match.group(1) else: error("\n\tUnknown plugin %" % plugin) sys.exit(1) # shrink the release identifier 4.2.1 or 4.2.1.883 -> 421 li = release.split('.') release = ''.join(li) if len(li) < 4 else ''.join(li[:-1]) if len(release) == 2: release = "%s0" % release return release def set_version(version): """Set release identifier in CHANGELOG, VERSION and Dbui.js Args: version (str): release identifier """ print "\n", "."*79 print "Update CHANGELOG and Dbui.js files with release", version, "..." # check tag in git if version in check_output(["git", "tag"]).split("\n"): print "\n\tRelease %s already exit in git" % version sys.exit(1) print 'Set release', version, 'in', DBUIJS with open(DBUIJS) as fi: txt = fi.read() # look for a pattern Dbui.version = '0.8.3'; in appbase.js # split the the string in 3 parts (pre, version, post) match = re.match(r"(.+ version: ')([\w._-]*)('.+)", txt, re.DOTALL) if match.group(2) == version: msg = '\n\tVersion "%s" already exists in the Dbui.js file !' print msg % version rep = raw_input('\tDo you want to continue [n]?') if rep not in ('y', 'yes'): sys.exit(1) # update the version and write a new file txt = match.group(1) + version + match.group(3) with open(DBUIJS, 'w') as fi: fi.write(txt) # look for a pattern HEAD in the CHANGELOG # split the the string in 2 parts (pre HEAD, post HEAD) print 'Set release', version, 'in', CHANGELOG with open(CHANGELOG) as fi: txt = fi.read() match = re.match("(.+HEAD\n)(.*)", txt, re.DOTALL) if match is None: print '\n\tNo HEAD tag in the CHANGELOG!\n' rep = raw_input('\tDo you want to continue [n]?') if rep not in ('y', 'yes'): sys.exit(1) # update the version and edit the CHANGELOG tpl = (match.group(1), version, NOW.strftime('%b %Y'), match.group(2)) txt = '%s\n%s (%s)\n%s' % tpl with open(CHANGELOG, 'w') as fi: fi.write(txt) call(["vim", CHANGELOG]) # update VERSION print 'Set release', version, 'in', VERSION with open(VERSION, 'w') as fi: fi.write(version) # cleaning fn = "%s~" % CHANGELOG if os.path.exists(fn): os.remove(fn)