Closed DominusKelvin closed 5 months ago
I love the idea of generators, been craving it for a while because I have tons of similar pages.
We also have to look at generators for actions.
sails generate controller create-dashboard
I just mentioned 'controller' since action is being used already
To get something like this in the exits:
exits: {
success: {
responseType: 'inertia' or 'inertiaRedirect',
description: 'this is description'
},
}
I have a few questions in mind:
sails generate api Products
? - creates the model, page and controllercreate-sails-generators
sounds more like a sails package to me and we want this for TBJS, can the name be reviewed?These are just a few things are the top of my head, more to come as we proceed.
@DominusKelvin
Hey @lennyAiko for the name I chose create-sails-generator
because we already have create-sails
which is the master of ceremony to scaffold a new Boring Stack project.
And for the how create-sails-generator
will detect what UI you are using its quite simple: we can check package.json
sails generate api Products
sound like fun but I think I can do one better.
And yes the generator can put in the response type as that's one of the reason why I'm working on it, it will also smartly try to guess the page you want to point to. Should be fun.
Indeed, this is fun. @DominusKelvin
I had to pause working on this for a day or two to give myself that fallowing time to think of the API I want. So far I want the command to be page-centric even when you want to create an action. Let me know what you think @lennyAiko
Started off with the generators to evolve the responses so you don't have to copy and paste all the time.
I had to pause working on this for a day or two to give myself that fallowing time to think of the API I want. So far I want the command to be page-centric even when you want to create an action. Let me know what you think @lennyAiko
So basically, even the actions will be generated based on the page? It makes things more straightforward, and it will reduce the number of commands to run.
However, will there be a separate API to generate actions separately? Say I need to generate an action for delete or other similar actions that do not necessarily require a page.
I had to pause working on this for a day or two to give myself that fallowing time to think of the API I want. So far I want the command to be page-centric even when you want to create an action. Let me know what you think @lennyAiko
So basically, even the actions will be generated based on the page? It makes things more straightforward, and it will reduce the number of commands to run.
However, will there be a separate API to generate actions separately? Say I need to generate an action for delete or other similar actions that do not necessarily require a page.
Yeah so for that you can rely on the sails generate action
. For this version of create-sails-generator
. I am assuming creating page with accompanying action.
I had to pause working on this for a day or two to give myself that fallowing time to think of the API I want. So far I want the command to be page-centric even when you want to create an action. Let me know what you think @lennyAiko
So basically, even the actions will be generated based on the page? It makes things more straightforward, and it will reduce the number of commands to run. However, will there be a separate API to generate actions separately? Say I need to generate an action for delete or other similar actions that do not necessarily require a page.
Yeah so for that you can rely on the
sails generate action
. For this version ofcreate-sails-generator
. I am assuming creating page with accompanying action.
That's really nice!
That means we if we are still going to rely on sails generate action
we will need to generate those responses and manually add them to exit.
Yes @lennyAiko it's a trade off.
As I continue to work on Sails.js projects within The Boring JavaScript Stack, I've encountered challenges in maintaining development efficiency and consistency across our codebase. In an effort to address these issues, I am proposing the introduction of create-sails-generator, a tool tailored specifically for development in The Boring JavaScript Stack.
With the introduction of
create-sails-generator
you should be able to run:And a file will be created in
assets/js/pages
for you. If you are using React it should create adashboard.js
, and if you are using Vue, it should createdashboard.vue
, etc.Also for things like the
responses/inertia.js
response we can evolve these responses by lettingcreate-sails-generator
expose commands for you to get the latest changes by runningsails generate response inertia
for example.The sky is the limit to the codegen we can do with this generator in order to improve the DX of working with TBJS.
Let me know what you all think.