<FromGitter>
<Blacksmoke16> then dont need the initializer
<FromGitter>
<andrewc910> Beautiful! Thank you 😁 I would love a code review in a couple days. Need to merge and move quite a few things.
<FromGitter>
<andrewc910> I've only been programming for about 7 months. Mostly ruby, just moved to crystal. I would love for this shard to be production ready, however my main point is to learn and build up an OSS profolio.
<FromGitter>
<Blacksmoke16> would it not be possible to make it more generic? like include a module that requires the user to implement a few methods?
<FromGitter>
<andrewc910> What methods do you have in mind? I'm completely open to making the shard itself more generic. But I believe the cli/code generation would work best if it was opinionated.
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<Blacksmoke16> also prob want to add `.vscode` to `.gitignore`
<FromGitter>
<Blacksmoke16> and `./bin` which it should have been already
<FromGitter>
<Blacksmoke16> and `shard.lock` since this is more of a lib no?
<FromGitter>
<andrewc910> Yeah, suppose to be a lib. Will add all that to gitignore :)
<FromGitter>
<Blacksmoke16> is what gets generated when you do `crystal init`
<FromGitter>
<andrewc910> I had to reinitialize my repo for stupid reasons so that would make sense as why those aren't in the ignore file. Thanks!
<FromGitter>
<Blacksmoke16> playing devils advocate, is all the logic to generate this stuff worth it?
<FromGitter>
<Blacksmoke16> what is being generated exactly? like the fields and stuff that go into your `User` model?
<FromGitter>
<Blacksmoke16> also you can setup shards to run your build step, i.e. when someone adds it and runs `shards install` it'll build the `contrive` binary and put it in their bin
<FromGitter>
<andrewc910> config, routes, model and migrations are generated. Most methods are in macros divided by ORM.
<FromGitter>
<andrewc910> Only methods that aren't in a macro are methods used in controllers.
<FromGitter>
<Blacksmoke16> gotcha
<FromGitter>
<andrewc910> btw, thanks for the input and even glancing at the code! As said before, this is more of a learning process for me in both crystal and authentication. Any guidance is appreciated.
<FromGitter>
<Blacksmoke16> what would happen if you go to use this on an already existing project?
<FromGitter>
<Blacksmoke16> id imagine it would override the files?
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<andrewc910> Because i started with the amber cli, it already has features for that. If it finds a file with a duplicate name (IE: user.cr) it asks if you would like to keep or override.
<FromGitter>
<Blacksmoke16> i see, and is this generation approach worth it? seems like a lot of work, hard to test and could easily break
<FromGitter>
<Blacksmoke16> i would imagine something like
<FromGitter>
<andrewc910> I definitely plan on writing some info about manual installation. The cli isn't meant for people such as yourself(at least that's what i imagine). The cli is more for new programmers.
<FromGitter>
<andrewc910> ```include Contrive::Authenticable::Validations(Granite)``` I like this but i am not sure how i would like the macro with a bunch of if/else's based on the orm. That's why i made 2 different macros. But this isn't very DRY :/
<FromGitter>
<Blacksmoke16> well all the logic is pretty much the same between then, except the validation logic
<FromGitter>
<andrewc910> That's very true. I will try and merge the 2 macros today and see what happens.
<FromGitter>
<Blacksmoke16> its deff harder when you try to support multiple frameworks
<FromGitter>
<Blacksmoke16> like if you were to add lucky support
<FromGitter>
<andrewc910> Yeah i am on the fence about lucky and others. I imagine most of the macros and individual methods will work but the cli wouldn't. One idea it make framework/orm specific templates. So instead of `contrive g auth user granite` it would be `contrive g granite_auth user amber`
<FromGitter>
<andrewc910> However, i feel that's way down the line. I work with amber using the jennifer orm hence why jennifer is supported.
<FromGitter>
<Blacksmoke16> id still argue the cli isnt worth the effort
<FromGitter>
<Blacksmoke16> KISS, get the core stuff working then can focus on QoL stuff
<FromGitter>
<Blacksmoke16> i think you could do something like
<FromGitter>
<andrewc910> You're probably right. More time definitely goes into the CLI than anything else. If we put away the cli for now, how would you recommend installation to be?
<FromGitter>
<andrewc910> Just copy/pasta migrations, routes, config and lines to add in models?
<FromGitter>
<Blacksmoke16> either use a generic arg for the orm, or have a separate module for the validations, i.e. if they want them they can include them
<FromGitter>
<Blacksmoke16> chances are they would already have stuff setup for creating/updating a user no?
<FromGitter>
<andrewc910> On going projects? Probably a safe bet. New projects wouldn't?
<FromGitter>
<Blacksmoke16> i think if you just focus on the core of what you're trying to do and not try to do everything for them it'll be a lot easier
<FromGitter>
<Blacksmoke16> idt it should be an authentication shard's responsibility to create db migrations and stuff. what needs to be done should be clear in your docs, so the user can see `oh i need to add some columns to my user model`, how they go about doing it doesnt really matter
<FromGitter>
<Blacksmoke16> now if you use amber a lot there isn't anything wrong with having a deeper integration with it, but shouldnt be too tightly coupled to any one framework
<FromGitter>
<Blacksmoke16> in the end its your project, just keep in mind maintainability, and how you're going to test all this
<FromGitter>
<Blacksmoke16> ` {% if !skip_validation && orm == 'jennifer' %}` idt that would compile
<FromGitter>
<Blacksmoke16> `"` for strings
<FromGitter>
<andrewc910> You bring up some very good points. I can't even think of how i would test this cli. Something like generating the appropriate framework, then running my cli then testing seems like a nightmare
<FromGitter>
<andrewc910> And without the macro, I undefined method errors due to the validations. I guess I could mixing the modules for granite and Jennifer?
<FromGitter>
<andrewc910> 🤦♂️ duh. okay I'll remove the crypto mixin and use the fqn... May I ask what's fqn?
<FromGitter>
<Blacksmoke16> i suppose full namespace would be the more common term in crystal/ruby land
<FromGitter>
<Blacksmoke16> what are the errors?
<FromGitter>
<Blacksmoke16> might just have to use `extend` or add the logic in a `macro included` hook
<FromGitter>
<andrewc910> Ive never used extend or macro include. I'll look into them. I'll send you the error later today when I'm back at my comp. Out running errands. It errors out when the validation file is `require`d outside the class.
<FromGitter>
<andrewc910> I imagine the file is being loaded and Crystal can't determine what the validations are so it throws the undefined method error before the compiler reads the `include` inside the class.
<FromGitter>
<Blacksmoke16> validate is prob a macro
<FromGitter>
<Blacksmoke16> its expanding too early, so yea, a macro hook would be the way to do it i think
<FromGitter>
<andrewc910> Okay! Thanks for the tip. I'll look at crystal docs!
<FromGitter>
<andrewc910> Okay, I understand the problem at hand. I grasp how it can be fixed but I certainly can't implement yet. I didn't see any examples of `extend` in the docs. One of the few that's missing. If I had to take a guess, my validation macros should be renamed to `extend` is that correct? From their, I just require and include them and that will do the trick? I feel like I'm missing something
<FromGitter>
<Blacksmoke16> `include` makes a type include methods defined in that module as instance methods
<FromGitter>
<Blacksmoke16> extend does the same but makes them class methods
<FromGitter>
<Blacksmoke16> since `validate` is a macro versus a method, id go with `include` with an included hook
<FromGitter>
<eliasjpr> Finally!!! The auth shard everyone has been waiting for
<FromGitter>
<andrewc910> Let's wait and see if it's any good 😂 I do plan on integrating most modules of devise. Just need some expert guidance is all!