Example #1
0
def build(env, ciprcfg, console):
    """
    Build the current project for distribution
    """
    os.putenv('CIPR_PACKAGES', env.package_dir)
    os.putenv('CIPR_PROJECT', env.project_directory)
        
    if path.exists(env.build_dir):
        shutil.rmtree(env.build_dir)
        
    os.makedirs(env.build_dir)
        
    if not path.exists(env.dist_dir):
        os.makedirs(env.dist_dir)

    for src, dst in util.sync_dir_to(env.project_directory, env.build_dir, exclude=['.cipr', '.git', 'build', 'dist']):
        console.quiet('  %s -> %s' % (src, dst))
    
    for package in ciprcfg.packages.keys():
        for src, dst in util.sync_lua_dir_to(path.join(env.package_dir, package), env.build_dir, exclude=['.git'], include=['*.lua']):
            console.quiet('  %s -> %s' % (src, dst))        
    
    src = path.join(env.code_dir, 'cipr.lua')
    dst = path.join(env.build_dir, 'cipr.lua')
    shutil.copy(src, dst)
        
    cmd = AND(clom.cd(env.build_dir), clom['/Applications/CoronaSDK/Corona Terminal'](env.build_dir))

    console.normal('Be sure to output your app to %s' % env.dist_dir)
    
    try:
        cmd.shell.execute()
    except KeyboardInterrupt:
        pass
Example #2
0
def build(env, ciprcfg, console):
    """
    Build the current project for distribution
    """
    os.putenv('CIPR_PACKAGES', env.package_dir)
    os.putenv('CIPR_PROJECT', env.project_directory)

    build_settings = path.join(env.project_directory, 'build.settings')

    with open(build_settings, 'r') as f:
        data = f.read()

    m = _build_re.search(data)
    if m:
        ver = int(m.group(2))
        data = data.replace(m.group(0), 'CFBundleVersion = "%d"' % (ver + 1))

        with open(build_settings, 'w') as f:
            f.write(data)


    if path.exists(env.build_dir):
        shutil.rmtree(env.build_dir)

    os.makedirs(env.build_dir)

    if path.exists(env.dist_dir):
        shutil.rmtree(env.dist_dir)

    os.makedirs(env.dist_dir)

    console.normal('Building in %s' % env.build_dir)

    console.normal('Copy project files...')
    for src, dst in util.sync_dir_to(env.project_directory, env.build_dir, exclude=['.cipr', '.git', 'build', 'dist', '.*']):
        console.quiet('  %s -> %s' % (src, dst))
        if src.endswith('.lua'):
            _fix_lua_module_name(src, dst)


    console.normal('Copy cipr packages...')
    for package in ciprcfg.packages.keys():
        for src, dst in util.sync_lua_dir_to(path.join(env.package_dir, package), env.build_dir, exclude=['.git'], include=['*.lua']):
            console.quiet('  %s -> %s' % (src, dst))
            if src.endswith('.lua'):
                _fix_lua_module_name(src, dst)

    src = path.join(env.code_dir, 'cipr.lua')
    dst = path.join(env.build_dir, 'cipr.lua')
    shutil.copy(src, dst)

    cmd = AND(clom.cd(env.build_dir), clom['/Applications/CoronaSDK/Corona Terminal'](env.build_dir))

    console.normal('Be sure to output your app to %s' % env.dist_dir)

    try:
        cmd.shell.execute()
    except KeyboardInterrupt:
        pass
Example #3
0
def build(env, ciprcfg, console):
    """
    Build the current project for distribution
    """
    os.putenv('CIPR_PACKAGES', env.package_dir)
    os.putenv('CIPR_PROJECT', env.project_directory)

    build_settings = path.join(env.project_directory, 'build.settings')

    with open(build_settings, 'r') as f:
        data = f.read()

    m = _build_re.search(data)
    if m:
        ver = int(m.group(2))
        data = data.replace(m.group(0), 'CFBundleVersion = "%d"' % (ver + 1))

        with open(build_settings, 'w') as f:
            f.write(data)


    if path.exists(env.build_dir):
        shutil.rmtree(env.build_dir)

    os.makedirs(env.build_dir)

    if path.exists(env.dist_dir):
        shutil.rmtree(env.dist_dir)

    os.makedirs(env.dist_dir)

    console.normal('Building in %s' % env.build_dir)

    console.normal('Copy project files...')
    for src, dst in util.sync_dir_to(env.project_directory, env.build_dir, exclude=['.cipr', '.git', 'build', 'dist', '.*']):
        console.quiet('  %s -> %s' % (src, dst))
        if src.endswith('.lua'):
            _fix_lua_module_name(src, dst)


    console.normal('Copy cipr packages...')
    for package in ciprcfg.packages.keys():
        for src, dst in util.sync_lua_dir_to(path.join(env.package_dir, package), env.build_dir, exclude=['.git'], include=['*.lua']):
            console.quiet('  %s -> %s' % (src, dst))
            if src.endswith('.lua'):
                _fix_lua_module_name(src, dst)

    src = path.join(env.code_dir, 'cipr.lua')
    dst = path.join(env.build_dir, 'cipr.lua')
    shutil.copy(src, dst)

    cmd = AND(clom.cd(env.build_dir), clom[CORONA_SIMULATOR_PATH](env.build_dir))

    console.normal('Be sure to output your app to %s' % env.dist_dir)

    try:
        cmd.shell.execute()
    except KeyboardInterrupt:
        pass
Example #4
0
def open_in_terminal():
    dirs_to_open = [p for p in nautilus.paths if os.path.isdir(p)]

    if (not dirs_to_open) or (len(dirs_to_open) != len(nautilus.files)):
        dirs_to_open.append(nautilus.current_path)

    xterm = getattr(clom, 'x-terminal-emulator')
    for p in dirs_to_open:
        AND(clom.cd(p), xterm).shell()
Example #5
0
def run(env):
    """
    Run current project in the Corona Simulator
    """
    os.putenv('CIPR_PACKAGES', env.package_dir)
    os.putenv('CIPR_PROJECT', env.project_directory)

    # `Corona Terminal` doesn't support spaces in filenames so we cd in and use '.'.

    cmd = AND(
        clom.cd(path.dirname(env.project_directory)), clom[
            '/Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS/Corona Simulator']
        (path.basename(env.project_directory)))

    try:
        cmd.shell.execute()
    except KeyboardInterrupt:
        pass
Example #6
0
def run(env):
    """
    Run current project in the Corona Simulator
    """
    os.putenv('CIPR_PACKAGES', env.package_dir)
    os.putenv('CIPR_PROJECT', env.project_directory)

    # `Corona Terminal` doesn't support spaces in filenames so we cd in and use '.'.

    cmd = AND(
        clom.cd(path.dirname(env.project_directory)),
        clom['/Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS/Corona Simulator'](path.basename(env.project_directory))
    )

    try:
        cmd.shell.execute()
    except KeyboardInterrupt:
        pass
Example #7
0
def packageipa(env, console):    
    """
    Package the built app as an ipa for distribution in iOS App Store
    """
    filenames = glob(path.join(env.dist_dir, '*.app'))
    filename, ext = path.splitext(path.basename(filenames[0]))
    ipa_name = filename + '.ipa'
    output_dir = path.dirname(env.dist_dir)
    ipa_path = path.join(output_dir, ipa_name)
    
    if path.exists(ipa_path):
        console.quiet('Removing %s' % ipa_path)
        os.remove(ipa_path)
        
    cmd = AND(clom.cd(output_dir), clom.zip(r=ipa_name).with_args('Payload/%s.app' % filename))
    cmd.shell.execute()


    console.quiet('Packaged %s' % ipa_path)
Example #8
0
def install(args, console, env, ciprcfg, opts):
    """
    Install a package from github and make it available for use.
    """
    if len(args) == 0:
        # Is this a cipr project?
        if ciprcfg.exists:
            # Install all the packages for this project
            console.quiet('Installing current project packages...')
            for name, source in ciprcfg.packages.items():
                if opts.upgrade:
                    app.command.run(['install', '--upgrade', source])
                else:
                    app.command.run(['install', source])
        else:
            console.error('No cipr project or package found.')
        return
    else:
        for source in args:
            package, name, version, type = _package_info(source)

            if not path.exists(env.package_dir):
                os.makedirs(env.package_dir)

            package_dir = path.join(env.package_dir, name)

            if path.exists(package_dir):
                if opts.upgrade:
                    app.command.run(['uninstall', name])
                else:
                    console.quiet(
                        'Package %s already exists. Use --upgrade to force a re-install.'
                        % name)
                    return

            console.quiet('Installing %s...' % name)

            if type == 'git':
                tmpdir = tempfile.mkdtemp(prefix='cipr')
                clom.git.clone(package, tmpdir).shell.execute()

                if version:
                    cmd = AND(clom.cd(tmpdir), clom.git.checkout(version))
                    cmd.shell.execute()

                package_json = path.join(tmpdir, 'package.json')
                if path.exists(package_json):
                    # Looks like a cipr package, copy directly
                    shutil.move(tmpdir, package_dir)
                else:
                    # Not a cipr package, sandbox in sub-directory
                    shutil.move(tmpdir, path.join(package_dir, name))

                console.quiet('`%s` installed from git repo to `%s`' %
                              (name, package_dir))

            elif path.exists(package):
                # Local
                os.symlink(package, package_dir)
            else:
                console.error('Package `%s` type not recognized' % package)
                return

            pkg = Package(package_dir, source)
            ciprcfg.add_package(pkg)

            if pkg.dependencies:
                console.quiet('Installing dependancies...')
                for name, require in pkg.dependencies.items():
                    if opts.upgrade:
                        app.command.run(['install', '--upgrade', require])
                    else:
                        app.command.run(['install', require])
Example #9
0
def install(args, console, env, ciprcfg, opts):
    """
    Install a package from github and make it available for use.
    """
    if len(args) == 0:
        # Is this a cipr project?
        if ciprcfg.exists:
            # Install all the packages for this project
            console.quiet('Installing current project packages...')
            for name, source in ciprcfg.packages.items():
                if opts.upgrade:
                    app.command.run(['install', '--upgrade', source])
                else:
                    app.command.run(['install', source])
        else:
            console.error('No cipr project or package found.')
        return
    else:
        for source in args:
            package, name, version, type = _package_info(source)

            if not path.exists(env.package_dir):
                os.makedirs(env.package_dir)

            package_dir = path.join(env.package_dir, name)

            if path.exists(package_dir):
                if opts.upgrade:
                    app.command.run(['uninstall', name])
                else:
                    console.quiet('Package %s already exists. Use --upgrade to force a re-install.' % name)
                    return

            console.quiet('Installing %s...' % name)


            if type == 'git':        
                tmpdir = tempfile.mkdtemp(prefix='cipr')
                clom.git.clone(package, tmpdir).shell.execute()

                if version:
                    cmd = AND(clom.cd(tmpdir), clom.git.checkout(version))
                    cmd.shell.execute()

                package_json = path.join(tmpdir, 'package.json')
                if path.exists(package_json):
                    # Looks like a cipr package, copy directly
                    shutil.move(tmpdir, package_dir)
                else:
                    # Not a cipr package, sandbox in sub-directory
                    shutil.move(tmpdir, path.join(package_dir, name))

                console.quiet('`%s` installed from git repo to `%s`' % (name, package_dir))

            elif path.exists(package):
                # Local        
                os.symlink(package, package_dir)
            else:
                console.error('Package `%s` type not recognized' % package)
                return
            
            pkg = Package(package_dir, source)
            ciprcfg.add_package(pkg)

            if pkg.dependencies:
                console.quiet('Installing dependancies...')
                for name, require in pkg.dependencies.items():
                    if opts.upgrade:
                        app.command.run(['install', '--upgrade', require])
                    else:
                        app.command.run(['install', require])