Example #1
0
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")
Example #2
0
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();")
Example #3
0
def source(session, config, 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, 0, 1)

    session.setField("unify.application.namespace", name)

    assetManager.addSourceProfile()
    if jasy.__version__ < "1.1":
        outputManager.storeKernel(PREFIX + "/script/kernel.js", classes=[kernelName])
    else:
        outputManager.storeKernel(PREFIX + "/script/kernel.js", kernelName)

    for permutation in session.permutate():
        # Resolving dependencies
        resolver = Resolver(session).addClassName("%s.Application" % name)

        # Building class loader
        outputManager.storeLoader(
            resolver.getSortedClasses(), (PREFIX + "/script/%s-" + HASH + ".js") % name, "unify.core.Init.startUp();"
        )
Example #4
0
def test_source(main="test.Main"):
    """Generates source (development) version of test runner"""

    session.setField("debug", True)
    session.permutateField("json")
    session.permutateField("engine")
    session.permutateField("runtime")

    # Initialize shared objects
    assetManager = AssetManager(session).addSourceProfile()
    outputManager = OutputManager(session, assetManager, compressionLevel=0, formattingLevel=1)
    fileManager = FileManager(session)
    
    # Store kernel script
    outputManager.storeKernel("{{prefix}}/script/kernel.js", bootCode="test.Kernel.init();")
    
    for permutation in session.permutate():

        # Resolving dependencies
        classes = Resolver(session).addClassName(main).getSortedClasses()

        # Writing source loader
        outputManager.storeLoader(classes, "{{prefix}}/script/test-{{id}}.js")
Example #5
0
def source(session, config, kernelName="unify.Kernel"):
	name = config.get("name")
	assetManager = AssetManager(session)
	outputManager = OutputManager(session, assetManager, 0, 1)

	session.setField("unify.application.namespace", name)

	assetManager.addSourceProfile()
	if jasy.__version__ < "1.1":
		outputManager.storeKernel("$prefix/script/kernel.js", classes=[kernelName])
	else:
		outputManager.storeKernel("$prefix/script/kernel.js", kernelName)

	for permutation in session.permutate():
		# Resolving dependencies
		resolver = Resolver(session).addClassName("%s.Application" % name)
		
		# Building class loader
		outputManager.storeLoader(resolver.getSortedClasses(), "$prefix/script/%s-$permutation.js" % name, "unify.core.Init.startUp();")
Example #6
0
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")
Example #7
0
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();"
        )
Example #8
0
def cacheManifest(session,
                  startClassName,
                  scripts=["script/application-%s.js"],
                  htmlfile="index.html",
                  kernel="script/kernel.js",
                  ignoreAssets=False):
    # Check for new jasy replacement system (1.1.0-rc4)
    if session.expandFileName("{{id}}") != "{{id}}":
        PREFIX = "{{prefix}}"
        HASH = "{{id}}"
    else:
        PREFIX = "$prefix"
        HASH = "$permutation"

    timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
    appcache = """CACHE MANIFEST

# Jasy AppCache Manifest file
# Version: {version}

CACHE:
{htmlfile}
{kernel}
{scripts}
{assets}

NETWORK:
*"""

    htmlcache = '<!DOCTYPE html><html manifest="%s"></html>'
    assetManager = AssetManager(session).addBuildProfile()
    outputManager = OutputManager(session, assetManager)
    fileManager = FileManager(session)

    # Create an application cache file for each permutation
    for permutation in session.permutate():
        if ignoreAssets:
            assets = []
        else:
            classes = Resolver(session).addClassName(
                startClassName).getSortedClasses()
            assetConfig = json.loads(assetManager.export(classes))
            assets = filenamesFromAsset("", assetConfig["assets"],
                                        assetConfig["profiles"])

        # Set options
        if hasattr(permutation, "getId"):
            checksum = permutation.getId()
        else:
            checksum = session.expandFileName(
                HASH)  #instead of permutation.getChecksum()

        scriptFiles = []
        for script in scripts:
            scriptFiles.append(script % checksum)

        manifestFilename = "appcache-%s.manifest" % (checksum)
        fileManager.writeFile(
            PREFIX + "/" + manifestFilename,
            appcache.format(version=timestamp,
                            htmlfile=htmlfile,
                            kernel=kernel,
                            scripts="\n".join(scriptFiles),
                            assets="\n".join(assets)))

        fileManager.writeFile(PREFIX + "/index-%s.html" % (checksum),
                              htmlcache % manifestFilename)