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

manage project structure with CLI #58

Open
11 tasks
pi0 opened this issue Mar 25, 2022 · 4 comments
Open
11 tasks

manage project structure with CLI #58

pi0 opened this issue Mar 25, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@pi0
Copy link
Member

pi0 commented Mar 25, 2022

This is a superset of nuxt/nuxt.js#13552 and a requirement of devtools vision.

Nuxt heavily depends on filesystem structure to configure project. As a result, we introduce filesystem entities such as pages, components, composables and plugins.

However, it is not easy to manage such entities. Creating a page, see what components are scanned, what plugins are available, what pages are there and mapped to which routes, etc.

The idea is to expose entity namespaces from nuxi cli to manage these. Some examples:

nuxi pages add <name>
nuxi pages show
nuxi pages update /blog/* --meta title="Blog:"

nuxi plugins add <name>
nuxi plugins show
nuxi plugins disable <name>

nuxi composables show

Related: nuxi module * (https://github.com/nuxt/framework/discussions/569)

By exposing this functionality from CLI (and later an API service), they can be used both for CLI lovers and also nuxt devtools to easily manage entities without duplicating logic.

Roadmap:

  • Scaffold shortcuts for nuxi add <template> <name> as nuxi <template> add <name>
  • Implement show for each
  • Update utilities - penging unjs template (@pi0) (meanwhile ideas welcome)
  • Wait for devtools to share vision and next steps

Entities we can start with:

  • component
  • composable
  • layout
  • middleware
  • page
  • plugin
  • api
@pi0 pi0 added the enhancement New feature or request label Mar 25, 2022
@pi0 pi0 mentioned this issue Mar 25, 2022
19 tasks
@Atinux
Copy link
Member

Atinux commented Mar 25, 2022

One note for shortcuts: api and middleware won't take an s (nuxi middleware add auth).

I really like the idea, how and where would you see the implementation?

@pi0
Copy link
Member Author

pi0 commented Mar 25, 2022

One note for shortcuts: api and middleware won't take an s (nuxi middleware add auth).

indeed :) Update generic comment

how and where would you see the implementation?

Nothing is stopping to implement shortcuts for <entity> add and then <entity> show commands. We can have a new nuxi subcommand for each entity like nuxi/src/commands/pages.ts and a utility as nuxi/src/entity/pages.ts that holds implementation.

Next step, we need a proper utility from unjs, especially for modifications and properly test it before using it in cli. In the meantime, ideas more than welcome about what updates we could imagine. For me, could imagine adding static page meta and rename (apart from config modification. it is out of scope)

The rest needs a poc of devtools and CLI api service.

@Diizzayy
Copy link
Member

Diizzayy commented Mar 25, 2022

@pi0 @Atinux I'll begin working on the underlying implementation for entity shortcuts nuxi <entity> <add/show>

The unjs templating util will be an integral part of way forward ( ie: proper testing and extension ) so it'll be interesting to see how we can best construct a robust solution!

@mlcsthor
Copy link

Do you think it would be possible to add a custom template system? For example add this in the Nuxt config:

templates : {
  custom: {
    dir: <target dir>,
    file: <template file>  // or take a file with the same name in a new templates directory
  }
}

and then run nuxi add custom MyCustom

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

No branches or pull requests

4 participants