def build(session, config, cdnPrefix="asset", compressionLevel=2, formattingLevel=0, kernelName="unify.Kernel"): name = config.get("name") assetManager = AssetManager(session) outputManager = OutputManager(session, assetManager, compressionLevel, formattingLevel) fileManager = FileManager(session) session.setField("unify.application.namespace", name) # Assets assetManager.addBuildProfile(cdnPrefix) assetManager.deploy(Resolver(session).addClassName("%s.Application" % name).getIncludedClasses()) # Store loader script if jasy.__version__ < "1.1": outputManager.storeKernel("$prefix/script/kernel.js", classes=[kernelName]) else: outputManager.storeKernel("$prefix/script/kernel.js", kernelName) # Copy files from source fileManager.updateFile("source/index.html", "$prefix/index.html") # Process every possible permutation for permutation in session.permutate(): # Resolving dependencies resolver = Resolver(session).addClassName("%s.Application" % name) # Compressing classes outputManager.storeCompressed(resolver.getSortedClasses(), "$prefix/script/%s-$permutation.js" % name, "unify.core.Init.startUp();")
def test_build(main="test.Main"): """Generates build (deployment) version of test runner""" session.setField("debug", True) session.permutateField("json") session.permutateField("engine") session.permutateField("runtime") # Initialize shared objects assetManager = AssetManager(session).addBuildProfile() outputManager = OutputManager(session, assetManager, compressionLevel=2) fileManager = FileManager(session) # Deploy assets outputManager.deployAssets([main]) # Store kernel script outputManager.storeKernel("{{prefix}}/script/kernel.js", bootCode="test.Kernel.init();") # Copy files from source for name in ["index.html", "phantom.js", "node.js"]: fileManager.updateFile("source/%s" % fileName, "{{prefix}}/%s" % fileName) for permutation in session.permutate(): # Resolving dependencies classes = Resolver(session).addClassName(main).getSortedClasses() # Compressing classes outputManager.storeCompressed(classes, "{{prefix}}/script/test-{{id}}.js")
def api(): """Generates the API viewer for the current project""" sourceFolder = session.getProjectByName("core").getPath() + "/source/" # Configure fields session.setField("debug", False) session.permutateField("es5") # Initialize shared objects assetManager = AssetManager(session).addBuildProfile() outputManager = OutputManager(session, assetManager, compressionLevel=2) fileManager = FileManager(session) # Deploy assets outputManager.deployAssets(["core.apibrowser.Browser"]) # Write kernel script outputManager.storeKernel("{{prefix}}/script/kernel.js", bootCode="core.apibrowser.Kernel.init();") # Copy files from source fileManager.updateFile(sourceFolder + "/apibrowser.html", "{{prefix}}/index.html") # Rewrite template as jsonp for tmpl in ["main", "error", "entry", "type", "params", "info", "origin", "tags"]: jsonTemplate = json.dumps({ "template" : open(sourceFolder + "/tmpl/apibrowser/%s.mustache" % tmpl).read() }) fileManager.writeFile("{{prefix}}/tmpl/%s.js" % tmpl, "apiload(%s, '%s.mustache')" % (jsonTemplate, tmpl)) # Process every possible permutation for permutation in session.permutate(): # Resolving dependencies resolver = Resolver(session).addClassName("core.apibrowser.Browser") # Compressing classes outputManager.storeCompressed(resolver.getSortedClasses(), "{{prefix}}/script/apibrowser-{{id}}.js", "new core.apibrowser.Browser;") # Write API data ApiWriter(session).write("{{prefix}}/data")
def build(session, config, cdnPrefix="asset", compressionLevel=2, formattingLevel=0, kernelName="unify.Kernel"): # Check for new jasy replacement system (1.1.0-rc4) if session.expandFileName("{{id}}") != "{{id}}": PREFIX = "{{prefix}}" HASH = "{{id}}" else: PREFIX = "$prefix" HASH = "$permutation" name = config.get("name") assetManager = AssetManager(session) outputManager = OutputManager(session, assetManager, compressionLevel, formattingLevel) fileManager = FileManager(session) session.setField("unify.application.namespace", name) # Assets assetManager.addBuildProfile(cdnPrefix) assetManager.deploy(Resolver(session).addClassName("%s.Application" % name).getIncludedClasses()) # Store loader script if jasy.__version__ < "1.1": outputManager.storeKernel(PREFIX + "/script/kernel.js", classes=[kernelName]) else: outputManager.storeKernel(PREFIX + "/script/kernel.js", kernelName) # Copy files from source fileManager.updateFile("source/index.html", PREFIX + "/index.html") # Process every possible permutation for permutation in session.permutate(): # Resolving dependencies resolver = Resolver(session).addClassName("%s.Application" % name) # Compressing classes outputManager.storeCompressed( resolver.getSortedClasses(), (PREFIX + "/script/%s-" + HASH + ".js") % name, "unify.core.Init.startUp();" )