From 8c8e8290c0b28e09487a211386d4908572222335 Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Wed, 1 Nov 2023 09:32:19 +0600 Subject: [PATCH] Add `db` command And move `phpmyadmin` as a subcommand of the db command --- package.json | 2 ++ ...vip-phpmyadmin.ts => vip-db-phpmyadmin.ts} | 6 +++--- src/bin/vip-db.ts | 21 +++++++++++++++++++ src/bin/vip.js | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) rename src/bin/{vip-phpmyadmin.ts => vip-db-phpmyadmin.ts} (85%) create mode 100755 src/bin/vip-db.ts diff --git a/package.json b/package.json index 17b50b84fb..cb2e531706 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,8 @@ "vip-config-software": "dist/bin/vip-config-software.js", "vip-config-software-get": "dist/bin/vip-config-software-get.js", "vip-config-software-update": "dist/bin/vip-config-software-update.js", + "vip-db": "dist/bin/vip-db.js", + "vip-db-phpmyadmin": "dist/bin/vip-db-phpmyadmin.js", "vip-dev-env": "dist/bin/vip-dev-env.js", "vip-dev-env-create": "dist/bin/vip-dev-env-create.js", "vip-dev-env-update": "dist/bin/vip-dev-env-update.js", diff --git a/src/bin/vip-phpmyadmin.ts b/src/bin/vip-db-phpmyadmin.ts similarity index 85% rename from src/bin/vip-phpmyadmin.ts rename to src/bin/vip-db-phpmyadmin.ts index e30103203a..60b640e841 100755 --- a/src/bin/vip-phpmyadmin.ts +++ b/src/bin/vip-db-phpmyadmin.ts @@ -15,8 +15,8 @@ import { PhpMyAdminCommand } from '../commands/phpmyadmin'; const examples = [ { - usage: 'vip phpmyadmin @mysite.develop', - description: 'Open PhpMyAdmin for the @mysite.develop environment', + usage: 'vip db phpmyadmin @mysite.develop', + description: 'Open PhpMyAdmin console for the database of the @mysite.develop environment', }, ]; @@ -41,7 +41,7 @@ void command( { envContext: true, module: 'phpmyadmin', requiredArgs: 0, - usage: 'vip phpmyadmin', + usage: 'vip db phpmyadmin', } ) .examples( examples ) .argv( process.argv, async ( arg: string[], { app, env }: { app: App; env: AppEnvironment } ) => { diff --git a/src/bin/vip-db.ts b/src/bin/vip-db.ts new file mode 100755 index 0000000000..8bf650f687 --- /dev/null +++ b/src/bin/vip-db.ts @@ -0,0 +1,21 @@ +#!/usr/bin/env node + +/** + * External dependencies + */ + +/** + * Internal dependencies + */ +import command from '../lib/cli/command'; +import { trackEvent } from '../lib/tracker'; + +void command( { usage: 'vip db' } ) + .command( 'phpmyadmin', 'Open PhpMyAdmin console for your application database' ) + .example( + 'vip db phpmyadmin @mysite.develop', + 'Open PhpMyAdmin console for your database of the @mysite.develop environment' + ) + .argv( process.argv, async () => { + await trackEvent( 'vip_db_command_execute' ); + } ); diff --git a/src/bin/vip.js b/src/bin/vip.js index 5068f7c941..dcb8537cbf 100755 --- a/src/bin/vip.js +++ b/src/bin/vip.js @@ -42,7 +42,7 @@ const runCmd = async function () { .command( 'logs', 'Get logs from your VIP applications' ) .command( 'search-replace', 'Perform search and replace tasks on files' ) .command( 'slowlogs', 'Get slowlogs from your VIP applications' ) - .command( 'phpmyadmin', 'Open PHPMyAdmin console for your VIP application database' ) + .command( 'db', 'Run operations on your VIP application database' ) .command( 'sync', 'Sync production to a development environment' ) .command( 'whoami', 'Display details about the currently logged-in user' ) .command( 'validate', 'Validate your VIP application and environment' )