-
Notifications
You must be signed in to change notification settings - Fork 208
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
Add Jennifer support #766
Add Jennifer support #766
Conversation
shard.yml
Outdated
@@ -70,6 +70,10 @@ dependencies: | |||
github: amberframework/teeplate | |||
version: ~> 0.5.0 | |||
|
|||
inflector: |
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.
We already have this shard some lines below 😅
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.
missed this ). Will fix later
Supporting many different ORMs is going to get complicated in recipes. Maybe the model folder in a recipe should have sub folders for each ORM. It would simplify the model template considerably. I didn't look too deeply into Jennifer but support for scopes is nice. How does it present errors ? |
hi @damianham |
4122cda
to
d9cefc1
Compare
Hi @imdrasil Actually I wouldn't bother reworking it because I don't think this is the right solution. I think the right solution to provide support for Jennifer is a recipe. It is a new feature that has just been merged into the main branch and over time I think it will solve many issues. There have been discussions about supporting plugins, and different build/packaging systems and even a suggestion to remove the built-in generators and replace them with a default recipe. Support for Jennifer could be provided by a recipe also and the core amber code will not need to be modified. However you have added jennifer to the model options and it gave me a decent idea which builds on the idea of extracting the built-in app generator and using a default recipe instead. What we could do is have a collection of default recipes for the various options and build the recipe name from the given options if no recipe option is given, e.g. amber new myapp create a new amber app from a recipe at default/granite amber new myapp -d mysql -m jennifer -t ecr create a new amber app from a recipe at default/jennifer (no need to differentiate between database engine and template language as yet) |
@imdrasil this is awesome! @damianham at the time there was no I will review this PR, it will take some time since is a big PR |
@eliasjpr yes that is correct this entire PR could be provided by a recipe. I have submitted a new PR to the amberframework/recipes repo which creates basic/granite and basic/crecto so to support Jennifer it is a case of copy the granite or crecto recipe to basic/jennifer and then amend accordingly. |
@damianham found it. So I will wait until it will be merged and rework this PR as a recipe. What do you think? |
@imdrasil yes I think that is the best way forward. |
@imdrasil the basic recipes have been merged into the recipes repo now so you could start to implement a basic/jennifer ORM recipe |
Hm, as I can see recipes includes only markup. So I should move all markup there and leave all specific classes in this PR, am I right? |
I think that this PR will not be needed, everything to use jennifer in an app would be built in to the recipe. What you would probably do is start with a copy of basic/granite in basic/jennifer and modify the model and scaffold accordingly and if the Jennifer ORM model provides the same kind of interface to views as granite then you will probably not need to modify the scaffold views. I think the files to modify in the basic/jennifer recipe would probably be: Then you can add a test in spec/recipes_spec.cr for your recipe. If you want to go the extra mile you could also create a misc/modular_jennifer recipe and follow the directory layout of the misc/modular recipe which simply places the controller, models and views in the same folder. Adding a misc/modular_jennifer recipe after creating the basic/jennifer recipe should be as simple as copying the controller and model templates in the right place. |
ok, will take a look closer later. Also I may be wrong, but it seems there is no way to use several recipes at the same time (e.g. jennifer and react). |
That is true unless there is a react/jennifer recipe. An app is created with a recipe and subsequent amber generate scaffold uses the scaffold template in the recipe that was used to generate the app. However in #749 I discuss an option whereby a recipe could depend on another recipe. The problem we will soon have a situation where we update the amber release and we than have to update the shard.yml file in all recipes, so recipe maintenance will become a real chore. By moving to a recipe dependency chain a recipe could be diffs from a base recipe. We are planning to implement before and after hooks and plugins which will give us more flexibility. The hooks will be for each kind of artifact being generated and stored within the recipe/hooks folder. We could also move the ORMs to plugins and install an ORM plugin during app generation. We may end up with everything in recipes and plugins and the existing built-in generators being completely removed. I just need to find some time to get around to implementing those features. For the moment if you can implement a basic/jennifer recipe that would be awesome. |
@damianham @faustinoaq Are we going to remove the flags |
@damianham How do you upgrade the recipes on a project when a new version of Amber comes out? |
@drujensen I don't foresee any need to change the behaviour for the -t flag at the moment as it just selects whether to generate .ecr or .slang views and both are provided in the recipe template. We can retain the -m flag and internally convert that to an appropriate recipe by appending the given ORM name to 'basic/'. E.g -m granite (or no -m flag) would use basic/granite, -m crecto would use basic/crecto, -m jennifer would use basic/jennifer -m mongo basic/mongo etc. However I also like the idea of moving the ORM to a plugin so the -m would resolve to an ORM plugin and if we can move the ORM to a plugin then I am sure we would be able to move the views to a plugin so -t could support all of the template languages supported by crystal using the same principle. One of the problems we will face with plugins is that with the default layout and the modular layout we have 2 directory layouts so plugins will have to support these 2 directory layouts. TBH I would be in favour of moving completely to the modular layout to avoid this issue. If you look at the react/preact_redux recipe I have everything related to a feature located in one folder i.e. model, controller, views, javascript and stylesheet. It is a good way to organise code. For example MEAN.JS organises an application this way. As you pointed out in another PR or issue, maintenance of recipes is going to be a lot of work as new amber releases come out and so separating the generation of an amber app into a base app with the shards and config etc and then adding plugins according to the command line arguments may alleviate the burden somewhat. I think @robocarp already mentioned that we would need to have a mechanism to auto update recipes as new releases come out. There is also an issue #733 to have a recipe cache per repository so maybe we can implement auto updating recipes along with that enhancement. Once your app is generated then you would have to update shards and config manually as you do now to use a newer version of amber or shards etc. At the moment I am making decisions regarding recipes but I would really appreciate any suggestions and guidance from everyone about how you would like it to work. Also are we happy with the recipes organisation at the moment? Is it a good idea to have default at the root and everything else in a sub folder? Should modular recipe be at the root alongside default? Should modular be the default app template? Should we work towards a base app and then additional plugins as discussed above? There are many questions and everyone's feedback is appreciated. What would be even more appreciated is people chipping in and implementing some of these new features :-) |
I am against that. I am a fan of the Rails "separation of concern" layout and prefer it over the modular.
No, No
Currently to update the templates, you update the To be honest, I am leaning toward recipes as being a bad idea altogether. Rails popularity is because anyone could easily jump right in and they know exactly where everything is. It provides very simple scaffolding on purpose. It was never meant to be used as production code. The idea was to provide a recommended design pattern that everyone would be familiar with. Amber out of the box generates the same simple structure that any Rails developer will feel right at home with. I do not want to lose that simplicity. It is also front-end agnostic on purpose since there are thousands of JS frameworks and we do not want to maintain solutions for all the different flavors. It was brought up by @jwaldrip that we should lose the
I wrote the original templates and I am happy with them. Here are my concerns with recipes so far:
Unfortunately, I don't have any time right now to help. I will have some time this summer. I have some idea's on how to address these concerns (mainly changing recipes into crystal libraries as shards) and will work on this when I get a chance. |
@drujensen I understand your concerns, although, I think recipes is a great idea
I think recipes as shard would be an interesting idea (just like amber-saludo example), although, if you use shards then you can't generate a full project from scratch like recipes do, you will need to have a project first, well at least a I think recipes is a more elegant and easier to maintain approach. Recipes are easier to test, maintain and deploy. One repo for blessed recipes is the way to go IMHO. 😅 WDYT? |
@faustinoaq I think we need to discuss our goals with Amber and I don't see hosting and maintaining recipes as one of them. IMO the Amber team does not have the band-width or time to maintain recipes for possibly hundreds of different flavors of front-end and back-end combinations. If we do decide to support the ability to I understand the issue with bootstrapping a new project using shards and here is my proposed solution. I think we should be able to start a project using With this in mind, I think any modifications to the templates (recipes) could simply be adding a shard to the project before running the There are many advantages to this approach:
I would like to make sure we stay focused on the goals we set for Amber and I don't see maintaining multiple flavors of different recipes as one of those goals. |
@drujensen I agree that recipes are beyond the original goals of Amber and maintaining many blessed recipes could become a time consuming task. However, the fact that we curate blessed recipes also gives us the ability to ensure they stay up to date and perform well with no nasty surprises. I based the idea and implementation a little bit on Yo http://yeoman.io/ but made it a bit easier to create an app from a recipe by naming the recipe and downloading on the fly rather than the Yo method of installing a generator as an npm module. Once you have an amber binary on the path creating a new app from a recipe is very simple and does not involve pre-installing generators. You seem to be in favour of the Yo method of installing the generator before use. There is one way in which we could have the simplicity of the recipe name as an arg to the new app generator while removing blessed curated recipes from the core project and that is to have a shard which converts the recipe name to a URL to the recipe zip file which could be anywhere on the web. #764 adds support for a recipe URL but as a user of the recipe feature I would rather type
than
hence from my point of view, curated recipes, either in their current form or via a shard that converts the name to a URL, are a much easier option for end users. |
@drujensen Yeah, no problem, Indeed, I suggested some time ago we should use
I think this is not a problem Recipes can be maintained by community, also out blessed recipes are not hundred, just a few.
Recipes doesn't modify amber, recipes are just pre-made amber projects with custom stuff. I think you can already use shards if you want to, but as I said before we would need to have at least a
@drujensen Yeah, I like your proposed solution (as I said before, I already proposed that some time ago) ,and I think you are a it confused 😅 We already concluded that
Recipes is not against Amber goals. This is just a nice alternative to manage custom generators and cleanup a lot of templates we already have on amber itself. Recipes are nice because:
Is way easier to use react recipe, than create an amber project from scratch and figure out how to configure all front-end stuff. This will allow us to cleanup a lot of default front-end files in current amber (a lot of web pack files and more) And now we would be able to use custom configuration, not only npm/webpack/boostrap but yarn, rollup, foundation, and other popular stuff.
@damianham I think blessed recipes is not that hard to maintain. IMO is harder to maintain multiples repositores "shards", each one with multiples issues and PRs to track and review. @damianham I agree, recipes are easy and useful, and with amberframework/recipes#14 are even easier to maintain and deploy So, @drujensen WDYT? Can you give us access to Github Token to start using |
@faustinoaq agree with a lot of mentioned stuff, but:
|
@faustinoaq @drujensen I agree with targeting recipes with shards, and especially with the overlay idea that @drujensen has mentioned a few times. I see that as the "eventual destination" of this feature. Recipes is a big task that needs a lot of iteration before it's going to be perfect. |
b938880
to
c4d81b8
Compare
@imdrasil Is this still work in progress? @robacarp Yeah, I agree recipes can be shards, although, we need to test current implementation I'm already doing a lot of work on recipes to remove code duplication and add more tests about code formatting, ameba and The final goal would be recipes as shards, but we still need some features like |
@faustinoaq yeah and going to finish refactoring till tomorrow evening (my time). Sorry for such a long running PR - I got a lot of work to do on my work. |
Hi @imdrasil I just created, amberframework/recipes#20, please take a look! 😉 BTW, I like some nice cleanup you did here, I think we can merge some code here (no Jennifer specific) 👍 |
f41fa48
to
22e6e29
Compare
22e6e29
to
d114155
Compare
cf0994d
to
f06be0d
Compare
f06be0d
to
e3da4fd
Compare
Moved to amberframework/recipes#20 @imdrasil Thanks you! |
WIP: this PR is not ready to be merged
ATM this PR is created to describe my current vision how to integrate Jennifer into Amber. After clarifying all aspects and details - tests suite will be added and related Jennifer release created.
Description of the Change
Add Jennifer and Sam support
Alternate Designs
The reason why Sam has been added as well is its usage by some Jennifer processes.
Benefits
amber
utilityPossible Drawbacks