From 92c28f5098134110188962ebdabf11474c78294d Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:01:37 -0300 Subject: [PATCH 01/14] added extensions to config --- config/config.exs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index 87faebb..5fd7ca1 100644 --- a/config/config.exs +++ b/config/config.exs @@ -9,7 +9,8 @@ import Config config :phoenix_extensions, ecto_repos: [PhoenixExtensions.Repo], - generators: [timestamp_type: :utc_datetime] + generators: [timestamp_type: :utc_datetime], + extensions: [Extensions.TelegramBot] # Configures the endpoint config :phoenix_extensions, PhoenixExtensionsWeb.Endpoint, From 2cc158064137aa22b1c14b0858033af82d4f61de Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:03:34 -0300 Subject: [PATCH 02/14] import extension config --- config/config.exs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/config.exs b/config/config.exs index 5fd7ca1..524d54a 100644 --- a/config/config.exs +++ b/config/config.exs @@ -65,3 +65,6 @@ config :phoenix, :json_library, Jason # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{config_env()}.exs" + +# Import Telegram Bot Extension Config +import_config Path.join(["extensions", "telegram_bot", "config", "#{config_env()}.exs"]) From 700ef6bdfc57da89e889c960ff3aed6cf0e032ae Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:07:26 -0300 Subject: [PATCH 03/14] initializes extensions --- lib/phoenix_extensions/application.ex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/phoenix_extensions/application.ex b/lib/phoenix_extensions/application.ex index 3a2d6ac..a13fa66 100644 --- a/lib/phoenix_extensions/application.ex +++ b/lib/phoenix_extensions/application.ex @@ -23,6 +23,11 @@ defmodule PhoenixExtensions.Application do PhoenixExtensionsWeb.Endpoint ] + # Initialize extensions + Enum.each(Application.get_env(:phoenix_extensions, :extensions, []), fn extension -> + extension.init() + end) + # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: PhoenixExtensions.Supervisor] From 0a280271e76788dacc5a51d2f7b39e9b5d46b85e Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:09:03 -0300 Subject: [PATCH 04/14] create extension with mix.new in extensions directory --- .../extension_telegram_bot/.formatter.exs | 4 +++ extensions/extension_telegram_bot/.gitignore | 23 +++++++++++++++ extensions/extension_telegram_bot/README.md | 21 ++++++++++++++ .../lib/extension_telegram_bot.ex | 18 ++++++++++++ extensions/extension_telegram_bot/mix.exs | 28 +++++++++++++++++++ .../test/extension_telegram_bot_test.exs | 8 ++++++ .../test/test_helper.exs | 1 + 7 files changed, 103 insertions(+) create mode 100644 extensions/extension_telegram_bot/.formatter.exs create mode 100644 extensions/extension_telegram_bot/.gitignore create mode 100644 extensions/extension_telegram_bot/README.md create mode 100644 extensions/extension_telegram_bot/lib/extension_telegram_bot.ex create mode 100644 extensions/extension_telegram_bot/mix.exs create mode 100644 extensions/extension_telegram_bot/test/extension_telegram_bot_test.exs create mode 100644 extensions/extension_telegram_bot/test/test_helper.exs diff --git a/extensions/extension_telegram_bot/.formatter.exs b/extensions/extension_telegram_bot/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/extensions/extension_telegram_bot/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/extensions/extension_telegram_bot/.gitignore b/extensions/extension_telegram_bot/.gitignore new file mode 100644 index 0000000..40c6054 --- /dev/null +++ b/extensions/extension_telegram_bot/.gitignore @@ -0,0 +1,23 @@ +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# If the VM crashes, it generates a dump, let's ignore it too. +erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). +*.ez + +# Ignore package tarball (built via "mix hex.build"). +extension_telegram_bot-*.tar + +# Temporary files, for example, from tests. +/tmp/ diff --git a/extensions/extension_telegram_bot/README.md b/extensions/extension_telegram_bot/README.md new file mode 100644 index 0000000..04e54fc --- /dev/null +++ b/extensions/extension_telegram_bot/README.md @@ -0,0 +1,21 @@ +# ExtensionTelegramBot + +**TODO: Add description** + +## Installation + +If [available in Hex](https://hex.pm/docs/publish), the package can be installed +by adding `extension_telegram_bot` to your list of dependencies in `mix.exs`: + +```elixir +def deps do + [ + {:extension_telegram_bot, "~> 0.1.0"} + ] +end +``` + +Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) +and published on [HexDocs](https://hexdocs.pm). Once published, the docs can +be found at . + diff --git a/extensions/extension_telegram_bot/lib/extension_telegram_bot.ex b/extensions/extension_telegram_bot/lib/extension_telegram_bot.ex new file mode 100644 index 0000000..64c7bb8 --- /dev/null +++ b/extensions/extension_telegram_bot/lib/extension_telegram_bot.ex @@ -0,0 +1,18 @@ +defmodule ExtensionTelegramBot do + @moduledoc """ + Documentation for `ExtensionTelegramBot`. + """ + + @doc """ + Hello world. + + ## Examples + + iex> ExtensionTelegramBot.hello() + :world + + """ + def hello do + :world + end +end diff --git a/extensions/extension_telegram_bot/mix.exs b/extensions/extension_telegram_bot/mix.exs new file mode 100644 index 0000000..a2d21dd --- /dev/null +++ b/extensions/extension_telegram_bot/mix.exs @@ -0,0 +1,28 @@ +defmodule ExtensionTelegramBot.MixProject do + use Mix.Project + + def project do + [ + app: :extension_telegram_bot, + version: "0.1.0", + elixir: "~> 1.18", + start_permanent: Mix.env() == :prod, + deps: deps() + ] + end + + # Run "mix help compile.app" to learn about applications. + def application do + [ + extra_applications: [:logger] + ] + end + + # Run "mix help deps" to learn about dependencies. + defp deps do + [ + # {:dep_from_hexpm, "~> 0.3.0"}, + # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} + ] + end +end diff --git a/extensions/extension_telegram_bot/test/extension_telegram_bot_test.exs b/extensions/extension_telegram_bot/test/extension_telegram_bot_test.exs new file mode 100644 index 0000000..12c2e8a --- /dev/null +++ b/extensions/extension_telegram_bot/test/extension_telegram_bot_test.exs @@ -0,0 +1,8 @@ +defmodule ExtensionTelegramBotTest do + use ExUnit.Case + doctest ExtensionTelegramBot + + test "greets the world" do + assert ExtensionTelegramBot.hello() == :world + end +end diff --git a/extensions/extension_telegram_bot/test/test_helper.exs b/extensions/extension_telegram_bot/test/test_helper.exs new file mode 100644 index 0000000..869559e --- /dev/null +++ b/extensions/extension_telegram_bot/test/test_helper.exs @@ -0,0 +1 @@ +ExUnit.start() From 6f99cc5b8a122402e908d630d5e3c7b82b3f3a5a Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:09:52 -0300 Subject: [PATCH 05/14] add extension configs --- extensions/extension_telegram_bot/config/dev.exs | 0 extensions/extension_telegram_bot/config/prod.exs | 0 extensions/extension_telegram_bot/config/test.exs | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 extensions/extension_telegram_bot/config/dev.exs create mode 100644 extensions/extension_telegram_bot/config/prod.exs create mode 100644 extensions/extension_telegram_bot/config/test.exs diff --git a/extensions/extension_telegram_bot/config/dev.exs b/extensions/extension_telegram_bot/config/dev.exs new file mode 100644 index 0000000..e69de29 diff --git a/extensions/extension_telegram_bot/config/prod.exs b/extensions/extension_telegram_bot/config/prod.exs new file mode 100644 index 0000000..e69de29 diff --git a/extensions/extension_telegram_bot/config/test.exs b/extensions/extension_telegram_bot/config/test.exs new file mode 100644 index 0000000..e69de29 From f2d51e2cb0c8e92f953bc16eb338998dea4a0881 Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:10:46 -0300 Subject: [PATCH 06/14] rename to telegram_bot --- .../{extension_telegram_bot => telegram_bot}/.formatter.exs | 0 extensions/{extension_telegram_bot => telegram_bot}/.gitignore | 0 extensions/{extension_telegram_bot => telegram_bot}/README.md | 0 .../{extension_telegram_bot => telegram_bot}/config/dev.exs | 0 .../{extension_telegram_bot => telegram_bot}/config/prod.exs | 0 .../{extension_telegram_bot => telegram_bot}/config/test.exs | 0 .../lib/extension_telegram_bot.ex | 0 extensions/{extension_telegram_bot => telegram_bot}/mix.exs | 0 .../test/extension_telegram_bot_test.exs | 0 .../{extension_telegram_bot => telegram_bot}/test/test_helper.exs | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename extensions/{extension_telegram_bot => telegram_bot}/.formatter.exs (100%) rename extensions/{extension_telegram_bot => telegram_bot}/.gitignore (100%) rename extensions/{extension_telegram_bot => telegram_bot}/README.md (100%) rename extensions/{extension_telegram_bot => telegram_bot}/config/dev.exs (100%) rename extensions/{extension_telegram_bot => telegram_bot}/config/prod.exs (100%) rename extensions/{extension_telegram_bot => telegram_bot}/config/test.exs (100%) rename extensions/{extension_telegram_bot => telegram_bot}/lib/extension_telegram_bot.ex (100%) rename extensions/{extension_telegram_bot => telegram_bot}/mix.exs (100%) rename extensions/{extension_telegram_bot => telegram_bot}/test/extension_telegram_bot_test.exs (100%) rename extensions/{extension_telegram_bot => telegram_bot}/test/test_helper.exs (100%) diff --git a/extensions/extension_telegram_bot/.formatter.exs b/extensions/telegram_bot/.formatter.exs similarity index 100% rename from extensions/extension_telegram_bot/.formatter.exs rename to extensions/telegram_bot/.formatter.exs diff --git a/extensions/extension_telegram_bot/.gitignore b/extensions/telegram_bot/.gitignore similarity index 100% rename from extensions/extension_telegram_bot/.gitignore rename to extensions/telegram_bot/.gitignore diff --git a/extensions/extension_telegram_bot/README.md b/extensions/telegram_bot/README.md similarity index 100% rename from extensions/extension_telegram_bot/README.md rename to extensions/telegram_bot/README.md diff --git a/extensions/extension_telegram_bot/config/dev.exs b/extensions/telegram_bot/config/dev.exs similarity index 100% rename from extensions/extension_telegram_bot/config/dev.exs rename to extensions/telegram_bot/config/dev.exs diff --git a/extensions/extension_telegram_bot/config/prod.exs b/extensions/telegram_bot/config/prod.exs similarity index 100% rename from extensions/extension_telegram_bot/config/prod.exs rename to extensions/telegram_bot/config/prod.exs diff --git a/extensions/extension_telegram_bot/config/test.exs b/extensions/telegram_bot/config/test.exs similarity index 100% rename from extensions/extension_telegram_bot/config/test.exs rename to extensions/telegram_bot/config/test.exs diff --git a/extensions/extension_telegram_bot/lib/extension_telegram_bot.ex b/extensions/telegram_bot/lib/extension_telegram_bot.ex similarity index 100% rename from extensions/extension_telegram_bot/lib/extension_telegram_bot.ex rename to extensions/telegram_bot/lib/extension_telegram_bot.ex diff --git a/extensions/extension_telegram_bot/mix.exs b/extensions/telegram_bot/mix.exs similarity index 100% rename from extensions/extension_telegram_bot/mix.exs rename to extensions/telegram_bot/mix.exs diff --git a/extensions/extension_telegram_bot/test/extension_telegram_bot_test.exs b/extensions/telegram_bot/test/extension_telegram_bot_test.exs similarity index 100% rename from extensions/extension_telegram_bot/test/extension_telegram_bot_test.exs rename to extensions/telegram_bot/test/extension_telegram_bot_test.exs diff --git a/extensions/extension_telegram_bot/test/test_helper.exs b/extensions/telegram_bot/test/test_helper.exs similarity index 100% rename from extensions/extension_telegram_bot/test/test_helper.exs rename to extensions/telegram_bot/test/test_helper.exs From 24f1a5ce916847f8506bac0627d1a2ee0a24a33c Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:12:29 -0300 Subject: [PATCH 07/14] add init funtion --- extensions/telegram_bot/lib/extension.ex | 10 ++++++++++ .../telegram_bot/lib/extension_telegram_bot.ex | 18 ------------------ extensions/telegram_bot/mix.exs | 2 +- 3 files changed, 11 insertions(+), 19 deletions(-) create mode 100644 extensions/telegram_bot/lib/extension.ex delete mode 100644 extensions/telegram_bot/lib/extension_telegram_bot.ex diff --git a/extensions/telegram_bot/lib/extension.ex b/extensions/telegram_bot/lib/extension.ex new file mode 100644 index 0000000..13defb0 --- /dev/null +++ b/extensions/telegram_bot/lib/extension.ex @@ -0,0 +1,10 @@ +defmodule Extensions.TelegramBot do + @moduledoc false + + require Logger + + def init() do + Logger.info("Telegram Bot Extension Initialized") + :ok + end +end diff --git a/extensions/telegram_bot/lib/extension_telegram_bot.ex b/extensions/telegram_bot/lib/extension_telegram_bot.ex deleted file mode 100644 index 64c7bb8..0000000 --- a/extensions/telegram_bot/lib/extension_telegram_bot.ex +++ /dev/null @@ -1,18 +0,0 @@ -defmodule ExtensionTelegramBot do - @moduledoc """ - Documentation for `ExtensionTelegramBot`. - """ - - @doc """ - Hello world. - - ## Examples - - iex> ExtensionTelegramBot.hello() - :world - - """ - def hello do - :world - end -end diff --git a/extensions/telegram_bot/mix.exs b/extensions/telegram_bot/mix.exs index a2d21dd..2543a5e 100644 --- a/extensions/telegram_bot/mix.exs +++ b/extensions/telegram_bot/mix.exs @@ -1,4 +1,4 @@ -defmodule ExtensionTelegramBot.MixProject do +defmodule Extensions.TelegramBot.MixProject do use Mix.Project def project do From eb15bae67017750d6ff2fe62af22385e22f75d1d Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:13:02 -0300 Subject: [PATCH 08/14] add phoenix dep --- extensions/telegram_bot/mix.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/telegram_bot/mix.exs b/extensions/telegram_bot/mix.exs index 2543a5e..61a87fd 100644 --- a/extensions/telegram_bot/mix.exs +++ b/extensions/telegram_bot/mix.exs @@ -21,6 +21,7 @@ defmodule Extensions.TelegramBot.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ + {:phoenix, "~> 1.7.18"}, # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} ] From 7088820738dff0ccc98d605ffa9a42ea4b3971c8 Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:16:24 -0300 Subject: [PATCH 09/14] added extensions to mix --- mix.exs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index dd2acc3..95d94c4 100644 --- a/mix.exs +++ b/mix.exs @@ -27,6 +27,13 @@ defmodule PhoenixExtensions.MixProject do defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] + # Specifies your project extensions. + defp extensions do + [ + {:extension_telegram_bot, path: Path.join(["extensions", "telegram_bot"])} + ] + end + # Specifies your project dependencies. # # Type `mix help deps` for examples and options. @@ -58,7 +65,7 @@ defmodule PhoenixExtensions.MixProject do {:jason, "~> 1.2"}, {:dns_cluster, "~> 0.1.1"}, {:bandit, "~> 1.5"} - ] + ] ++ extensions() end # Aliases are shortcuts or tasks specific to the current project. From 1a859db77e135f29ae1a6ed9d127a2a57d63b218 Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:18:09 -0300 Subject: [PATCH 10/14] expand path in config --- config/config.exs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index 524d54a..e0af7c1 100644 --- a/config/config.exs +++ b/config/config.exs @@ -67,4 +67,6 @@ config :phoenix, :json_library, Jason import_config "#{config_env()}.exs" # Import Telegram Bot Extension Config -import_config Path.join(["extensions", "telegram_bot", "config", "#{config_env()}.exs"]) +import_config ["extensions", "telegram_bot", "config", "#{config_env()}.exs"] + |> Path.join() + |> Path.expand() From e9c617dd6ae81c7105c35b9a266d1c9eece3c0c8 Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:19:10 -0300 Subject: [PATCH 11/14] added web domain --- extensions/telegram_bot/lib/web/controllers/controller.ex | 0 extensions/telegram_bot/lib/web/router.ex | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 extensions/telegram_bot/lib/web/controllers/controller.ex create mode 100644 extensions/telegram_bot/lib/web/router.ex diff --git a/extensions/telegram_bot/lib/web/controllers/controller.ex b/extensions/telegram_bot/lib/web/controllers/controller.ex new file mode 100644 index 0000000..e69de29 diff --git a/extensions/telegram_bot/lib/web/router.ex b/extensions/telegram_bot/lib/web/router.ex new file mode 100644 index 0000000..e69de29 From c170e38c35863315df86d1369944787e742e3c8d Mon Sep 17 00:00:00 2001 From: Camilo Date: Sat, 1 Feb 2025 10:20:55 -0300 Subject: [PATCH 12/14] apply format --- .formatter.exs | 6 +++++- extensions/telegram_bot/lib/extension.ex | 12 ++++++------ extensions/telegram_bot/mix.exs | 2 +- lib/phoenix_extensions/application.ex | 6 +++--- .../controllers/error_html_test.exs | 3 ++- .../controllers/error_json_test.exs | 4 +++- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.formatter.exs b/.formatter.exs index ef8840c..2a3cb60 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -2,5 +2,9 @@ import_deps: [:ecto, :ecto_sql, :phoenix], subdirectories: ["priv/*/migrations"], plugins: [Phoenix.LiveView.HTMLFormatter], - inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"] + inputs: [ + "*.{heex,ex,exs}", + "{extensions,config,lib,test}/**/*.{heex,ex,exs}", + "priv/*/seeds.exs" + ] ] diff --git a/extensions/telegram_bot/lib/extension.ex b/extensions/telegram_bot/lib/extension.ex index 13defb0..a5def7b 100644 --- a/extensions/telegram_bot/lib/extension.ex +++ b/extensions/telegram_bot/lib/extension.ex @@ -1,10 +1,10 @@ defmodule Extensions.TelegramBot do - @moduledoc false + @moduledoc false - require Logger + require Logger - def init() do - Logger.info("Telegram Bot Extension Initialized") - :ok - end + def init() do + Logger.info("Telegram Bot Extension Initialized") + :ok + end end diff --git a/extensions/telegram_bot/mix.exs b/extensions/telegram_bot/mix.exs index 61a87fd..759d44f 100644 --- a/extensions/telegram_bot/mix.exs +++ b/extensions/telegram_bot/mix.exs @@ -21,7 +21,7 @@ defmodule Extensions.TelegramBot.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ - {:phoenix, "~> 1.7.18"}, + {:phoenix, "~> 1.7.18"} # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} ] diff --git a/lib/phoenix_extensions/application.ex b/lib/phoenix_extensions/application.ex index a13fa66..591a441 100644 --- a/lib/phoenix_extensions/application.ex +++ b/lib/phoenix_extensions/application.ex @@ -11,9 +11,9 @@ defmodule PhoenixExtensions.Application do PhoenixExtensionsWeb.Telemetry, PhoenixExtensions.Repo, {Ecto.Migrator, - repos: Application.fetch_env!(:phoenix_extensions, :ecto_repos), - skip: skip_migrations?()}, - {DNSCluster, query: Application.get_env(:phoenix_extensions, :dns_cluster_query) || :ignore}, + repos: Application.fetch_env!(:phoenix_extensions, :ecto_repos), skip: skip_migrations?()}, + {DNSCluster, + query: Application.get_env(:phoenix_extensions, :dns_cluster_query) || :ignore}, {Phoenix.PubSub, name: PhoenixExtensions.PubSub}, # Start the Finch HTTP client for sending emails {Finch, name: PhoenixExtensions.Finch}, diff --git a/test/phoenix_extensions_web/controllers/error_html_test.exs b/test/phoenix_extensions_web/controllers/error_html_test.exs index 2fcc5f0..6f23286 100644 --- a/test/phoenix_extensions_web/controllers/error_html_test.exs +++ b/test/phoenix_extensions_web/controllers/error_html_test.exs @@ -9,6 +9,7 @@ defmodule PhoenixExtensionsWeb.ErrorHTMLTest do end test "renders 500.html" do - assert render_to_string(PhoenixExtensionsWeb.ErrorHTML, "500", "html", []) == "Internal Server Error" + assert render_to_string(PhoenixExtensionsWeb.ErrorHTML, "500", "html", []) == + "Internal Server Error" end end diff --git a/test/phoenix_extensions_web/controllers/error_json_test.exs b/test/phoenix_extensions_web/controllers/error_json_test.exs index 0d6beac..6d21e04 100644 --- a/test/phoenix_extensions_web/controllers/error_json_test.exs +++ b/test/phoenix_extensions_web/controllers/error_json_test.exs @@ -2,7 +2,9 @@ defmodule PhoenixExtensionsWeb.ErrorJSONTest do use PhoenixExtensionsWeb.ConnCase, async: true test "renders 404" do - assert PhoenixExtensionsWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}} + assert PhoenixExtensionsWeb.ErrorJSON.render("404.json", %{}) == %{ + errors: %{detail: "Not Found"} + } end test "renders 500" do From 0b569294ca18bb841b6dd20c854f9bdb9e80ad4a Mon Sep 17 00:00:00 2001 From: Camilo Date: Sun, 2 Feb 2025 11:15:40 -0300 Subject: [PATCH 13/14] renamed modules --- config/config.exs | 2 +- extensions/telegram_bot/lib/extension.ex | 2 +- extensions/telegram_bot/mix.exs | 2 +- .../{extension_telegram_bot_test.exs => telegram_bot_test.exs} | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename extensions/telegram_bot/test/{extension_telegram_bot_test.exs => telegram_bot_test.exs} (70%) diff --git a/config/config.exs b/config/config.exs index e0af7c1..f8e9757 100644 --- a/config/config.exs +++ b/config/config.exs @@ -10,7 +10,7 @@ import Config config :phoenix_extensions, ecto_repos: [PhoenixExtensions.Repo], generators: [timestamp_type: :utc_datetime], - extensions: [Extensions.TelegramBot] + extensions: [PhoenixExtensions.Extensions.TelegramBot] # Configures the endpoint config :phoenix_extensions, PhoenixExtensionsWeb.Endpoint, diff --git a/extensions/telegram_bot/lib/extension.ex b/extensions/telegram_bot/lib/extension.ex index a5def7b..e3c9c5f 100644 --- a/extensions/telegram_bot/lib/extension.ex +++ b/extensions/telegram_bot/lib/extension.ex @@ -1,4 +1,4 @@ -defmodule Extensions.TelegramBot do +defmodule PhoenixExtensions.Extensions.TelegramBot do @moduledoc false require Logger diff --git a/extensions/telegram_bot/mix.exs b/extensions/telegram_bot/mix.exs index 759d44f..b421bd7 100644 --- a/extensions/telegram_bot/mix.exs +++ b/extensions/telegram_bot/mix.exs @@ -1,4 +1,4 @@ -defmodule Extensions.TelegramBot.MixProject do +defmodule PhoenixExtensions.Extensions.TelegramBot.MixProject do use Mix.Project def project do diff --git a/extensions/telegram_bot/test/extension_telegram_bot_test.exs b/extensions/telegram_bot/test/telegram_bot_test.exs similarity index 70% rename from extensions/telegram_bot/test/extension_telegram_bot_test.exs rename to extensions/telegram_bot/test/telegram_bot_test.exs index 12c2e8a..4578924 100644 --- a/extensions/telegram_bot/test/extension_telegram_bot_test.exs +++ b/extensions/telegram_bot/test/telegram_bot_test.exs @@ -1,4 +1,4 @@ -defmodule ExtensionTelegramBotTest do +defmodule PhoenixExtensions.Extensions.TelegramBotTest do use ExUnit.Case doctest ExtensionTelegramBot From b6e2640c05283e306920bc8d7d7515548c6d4e53 Mon Sep 17 00:00:00 2001 From: Camilo Date: Sun, 2 Feb 2025 12:51:02 -0300 Subject: [PATCH 14/14] added core libs --- .formatter.exs | 2 +- core/.formatter.exs | 4 ++++ core/.gitignore | 23 +++++++++++++++++++++++ core/lib/core.ex | 18 ++++++++++++++++++ core/mix.exs | 28 ++++++++++++++++++++++++++++ core/test/core_test.exs | 8 ++++++++ core/test/test_helper.exs | 1 + extensions/telegram_bot/mix.exs | 1 + 8 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 core/.formatter.exs create mode 100644 core/.gitignore create mode 100644 core/lib/core.ex create mode 100644 core/mix.exs create mode 100644 core/test/core_test.exs create mode 100644 core/test/test_helper.exs diff --git a/.formatter.exs b/.formatter.exs index 2a3cb60..9f4639b 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -4,7 +4,7 @@ plugins: [Phoenix.LiveView.HTMLFormatter], inputs: [ "*.{heex,ex,exs}", - "{extensions,config,lib,test}/**/*.{heex,ex,exs}", + "{core,extensions,config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs" ] ] diff --git a/core/.formatter.exs b/core/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/core/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/core/.gitignore b/core/.gitignore new file mode 100644 index 0000000..17ce19a --- /dev/null +++ b/core/.gitignore @@ -0,0 +1,23 @@ +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# If the VM crashes, it generates a dump, let's ignore it too. +erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). +*.ez + +# Ignore package tarball (built via "mix hex.build"). +core-*.tar + +# Temporary files, for example, from tests. +/tmp/ diff --git a/core/lib/core.ex b/core/lib/core.ex new file mode 100644 index 0000000..1c53942 --- /dev/null +++ b/core/lib/core.ex @@ -0,0 +1,18 @@ +defmodule Core do + @moduledoc """ + Documentation for `Core`. + """ + + @doc """ + Hello world. + + ## Examples + + iex> Core.hello() + :world + + """ + def hello do + :world + end +end diff --git a/core/mix.exs b/core/mix.exs new file mode 100644 index 0000000..9c748e1 --- /dev/null +++ b/core/mix.exs @@ -0,0 +1,28 @@ +defmodule Core.MixProject do + use Mix.Project + + def project do + [ + app: :phoenix_extensions_core, + version: "0.1.0", + elixir: "~> 1.18", + start_permanent: Mix.env() == :prod, + deps: deps() + ] + end + + # Run "mix help compile.app" to learn about applications. + def application do + [ + extra_applications: [:logger] + ] + end + + # Run "mix help deps" to learn about dependencies. + defp deps do + [ + # {:dep_from_hexpm, "~> 0.3.0"}, + # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} + ] + end +end diff --git a/core/test/core_test.exs b/core/test/core_test.exs new file mode 100644 index 0000000..661aff1 --- /dev/null +++ b/core/test/core_test.exs @@ -0,0 +1,8 @@ +defmodule CoreTest do + use ExUnit.Case + doctest Core + + test "greets the world" do + assert Core.hello() == :world + end +end diff --git a/core/test/test_helper.exs b/core/test/test_helper.exs new file mode 100644 index 0000000..869559e --- /dev/null +++ b/core/test/test_helper.exs @@ -0,0 +1 @@ +ExUnit.start() diff --git a/extensions/telegram_bot/mix.exs b/extensions/telegram_bot/mix.exs index b421bd7..bd0065f 100644 --- a/extensions/telegram_bot/mix.exs +++ b/extensions/telegram_bot/mix.exs @@ -21,6 +21,7 @@ defmodule PhoenixExtensions.Extensions.TelegramBot.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ + {:phoenix_extensions_core, path: Path.expand(Path.join(["..", "..", "core"]))}, {:phoenix, "~> 1.7.18"} # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}