2021-03-04 05:56:28 +08:00
|
|
|
defmodule Livebook.MixProject do
|
2021-01-08 03:55:45 +08:00
|
|
|
use Mix.Project
|
|
|
|
|
2022-09-02 18:03:32 +08:00
|
|
|
@elixir_requirement "~> 1.14"
|
2022-10-27 04:19:37 +08:00
|
|
|
@version "0.7.2"
|
2021-05-20 05:30:53 +08:00
|
|
|
@description "Interactive and collaborative code notebooks - made with Phoenix LiveView"
|
|
|
|
|
2022-09-02 18:03:32 +08:00
|
|
|
@app_elixir_version "1.14.0"
|
2022-07-18 17:51:17 +08:00
|
|
|
@app_rebar3_version "3.19.0"
|
2022-02-07 19:33:28 +08:00
|
|
|
|
2021-01-08 03:55:45 +08:00
|
|
|
def project do
|
|
|
|
[
|
2021-03-04 05:56:28 +08:00
|
|
|
app: :livebook,
|
2021-05-20 05:30:53 +08:00
|
|
|
version: @version,
|
2022-01-27 21:52:59 +08:00
|
|
|
elixir: @elixir_requirement,
|
2021-05-20 05:30:53 +08:00
|
|
|
name: "Livebook",
|
|
|
|
description: @description,
|
2021-01-08 03:55:45 +08:00
|
|
|
elixirc_paths: elixirc_paths(Mix.env()),
|
|
|
|
start_permanent: Mix.env() == :prod,
|
|
|
|
aliases: aliases(),
|
2022-01-20 05:20:05 +08:00
|
|
|
deps: with_lock(target_deps(Mix.target()) ++ deps()),
|
2021-04-27 22:34:02 +08:00
|
|
|
escript: escript(),
|
2022-01-27 21:52:59 +08:00
|
|
|
package: package(),
|
2022-01-20 19:00:06 +08:00
|
|
|
default_release: :livebook,
|
2022-01-27 21:52:59 +08:00
|
|
|
releases: releases()
|
2021-01-08 03:55:45 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def application do
|
|
|
|
[
|
2021-03-04 05:56:28 +08:00
|
|
|
mod: {Livebook.Application, []},
|
2022-01-18 00:34:38 +08:00
|
|
|
extra_applications:
|
|
|
|
[:logger, :runtime_tools, :os_mon, :inets, :ssl, :xmerl] ++
|
|
|
|
extra_applications(Mix.target()),
|
2021-10-05 06:49:01 +08:00
|
|
|
env: Application.get_all_env(:livebook)
|
2021-01-08 03:55:45 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2022-01-18 00:34:38 +08:00
|
|
|
defp extra_applications(:app), do: [:wx]
|
|
|
|
defp extra_applications(_), do: []
|
|
|
|
|
2022-11-04 00:49:07 +08:00
|
|
|
defp elixirc_paths(:test), do: elixirc_paths(:dev) ++ ["test/support"]
|
|
|
|
defp elixirc_paths(_), do: ["lib", "proto/lib"]
|
2021-01-08 03:55:45 +08:00
|
|
|
|
2022-01-27 21:52:59 +08:00
|
|
|
defp package do
|
|
|
|
[
|
|
|
|
licenses: ["Apache-2.0"],
|
|
|
|
links: %{
|
|
|
|
"GitHub" => "https://github.com/livebook-dev/livebook"
|
|
|
|
},
|
2022-05-06 16:28:01 +08:00
|
|
|
files:
|
2022-11-04 00:49:07 +08:00
|
|
|
~w(lib static config mix.exs mix.lock README.md LICENSE CHANGELOG.md iframe/priv/static/iframe proto/lib)
|
2022-01-27 21:52:59 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
defp aliases do
|
|
|
|
[
|
|
|
|
"dev.setup": ["deps.get", "cmd npm install --prefix assets"],
|
|
|
|
"dev.build": ["cmd npm run deploy --prefix ./assets"],
|
2022-11-04 00:49:07 +08:00
|
|
|
"format.all": ["format", "cmd npm run format --prefix ./assets"],
|
|
|
|
"protobuf.generate": ["cmd --cd proto mix protobuf.generate"]
|
2022-01-27 21:52:59 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
defp escript do
|
|
|
|
[
|
|
|
|
main_module: LivebookCLI,
|
|
|
|
app: nil
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
2021-08-25 17:52:41 +08:00
|
|
|
# Although we use requirements here, the with_lock() function
|
|
|
|
# below ensures we only use the locked versions. This is important
|
|
|
|
# for two reasons:
|
|
|
|
#
|
|
|
|
# 1. because we bundle assets from phoenix, phoenix_live_view,
|
|
|
|
# and phoenix_html, we want to make sure we have those exact
|
|
|
|
# versions
|
|
|
|
#
|
|
|
|
# 2. we don't want users to potentially get a new dependency
|
|
|
|
# when installing from git or as an escript
|
|
|
|
#
|
|
|
|
# Therefore, to update any dependency, you must call before:
|
|
|
|
#
|
|
|
|
# mix deps.unlock foo bar baz
|
|
|
|
#
|
2021-01-08 03:55:45 +08:00
|
|
|
defp deps do
|
|
|
|
[
|
2021-08-25 17:52:41 +08:00
|
|
|
{:phoenix, "~> 1.5"},
|
|
|
|
{:phoenix_html, "~> 3.0"},
|
2022-10-04 14:46:55 +08:00
|
|
|
{:phoenix_live_view, "~> 0.18.1"},
|
|
|
|
{:phoenix_live_dashboard, "~> 0.7.0"},
|
2021-01-08 03:55:45 +08:00
|
|
|
{:telemetry_metrics, "~> 0.4"},
|
2021-12-12 16:40:38 +08:00
|
|
|
{:telemetry_poller, "~> 1.0"},
|
2021-01-08 03:55:45 +08:00
|
|
|
{:jason, "~> 1.0"},
|
2021-02-17 01:39:52 +08:00
|
|
|
{:plug_cowboy, "~> 2.0"},
|
2021-08-12 20:40:07 +08:00
|
|
|
{:earmark_parser, "~> 1.4"},
|
2021-08-18 03:43:58 +08:00
|
|
|
{:castore, "~> 0.1.0"},
|
2022-08-02 21:26:45 +08:00
|
|
|
{:aws_signature, "~> 0.3.0"},
|
2022-10-01 03:35:56 +08:00
|
|
|
{:ecto, "~> 3.9.0"},
|
2022-08-23 05:12:54 +08:00
|
|
|
{:phoenix_ecto, "~> 4.4.0"},
|
2022-11-04 00:49:07 +08:00
|
|
|
{:mint_web_socket, "~> 1.0.0"},
|
|
|
|
{:protobuf, "~> 0.8.0"},
|
2021-08-25 17:52:41 +08:00
|
|
|
{:phoenix_live_reload, "~> 1.2", only: :dev},
|
|
|
|
{:floki, ">= 0.27.0", only: :test},
|
2022-01-20 15:49:19 +08:00
|
|
|
{:bypass, "~> 2.1", only: :test}
|
2021-01-08 03:55:45 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2022-07-19 20:48:07 +08:00
|
|
|
defp target_deps(:app), do: [{:app_bundler, path: "app_bundler"}]
|
2022-01-20 05:20:05 +08:00
|
|
|
defp target_deps(_), do: []
|
|
|
|
|
2021-08-25 17:52:41 +08:00
|
|
|
@lock (with {:ok, contents} <- File.read("mix.lock"),
|
|
|
|
{:ok, quoted} <- Code.string_to_quoted(contents, warn_on_unnecessary_quotes: false),
|
|
|
|
{%{} = lock, _binding} <- Code.eval_quoted(quoted, []) do
|
|
|
|
for {dep, hex} when elem(hex, 0) == :hex <- lock,
|
|
|
|
do: {dep, elem(hex, 2)},
|
|
|
|
into: %{}
|
|
|
|
else
|
|
|
|
_ -> %{}
|
|
|
|
end)
|
|
|
|
|
|
|
|
defp with_lock(deps) do
|
|
|
|
for dep <- deps do
|
|
|
|
name = elem(dep, 0)
|
|
|
|
put_elem(dep, 1, @lock[name] || elem(dep, 1))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-27 21:52:59 +08:00
|
|
|
## Releases
|
2021-04-27 22:34:02 +08:00
|
|
|
|
2021-05-20 05:30:53 +08:00
|
|
|
defp releases do
|
2022-06-02 04:29:54 +08:00
|
|
|
macos_notarization = macos_notarization()
|
|
|
|
|
2022-11-03 02:06:42 +08:00
|
|
|
additional_paths = [
|
|
|
|
"rel/vendor/otp/erts-#{:erlang.system_info(:version)}/bin",
|
|
|
|
"rel/vendor/otp/bin",
|
|
|
|
"rel/vendor/elixir/bin"
|
|
|
|
]
|
|
|
|
|
2021-04-27 22:34:02 +08:00
|
|
|
[
|
|
|
|
livebook: [
|
|
|
|
include_executables_for: [:unix],
|
2022-01-27 21:52:59 +08:00
|
|
|
include_erts: false,
|
|
|
|
rel_templates_path: "rel/server",
|
|
|
|
steps: [:assemble, &remove_cookie/1]
|
2022-01-18 00:34:38 +08:00
|
|
|
],
|
2022-06-02 04:29:54 +08:00
|
|
|
app: [
|
2022-03-02 19:06:30 +08:00
|
|
|
include_erts: false,
|
|
|
|
rel_templates_path: "rel/app",
|
|
|
|
steps: [
|
|
|
|
:assemble,
|
|
|
|
&remove_cookie/1,
|
|
|
|
&standalone_erlang_elixir/1,
|
2022-07-19 20:48:07 +08:00
|
|
|
&AppBundler.bundle/1
|
2022-06-02 04:29:54 +08:00
|
|
|
],
|
|
|
|
app: [
|
|
|
|
name: "Livebook",
|
|
|
|
url_schemes: ["livebook"],
|
|
|
|
document_types: [
|
2022-06-03 03:33:23 +08:00
|
|
|
[
|
2022-06-02 04:29:54 +08:00
|
|
|
name: "LiveMarkdown",
|
|
|
|
extensions: ["livemd"],
|
2022-06-03 03:33:23 +08:00
|
|
|
macos: [
|
|
|
|
icon_path: "rel/app/icon.png",
|
|
|
|
role: "Editor"
|
2022-06-02 04:29:54 +08:00
|
|
|
],
|
2022-06-03 03:33:23 +08:00
|
|
|
windows: [
|
|
|
|
icon_path: "rel/app/icon.ico"
|
|
|
|
]
|
|
|
|
]
|
2022-06-02 04:29:54 +08:00
|
|
|
],
|
2022-06-03 03:33:23 +08:00
|
|
|
macos: [
|
2022-06-03 19:56:16 +08:00
|
|
|
app_type: :agent,
|
2022-06-03 03:33:23 +08:00
|
|
|
icon_path: "rel/app/icon-macos.png",
|
|
|
|
build_dmg: macos_notarization != nil,
|
2022-11-03 01:19:53 +08:00
|
|
|
notarization: macos_notarization,
|
2022-11-03 02:06:42 +08:00
|
|
|
additional_paths: additional_paths ++ ["/usr/local/bin"]
|
2022-06-03 03:33:23 +08:00
|
|
|
],
|
|
|
|
windows: [
|
|
|
|
icon_path: "rel/app/icon.ico",
|
2022-11-03 01:19:53 +08:00
|
|
|
build_installer: true,
|
2022-11-03 02:06:42 +08:00
|
|
|
additional_paths: additional_paths
|
2022-06-03 03:33:23 +08:00
|
|
|
]
|
2022-03-02 19:06:30 +08:00
|
|
|
]
|
2021-04-27 22:34:02 +08:00
|
|
|
]
|
|
|
|
]
|
|
|
|
end
|
2021-05-20 05:30:53 +08:00
|
|
|
|
2022-06-02 04:29:54 +08:00
|
|
|
defp macos_notarization do
|
|
|
|
identity = System.get_env("NOTARIZE_IDENTITY")
|
|
|
|
team_id = System.get_env("NOTARIZE_TEAM_ID")
|
|
|
|
apple_id = System.get_env("NOTARIZE_APPLE_ID")
|
|
|
|
password = System.get_env("NOTARIZE_PASSWORD")
|
|
|
|
|
|
|
|
if identity && team_id && apple_id && password do
|
|
|
|
[identity: identity, team_id: team_id, apple_id: apple_id, password: password]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-27 21:52:59 +08:00
|
|
|
defp remove_cookie(release) do
|
|
|
|
File.rm!(Path.join(release.path, "releases/COOKIE"))
|
|
|
|
release
|
|
|
|
end
|
|
|
|
|
|
|
|
defp standalone_erlang_elixir(release) do
|
|
|
|
Code.require_file("rel/app/standalone.exs")
|
|
|
|
|
|
|
|
release
|
2022-05-07 05:53:10 +08:00
|
|
|
|> Standalone.copy_otp()
|
2022-01-27 23:35:17 +08:00
|
|
|
|> Standalone.copy_elixir(@app_elixir_version)
|
2022-07-18 17:51:17 +08:00
|
|
|
|> Standalone.copy_hex()
|
|
|
|
|> Standalone.copy_rebar3(@app_rebar3_version)
|
2022-01-27 21:52:59 +08:00
|
|
|
end
|
2021-01-08 03:55:45 +08:00
|
|
|
end
|