Internal types

ShareAdd.EnvNullType

Used to denote that package is to be deleted (like moving to an environment analog of dev/null)

source
ShareAdd.EnvSetType
struct EnvSet
  • envs::Set{String} - set of environment names
  • extraneous_pks::Set{String} - (internally used, see optim_set function for details)
  • extra_lng::Int - as above
  • no_of_sets::Int - as above
source

Internal functions

ShareAdd._collect_siblings!Method

Recursively collect packages from workspace projects into result, skipping the project at current_dir and any names already in current_deps.

source
ShareAdd._find_parent_workspaceMethod
_find_parent_workspace(project_file::String) -> Union{Nothing, String}

Low-level helper: walk up from project_file looking for an immediate parent workspace that lists the project.

source
ShareAdd._locate_project_fileMethod
_locate_project_file(dir) -> Union{Nothing, String}

Return the path to the first JuliaProject.toml or Project.toml found in dir, or nothing.

source
ShareAdd.activate_tempMethod
activate_temp()

If current environment is a temporary one, does nothing. Otherwise activates a temporary environment. If the initial environment was a package (under development), makes this package available in the new environment by calling Pkg.develop.

Returns nothing.

source
ShareAdd.check_packagesMethod
check_packages(packages; depot = first(DEPOT_PATH)) -> NamedTuple

checks whether packages are available in the current environment, shared environments, or are installable.

Returns a NamedTuple with the following fields:

  • inpath_pkgs: packages that are already present in some environment in LOAD_PATH
  • inshared_pkgs: packages that are available in some shared environments
  • installable_pkgs: available packages
  • unavailable_pkgs: packages that are not available from any registry
  • shared_pkgs: Dictionary of packages in shared environments
  • current_pr: information about the current environment as @NamedTuple{name::String, shared::Bool}
source
ShareAdd.check_workspace_packagesMethod
check_workspace_packages(packages, current_project::String)
    -> (workspace_pkgs::Vector{String}, workspace_paths::Dict{String,String})

Check which of the requested packages are available through workspace siblings of the environment at current_project.

Returns a tuple of:

  • workspace_pkgs – the subset of packages found in workspace siblings
  • workspace_paths – mapping from each such package name to the sibling project directory that provides it
source
ShareAdd.cleanup_testenvsMethod

Removes folders created in the ~/.julia/environments/ folder during the testing. Used in the test suite, but also on the package startup just for the case the test errored.

source
ShareAdd.delete_shared_envMethod
delete_shared_env(env::Union{AbstractString, EnvInfo}; force = SKIPPING)

Deletes the shared environment env by erasing it's directory. Set force=FORCING if you want to delete the environment even if it is currently in LOAD_PATH.

Returns true, if the environment has been deleted, and false otherwise.

source
ShareAdd.delete_shared_pkgMethod
delete_shared_pkg(pkg::AbstractString; inall, force)
delete_shared_pkg(p::Pair{EnvInfo, <:AbstractString}; force)
delete_shared_pkg(p::Pair{<:AbstractString, <:AbstractString}; force)

Deletes the package pkg from it's shared environment. Deletes this environment if it was the only package there. If the package may be present in multiple environments, and you want to delete it from all of them, set inall=true. Set force=true if you want to delete the package even if it is currently loaded, and it's env, in case it is empty then, even if it is in LOAD_PATH.

Returns NamedTuple (; success, nowempty), where `nowempty` is a flag for the containing environment being now empty.

source
ShareAdd.env_foldersMethod
env_folders(; depot = first(DEPOT_PATH), create=false) -> 
    (; envs_folder, main_env, envs_exist)

Returns a named tuple containing the path to the main folder holding all share environments, the path to the main shared environment, and a boolean indicating whether the main environment folder exists.

If create=true, the main environment folder will be created if it does not exist.

source
ShareAdd.env_pathFunction
env_path(env_name::AbstractString, depot = first(DEPOT_PATH); skipfirstchar = true) -> String

Returns the path of the environment with name env_name. If skipfirstchar is true, the first character of env_name is skipped, so that the name of a shared environment can be passed without the leading @.

source
ShareAdd.find_workspace_rootMethod
find_workspace_root(project_file::String) -> Union{Nothing, String}

Find the root Project.toml of the workspace containing project_file. Returns nothing if project_file is not part of any workspace, or if running on Julia < 1.12.

Walks up the directory tree from project_file, looking for a parent Project.toml whose [workspace].projects lists a path that resolves to the directory of project_file. Stops at the filesystem root or when leaving homedir() (if the search started inside it).

Handles nested workspaces by repeating the upward search from each discovered root.

source
ShareAdd.list_shared_envsMethod
list_shared_envs() -> Vector{String}
list_shared_envs(pkg_name) -> Vector{String}

Returns the names of all shared environments (if called without an argument), or the environment(s) containing the package pkg_name.

source
ShareAdd.optim_setMethod
optim_set(pks::AbstractArray{<:AbstractString}, envs::AbstractVector{EnvInfo}) -> OptimSet
optim_set(pkgs::AbstractArray{PackageInfo}) -> OptimSet

Finds the optimum set of environments for the given list of packages. Optimal is a set of environments with the least number of extraneous packages. If two sets have the same number of extraneous packages, then the one with the least number of environments is chosen.

The function is internal.

source
ShareAdd.prompt2installFunction
prompt2install(new_package::AbstractString, args...; kwargs...) -> Union{Nothing, String, EnvInfo, EnvNull}

Will return ENV_NULL to indicate that package is not to be installed in any environment (in using by tidyup)

source
ShareAdd.prompt2installMethod
prompt2install(packages::AbstractVector{<:AbstractString})
prompt2install(package::AbstractString)

Prompt user to select a shared environment to install a package or packages.

For a single package, if the user selects an environment, the package will be installed there. If the user selects "A new shared environment (you will be prompted for the name)", the user will be prompted to enter a name for a new environment.

For multiple packages, the function will be called on each package and the user will be prompted for each package.

The function will return a vector of NamedTuples, each with field pkg and env, where pkg is the name of the package and env is the environment where it should be installed.

The function will return nothing if the user selects "Quit. Do Nothing." on any of the prompts.

source
ShareAdd.shared_environments_envinfosMethod
shared_environments_envinfos(; std_lib=false, depot = first(DEPOT_PATH)) -> 
    (; shared_envs::Dict{name, EnvInfo},
    envs_folder_path::String, 
    shared_env_names::Vector{String})
source
ShareAdd.workspace_sibling_packagesMethod
workspace_sibling_packages(root_project::String, current_project::String)
    -> Dict{String, String}

Given the path to a workspace root Project.toml and the path to the currently active Project.toml, return a Dict that maps every package name reachable through workspace sibling projects to the directory of the sibling project that provides it.

"Reachable" means the package is either the sibling itself (it has name and uuid fields) or one of its declared [deps]. Packages that are already in the current project's [deps] are excluded.

source

Index