-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Igniter task to install Phoenix #140
base: main
Are you sure you want to change the base?
Conversation
"" | ||
end | ||
|
||
!String.valid?(Rewrite.Source.get(source, :content)) -> |
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.
Some files do not have a valid string content, for eg binary files like favicon.ico
but I think we still need to display that such file will be created. Might need to improve this code to detect updates as well.
mix.exs
Outdated
@@ -100,6 +100,7 @@ defmodule Igniter.MixProject do | |||
{:spitfire, "~> 0.1 and >= 0.1.3"}, | |||
{:sourceror, "~> 1.4"}, | |||
{:jason, "~> 1.4"}, | |||
{:phx_new, "~> 1.7", runtime: false}, |
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.
Is this okay?
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.
🤔 This one is tough. I don't actually think we need this. IIRC phx_new
will be available as long as the user has the archive installed? Which could mean that we can just at the start say "please install phx_new
to use this task" if the module is not defined.
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.
So we could have it as a test only dependency in that case.
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.
I don't actually think we need this. IIRC
phx_new
will be available as long as the user has the archive installed? Which could mean that we can just at the start say "please installphx_new
to use this task" if the module is not defined.
Should we have it as an optional dependency, in that case? That seems like the best of both worlds: It doesn't become a transient dependency that all apps using Igniter are required to fetch, but it still allows Igniter to test against it and specify a version spec that Igniter's compatible with.
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.
🤔 I think that would make sense, yes. Since we'd be switching in our code on the module being compiled, it wouldn't matter if it's from a dep or the archive.
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.
Changed to optional: true
and added a check. Tested in a project, it will ask to install phx_new
if not available.
This is awesome! Having not looked at the code yet, a couple quick thoughts:
|
Not required. You can execute the task in any project, the files are relative to the root path. So that can potentially be used to upgrade Phoenix in your app for example.
I was thinking about it and forgot to propose in this PR 😂 |
- make :phx_new optional and check if it's loaded - add remaining user-facing opts - require Elixir ~> 1.15 - validate %Project{} - use Phoenix extension
Hey @zachdaniel here's the initial draft for
igniter.install_phoenix
. In short it does mimic phx.new.ex by wrapping generator.ex and single.ex to include the Igniter pipeline. With this approach we can reuse the same template files and reuse some functions, for egSingle.render/3
, and also allows us to gradually migrate the generator to use Igniter functions.Before moving forward, I'd like some feedback and review of the current code (see the comments).
To test this PR:
mix deps.get mix igniter.install_phoenix .