silverstripe / silverstripe-framework

Silverstripe Framework, the MVC framework that powers Silverstripe CMS
https://www.silverstripe.org
BSD 3-Clause "New" or "Revised" License
722 stars 821 forks source link

Refactor sake around Symfony console #11341

Open emteknetnz opened 1 month ago

emteknetnz commented 1 month ago

sake is basic though functional way to run cli commands

It's very non-standard, and it's likely that we could make the interface significantly better by changing it to use symfony/console instead. There may also be some downstream benefits of making it easier to project to extend/customise if they have a need to

Related

Acceptance criteria

CMS 5 PRs

CMS 6 PRs

kitchen sink run

GuySartorelli commented 2 weeks ago

I've gotten pretty far with this for everything included in installer. I'm nearly at the point where I can clean up and start writing tests (and then move onto the rest of kitchen sink).

One thing I'd like some opinions on is how the dev/ commands should be arranged.

Right now the PRs have these just swapping dev/ to dev:, i.e. you can run the commands like so: HTTP route CLI command CLI alias (for backwards compat)
dev/tasks/my-task dev:tasks:my-task dev/tasks/my-task
dev/config dev:config dev/config
dev/build dev:build dev/build

Example of the existing command setup

This however keeps all of the commands clumped together in an unhelpful way, and means you have to type dev: before every command, which is completely unnecessary in the CLI. The only reason they had that historically is because sake was just a CLI wrapper for the HTTP controllers, so the routes had to be identical. Now they don't.

I would like to change the commands to be more meaningful in CLI, while keeping their HTTP routes as they currently are. That would look more like this:

HTTP route CLI command CLI alias (for backwards compat)
dev/tasks/my-task tasks:my-task dev/tasks/my-task
dev/config config:dump dev/config
dev/build db:build dev/build

Example of the proposed command setup

This gives us a more sensible grouping for the CLI commands, allows for new commands to be more easily added to those groupings in a meaningful way, reduces unnecessary key-strokes, and I think just looks way tidier.

(I'm planning on hiding the tasks from this initial list (at least if there are more than some configurable number of them) and only showing them when you run sake tasks (or sake dev:tasks if this proposal isn't accepted) so don't get too caught up on how those are filling the output)

@silverstripe/core-team Does anyone have any thoughts on this?

wilr commented 2 weeks ago

@GuySartorelli 100% agree. Coming from a laravel view that makes a lot more sense than prefixing everything dev. 👍

emteknetnz commented 2 weeks ago

Looks good, happy to get rid of the dev prefix

kinglozzer commented 2 weeks ago

+1 for getting rid of the dev prefix

michalkleiner commented 2 weeks ago

All good to drop the dev: prefix.

emteknetnz commented 1 day ago

@GuySartorelli Will need to rebase the PRs that have phpunit/phpunit in require rather than require-dev. behat-extension is one of them, there may be others.

I'm unable to install of the PR's at the same time locally due to conflicts between phpunit 11 which was just merged and phpunit 9

GuySartorelli commented 1 day ago

Yup there's rebasing to be done, just needed that CMS 5 pr merged first 👍