You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/ISSUE_TEMPLATE/bug-report.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,13 +16,13 @@ assignees: ''
16
16
--
17
17
Write a clear and concise description of what the bug is here.
18
18
19
-
**To Reproduce**
20
-
--
21
-
Write the steps to reproduce the behavior here:
22
-
1. ...
23
-
2. ...
24
-
3. ...
25
-
4. ...
19
+
**Command Line Invocation**
20
+
<!-- If you are able to replicate this bug by running mysql-memory-server from the CLI, please replace "Not Applicable" with the command you used to invoke the package -->
21
+
Not Applicable
22
+
23
+
**Reproducible Code Example**
24
+
<!-- If you are able to replicate this bug with application code that uses this package, please replace "Not Applicable" with the code that reproduces the bug -->
25
+
Not Applicable
26
26
27
27
**Expected behavior**
28
28
--
@@ -42,6 +42,7 @@ None
42
42
- OS and OS version (e.g macOS 15.0.1):
43
43
- JS runtime and runtime version (E.g Node.js 22.9.0):
44
44
- mysql-memory-server version:
45
+
- In which environment does this bug occur? (Application Code, CLI, or both):
Copy file name to clipboardExpand all lines: README.md
+29-11Lines changed: 29 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# MySQL Memory Server
2
2
3
-
This package allows you to create ephemeral MySQL databases from JavaScript and/or TypeScript code, great for testing. When creating a new database, if the version selected is not installed on the system, the binary is downloaded from MySQL's CDN (cdn.mysql.com)
3
+
This package allows you to create ephemeral MySQL databases from JavaScript and/or TypeScript code and also the CLI, great for testing, CI, and learning MySQL. When creating a new database, if the version selected is not installed on the system, the binary is downloaded from MySQL's CDN (cdn.mysql.com)
4
4
5
5
You can run multiple MySQL databases with this package at the same time. Each database will use a random free port. The databases will automatically shutdown when the JS runtime process exits. A `stop()` method is also provided to stop each database instance.
6
6
@@ -30,7 +30,7 @@ Requirements for Linux:
30
30
- If using the system installed MySQL server: 8.0.20 and newer
31
31
- If not using the system installed MySQL server: 8.0.39, 8.0.40, 8.1.0, 8.2.0, 8.3.0, 8.4.2, 8.4.3, 9.0.1, 9.1.0
32
32
33
-
## Usage
33
+
## Example Usage - Application Code
34
34
35
35
This package supports both ESM and CJS so you can use import or require.
36
36
@@ -45,7 +45,7 @@ const db = await createDB()
45
45
46
46
//Create a new database with custom options set
47
47
constdb=awaitcreateDB({
48
-
// see Options for the options you can use in this object and their default values
48
+
// see Options below for the options you can use in this object and their default values
49
49
// for example:
50
50
version:'8.4.x'
51
51
})
@@ -73,6 +73,14 @@ await db.stop()
73
73
MySQL database initialization can take some time. If you run into a "Timeout exceeded" error with your tests, the timeout should be extended.
74
74
If using Jest, information about how to do this can be found here: https://jestjs.io/docs/jest-object#jestsettimeouttimeout
75
75
76
+
## Example Usage - CLI
77
+
78
+
```sh
79
+
# Options are added by doing --{optionName} {optionValue}
80
+
# See Options below for the options you can use with this package
@@ -93,7 +101,7 @@ If on Windows, this is the name of the named pipe that the MySQL X Plugin is lis
93
101
-`stop: () => Promise<void>`
94
102
The method to stop the database. The returned promise resolves when the database has successfully stopped.
95
103
96
-
######Options:
104
+
#### Options:
97
105
-`version: string`
98
106
99
107
Required: No
@@ -213,28 +221,38 @@ The internal queries that are ran before the queries in ```initSQLString``` are
213
221
***
214
222
### :warning: Internal Options :warning:
215
223
216
-
The following options are only meant for internal debugging use. Their behaviour may change or they may get removed between major/minor/patch versions and they are not to be considered stable. The options below will not follow Semantic Versioning so it is advised to not use them.
224
+
The following options are only meant for internal use (such as CI or the internals for running this package via the CLI). Their behaviour may change or they may get removed between major/minor/patch versions and they are not to be considered stable. The options below will not follow Semantic Versioning so it is advised to not use them.
217
225
218
226
-`_DO_NOT_USE_deleteDBAfterStopped: boolean`
219
227
220
-
Required: No
221
-
222
228
Default: true
223
229
224
230
Description: Changes whether or not the database will be deleted after it has been stopped. If set to `true`, the database WILL be deleted after it has been stopped.
225
231
226
232
-`_DO_NOT_USE_dbPath: string`
227
233
228
-
Required: No
229
-
230
234
Default: `TMPDIR/mysqlmsn/dbs/UUID` (replacing TMPDIR with the OS temp directory and UUID with a UUIDv4 without seperating dashes).
231
235
232
236
Description: The folder to store database-related data in
233
237
234
238
-`_DO_NOT_USE_binaryDirectoryPath: string`
235
239
236
-
Required: No
237
-
238
240
Default: `TMPDIR/mysqlmsn/binaries` (replacing TMPDIR with the OS temp directory)
239
241
240
242
Description: The folder to store the MySQL binaries when they are downloaded from the CDN.
243
+
244
+
-`_DO_NOT_USE_beforeSignalCleanupMessage: string`
245
+
246
+
Required: No
247
+
248
+
Default: undefined
249
+
250
+
Description: The message to get displayed in the console before the cleanup that happens when the Node.js process is stopped without the ```stop()``` method being called first.
251
+
252
+
-`_DO_NOT_USE_afterSignalCleanupMessage: string`
253
+
254
+
Required: No
255
+
256
+
Default: undefined
257
+
258
+
Description: The message to get displayed in the console after the cleanup that happens when the Node.js process is stopped without the ```stop()``` method being called first.
//Try to convert the options to their correct types.
23
+
//We do not need to do any proper type validation here as the library will make sure everything is correct.
24
+
//Like for example, if a string is passed to a number option, it'll be converted to NaN here, but the library
25
+
//will throw an error for it not being an actual number.
26
+
if(optionType==='boolean'){
27
+
if(optionValue==='true'){
28
+
options[optionName]=true
29
+
}elseif(optionValue==='false'){
30
+
options[optionName]=false
31
+
}else{
32
+
options[optionName]=optionValue
33
+
}
34
+
}elseif(optionType==='number'){
35
+
options[optionName]=parseInt(optionValue)
36
+
}else{
37
+
options[opt.slice(2)]=optionValue
38
+
}
39
+
}
40
+
console.log('Creating ephemeral MySQL database...')
41
+
constdb=awaitcreateDB(options);
42
+
console.log(`A MySQL databases has been successfully created with the following parameters:\n\nUsername: ${db.username} \nDatabase Name: ${db.dbName} \nPort: ${db.port} \nX Plugin Port: ${db.xPort} \nSocket: ${db.socket} \nX Plugin Socket: ${db.xSocket}\n`)
43
+
console.log(`If you want to use the MySQL CLI client to connect to the database, you can use either commands: \nmysql -u ${db.username} -P ${db.port} --protocol tcp \nOR\nmysql -u ${db.username} --socket ${db.socket}`)
0 commit comments