Current section

Files

Jump to
ehelper mix.exs
Raw

mix.exs

defmodule Ehelper.MixProject do
use Mix.Project
@app :ehelper
@version "0.2.7"
@source_url "https://github.com/cao7113/ehelper"
def project do
[
app: @app,
version: @version,
elixir: "~> 1.17",
start_permanent: Mix.env() == :prod,
# deps: deps(),
deps: env_deps(Mix.env()),
aliases: aliases(),
description: "Daily mix helper tasks",
package: package(),
# Docs
name: "Ehelper",
source_url: @source_url,
homepage_url: @source_url,
docs: &docs/0
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
mod: {Ehelper.Application, []},
extra_applications: [:logger, :runtime_tools, :inets, :ssl],
env: [
# here config go into ebin/ehelper.app file, can be configured by host-app config/*.exs
test: :test_from_mix_exs_application_func_env_key
]
]
end
# Run "mix help deps" to learn about dependencies.
# options ref https://hexdocs.pm/mix/Mix.Tasks.Deps.html#module-options
# mix help deps
# specifying :decimal is the same as {:decimal, ">= 0.0.0"}
defp deps do
[
{:git_ops, "~> 2.9", only: [:dev], runtime: false, local_linking: true},
# mix igniter.install git_ops
{:igniter, "~> 0.7", only: [:dev, :test], local_linking: true},
{:ex_doc, "~> 0.39", only: :dev, runtime: false, warn_if_outdated: true}
]
end
defp aliases() do
[
# install: ["archive.build -o _build/ehelper.ez", "archive.install _build/ehelper.ez --force"],
build: "archive.build -o _build/ehelper-#{@version}.ez",
install: "archive.install --force _build/ehelper-#{@version}.ez",
up: "do build + install",
c: "compile",
hi: [&hello/1]
]
end
def cli do
[
# default_task: "eh",
preferred_envs: [build: :prod, install: :prod, up: :prod]
]
end
defp docs do
[
# The main page in the docs
# main: "MyApp",
# logo: "path/to/logo.png",
# extras: ["README.md"]
]
end
# hex package metadata as https://hex.pm/docs/publish
def package do
[
links: %{
"GitHub" => @source_url,
"Docs" => "https://hexdocs.pm/ehelper"
},
files: ["lib", "priv", "mix.exs", "mix.lock", "README.md"],
licenses: ["Apache-2.0"],
maintainers: ["cao7113"]
]
end
## Support deps local-linking, generated by task: mix h.local.link at 2025-12-16 04:15:56.396106Z
# def env_deps(:prod), do: deps() |> prune_local_linking()
def env_deps(_), do: deps_with_linking_path()
def raw_deps, do: deps()
def deps_with_linking_path(deps \\ deps()) do
# Mix.Local.append_archives()
# :code.get_path() |> Enum.sort();
Mix.DepLink
|> Code.ensure_loaded()
|> case do
{:module, _} ->
deps
|> Mix.DepLink.deps_with_local_linking()
{:error, reason} ->
if Mix.env() in [:dev] do
Mix.shell().info(
"No Mix.DepLink : #{reason |> inspect}, run: mix archive.install hex ehelper"
)
end
deps |> prune_local_linking()
end
end
def prune_local_linking(deps \\ deps()) do
deps
|> Enum.map(fn
{app, v, opts} when is_list(opts) ->
{app, v, opts |> Keyword.delete(:local_linking)}
{app, opts} when is_list(opts) ->
{app, opts |> Keyword.delete(:local_linking)}
item ->
item
end)
end
defp hello(_) do
Mix.shell().info("Hello world")
# Mix.Task.run("paid.task", [
# "first_arg",
# "second_arg",
# "--license-key",
# System.fetch_env!("SOME_LICENSE_KEY")
# ])
end
end