dewetblomerus

dewetblomerus

Modifying Phoenix Generator and Failing to Maintain Old Behavior

@victorbjorklund thanks for your @ThinkingElixir #167 on Phoenix Generators.

This would solve a problem at work where we want all new services to have certain observability libraries installed and to respond to a health check without logging, etc.

I tried your article Build your custom Phoenix phx.new generator

I can not get into a state where my modified generator and the original generator both work. I need this because it would be bad if someone goes to make a side-project on their work laptop and ends up with the company’s setup.

Here are the steps I took:

  • Make a copy of the installer dir with my own name.
  • Rename the file and module name for /lib/mix/tasks/phx.new_project.ex
  • Edit /templates/phx_single/mix.exs

Now I can run mix phx.new_dw foo and I get the modified mix.exs. But if I run mix phx.new foo I also get the modified mix.exs.

I tried renaming the app: :phx_new in the installer/mix.exs. This really made it seem like I found the correct thing, because it generated a differently named file in ~/.asdf/installs/elixir/1.15.4-otp-26/.mix/archives/ but still, both commands generate the modified code.

I tried deleting and re-generating the files in ~/.asdf/installs/elixir/1.15.4-otp-26/.mix/archives/, this produced the same result.

Do you have an example of a GitHub project where you have a modified version of the generator that still allows you to call the official Phoenix generator when you want to?

Most Liked

dimitarvp

dimitarvp

Oh man, if you succeed in this and even open-source it, I am definitely buying you a pizza and a beer!

dewetblomerus

dewetblomerus

I will at least open source a toy version of this if I got it working. No pizza or beer required.

For personal projects, my only need is that mix_test_watch is included on every Elixir project ever :grinning_face:

Where Next?

Popular in Questions Top

New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: <h1>Create Post</h1> <%= ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement