View Source MishkaInstaller.Installer.DepHandler (Mishka Installer v0.0.3)

A module that holds new dependencies' information, and add them into database or validating to implement in runtime

responsibilities-of-this-module

Responsibilities of this module

  • Create Json - it helps developer to implement theire plugin/commponent into the project.
  • Add dependencies into database - for validating, stroing and keeping backup of runtime dependencies
  • Get dependencies information in several different ways

for-example-these-are-output-from-json-file

For example, these are output from Json file

[
  %{
    app: :mishka_installer,
    version: "0.0.2",
    type: :git, # :hex, if user upload elixir libraries (path), we should keep them in a temporary folder, and Docker should make it valume
    url: "https://github.com/mishka-group/mishka_installer", # if it is hex: https://hex.pm/packages/mishka_installer
    git_tag: "0.0.2", # we consider it when it is a git, and if does not exist we get master,
    custom_command: "ecto.migrate", # you can write nil or you task file like ecto.migrate
    dependency_type: :none, # :force_update, When you use this, the RunTime sourcing check what dependencies you use in your program have a higher version
    #compared to the old source. it just notice admin there is a update, it does not force the source to be updated
    dependencies: [ # this part let mishka_installer to know can update or not dependencies of a app, we should consider a backup file
      %{app: :mishka_developer_tools, max: "0.0.2", min: "0.0.1"},
      %{app: :mishka_social, max: "0.0.2", min: "0.0.1"}
    ]
  }
]

OR

%MishkaInstaller.Installer.DepHandler{
  app: "mishka_social",
  version: "0.0.2 ",
  type: "hex",
  url: "https://hex.pm/packages/mishka_social",
  git_tag: nil,
  custom_command: nil,
  dependency_type: "force_update",
  dependencies: [
    %{app: :phoenix, min: "1.6"},
    %{app: :phoenix_live_view, max: "0.17.7", min: "0.17.7"},
    %{app: :ueberauth, max: "0.17.7", min: "0.17.7"},
    %{app: :ueberauth_github, min: "0.8.1"},
    %{app: :ueberauth_google, min: "0.10.1"},
  ]
}

Link to this section Summary

Link to this section Types

@type app_info() :: String.t() | atom() | map() | list()
@type installed_apps() :: {atom(), description :: charlist(), vsn :: charlist()}
@type run() :: :hex | :git | :upload
@type t() :: %MishkaInstaller.Installer.DepHandler{
  app: String.t() | nil,
  custom_command: String.t() | nil,
  dependencies: [map()],
  dependency_type: String.t() | nil,
  git_tag: String.t() | nil,
  type: String.t() | nil,
  url: String.t() | nil,
  version: String.t() | nil
}

Link to this section Functions

@spec add_new_app(t()) ::
  {:ok, :add_new_app, any()} | {:error, :add_new_app, :changeset | :file, any()}
@spec append_mix([tuple()]) :: list()
Link to this function

check_or_create_deps_json(project_path \\ MishkaInstaller.get_config(:project_path))

View Source
@spec check_or_create_deps_json(binary()) ::
  {:ok, :check_or_create_deps_json, String.t()}
  | {:error, :check_or_create_deps_json, String.t()}
Link to this function

compare_dependencies_with_json(installed_apps \\ Application.loaded_applications())

View Source
@spec compare_dependencies_with_json(installed_apps() | any()) ::
  list() | {:error, :compare_dependencies_with_json, String.t()}
Link to this function

compare_installed_deps_with_app_file(app)

View Source
@spec compare_installed_deps_with_app_file(String.t()) ::
  {:error, :compare_installed_deps_with_app_file, String.t()}
  | {:ok, :compare_installed_deps_with_app_file, list()}
Link to this function

compare_sub_dependencies_with_json(installed_apps \\ Application.loaded_applications())

View Source
@spec compare_sub_dependencies_with_json(any()) ::
  list() | {:error, :compare_sub_dependencies_with_json, String.t()}
Link to this function

compare_version_with_installed_app(app, version)

View Source
Link to this function

create_deps_json_file(project_path)

View Source
@spec create_deps_json_file(binary()) ::
  {:error, :check_or_create_deps_json, binary()}
  | {:ok, :check_or_create_deps_json, binary()}
@spec create_mix_file() :: :ok
Link to this function

create_mix_file_and_start_compile(app_name, output_type)

View Source
@spec create_mix_file_and_start_compile(String.t() | atom(), atom()) :: :ok
@spec extensions_json_path() :: binary()
Link to this function

get_deps_from_mix(mix_module)

View Source
@spec get_deps_from_mix(module()) :: list()
Link to this function

get_deps_from_mix_lock()

View Source
@spec get_deps_from_mix_lock() :: list()
@spec mix_read_from_json() :: list()
Link to this function

move_and_replace_compiled_app_build(app_list)

View Source
Link to this function

read_dep_json(json \\ File.read!(extensions_json_path()))

View Source
@spec read_dep_json(any()) ::
  {:error, :read_dep_json, String.t()} | {:ok, :read_dep_json, list()}
Link to this function

run(type, app, output_type \\ :cmd)

View Source
@spec run(:git | :hex | :upload, app_info(), atom()) :: map()

## Run and Get a dependency

    Application.spec(:timex, :vsn)

    MishkaInstaller.Installer.DepHandler.run(:hex, "faker")

    app = %{url: "https://github.com/bitwalker/timex", tag: "3.7.5"}
    MishkaInstaller.Installer.DepHandler.run(:git, app)

    app = %{url: "https://github.com/bitwalker/timex", tag: "3.7.6"}
    MishkaInstaller.Installer.DepHandler.run(:git, app)

    app = %{url: "https://github.com/bitwalker/timex", tag: "3.7.8"}
    MishkaInstaller.Installer.DepHandler.run(:git, app)


    app = %{url: "https://github.com/elixirs/faker", tag: "v0.17.0"}
    MishkaInstaller.Installer.DepHandler.run(:git, app)

    app = %{url: "https://github.com/martinsvalin/html_entities", tag: "v0.5.1"}
    MishkaInstaller.Installer.DepHandler.run(:git, app)


    app = %{url: "https://github.com/beatrichartz/csv", tag: "v2.3.0"}
    MishkaInstaller.Installer.DepHandler.run(:git, app)

    MishkaInstaller.Installer.DepHandler.run(:upload, ["../mishka_installer/deployment/extensions/timex-3.7.8.zip"])