zachdaniel

zachdaniel

Creator of Ash

Test out Ash Frameworks' first igniter-backed generators/installers!

Ash and AshPostgres generators/installers, built with igniter are available on main!
I’ll be very grateful to anyone willing to give them a shot and report back with there experience.

Keep in mind, things will absolutely break. Not only are these brand new generators, but they are an entirely new kind of generator. For more on igniter, see this thread: Igniter - A code generation and project patching framework

Commands to dive in with!

Install the archive

mix archive.install hex igniter_new

Create a new app and install dependencies into it

We use the github dependencies here so that you can use the new installers, which are only available on main currently.

mix igniter.new app_name \
  --install ash@github:ash-project/ash

Or install multiple dependencies at once. iterex in this example doesn’t have an installer (as it doesn’t need one), so it just gets added to the mix.exs file with no other changes

# as a csv
mix igniter.new app_name \
  --install iterex,ash@github:ash-project/ash,ash_postgres@github:ash-project/ash_postgres
# in multiple flags
mix igniter.new app_name \
  --install iterex \
  --install ash@github:ash-project/ash \
  --install ash_postgres@github:ash-project/ash_postgres

Or, modify an existing app!

first, add igniter to your mix.exs

defp deps do
  [
    {:igniter, "~> 0.2"}
  ]
end

Install dependencies

mix igniter.install ash@github:ash-project/ash

Install dependencies with example code!

mix igniter.install ash@github:ash-project/ash --example

Generate a resource

mix ash.gen.resource Twitter.Tweets.Tweet \
  --uuid-primary-key id \
  --attribute text:string:required:public

And generate another one, see how the domain is modified to reference the newly created resource?

mix ash.gen.resource Twitter.Tweets.Like \
  --uuid-primary-key id \
  --relationship belongs_to:tweet:Twitter.Tweets.Tweet:required:public

Generate a resource using a specific extension!

You will want to install ash_postgres first for this to work:

mix igniter.install ash_postgres@github:ash-project/ash_postgres
mix ash.gen.resource Twitter.Tweets.Tweet \
  --uuid-primary-key id \
  --attribute text:string:required:public
  --extend postgres

Modify an existing resource to use a new extension

swap its data layer to use ets

mix ash.extend Twitter.Tweets.Tweet ets

And swap it back to use postgres

mix ash.extend Twitter.Tweets.Tweet postgres

Or add a new extension

mix ash.extend Twitter.Tweets.Tweet Ash.Policy.Authorizer

There are a couple more generators you can play with like mix ash.gen.enum, but I think this is enough to get started.

Happy hacking :sunglasses:

Most Liked

zachdaniel

zachdaniel

Creator of Ash

Hmm…I think this issue is unrelated to igniter in that case. If you were to make a fresh project and point a mix dependency at github, you’d likely encounter this same issue. You’ll probably need to wait until we release proper hex version to try these out in that case, sorry about that :cry:

zachdaniel

zachdaniel

Creator of Ash

This is actually kind of a tough one because of the way that we pass arguments down into nested generators :thinking: I will see what I can do :slight_smile:

Where Next?

Popular in News & Updates Top

martosaur
InstructorLite - v1.1.1 and v1.1.2 Pass Gemini token in request header rather than in request parameter (as is shown in API reference :...
New
zachdaniel
Hey friends! A long time quality of life feature we’ve been wanting to add is the ability to refer to to-one relationships in calculation...
New
bartblast
Hologram v0.6.0 is here, bringing production-ready features to the full-stack Elixir web framework! This release focuses on enhanced secu...
New
jimsynz
As some of you know, I have been working on a tight integration between Ash and Reactor which has triggered a few small bug fixes in Spar...
New
zachdaniel
:police_car_light: New AshAuthentication Installers :police_car_light: The AshAuthentication igniter installers are released! Today on s...
New
bartblast
Backward Incompatible Changes Change template sigil from ~H to ~HOLO Require Elixir 1.15+ and Erlang/OTP 24+ New Features Add “select”...
New
sorenone
Oban v2.23.0 has been released. Sharpens resilience under database outages, catches misconfigured unique constraints at compile time, an...
New
fhunleth
We are thrilled to announce another update for Nerves Systems to nerves_system_br 1.22.5-based releases. Nerves systems are the device su...
New
fhunleth
Circuits.GPIO lets you read and write to I/O pins on embedded hardware like that used by Nerves. The new v2.0 version makes it possible t...
New
zachdaniel
Ash Framework 3.0: Release Candidates! The day is finally here! This is the culmination of years of work from the Ash team and community ...
New

Other popular topics Top

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
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
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
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement