Create and replace mix.exs file

Hi dear @lud, I talked about this way I want to do in these post, I am open to receive any suggestion

and

and

in this video, you can see a simple demo

with these line I add a dep or delete it from my source

So, my user need to add his package into deps function and I create this for him/her

So all the plugins are called from a JSON file which is created from my database

for example

  %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",
    update_server: nil,
    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"},
    ]
  }

So the only problem exist here that is keeping state when a dep was installed before. So my library let users register an event; before compiling I send a name of app and some information, if an app needs to save something, it prevents to force_update, if not it is going to be run the bottom function.

  # If you have a Task in your project you can load it in a list like [{:task_one, "ecto.migrate"}], it should be a list
  @spec deps(list()) :: list
  def deps(custom_command \\ []) when is_list(custom_command) do
    [{:get, "deps.get"}, {:compile, "deps.compile"}] ++ custom_command
    |> Enum.map(fn {operation, command} ->
      {stream, status} = System.cmd("mix", [command], into: IO.stream(), stderr_to_stdout: true)
      %{operation: operation, output: stream, status: status}
    end)
  end

In this function, when the lib gets an answer, it sends a pubsu to used admin dashboard

A simple dashboard I’m developing it: mishka_installer/lib/installer/live/dep_getter.ex at master · mishka-group/mishka_installer · GitHub after that I add it in my CMS: GitHub - mishka-group/mishka-cms: MishkaCms an open source and real time API base CMS Powered by Elixir and Phoenix

My solution for event

1 Like