@hesed/mysql 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +289 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/dev.js +5 -0
  5. package/bin/run.cmd +3 -0
  6. package/bin/run.js +5 -0
  7. package/dist/commands/mysql/auth/add.d.ts +18 -0
  8. package/dist/commands/mysql/auth/add.js +57 -0
  9. package/dist/commands/mysql/auth/test.d.ts +12 -0
  10. package/dist/commands/mysql/auth/test.js +41 -0
  11. package/dist/commands/mysql/auth/update.d.ts +18 -0
  12. package/dist/commands/mysql/auth/update.js +74 -0
  13. package/dist/commands/mysql/describe-table.d.ts +11 -0
  14. package/dist/commands/mysql/describe-table.js +37 -0
  15. package/dist/commands/mysql/explain-query.d.ts +13 -0
  16. package/dist/commands/mysql/explain-query.js +39 -0
  17. package/dist/commands/mysql/list-databases.d.ts +9 -0
  18. package/dist/commands/mysql/list-databases.js +31 -0
  19. package/dist/commands/mysql/list-tables.d.ts +9 -0
  20. package/dist/commands/mysql/list-tables.js +31 -0
  21. package/dist/commands/mysql/query.d.ts +14 -0
  22. package/dist/commands/mysql/query.js +47 -0
  23. package/dist/commands/mysql/show-indexes.d.ts +11 -0
  24. package/dist/commands/mysql/show-indexes.js +37 -0
  25. package/dist/config.d.ts +13 -0
  26. package/dist/config.js +18 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +1 -0
  29. package/dist/mysql/config-loader.d.ts +32 -0
  30. package/dist/mysql/config-loader.js +27 -0
  31. package/dist/mysql/database.d.ts +85 -0
  32. package/dist/mysql/database.js +5 -0
  33. package/dist/mysql/index.d.ts +3 -0
  34. package/dist/mysql/index.js +1 -0
  35. package/dist/mysql/mysql-client.d.ts +60 -0
  36. package/dist/mysql/mysql-client.js +131 -0
  37. package/dist/mysql/mysql-utils.d.ts +68 -0
  38. package/dist/mysql/mysql-utils.js +370 -0
  39. package/dist/mysql/query-validator.d.ts +38 -0
  40. package/dist/mysql/query-validator.js +103 -0
  41. package/oclif.manifest.json +527 -0
  42. package/package.json +102 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Hesed
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,289 @@
1
+ # mysql
2
+
3
+ CLI for MySQL database interaction
4
+
5
+ [![Version](https://img.shields.io/npm/v/@hesed/mysql.svg)](https://npmjs.org/package/@hesed/mysql)
6
+ [![Downloads/week](https://img.shields.io/npm/dw/@hesed/mysql.svg)](https://npmjs.org/package/@hesed/mysql)
7
+
8
+ # Install
9
+
10
+ ```bash
11
+ sdkck plugins install @hesed/mysql
12
+ ```
13
+
14
+ <!-- toc -->
15
+ * [mysql](#mysql)
16
+ * [Install](#install)
17
+ * [Usage](#usage)
18
+ * [Commands](#commands)
19
+ <!-- tocstop -->
20
+
21
+ # Usage
22
+
23
+ <!-- usage -->
24
+ ```sh-session
25
+ $ npm install -g @hesed/mysql
26
+ $ mq COMMAND
27
+ running command...
28
+ $ mq (--version)
29
+ @hesed/mysql/0.1.0 darwin-arm64 node-v22.14.0
30
+ $ mq --help [COMMAND]
31
+ USAGE
32
+ $ mq COMMAND
33
+ ...
34
+ ```
35
+ <!-- usagestop -->
36
+
37
+ # Commands
38
+
39
+ <!-- commands -->
40
+ * [`mq mysql auth add`](#mq-mysql-auth-add)
41
+ * [`mq mysql auth test`](#mq-mysql-auth-test)
42
+ * [`mq mysql auth update`](#mq-mysql-auth-update)
43
+ * [`mq mysql describe-table`](#mq-mysql-describe-table)
44
+ * [`mq mysql explain-query QUERY`](#mq-mysql-explain-query-query)
45
+ * [`mq mysql list-databases`](#mq-mysql-list-databases)
46
+ * [`mq mysql list-tables`](#mq-mysql-list-tables)
47
+ * [`mq mysql query QUERY`](#mq-mysql-query-query)
48
+ * [`mq mysql show-indexes`](#mq-mysql-show-indexes)
49
+
50
+ ## `mq mysql auth add`
51
+
52
+ Add a MySQL connection profile
53
+
54
+ ```
55
+ USAGE
56
+ $ mq mysql auth add [--json] [-d <value>] [--host <value>] [-p <value>] [-P <value>] [--profile <value>] [--ssl]
57
+ [-u <value>]
58
+
59
+ FLAGS
60
+ -P, --port=<value> MySQL port
61
+ -d, --database=<value> Database name
62
+ -p, --password=<value> Password
63
+ -u, --user=<value> Username
64
+ --host=<value> MySQL host
65
+ --profile=<value> Profile name
66
+ --[no-]ssl Use SSL
67
+
68
+ GLOBAL FLAGS
69
+ --json Format output as json.
70
+
71
+ DESCRIPTION
72
+ Add a MySQL connection profile
73
+
74
+ EXAMPLES
75
+ $ mq mysql auth add
76
+
77
+ $ mq mysql auth add --no-ssl
78
+ ```
79
+
80
+ _See code: [src/commands/mysql/auth/add.ts](https://github.com/hesedcasa/mysql/blob/v0.1.0/src/commands/mysql/auth/add.ts)_
81
+
82
+ ## `mq mysql auth test`
83
+
84
+ Test MySQL database connection
85
+
86
+ ```
87
+ USAGE
88
+ $ mq mysql auth test [--json] [--profile <value>]
89
+
90
+ FLAGS
91
+ --profile=<value> Profile name to test
92
+
93
+ GLOBAL FLAGS
94
+ --json Format output as json.
95
+
96
+ DESCRIPTION
97
+ Test MySQL database connection
98
+
99
+ EXAMPLES
100
+ $ mq mysql auth test
101
+
102
+ $ mq mysql auth test --profile staging
103
+ ```
104
+
105
+ _See code: [src/commands/mysql/auth/test.ts](https://github.com/hesedcasa/mysql/blob/v0.1.0/src/commands/mysql/auth/test.ts)_
106
+
107
+ ## `mq mysql auth update`
108
+
109
+ Update an existing MySQL connection profile
110
+
111
+ ```
112
+ USAGE
113
+ $ mq mysql auth update [--json] [-d <value>] [--host <value>] [-p <value>] [-P <value>] [--profile <value>] [--ssl]
114
+ [-u <value>]
115
+
116
+ FLAGS
117
+ -P, --port=<value> MySQL port
118
+ -d, --database=<value> Database name
119
+ -p, --password=<value> Password
120
+ -u, --user=<value> Username
121
+ --host=<value> MySQL host
122
+ --profile=<value> Profile name to update
123
+ --[no-]ssl Use SSL
124
+
125
+ GLOBAL FLAGS
126
+ --json Format output as json.
127
+
128
+ DESCRIPTION
129
+ Update an existing MySQL connection profile
130
+
131
+ EXAMPLES
132
+ $ mq mysql auth update --ssl
133
+
134
+ $ mq mysql auth update --profile staging
135
+ ```
136
+
137
+ _See code: [src/commands/mysql/auth/update.ts](https://github.com/hesedcasa/mysql/blob/v0.1.0/src/commands/mysql/auth/update.ts)_
138
+
139
+ ## `mq mysql describe-table`
140
+
141
+ Describe the structure of a MySQL table
142
+
143
+ ```
144
+ USAGE
145
+ $ mq mysql describe-table -t <value> [--format table|json|toon] [--profile <value>]
146
+
147
+ FLAGS
148
+ -t, --table=<value> (required) Table name to describe
149
+ --format=<option> [default: table] Output format
150
+ <options: table|json|toon>
151
+ --profile=<value> Database profile name from config
152
+
153
+ DESCRIPTION
154
+ Describe the structure of a MySQL table
155
+
156
+ EXAMPLES
157
+ $ mq mysql describe-table --table users
158
+
159
+ $ mq mysql describe-table --table orders --format json --profile prod
160
+ ```
161
+
162
+ _See code: [src/commands/mysql/describe-table.ts](https://github.com/hesedcasa/mysql/blob/v0.1.0/src/commands/mysql/describe-table.ts)_
163
+
164
+ ## `mq mysql explain-query QUERY`
165
+
166
+ Show the execution plan for a MySQL query
167
+
168
+ ```
169
+ USAGE
170
+ $ mq mysql explain-query QUERY [--format table|json|toon] [--profile <value>]
171
+
172
+ ARGUMENTS
173
+ QUERY SQL query to explain
174
+
175
+ FLAGS
176
+ --format=<option> [default: table] Output format
177
+ <options: table|json|toon>
178
+ --profile=<value> Database profile name from config
179
+
180
+ DESCRIPTION
181
+ Show the execution plan for a MySQL query
182
+
183
+ EXAMPLES
184
+ $ mq mysql explain-query "SELECT * FROM users WHERE id = 1"
185
+
186
+ $ mq mysql explain-query "SELECT * FROM orders JOIN users ON orders.user_id = users.id" --format json
187
+ ```
188
+
189
+ _See code: [src/commands/mysql/explain-query.ts](https://github.com/hesedcasa/mysql/blob/v0.1.0/src/commands/mysql/explain-query.ts)_
190
+
191
+ ## `mq mysql list-databases`
192
+
193
+ List all databases accessible on the MySQL server
194
+
195
+ ```
196
+ USAGE
197
+ $ mq mysql list-databases [--profile <value>]
198
+
199
+ FLAGS
200
+ --profile=<value> Database profile name from config
201
+
202
+ DESCRIPTION
203
+ List all databases accessible on the MySQL server
204
+
205
+ EXAMPLES
206
+ $ mq mysql list-databases
207
+
208
+ $ mq mysql list-databases --profile staging
209
+ ```
210
+
211
+ _See code: [src/commands/mysql/list-databases.ts](https://github.com/hesedcasa/mysql/blob/v0.1.0/src/commands/mysql/list-databases.ts)_
212
+
213
+ ## `mq mysql list-tables`
214
+
215
+ List all tables in the current MySQL database
216
+
217
+ ```
218
+ USAGE
219
+ $ mq mysql list-tables [--profile <value>]
220
+
221
+ FLAGS
222
+ --profile=<value> Database profile name from config
223
+
224
+ DESCRIPTION
225
+ List all tables in the current MySQL database
226
+
227
+ EXAMPLES
228
+ $ mq mysql list-tables
229
+
230
+ $ mq mysql list-tables --profile local
231
+ ```
232
+
233
+ _See code: [src/commands/mysql/list-tables.ts](https://github.com/hesedcasa/mysql/blob/v0.1.0/src/commands/mysql/list-tables.ts)_
234
+
235
+ ## `mq mysql query QUERY`
236
+
237
+ Execute a SQL query against a MySQL database
238
+
239
+ ```
240
+ USAGE
241
+ $ mq mysql query QUERY [--format table|json|csv|toon] [--profile <value>] [--skip-confirmation]
242
+
243
+ ARGUMENTS
244
+ QUERY SQL query to execute
245
+
246
+ FLAGS
247
+ --format=<option> [default: table] Output format
248
+ <options: table|json|csv|toon>
249
+ --profile=<value> Database profile name from config
250
+ --skip-confirmation Skip confirmation prompt for destructive operations
251
+
252
+ DESCRIPTION
253
+ Execute a SQL query against a MySQL database
254
+
255
+ EXAMPLES
256
+ $ mq mysql query "SELECT * FROM users LIMIT 10"
257
+
258
+ $ mq mysql query "UPDATE users SET email = 'user@email.com' WHERE id = 999" --format json
259
+
260
+ $ mq mysql query "DELETE FROM sessions" --profile prod --skip-confirmation
261
+ ```
262
+
263
+ _See code: [src/commands/mysql/query.ts](https://github.com/hesedcasa/mysql/blob/v0.1.0/src/commands/mysql/query.ts)_
264
+
265
+ ## `mq mysql show-indexes`
266
+
267
+ Show indexes for a MySQL table
268
+
269
+ ```
270
+ USAGE
271
+ $ mq mysql show-indexes -t <value> [--format table|json|toon] [--profile <value>]
272
+
273
+ FLAGS
274
+ -t, --table=<value> (required) Table name to show indexes for
275
+ --format=<option> [default: table] Output format
276
+ <options: table|json|toon>
277
+ --profile=<value> Database profile name from config
278
+
279
+ DESCRIPTION
280
+ Show indexes for a MySQL table
281
+
282
+ EXAMPLES
283
+ $ mq mysql show-indexes --table users
284
+
285
+ $ mq mysql show-indexes --table orders --format json --profile prod
286
+ ```
287
+
288
+ _See code: [src/commands/mysql/show-indexes.ts](https://github.com/hesedcasa/mysql/blob/v0.1.0/src/commands/mysql/show-indexes.ts)_
289
+ <!-- commandsstop -->
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({development: true, dir: import.meta.url})
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({dir: import.meta.url})
@@ -0,0 +1,18 @@
1
+ import { Command } from '@oclif/core';
2
+ import type { ConnectionTestResult } from '../../../mysql/index.js';
3
+ export default class AuthAdd extends Command {
4
+ static args: {};
5
+ static description: string;
6
+ static enableJsonFlag: boolean;
7
+ static examples: string[];
8
+ static flags: {
9
+ database: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ host: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ ssl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ };
17
+ run(): Promise<ConnectionTestResult>;
18
+ }
@@ -0,0 +1,57 @@
1
+ import { input } from '@inquirer/prompts';
2
+ import { Command, Flags } from '@oclif/core';
3
+ import { action } from '@oclif/core/ux';
4
+ import { default as fs } from 'fs-extra';
5
+ import { default as path } from 'node:path';
6
+ import { testDirectConnection } from '../../../mysql/index.js';
7
+ export default class AuthAdd extends Command {
8
+ static args = {};
9
+ static description = 'Add a MySQL connection profile';
10
+ static enableJsonFlag = true;
11
+ static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --no-ssl'];
12
+ static flags = {
13
+ database: Flags.string({ char: 'd', description: 'Database name', required: !process.stdout.isTTY }),
14
+ host: Flags.string({ description: 'MySQL host', required: !process.stdout.isTTY }),
15
+ password: Flags.string({ char: 'p', description: 'Password', required: !process.stdout.isTTY }),
16
+ port: Flags.integer({ char: 'P', description: 'MySQL port', required: !process.stdout.isTTY }),
17
+ profile: Flags.string({ description: 'Profile name', required: !process.stdout.isTTY }),
18
+ ssl: Flags.boolean({ allowNo: true, default: false, description: 'Use SSL', required: false }),
19
+ user: Flags.string({ char: 'u', description: 'Username', required: !process.stdout.isTTY }),
20
+ };
21
+ async run() {
22
+ const { flags } = await this.parse(AuthAdd);
23
+ const profileName = flags.profile ?? (await input({ message: 'Profile name:', required: true }));
24
+ const host = flags.host ?? (await input({ message: 'MySQL host:', required: true }));
25
+ const port = flags.port ?? Number(await input({ default: '3306', message: 'Port:', required: true }));
26
+ const user = flags.user ?? (await input({ message: 'Username:', required: true }));
27
+ const password = flags.password ?? (await input({ message: 'Password:', required: true }));
28
+ const database = flags.database ?? (await input({ message: 'Database:', required: true }));
29
+ const configPath = path.join(this.config.configDir, 'mysql-config.json');
30
+ const profileData = { database, host, password, port, ssl: flags.ssl, user };
31
+ const exists = await fs.pathExists(configPath);
32
+ let config;
33
+ if (exists) {
34
+ config = await fs.readJSON(configPath);
35
+ }
36
+ else {
37
+ await fs.createFile(configPath);
38
+ config = { defaultProfile: profileName, profiles: {} };
39
+ }
40
+ config.profiles[profileName] = profileData;
41
+ if (Object.keys(config.profiles).length === 1) {
42
+ config.defaultProfile = profileName;
43
+ }
44
+ await fs.writeJSON(configPath, config, { mode: 0o600 });
45
+ action.start('Testing connection');
46
+ const result = await testDirectConnection(profileData);
47
+ if (result.success) {
48
+ action.stop('✓ successful');
49
+ this.log(`Profile "${profileName}" added successfully`);
50
+ }
51
+ else {
52
+ action.stop('✗ failed');
53
+ this.error('Connection failed. Please check your configuration.');
54
+ }
55
+ return result;
56
+ }
57
+ }
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ import type { ConnectionTestResult } from '../../../mysql/index.js';
3
+ export default class AuthTest extends Command {
4
+ static args: {};
5
+ static description: string;
6
+ static enableJsonFlag: boolean;
7
+ static examples: string[];
8
+ static flags: {
9
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ run(): Promise<ConnectionTestResult>;
12
+ }
@@ -0,0 +1,41 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import { action } from '@oclif/core/ux';
3
+ import { readConfig } from '../../../config.js';
4
+ import { testDirectConnection } from '../../../mysql/index.js';
5
+ export default class AuthTest extends Command {
6
+ static args = {};
7
+ static description = 'Test MySQL database connection';
8
+ static enableJsonFlag = true;
9
+ static examples = [
10
+ '<%= config.bin %> <%= command.id %>',
11
+ '<%= config.bin %> <%= command.id %> --profile staging',
12
+ ];
13
+ static flags = {
14
+ profile: Flags.string({ description: 'Profile name to test', required: false }),
15
+ };
16
+ async run() {
17
+ const { flags } = await this.parse(AuthTest);
18
+ const config = await readConfig(this.config.configDir, this.log.bind(this));
19
+ if (!config) {
20
+ return {
21
+ error: 'Missing connection config',
22
+ success: false,
23
+ };
24
+ }
25
+ const profile = config.profiles[flags.profile ?? config.defaultProfile];
26
+ if (!profile) {
27
+ this.error(`Profile "${flags.profile}" not found. Available: ${Object.keys(config.profiles).join(', ')}`);
28
+ }
29
+ action.start('Testing connection');
30
+ const result = await testDirectConnection(profile);
31
+ if (result.success) {
32
+ action.stop('✓ successful');
33
+ this.log('Successfully connected to MySQL');
34
+ }
35
+ else {
36
+ action.stop('✗ failed');
37
+ this.error('Failed to connect to MySQL.');
38
+ }
39
+ return result;
40
+ }
41
+ }
@@ -0,0 +1,18 @@
1
+ import { Command } from '@oclif/core';
2
+ import type { ConnectionTestResult } from '../../../mysql/index.js';
3
+ export default class AuthUpdate extends Command {
4
+ static args: {};
5
+ static description: string;
6
+ static enableJsonFlag: boolean;
7
+ static examples: string[];
8
+ static flags: {
9
+ database: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ host: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ ssl: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ };
17
+ run(): Promise<ConnectionTestResult | void>;
18
+ }