-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
[legacy-framework] feat(cli): generate command #187
Conversation
packages/cli/src/command.ts
Outdated
protected indent = false | ||
|
||
logTheme(str: string, options?: LogOptions) { | ||
this.log(chalk.bgWhite.hex(this.themeColor).bold(str), options) |
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.
Can we reuse the log
util for these? I've opened #194 for adding a utils package, but importing from server
is fine for now.
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.
ok that's fine, I can do that. I mentioned in the PR description that using server as a logger felt like a weird merging of responsibilities for that package so I held off initially. I'll move to server
under the assumption that it'll eventually get codemodded to the utils
package
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.
Thanks! Better to make a step towards the right solution than no step at all :)
|
||
enum ResourceType { | ||
Resource = 'resource', | ||
Model = 'model', |
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 don't currently have model files, so just leave this out for now
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.
I was figuring that model would add the model to the prisma file, generate a query + mutation, and then run prisma migrate
. Just a shorthand for adding data to the db
without generating a UI for it
Sweet! All the input checks are great!! Over in the main issue I proposed Rails uses |
Here's what I think we should use for naming. Rails and redwood use
|
oops! |
@flybayer couple of thoughts re: your naming/architecture comments:
Agree that deviation is not ideal, although I do think the term As for
Totally agree here. I hadn't gotten up to supporting nested paths yet, was building this pretty incrementally. Should be pretty simple to make this happen. I'll build in some fallback support for what to do if a particular context path doesn't exist (e.g. find best match, provide option to create the context resources similar to |
Ok, great suggestion. Go with
We definitely shouldn't use model for also generating queries/mutations. Model should be for an actual model, i.e. database table and model validation/authn. I'm open to something better than crud for queries/mutations, but I think crud is very accurate here. Most people know what crud is. If not, they will learn quickly because it's a simple concept.
Sounds good! Just make sure you finish the core stuff first before polishing. Alpha release will be about 21 hours from now. |
It's 9p for me now, so during my day tomorrow I can finish up some stuff if you need. Just let me know where you're at when you are done for your day :) |
f59c6f7
to
4f3c27b
Compare
Just curious why the template id directory is
|
ac4ea88
to
f7c32cc
Compare
@flybayer yeoman has a bug where it doesn't handle |
Outstanding known issues that we'll want to fix (I can open issues for these):
All things considered, the generator is pretty robust right now. It's not incredibly smart as far as how it generates things, but definitely smart enough to give people something to play with this weekend. I'd be comfortable merging as is. |
Reorder the options like below (so help command prints in this order)
Running outside a project logs error but then continues instead of quitting:
Change
|
High priority
|
056688a
to
0647e12
Compare
@aem I disabled |
Pull Request Type
Checklist
packages/server/src/log.ts
(or N/A)command.ts
so all commands have accessWhat's the reason for the change? ❓
Closes blitz-js/legacy-framework#862, closes blitz-js/legacy-framework#845
What are the changes and their implications? ⚙️
Introduces
blitz generate
. Here's the docs forblitz generate --help
, which should be fairly self-explanatory as far as the implications of this PR:The one thing left up for debate is the terminology of
resource
. In my mind I've been thinking aboutresource
to mean a full set of files (model + mutation + page + query), but I can see how that can be confusing. For example, in the Java/REST world "resource" usually means a single REST endpoint or a small collection of related endpoints.Having said that, I do think if our goal is to truly create a full app ecosystem, I think we can reasonably take some creative license here to define our own DSL. As long as our docs are clear and have good guides for these words (e.g. a glossary that defines what we mean when we say "resource") I think it's totally reasonable to redefine these words to have special meaning in the context of Blitz.
Does this introduce a breaking change?⚠️
Other information
The
generate
command functions as a wizard and attempts to prevent you from hitting pitfalls as much as possible. You'll notice >100 lines of validation code in the command, the idea is to provide guardrails as much as possible to prevent users from doing anything bad, and either correcting for them or giving them a prompt to correct the error themselves rather than either (a) making assumptions that could be destructive, or (b) just failing hard.