EnvironmentMigrators.EnvironmentMigratorsModule

Welcome to EnvironmentMigrators.jl.

Use EnvironmentMigrators.wizard() for interactive use.

High level interface (unexported)

  • list_shared_environments([depot])
  • select_shared_environments([depot])
  • backup_current_environment(; fileaction = cp)
  • migrate_selected_environment(selected_environment; backup = true)
  • migrate_current_environment_to(path)
  • wizard([depot])

Exported types

  • SimpleEnvironmentMigrator
  • SimpleBackupOnlyEnvironmentMigrator

Exported methods

  • migrate(m::EnvironmentMigrators.AbstractEnvironmentMigrator)
  • backup(m::EnvironmentMigrators.AbstractEnvironmentMigrator)
EnvironmentMigrators.AbstractEnvironmentMigratorType
AbstractEnvironmentMigrator

Base abstract type for EnvironmentMigrators.

Interface:

  • source_project_toml(m::AbstractEnvironmentMigrator)
    • return path of (Julia)Project.toml to copy from or nothing if there is no source
  • source_manifest_toml(m::AbstractEnvironmentMigrator)
    • return path of (Julia)Manifest.toml to copy from or nothing if there is no source
  • target_project_toml(m::AbstractEnvironmentMigrator)
    • return path of (Julia)Project.toml to backup and to which to copy
  • target_manifest_toml(m::AbstractEnvironmentMigrator)
    • return path of (Julia)Manifest.toml to backup and to which to copy
  • fileaction(m::AbstractEnvironmentMigrator)
    • action to take during backup operations
  • backup(m::AbstractEnvironmentMigrator)
    • save a copy of the target environment in a timestamped subfolder
  • migrate(m::AbstractEnvironmentMigrator; backup = true, update = true)
    • migrate project and manifest files from source to target

Subtypes:

  • SimpleEnvironmentMigrator
    • set source and target project and manifest files as fields
  • SimpleBackupOnlyEnvironmentMigrator
    • set target project and manifest files as fields
EnvironmentMigrators.SimpleBackupOnlyEnvironmentMigratorType
SimpleBackupOnlyEnvironmentMigrator{F}([target_project_toml, target_manifest_toml], fileaction::F)

AbstractEnvironmentMigrator only for backing up the target project and manifest tomls to a timestamped folder. The target project and manifest tomls will default to the current project and manifest tomls.

EnvironmentMigrators.SimpleEnvironmentMigratorType
SimpleEnvironmentMigrator([source_project_toml, source_target_toml], [target_project_toml, target_manifest_toml])

An AbstractEnvironmentMigrator where one can set source and target project and manifest files as fields. If source_project_toml and source_manifest_toml are not specified, they will be nothing. If target_project_toml and target_manifest_toml are not specified, they will be set to the current environment.

Fields

  • source_project_toml
  • source_manifest_toml
  • target_project_toml
  • target_manifest_toml

Method details

fileaction(m) will return cp if source_project_toml is nothing or mv otherwise.

EnvironmentMigrators.backupMethod
backup(m::AbstractEnvironmentMigrator)

Backup an environment. Typically, this involves copying the Project.toml and Manifest.toml to a time-stamped backup subfolder.

Extended Help

The standard backup procedure is as follows.

  1. Check that the target project and manifest TOMLs are in the same directory.
  2. Check that one of either the project or manifest TOMLs exist
  3. Create a time stamp in the format "yyyy-mm-ddHHMM_SS
  4. Create a subpath in the same directory as the project TOML called backups/[timestamp]
  5. Copy (or move) the project and manifest TOMLs to the backup path if they exist.
EnvironmentMigrators.backup_current_environmentMethod
backup_current_environments([depot]; fileaction=cp)

Backup the Project.toml and Manifest.toml to backups/timestamp where timestamp = Dates.format(Dates.now(), "yyyy-mm-dd_HH_MM_SS")`.

fileaction is a keyword parameter for a function that accepts two parameters. fileaction defaults to cp for copy. An alternative is mv for move. depot defaults to first(DEPOT_PATH).

EnvironmentMigrators.get_current_project_and_manifestMethod
get_current_project_and_manifest()

Return the current project and manifest TOML files.

Implementation details

  • Base.active_project() is used to determine the location the current (Julia)Project.toml
  • JuliaManifest.toml takes precedent over Manifest.toml in the same directory as the Project.toml
EnvironmentMigrators.migrateMethod
migrate(m::AbstractEnvironmentMigrator; backup = true, update = true)

Move an environment from one place to another. backup - whether to perform a backup of the target environment (true) or not (false). update - whether to perform an update of the source environment (true) or not (false).

Extended Help

The typical migration procedure is as follows.

  1. Backup the target environment by moving the files if indicated.
  2. Copy the (Julia)Project.toml from the source to the target environment.
  3. Copy the (Julia)Manifest.toml from the source to the target environment.
  4. Activate the target environment
  5. Pkg.status()
  6. Pkg.upgrade_manifest() - skip if error
  7. Pkg.resolve()
  8. Pkg.instantiate()
  9. Pkg.status()
  10. Pkg.update()
EnvironmentMigrators.migrate_selected_environmentMethod
migrate_selected_environment(selected_env)

Migrate the selected environment specified as a directory in selected_env to the current active project.

selected_env should be the absolute path to an environment directory.

EnvironmentMigrators.select_shared_environmentsFunction
select_shared_environments([depot])

Present an interactive menu to select a shared environment to copy from. Also provide options to select the current enviornment for backup or quit. depot defaults to first(DEPOT_PATH).