Packages
leaf
0.13.3
0.13.9
0.13.8
0.13.7
0.13.5
0.13.4
0.13.3
0.13.2
0.13.1
0.13.0
0.12.0
0.11.1
0.11.0
0.10.1
0.10.0
0.9.0
0.8.0
0.7.0
0.6.1
0.6.0
0.5.1
0.5.0
0.4.1
0.4.0
0.3.2
0.3.1
0.3.0
0.2.24
0.2.23
0.2.22
0.2.21
0.2.20
0.2.19
0.2.18
0.2.17
0.2.16
0.2.13
0.2.12
0.2.11
0.2.10
0.2.9
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0
Visual WYSIWYG + Obsidian-style hybrid live preview + markdown editor for Phoenix LiveView
Current section
Files
Jump to
Current section
Files
mix.exs
defmodule Leaf.MixProject do
use Mix.Project
@version "0.13.3"
@source_url "https://github.com/alexdont/leaf"
def project do
[
app: :leaf,
version: @version,
elixir: "~> 1.15",
start_permanent: Mix.env() == :prod,
deps: deps(),
name: "Leaf",
description:
"Visual WYSIWYG + Obsidian-style hybrid live preview + markdown editor for Phoenix LiveView",
package: package(),
docs: docs(),
source_url: @source_url,
dialyzer: [plt_add_apps: [:mix]],
aliases: aliases()
]
end
defp aliases do
[
# One gate for a release: everything that has to be clean before
# publishing, in the order that fails fastest. Mirrors phoenix_kit_posts.
# The test step goes through `cmd` so it runs in MIX_ENV=test the way a
# bare `mix test` would; inside an alias it would inherit :dev.
quality: ["format", "credo --strict", "dialyzer", "cmd mix test"],
"quality.ci": ["format --check-formatted", "credo --strict", "dialyzer", "cmd mix test"],
# The undo/redo stack is real logic living in the JS bundle, so the
# Elixir suite alone no longer covers this library. Runs after it, and
# skips rather than fails where node is unavailable — the Elixir tests
# remain the gate.
test: ["test", "test.js"],
"test.js": &run_js_tests/1
]
end
# `node --test` over the shipped hook bundle. Files are passed explicitly:
# with no arguments node walks the CWD looking for anything test-shaped,
# which would hand it deps/, _build/ and node_modules/ as well.
#
# `*_dom.test.cjs` drive the editor against a real DOM and need jsdom, a
# devDependency in package.json. Without it they skip themselves with a
# message, so a clone that never ran `npm install` still passes — the
# stubbed tests are the floor, the DOM tests are the ones that catch DOM
# bugs. Install with `npm install` in this directory.
defp run_js_tests(_args) do
files = Path.wildcard("test/js/*.test.cjs")
cond do
files == [] ->
Mix.shell().info("[skip] no test/js/*.test.cjs files")
System.find_executable("node") == nil ->
Mix.shell().info("[skip] node not found — skipping test/js")
true ->
{output, status} = System.cmd("node", ["--test" | files], stderr_to_stdout: true)
IO.puts(output)
if status != 0, do: Mix.raise("JS tests failed")
# A skipped DOM test is a test that did not run. Green without jsdom
# is the floor, not the gate — say so where it will be seen.
# With jsdom present, a skip is one a test asked for, not a missing
# dependency.
case Regex.run(~r/^# skipped ([1-9]\d*)/m, output) do
[_, n] ->
if File.dir?("node_modules/jsdom") do
Mix.shell().error(
"[test.js] #{n} tests were skipped (marked skip in the test files)."
)
else
Mix.shell().error(
"[test.js] #{n} DOM tests were SKIPPED (jsdom not installed). Run `npm install` in #{File.cwd!()} — the skipped ones are the tests that catch DOM bugs."
)
end
_ ->
:ok
end
end
end
def application do
[
extra_applications: [:logger]
]
end
defp deps do
[
{:phoenix_live_view, "~> 1.0"},
{:phoenix_html, "~> 4.0"},
# Live editing broadcasts between the sessions in a document. It arrives
# transitively through phoenix_live_view today, which is luck rather than
# a contract — Leaf calls it directly, so Leaf asks for it.
{:phoenix_pubsub, "~> 2.0"},
{:mdex, "~> 0.13"},
{:gettext, "~> 0.26 or ~> 1.0", optional: true},
{:ex_doc, "~> 0.34", only: :dev, runtime: false},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
]
end
defp package do
[
licenses: ["MIT"],
links: %{"GitHub" => @source_url},
files:
~w(lib priv/static/assets priv/gettext .formatter.exs mix.exs README.md LICENSE CHANGELOG.md)
]
end
defp docs do
[
main: "readme",
extras: ["README.md", "CHANGELOG.md", "LICENSE"]
]
end
end