expressjs / discussions

Public discussions for the Express.js organization
62 stars 14 forks source link

Express CLI #197

Open waleedtariq109 opened 6 months ago

waleedtariq109 commented 6 months ago

First of all, a huge appreciation to the Express team for coming together and reviving Express.

My suggestion is: Express should release its CLI, which scaffolds the project boilerplate. While Express itself is a framework, the current setup process requires starting from scratch, leading to a less-than-ideal experience. Let's discuss the need for a cleaner, more robust, and modern version of the Express CLI, going beyond the capabilities of express-generator.

wesleytodd commented 6 months ago

Hey! I agree. We have the generator package but it is quite old and doesn't follow the create-* pattern which the package managers support either. I think it would be awesome change the name of that, but that likely might mean a full rewrite. Maybe the next best steps here are to list the requirements?

waleedtariq109 commented 6 months ago

@wesleytodd I completely agree, and I would also like to join the Express team in creating and maintaining the brand-new CLI package. In the meantime, I am preparing some initial requirements and would like to share them with you here when it's done.

jonchurch commented 6 months ago

I previously was excited about the idea of having the cli generator, but see the value less now. Id be interested to see your ideas about what it should do.

Express is so lean that Im not certain what we would need to scaffold for folks. Previously the generator focused on scaffolding a server side rendered static html site using view engines. That's not as relevant today.

Call it a lack of imagination on my part, but before you begin work @waleedtariq109 can you give an idea of what your vision is for a cli package?

UlisesGascon commented 6 months ago

Express is so lean that Im not certain what we would need to scaffold for folks. Previously the generator focused on scaffolding a server side rendered static html site using view engines. That's not as relevant today.

AFAIK, with the current roadmap, I share this vision too. But here's a random idea from my side: what if we just offer a CLI that lists all the projects in the current example folder and allows you to choose one of them to start a project? This way, you actually have tons of options out of the box. Maybe I'm going too far; it's just an idea.

waleedtariq109 commented 6 months ago

@jonchurch I've been preparing the initial proposal, and when it's ready, I'd be happy to share it here as it also reflects my vision for the CLI.

wesleytodd commented 6 months ago

Even if we get the most simple setup, I think the value of a generator for new users cannot be over stated. It is much different to say "create a file and copy this" vs npm init express.

waleedtariq109 commented 6 months ago

@wesleytodd @jonchurch Just to provide a brief overview of my thoughts: Instead of installing Express using npm i express, it's recommended to use the Express CLI for scaffolding the project. The official way to do this is by executing the command npx express init my-app. This command will initialize an Express app. Additionally, it will prompt you with a few questions before initializing the app, such as whether you want to set up a Git repository and which package manager you prefer to use, among other things etc.

This has to be the Offical way of express

ctcpip commented 6 months ago

follow the create-* pattern which the package managers support

what is this referring to?

wesleytodd commented 6 months ago

The official way to do this is by executing the command npx express init my-app

I would prefer we document both that and npm init express

wesleytodd commented 6 months ago

what is this referring to?

package managers have a feature to download and execute packages with the naming pattern create-. For example:

$ npm init express

Will find the package create-express or @express/create and will run the properly named bin script just like npx would.

The most famous example of this is create-react-app.

wesleytodd commented 6 months ago

such as whether you want to set up a Git repository and which package manager you prefer to use, among other things etc.

And then for this part, I think we should use the pattern I have been working out here: https://github.com/pkgjs/create-pkg/issues/7

jonchurch commented 6 months ago

@ctcpip see the npm init docs: https://docs.npmjs.com/cli/v8/commands/npm-init

waleedtariq109 commented 6 months ago

such as whether you want to set up a Git repository and which package manager you prefer to use, among other things etc.

And then for this part, I think we should use the pattern I have been working out here: pkgjs/create-pkg#7

Exactly, I also think the same way. We should use this pattern to provide a better DX, and I am also willing and passionate to contribute as a member. 😊

waleedtariq109 commented 6 months ago

@wesleytodd I think we have to start working on gathering the requirements, or is it too early?

wesleytodd commented 6 months ago

Not too early at all! I think my personal focus is on the pressing work around v5, security, governance, and LTS strategy but that doesn't block anything. Just might mean I personally cannot help much yet. I think updating this issue to be that requirements and plan would be good. Or if this conversation is already too long you could do it as a new issue.

jonchurch commented 6 months ago

I think gathering requirements is the stage we are in right now. The idea of having express itself expose a bin so we can do npx express <something> is interesting to me, but is a big departure from how things are now.

For context, express-generator gets less than 9k downloads weekly currently. Which is not zero, but effectively rounds to it when you consider express gets 29 million downloads per week. Meaning, I don't think the generator is holding back any users, or presenting them with issues we need to address with priority. It certainly doesn't seem to be harming adoption!

I'd love to see a proposal of what problems a CLI would solve (I think there are many it could tackle!), and the actual implementation of it being an npm init or npx express pattern is a detail which is tangential to those problems we'd want to solve.

wesleytodd commented 6 months ago

The idea of having express itself expose a bin so we can do npx express is interesting to me, but is a big departure from how things are now.

I personally am opposed to this at first glance. I will hold that weakly, but also I think the package we ship to prod servers should not include more than the requirements for runtime.

For context, express-generator gets less than 9k downloads weekly currently.

Yeah this is more of an indication of it's failure to be updated than it's usefulness in general imo.

jonchurch commented 6 months ago

It is indeed trending downward, peaked at around 800k/year back in 2018 ish if these numbers are accurate:

Screenshot 2024-02-28 at 1 34 18 PM
crandmck commented 6 months ago

For context, express-generator gets less than 9k downloads weekly currently. Which is not zero, but effectively rounds to it when you consider express gets 29 million downloads per week.

Obviously, Express itself is extremely popular--no one is going to argue with that, but aren't "downloads" of express/express here (i.e. from npm stats) counted every time anyone does an npm/npx update or install of any app with an Express dependency? OTOH, express-generator is a CLI build-time tool, so those are actual installations of the CLI (not run-time deps), which makes the two statistics not really comparable. I'm no npm expert, so perhaps I'm misunderstanding this?

Anyway, I don't think we should get too hung up on the numbers of downloads. I just want to second what @wesleytodd said:

Even if we get the most simple setup, I think the value of a generator for new users cannot be over stated. It is much different to say "create a file and copy this" vs npm init express.

I think having a easy tool for new users is very valuable, even if intermediate to advanced devs don't use it and it doesn't cover many use cases. As long as it covers some basic use cases and patterns, it has value IMO.

waleedtariq109 commented 6 months ago

@crandmck Yup, I totally agree with you. It is a valuable tool for new users. Of course, we don't have to cover every use case, but we should include all the basic operations like creating a route, using middleware with CLI, etc. Although it may sound like no one uses these commands except for npm express init but I think it's a great value addition.