Skip to content
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

Make the tool more interactive #740

Open
2 tasks done
jean-michelet opened this issue Jul 5, 2024 · 1 comment
Open
2 tasks done

Make the tool more interactive #740

jean-michelet opened this issue Jul 5, 2024 · 1 comment

Comments

@jean-michelet
Copy link
Contributor

jean-michelet commented Jul 5, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

After #737, I think we should make fastify-cli more interactive.

1) When running generate, we should perhaps ask users a few questions in a relevant order.

  • Use of typescript? Esm/Cjs?
  • do they want to set up an environment?
  • do they want to set up a database, a migration system?
  • do they want to use swagger? under pressure? or any other relevant question?
  • do they want to use authentication? what kind?

2. We could also create a command to create plugins for an existing project.

If the plugin is customized :

  • choose a name
  • does this plugin have any dependencies?

3. We could also enable core and community plugins to be installed with fastify-cli.

After installation, we could check whether a plugin has a specific configuration file following the convention of our choice, and use it to automatically generate the plugin file with some default configuration and comments in the project.

Motivation

The idea here is to make a more relevant and educative tool. I realize it would be a lot of work, but it could also improve the developer experience, I think, and that's something I'd love to do.

Example

1. generate command

When a user runs fastify generate, the CLI might interact with them to configure the project specifics:

$ fastify generate
Welcome to Fastify project generator!

? Use TypeScript? (Y/n) Y
? Module system (Use arrow keys)
> ESM
  CJS
? Set up an environment configuration? (Y/n) Y
? Set up a database with migration system? (Y/n) n
? Include Swagger for API documentation? (Y/n) Y
? Include authentication? (Y/n) Y
? What kind of authentication:
  > OAuth
    JWT
    Basic

Generating project with TypeScript, ESM, Swagger, and OAuth authentication...
Project generated successfully!

2. New command to add plugins to a project

When creating a new plugin within an existing project, the CLI can guide through setting it up:

$ fastify add-plugin
? Name of the plugin: awesome-logger
? Does this plugin have any dependencies? (Y/n) Y
? List dependencies (comma separated): pino

Creating plugin 'awesome-logger' with dependencies: pino
Plugin created successfully!

3. Installation of core and community plugins

The process to install plugins can also be streamlined with smart configuration:

$ fastify @fastify/cors
? Search and install plugin: '@fastify/cors'
Searching '@fastify/cors'...
? '@fastify/cors' requires specific configuration. Generate default config? (Y/n) Y
Installing '@fastify/cors'...

Plugin installed and configured successfully!
@climba03003
Copy link
Member

which is #491 and I give up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants