Exemple #1
0
def cmd_sync(args):
    """cmd_sync validate and prepare synchronization operation environment"""
    flags = Flags(install=not args.without_install,
                  update=not args.without_update,
                  downgrade=not args.without_downgrade,
                  remove=not args.without_remove)

    utility.ensure_directory(DEPSINSTALL_DIR_PATH)

    # load currently installed dependencies
    installedDeps = InstalledDependencies(load_installed_deps_file())
    # make sure all dependencies are installed
    check_integrity(installedDeps, DEPSINSTALL_DIR_PATH)
    
    dependencyManager = DependencyManager(installedDeps, DEPSINSTALL_DIR_PATH)

    registryClient = get_registry_client()
    if not registryClient:
        print "registry server is not set, please set it before running ppm"
        return

    settings = Settings()
    if settings.get_current_project():
        project_name = settings.get_current_project()
        try:
            jsonData = registryClient.get_project_details(project_name)
        except Exception as e:
            print "Error occured while retrieving project {p} details from registry server: {e}".format(p=project_name, e=str(e))
            return
    elif os.path.exists(REQDEPS_FILE_PATH):
        try:
            jsonData = utility.load_json_file(REQDEPS_FILE_PATH)
        except Exception as e:
            print "Error occured while reading {f}: {e}".format(f=os.path.basename(REQDEPS_FILE_PATH), e=str(e))
            return            
    else:
        print "unable to fetch dependencies, you have to set a project or create a {d} file".format(d=os.path.basename(REQDEPS_FILE_PATH))
        return

    requiredDeps = RequiredDependencies(jsonData.get('devdependencies',{}))
    
    repositoryClient = get_repository_client()

    # synchronizing dependencies
    sync_dependencies(requiredDeps, installedDeps, registryClient, repositoryClient, dependencyManager, flags)

    # save newly installed packages as current dependencies
    save_installed_deps(installedDeps.get_data())
Exemple #2
0
def load_installed_deps_file():
    installedDepsContents = None
    if os.path.exists(CURRENTDEPS_FILE_PATH):
        installedDepsContents = utility.load_json_file(CURRENTDEPS_FILE_PATH)
    return installedDepsContents