2024-05-28 15:30:41 +12:00
|
|
|
defmodule Mix.Tasks.Igniter.Install do
|
2024-06-01 14:59:36 +12:00
|
|
|
@moduledoc """
|
|
|
|
Install a package or packages, and run any associated installers.
|
|
|
|
|
|
|
|
## Args
|
|
|
|
|
2024-06-14 03:02:55 +12:00
|
|
|
mix igniter.install package1 package2 package3
|
2024-06-01 14:59:36 +12:00
|
|
|
|
2024-06-14 02:57:10 +12:00
|
|
|
## Package formats
|
|
|
|
|
|
|
|
* `package` - The latest version of the package will be installed, pinned at the
|
|
|
|
major version, or minor version if there is no major version yet.
|
|
|
|
* `package@version` - The package will be installed at the specified version.
|
|
|
|
If the version given is generic, like `3.0`, it will be pinned as described above.
|
|
|
|
if it is specific, like `3.0.1`, it will be pinned at that *exact* version with `==`.
|
|
|
|
* `package@git:git_url` - The package will be installed from the specified git url.
|
|
|
|
* `package@github:project/repo` - The package will be installed from the specified github repo.
|
2024-06-14 03:05:11 +12:00
|
|
|
* `package@path:path/to/dep` - The package will be installed from the specified path.
|
2024-06-14 02:57:10 +12:00
|
|
|
|
2024-06-01 14:59:36 +12:00
|
|
|
## Switches
|
|
|
|
|
2024-07-10 01:00:36 +12:00
|
|
|
* `--dry-run` - Run the task without making any changes.
|
|
|
|
* `--yes` - Automatically answer yes to any prompts.
|
|
|
|
* `--example` - Request that installed packages include initial example code.
|
2024-06-01 14:59:36 +12:00
|
|
|
"""
|
2024-05-28 15:30:41 +12:00
|
|
|
use Mix.Task
|
|
|
|
|
2024-07-31 03:20:21 +12:00
|
|
|
@requirements "deps.compile"
|
|
|
|
|
2024-05-28 15:30:41 +12:00
|
|
|
@impl true
|
2024-06-01 14:59:36 +12:00
|
|
|
@shortdoc "Install a package or packages, and run any associated installers."
|
2024-06-14 03:02:55 +12:00
|
|
|
def run(argv) do
|
2024-07-11 00:40:46 +12:00
|
|
|
Mix.Task.run("compile")
|
2024-06-14 03:02:55 +12:00
|
|
|
{packages, argv} = Enum.split_while(argv, fn arg -> !String.starts_with?(arg, "-") end)
|
2024-05-28 15:30:41 +12:00
|
|
|
|
2024-06-14 03:02:55 +12:00
|
|
|
if Enum.empty?(packages) do
|
|
|
|
raise ArgumentError, "must provide at least one package to install"
|
|
|
|
end
|
|
|
|
|
|
|
|
Application.ensure_all_started([:rewrite])
|
2024-05-28 15:30:41 +12:00
|
|
|
|
2024-06-21 01:46:45 +12:00
|
|
|
Igniter.Util.Install.install(Enum.join(packages, ","), argv)
|
2024-05-28 15:30:41 +12:00
|
|
|
end
|
|
|
|
end
|