-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate phoenix gen to igniter #261
base: main
Are you sure you want to change the base?
Migrate phoenix gen to igniter #261
Conversation
lib/ash_phoenix/gen/live.ex
Outdated
# igniter | ||
Igniter.create_new_file(igniter, destination_path, contents, generate_opts) | ||
|
||
# Mix.Generator.create_file(destination_path, contents, generate_opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra comments.
This looks great! TO test it, see how we do it in the igniter tests. You'd define a resource in import Igniter.Test
# in your test
test_project()
|> Igniter.compose_task("ash_phoenix.gen.live", [....])
|> assert_creates("....") One challenge will be a dealing with the mix shell inputs, but there are tools for doing that IIRC you can send the answers to the prompts in order using this kind of code One other thing worth noting is that there is an active PR to set up a phoenix project instead of just We can either wait on that or proceed without it. We can probably proceed without it. |
Cool I will write the tests and make the changes you pointed out. Yeah probably we can continue with out the other PR. Once it is merged I would be happy to contribute back. |
Great work, thank you! |
I figured the Mix shell prompts. Now I am stuck with the test_project setup
In the task, it is failing at
|
Right. So, the difficulty here is that those files are not compiled, and this task uses introspection to determine what to do. This is a pretty hard problem TBH. I think we could add something like this to igniter (probably in test to start) def compile(igniter) do
igniter.rewrite
|> Stream.map(fn source ->
Kernel.ParallelCompiler.async(fn ->
Code.compile_string(Rewrite.Source.get(source, :content))
end)
end)
end |
Hi @zachdaniel One other issue, I tried your compile function. It seems that :erlang.get(:elixir_compiler_info) is returning undefined. I have not played around Kernel.ParallelCompiler that much. Do you have any insight in this.
|
🤔 yeah, so that may not work. I think for now, for these tests, you will have to test with actually defined domains & resources. Like in the |
Hi Ok I will try to create the resources in the |
Hi @zachdaniel Almost got it working. The last battle is with the indentation in the assert_creates I have tried
The above is blocker now. I have pushed all my changes to the PR. |
1. removing trim option in EEx.eval_file 2. removing indent fn 3. Code.format_string
asserting show.ex file creation
Contributor checklist
Atempt 1 to create PR. Once direction is right. I need to figure out how create tests. Perhaps embed a test project to generate the live views from it.