X Tutup
The Wayback Machine - https://web.archive.org/web/20201029110147/https://github.com/directus/api/pull/1614
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

Build a new CLI console #1614

Open
wants to merge 20 commits into
base: master
from
Open

Build a new CLI console #1614

wants to merge 20 commits into from

Conversation

@jooola
Copy link

@jooola jooola commented Jan 3, 2020

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

@jooola
Copy link
Author

@jooola jooola commented Jan 4, 2020

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
@benhaynes benhaynes requested a review from directus/api Jan 4, 2020
@WoLfulus
Copy link
Member

@WoLfulus WoLfulus commented Jan 5, 2020

Looking good so far. Are you doing only the base or you'll try to build the commands too?

@jooola
Copy link
Author

@jooola jooola commented Jan 5, 2020

@WoLfulus I don't know, should I ? The commands are in a separate branch but I could make a single big pull request.

@WoLfulus
Copy link
Member

@WoLfulus WoLfulus commented Jan 6, 2020

I asked just to know if there's more coming or if this PR was intended to be a boilerplate for a new CLI.

@rijkvanzanten
Copy link
Member

@rijkvanzanten rijkvanzanten commented Jan 6, 2020

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

@jooola
Copy link
Author

@jooola jooola commented Jan 6, 2020

Ok I'll push the rest of my work in this PR.

@jooola jooola force-pushed the jooola:symfony_cli branch from 8436fc5 to ac57577 Jan 6, 2020
@jooola
Copy link
Author

@jooola jooola commented Jan 6, 2020

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.

@rijkvanzanten
Copy link
Member

@rijkvanzanten rijkvanzanten commented Jan 8, 2020

@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

@rijkvanzanten rijkvanzanten added this to In progress in v8.4.0 via automation Jan 8, 2020
@rijkvanzanten
Copy link
Member

@rijkvanzanten rijkvanzanten commented Jan 8, 2020

@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?

@jooola jooola force-pushed the jooola:symfony_cli branch from 035ecdd to 631ba58 Jan 8, 2020
@jooola
Copy link
Author

@jooola jooola commented Jan 8, 2020

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
@jooola
Copy link
Author

@jooola jooola commented Jan 8, 2020

@rijkvanzanten @bjgajjar feel free to push on this branch.

@bjgajjar
Copy link
Contributor

@bjgajjar bjgajjar commented Jan 8, 2020

@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?

image

It occurs in PHP 7.3.8 and I installed all the composer dependencies.

@jooola
Copy link
Author

@jooola jooola commented Jan 8, 2020

@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.

@bjgajjar
Copy link
Contributor

@bjgajjar bjgajjar commented Jan 8, 2020

Yes - I tried with a fresh vendor folder too [ Removing the vendor as well as composer.lock]

Still getting the same error.

@jooola
Copy link
Author

@jooola jooola commented Jan 8, 2020

I'll need more information, let's not hijack this thread, we can continue debugging this on Slack or another ticket.

@jooola jooola force-pushed the jooola:symfony_cli branch from 320cd3b to 0f96258 Feb 9, 2020
@jooola jooola force-pushed the jooola:symfony_cli branch from 0f96258 to 22f06bc Feb 9, 2020
@jooola jooola force-pushed the jooola:symfony_cli branch from 22f06bc to d7b3004 Feb 10, 2020
@jooola
Copy link
Author

@jooola jooola commented Feb 12, 2020

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 ?

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

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.
X Tutup