-
Notifications
You must be signed in to change notification settings - Fork 8
feat: generate cli #98
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 23cc74c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
96a1304 to
74841c6
Compare
|
Looks all good to me, @boazpoolman :) |
…gin into feature/generate-cli
|
|
It is always generating javascript even in a typescript plugin because the path is wrong for the way the language detection works in @strapi/generators I think it will need to have a smarter detection where instead of just calling generate() from whatever the cwd is, it should first attempt to cd to the root of the current plugin (essentially look for a strapi plugin package.json and if it doesn't find one If it detects that it's outside a plugin directory (like if the user tries to run it from their strapi project rather than the plugin dir) then it should probably just log an error that it has to be run from within a plugin dir. I'm pretty sure we have code for that somewhere in one of the other generation commands that you could look at as an example, but I can't remember where exactly. |


What does it do?
It adds a new command to the CLI to generate boilerplate code for your plugin.
This command will start an interactive CLI where the user can give some input that is used to generate the code. The DX is almost exactly the same as the native
strapi generateCLI. The only thing different is the fact that you don't have to select the destination.This PR basically implements an extension of the
@strapi/generatorspackage. Both the file generation and most of the prompts are import from that package and re-used by calling thegenerateAPI.Why is it needed?
The native
strapi generateCLI allows for generating boilerplate code for plugins, but that only works for local plugins in thesrc/pluginsdirectory. For standalone plugins there is no way to generate boilerplate code.How to test it?
pnpm installpnpm run build && npx yalc push --publishnpx @strapi/sdk-plugin initnpx yalc add @strapi/sdk-pluginnode_modules/.bin/strapi-plugin generate