def update_master_files(dependencies):
    # Updates master.<platform>.js files accordingly
    for e in ['production', 'sandbox']:
        env_dir = '%s-env' % e
        env_path = os.path.join(version_dir_path(dependencies.version), env_dir)
        for p in ['android', 'ios']:
            print('Updating %s master.%s.js...' % (e, p))
            master_path = os.path.join(env_path, 'master.%s.js' % p)
            updated = '\n'

            for d in dependencies.dependency_list():
                platform_entry = dependencies.dependency_data[d]['entry'].get(p)
                if platform_entry:
                    updated += "require('%s');\n" % d
                    # Check if there are any "additional_requires" that we
                    # can include.
                    additional = dependencies.dependency_data[d] \
                    .get('additional_requires')

                    if additional:
                        for r in additional:
                            updated += "require('%s');\n" % r

            updated += '\n'
            updated += master_footer(p)
            updated += '\n'

            with open(master_path, 'w') as f:
                f.write(updated)
            print('Done')
def update_master_files(dependencies):
    # Updates master.<platform>.js files accordingly
    for e in ['production', 'sandbox']:
        env_dir = '%s-env' % e
        env_path = os.path.join(version_dir_path(dependencies.version),
                                env_dir)
        for p in ['android', 'ios']:
            print('Updating %s master.%s.js...' % (e, p))
            master_path = os.path.join(env_path, 'master.%s.js' % p)
            updated = '\n'

            for d in dependencies.dependency_list():
                platform_entry = dependencies.dependency_data[d]['entry'].get(
                    p)
                if platform_entry:
                    updated += "require('%s');\n" % d
                    # Check if there are any "additional_requires" that we
                    # can include.
                    additional = dependencies.dependency_data[d] \
                    .get('additional_requires')

                    if additional:
                        for r in additional:
                            updated += "require('%s');\n" % r

            updated += '\n'
            updated += master_footer(p)
            updated += '\n'

            with open(master_path, 'w') as f:
                f.write(updated)
            print('Done')
Ejemplo n.º 3
0
def build_header_bundle(version, minify, dev, sandbox, platform):
    """
    Takes a version of a base project, compiles a header bundle and writes it
    to stout.

    :param version: A string corresponding to the base version e.g. '0.1'
    """

    # Switch to the directory containing the correct version of our packager
    version_dir = version_dir_path(version)

    commands = ['node', 'index', '--header', '--platform', platform]

    if minify:
        commands.append('--minify')

    if dev:
        commands.append('--dev')

    if sandbox:
        commands.append('--sandbox')

    with cd(version_dir):
        header = subprocess.check_output(commands)
        print(header.decode('utf-8'))
def update_packages(dependencies):
    # Updates package.json files accordingly (production-env & sandbox-env).
    # If install is True, then install the latest packages also.
    # dependencies is a Dependencies object.

    for e in ['production', 'sandbox']:
        print(colored('Updating %s package.json file...' % e, 'yellow'))
        env_dir = '%s-env' % e
        env_path = os.path.join(version_dir_path(dependencies.version), env_dir)
        pkg_path = os.path.join(env_path, 'package.json')
        dependencies.update_package_file(pkg_path, e)

        update_modules = yn(colored('Would you like to update your local ' \
                                    'node_modules? [Y/n] ', 'yellow'))
        if update_modules:
            npm_install(env_path)
def update_packages(dependencies):
    # Updates package.json files accordingly (production-env & sandbox-env).
    # If install is True, then install the latest packages also.
    # dependencies is a Dependencies object.

    for e in ['production', 'sandbox']:
        print(colored('Updating %s package.json file...' % e, 'yellow'))
        env_dir = '%s-env' % e
        env_path = os.path.join(version_dir_path(dependencies.version),
                                env_dir)
        pkg_path = os.path.join(env_path, 'package.json')
        dependencies.update_package_file(pkg_path, e)

        update_modules = yn(colored('Would you like to update your local ' \
                                    'node_modules? [Y/n] ', 'yellow'))
        if update_modules:
            npm_install(env_path)
def main():
    print('Installing packager dependencies...')
    with cd(SERVER_DIR):
        print('\n[Installing dependencies for packager server]')
        subprocess.call(['npm', 'install', '--loglevel', 'http'])

    versions = get_versions()
    for v in versions:
        # Check if a node_modules_dir exists in the version dir.
        # If it does, then this version has been installed
        print('\n[Installing dependencies for packager v%s]' % v)
        version_directory = version_dir_path(v)
        with cd(version_directory):
            subprocess.call(['npm', 'install', '--loglevel', 'http'])

        production_env_dir = version_production_env_path(v)
        with cd(production_env_dir):
            subprocess.call(['npm', 'install', '--loglevel', 'http'])
Ejemplo n.º 7
0
def main():
    print('Installing packager dependencies...')
    with cd(SERVER_DIR):
        print('\n[Installing dependencies for packager server]')
        subprocess.call(['npm', 'install', '--loglevel', 'http'])

    versions = get_versions()
    for v in versions:
        # Check if a node_modules_dir exists in the version dir.
        # If it does, then this version has been installed
        print('\n[Installing dependencies for packager v%s]' % v)
        version_directory = version_dir_path(v)
        with cd(version_directory):
            subprocess.call(['npm', 'install', '--loglevel', 'http'])

        production_env_dir = version_production_env_path(v)
        with cd(production_env_dir):
            subprocess.call(['npm', 'install', '--loglevel', 'http'])