# Path: django_node/settings.py
# PACKAGE_DEPENDENCIES = setting_overrides.get(
#     'PACKAGE_DEPENDENCIES',
#     ()
# )
# 
# Path: django_node/utils.py
# def resolve_dependencies(node_version_required=None, npm_version_required=None, path_to_run_npm_install_in=None):
#     from . import node, npm  # Avoid a circular import
# 
#     # Ensure that the external dependencies are met
#     if node_version_required is not None:
#         node.ensure_version_gte(node_version_required)
#     if npm_version_required is not None:
#         npm.ensure_version_gte(npm_version_required)
# 
#     # Ensure that the required packages have been installed
#     if path_to_run_npm_install_in is not None:
#         npm.install(path_to_run_npm_install_in)


import os
import shutil
from .settings import PACKAGE_DEPENDENCIES
from .utils import resolve_dependencies


def install_dependencies(directory):
    resolve_dependencies(path_to_run_npm_install_in=directory)


def uninstall_dependencies(directory):
    path_to_dependencies = os.path.join(directory, 'node_modules')
    if os.path.isdir(path_to_dependencies):
        shutil.rmtree(path_to_dependencies)


def install_configured_package_dependencies():
    for directory in PACKAGE_DEPENDENCIES:
        install_dependencies(directory)


def uninstall_configured_package_dependencies():

# Path: django_node/settings.py
# PACKAGE_DEPENDENCIES = setting_overrides.get(
#     'PACKAGE_DEPENDENCIES',
#     ()
# )
# 
# Path: django_node/utils.py
# def resolve_dependencies(node_version_required=None, npm_version_required=None, path_to_run_npm_install_in=None):
#     from . import node, npm  # Avoid a circular import
# 
#     # Ensure that the external dependencies are met
#     if node_version_required is not None:
#         node.ensure_version_gte(node_version_required)
#     if npm_version_required is not None:
#         npm.ensure_version_gte(npm_version_required)
# 
#     # Ensure that the required packages have been installed
#     if path_to_run_npm_install_in is not None:
#         npm.install(path_to_run_npm_install_in)


# Path: django_node/package_dependent.py
import os
import shutil
from .settings import PACKAGE_DEPENDENCIES
from .utils import resolve_dependencies



def install_dependencies(directory):
    resolve_dependencies(path_to_run_npm_install_in=directory)


def uninstall_dependencies(directory):
    path_to_dependencies = os.path.join(directory, 'node_modules')
    if os.path.isdir(path_to_dependencies):
        shutil.rmtree(path_to_dependencies)


def install_configured_package_dependencies():
    for directory in PACKAGE_DEPENDENCIES:
        install_dependencies(directory)


def uninstall_configured_package_dependencies():

    for directory in PACKAGE_DEPENDENCIES: