type1fool

type1fool

An Igniter Saga - Generating Code for Agency Projects

Heyo @zachdaniel!

This topic continues a conversation that started in the Igniter topic.

The component generators turned out nicely, and I can’t wait to use them on new projects. :tada: I’m working on a new generator for adding Commanded and related config to projects.

When I attempt to add config for a module within my app, the generated config is appended to the top-level app config with string atoms as the keys. What I was expecting was a separate block of config with the module as the second argument, followed by the KW list.

Am I doing something wrong, or is this a possible bug?

Expected

config :yolo,
  ecto_repos: [Yolo.Repo],
  generators: [timestamp_type: :utc_datetime],
  consistency: :eventual,
  event_stores: [Yolo.EventSystem.EventStore]

config :yolo, Yolo.EventSystem.EventStore,
    migration_primary_key: [type: :binary_id],
    migration_foreign_key: [type: :binary_id],
    migration_timestamps: [type: :utc_datetime_usec]

config :yolo, Yolo.EventSystem.Application,
    event_store: [
      adapter: Commanded.EventStore.Adapters.EventStore,
      event_store: Yolo.EventSystem.EventStore
    ],
    phoenix_pubsub: [adapter: Phoenix.PubSub.PG2, pool_size: 1],
    pubsub: :local,
    registry: :local,
    snapshotting: %{}

Actual

config :yolo,
  ecto_repos: [Yolo.Repo],
  generators: [timestamp_type: :utc_datetime],
  consistency: :eventual,
  event_stores: [Yolo.EventSystem.EventStore],
  "Elixir.Yolo.EventSystem.EventStore": [
    migration_primary_key: [type: :binary_id],
    migration_foreign_key: [type: :binary_id],
    migration_timestamps: [type: :utc_datetime_usec]
  ],
  "Elixir.Yolo.EventSystem.Application": [
    event_store: [
      adapter: Commanded.EventStore.Adapters.EventStore,
      event_store: Yolo.EventSystem.EventStore
    ],
    phoenix_pubsub: [adapter: Phoenix.PubSub.PG2, pool_size: 1],
    pubsub: :local,
    registry: :local,
    snapshotting: %{}
  ]

Igniter Code

igniter
|> Igniter.compose_task("cauldron.install.ecto", [])
|> Igniter.Project.Deps.add_dep({:commanded, "~> 1.4"})
|> Igniter.Project.Deps.add_dep({:commanded_ecto_projections, "~> 1.4"})
|> Igniter.Project.Deps.add_dep({:commanded_eventstore_adapter, "~> 1.4"})
|> Igniter.apply_and_fetch_dependencies(yes: true)
|> Igniter.Project.Config.configure("config.exs", app_name, :consistency, :eventual)
|> Igniter.Project.Config.configure("config.exs", app_name, :event_stores, [
  event_store_module
])
|> Igniter.Project.Config.configure(
  "config.exs",
  app_name,
  event_store_module,
  migration_primary_key: [type: :binary_id],
  migration_foreign_key: [type: :binary_id],
  migration_timestamps: [type: :utc_datetime_usec]
)
|> Igniter.Project.Config.configure(
  "config.exs",
  app_name,
  event_system_application_module,
  event_store: [
    adapter: Commanded.EventStore.Adapters.EventStore,
    event_store: event_store_module
  ],
  phoenix_pubsub: [
    adapter: Phoenix.PubSub.PG2,
    pool_size: 1
  ],
  pubsub: :local,
  registry: :local,
  snapshotting: %{}
)

Module Variables at Runtime

Running the command in the :yolo sandbox app, these are the values used for the config path:

event_store_module = Yolo.EventSystem.EventStore
event_system_application_module = Yolo.EventSystem.Application

Most Liked

zachdaniel

zachdaniel

Creator of Ash

:bowing_man: thanks! I’ll take a look :slight_smile:

zachdaniel

zachdaniel

Creator of Ash

Fixed :smiley:

type1fool

type1fool

Excellent! :fire::fire::fire: I will give it a shot tomorrow.

Last Post!

zachdaniel

zachdaniel

Creator of Ash

Yes, that is correct. It’s used with OptionParser, so -m would be used as m: :migration, for example.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
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
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
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

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
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
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
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

We're in Beta

About us Mission Statement