-
Notifications
You must be signed in to change notification settings - Fork 8
Feature/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: 608d305 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 :) |
| { | ||
| kind: nameInfo.kind, | ||
| singularName: nameInfo.singularName, | ||
| id: nameInfo.displayName, |
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.
| id: nameInfo.displayName, | |
| id: nameInfo.singularName, |
| const attributes = await getAttributesPrompts(inquirer); | ||
| const bootstrapInfo = await inquirer.prompt([...bootstrapApiPrompts] as any); | ||
|
|
||
| generate( |
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 think we need to await these
| .description('Generate some boilerplate code for a Strapi plugin') | ||
| .option('-d, --debug', 'Enable debugging mode with verbose logs', false) | ||
| .option('--silent', "Don't log anything", false) | ||
| .action(async () => { |
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.
Not necessarily required, but could you make use of runAction here like the other commands, to help follow the error handling and awaiting that other commands use?
Warning
This PR is still in draft. Changes to the
@strapi/generatorspackage are needed for this to work correctly. This PR on the strapi/strapi repo addresses these changesWhat 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