v8-archive
v8-archive copied to clipboard
Build a new CLI console
This PR is the work initiated by the issue #1613. It is the first step for the creation of a complete and easily maintainable CLI tool for the directus api project.
Before merging, we need to fix few things :
-
Were can I get the application name, description and version. It shouldn't be hardcoded.
-
Should we make only one entry point for the CLI ? We could either build a fresh new CLI with a second entry point (
directus-next
or else), or mix the 2 CLI.
If we need to mix both CLI Console, I suggest to first run the old commands, and if the command isn't found, run the new one and let it handle the usage display (this just came out of my mind without more thinking).
A deprecated notice will also be required I think.
Another idea would be to make only alias commands with the old syntax that trigger the new command.
@directus/team
A small overview of the new CLI
jo@jofix: symfony_cli_commands ↓4↑1 ✚1…1 ~/git/directus/api $ ./bin/directus-next
directus-next v8.3.1
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--base-path[=BASE-PATH] Path to directus base directory [default: "/home/jo/git/directus/api"]
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
cache
cache:clear Clear all objects from cache
config
config:create Create a new configuration file
db
db:upgrade Upgrade the database schema
maintenance
maintenance:off Disable maintenance mode
maintenance:on Enable maintenance mode
maintenance:status Get maintenance mode status
user
user:create Create a new user
user:delete Delete an existing user
user:password Change an existing user password
Looking good so far. Are you doing only the base or you'll try to build the commands too?
@WoLfulus I don't know, should I ? The commands are in a separate branch but I could make a single big pull request.
I asked just to know if there's more coming or if this PR was intended to be a boilerplate for a new CLI.
Lets keep everything CI related in one PR, so we can merge / release it at once. We can move it into a new branch on this repo and go from there, or keep pushing to this PR. Doesn't change much
Ok I'll push the rest of my work in this PR.
It's still a WIP since I didn't write all the commands. But some commands needs a bit more attention, I hopped I could move any of the old command logic to dedicated files so it can be reused somewhere else.
@jooola that would be ideal, but a pretty big undertaking in the current codebase. I think we should focus on getting the IO of the CLI optimized now, and restructure where the code is located when we're moving to Laravel as a whole too
@jooola @bjgajjar and I will be reviewing / helping out with the CLI today 🙂
Are there any specific things you have on your to-do list for the CLI?
directus-next 8.3.1
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--base-path[=BASE-PATH] Path to directus base directory [default: "/home/jo/git/directus/api"]
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
cache
cache:clear Clear all objects from cache
config
config:create Create a new configuration file
db
db:install Populate the database
db:upgrade Upgrade the database schema
maintenance
maintenance:off Disable maintenance mode
maintenance:on Enable maintenance mode
maintenance:status Get maintenance mode status
user
user:create Create a new user
user:delete Delete an existing user
user:password Change an existing user password
@rijkvanzanten @bjgajjar feel free to push on this branch.
@jooola - Thanks for the quick fix.
But it seems like I'm missing something. Can you please help me to figure out the below error?
It occurs in PHP 7.3.8
and I installed all the composer dependencies.
@bjgajjar It might be a Symfony Console version mismatch. We upgraded phinx to match the latest version of this Component, you might still use the old one.
Have you tried with a fresh vendor folder ? If that doesn't work I'll need more infos.
Yes - I tried with a fresh vendor folder too [ Removing the vendor
as well as composer.lock
]
Still getting the same error.
I'll need more information, let's not hijack this thread, we can continue debugging this on Slack or another ticket.
I started to implement some of the commands, the easy ones. I might have overlooked some things, I tried only to keep the code clean and I trust the InstallerUtils/Service to do the required checks.
This feels like a huge change now and I wonder how you folks feel about this PR ?