mysql-memory-server 1.8.0 → 1.8.2

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.
package/README.md CHANGED
@@ -104,11 +104,9 @@ An object with two properties. ```version``` is the version of MySQL used to cre
104
104
  The method to stop the database. The returned promise resolves when the database has successfully stopped.
105
105
 
106
106
  #### Options:
107
- ##### For options that are not required, using ```undefined``` as a value will use the option's default value.
107
+ ##### All options are not required to be set. Using ```undefined``` as a value will use the option's default value.
108
108
  - `version: string`
109
109
 
110
- Required: No
111
-
112
110
  Default: undefined
113
111
 
114
112
  Description: Version of MySQL to use for the database. Uses semver for getting the version, so valid semver versions are allowed. For example, `8.x` is a valid version and will use the latest 8.x MySQL version.
@@ -123,32 +121,24 @@ If defined:
123
121
 
124
122
  - `dbName: string`
125
123
 
126
- Required: No
127
-
128
124
  Default: "dbdata"
129
125
 
130
126
  Description: The name of the database to create when initializing MySQL. You'd use this name to connect to the database.
131
127
 
132
128
  - `logLevel: "LOG" | "WARN" | "ERROR"`
133
129
 
134
- Required: No
135
-
136
130
  Default: "ERROR"
137
131
 
138
132
  Description: Log level for this package. If "ERROR" is used, only errors from this package will show up in the console. If "WARN" is used, warnings and errors from this package will show up in the console. If "LOG" is used, every log from this package will show up in the console.
139
133
 
140
134
  - `portRetries: number`
141
135
 
142
- Required: No
143
-
144
136
  Default: 10
145
137
 
146
138
  Description: Number of times to try connecting MySQL to a randomly generated port before giving up. According to the [MySQL Documentation](https://dev.mysql.com/doc/refman/en/server-options.html#option_mysqld_port "MySQL Documentation") if port 0 is used as the MySQL server port, the default value (3306) will be used. To get around this, a random number between 1025 - 65535 (inclusive) is generated and used for the database's port. If MySQL cannot successfully listen on a randomly generated port after `portRetries` then the `createDB()` promise is rejected. A warning is created when MySQL tries connecting to a port that is already in use. This option only applies for the MySQL port if the MySQL port is not explicitly set or if it's set to 0. This option also only applies for the MySQL X port if the MySQL X port is not explicitly set or if it's set to 0.
147
139
 
148
140
  - `downloadBinaryOnce: boolean`
149
141
 
150
- Required: No
151
-
152
142
  Default: true
153
143
 
154
144
  Description: If set to true, all versions requested that need to be downloaded from MySQL's CDN will be downloaded once and will stay on the system after the database stops. If set to false, the binaries that need to be downloaded will be downloaded for each database creation and will be deleted when the database is stopped.
@@ -157,64 +147,48 @@ Use `false` to save disk space after the databases have been stopped, or use `tr
157
147
 
158
148
  - `lockRetries: number`
159
149
 
160
- Required: No
161
-
162
150
  Default: 1,000
163
151
 
164
152
  Description: If `downloadBinaryOnce` is set to `true`, `lockRetries` is the number of times to check to see if the lock for the binary has been released (meaning it has been successfully downloaded and extracted). If the number of retries exceeds `lockRetries`, the `createDB()` promise gets rejected. This option is also used for the number of times to check to see if the lock for libaio has been released (only on Linux distros that use libaio1t64 instead of libaio1)
165
153
 
166
154
  - `lockRetryWait: number`
167
155
 
168
- Required: No
169
-
170
156
  Default: 1,000
171
157
 
172
158
  Description: If `downloadBinaryOnce` is set to `true` and/or on Linux distros that use libaio1t64 instead of libaio1, `lockRetryWait` is the number of milliseconds to wait before checking if the lock has been released.
173
159
 
174
160
  - `username: string`
175
161
 
176
- Required: No
177
-
178
162
  Default: root
179
163
 
180
164
  Description: The username of the user that is used to login to the database.
181
165
 
182
166
  - `port: number`
183
167
 
184
- Required: No
185
-
186
168
  Default: 0
187
169
 
188
170
  Description: The port that the database will listen on. If set to 0, a randomly generated port is used.
189
171
 
190
172
  - `xPort: number`
191
173
 
192
- Required: No
193
-
194
174
  Default: 0
195
175
 
196
176
  Description: The port that the MySQL X Plugin will listen on. If set to 0, a randomly generated port is used.
197
177
 
198
178
  - `ignoreUnsupportedSystemVersion: boolean`
199
179
 
200
- Required: No
201
-
202
180
  Default: false
203
181
 
204
182
  Description: This option only applies if the system-installed MySQL version is lower than the oldest supported MySQL version for this package (8.0.20) and the `version` option is not defined. If set to `true`, this package will use the latest version of MySQL instead of the system-installed version. If `false`, the package will throw an error.
205
183
 
206
184
  - `downloadRetries: number`
207
185
 
208
- Required: No
209
-
210
186
  Default: 3
211
187
 
212
188
  Description: The number of times to try to download a MySQL binary before giving up and rejecting the `createDB()` promise.
213
189
 
214
190
  - `initSQLString: string`
215
191
 
216
- Required: No
217
-
218
192
  Default: ""
219
193
 
220
194
  Description: A string with MySQL queries to run before the database starts to accept connections. This option can be used for things like initialising tables without having to first connect to the database to do that. The queries in the string get executed after ```mysql-memory-server```'s queries run. Uses the ```--init-file``` MySQL server option under the hood. Learn more at the [--init-file MySQL Documentation](https://dev.mysql.com/doc/refman/8.4/en/server-system-variables.html#sysvar_init_file)
@@ -223,37 +197,6 @@ The internal queries that are ran before the queries in ```initSQLString``` are
223
197
 
224
198
  - `arch: "arm64" | "x64"`
225
199
 
226
- Required: No
227
-
228
200
  Default: process.arch
229
201
 
230
202
  Description: The MySQL binary architecture to execute. MySQL does not offer server builds for Windows on ARM, so to get this package working on Windows on ARM, set the arch option to "x64" and Windows will emulate MySQL.
231
-
232
- ***
233
- ### :warning: Internal Options :warning:
234
-
235
- The following options are only meant for internal use (such as for testing this package 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.
236
-
237
- - `_DO_NOT_USE_deleteDBAfterStopped: boolean`
238
-
239
- Default: true
240
-
241
- 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.
242
-
243
- - `_DO_NOT_USE_dbPath: string`
244
-
245
- Default: `TMPDIR/mysqlmsn/dbs/UUID` (replacing TMPDIR with the OS temp directory and UUID with a UUIDv4 without seperating dashes).
246
-
247
- Description: The folder to store database-related data in
248
-
249
- - `_DO_NOT_USE_binaryDirectoryPath: string`
250
-
251
- Default: `TMPDIR/mysqlmsn/binaries` (replacing TMPDIR with the OS temp directory)
252
-
253
- Description: The folder to store the MySQL binaries when they are downloaded from the CDN.
254
-
255
- - `_DO_NOT_USE_cli: boolean`
256
-
257
- Default: ```false``` if the package is not being executed via the CLI and ```true``` if it is.
258
-
259
- Description: If set to ```true```, this enables certain CLI-only functionality. For example, when ran by the CLI, logging a message to the console when a shutdown signal (like CTRL + C) has been received and the MySQL database is shutting down and getting deleted.
package/dist/src/cli.js CHANGED
@@ -3,16 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const index_1 = require("./index");
5
5
  const constants_1 = require("./constants");
6
- async function main() {
6
+ function main() {
7
7
  const definedOptions = process.argv.filter((option) => option.startsWith('--'));
8
- const options = {
9
- _DO_NOT_USE_cli: true
10
- };
8
+ const options = {};
9
+ process.env.mysqlmsn_internal_DO_NOT_USE_cli = 'true';
11
10
  for (const opt of definedOptions) {
11
+ if (!constants_1.DEFAULT_OPTIONS_KEYS.includes(opt.replace('--', ''))) {
12
+ console.error(`Option ${opt} is not a valid option.`);
13
+ return;
14
+ }
12
15
  const index = process.argv.indexOf(opt);
13
16
  const optionValue = process.argv[index + 1];
14
17
  if (optionValue === undefined) {
15
- throw `Option ${opt} must have a value.`;
18
+ console.error(`Option ${opt} must have a value.`);
19
+ return;
16
20
  }
17
21
  const optionName = opt.slice(2);
18
22
  const optionType = constants_1.OPTION_TYPE_CHECKS[optionName].definedType;
@@ -39,17 +43,18 @@ async function main() {
39
43
  }
40
44
  }
41
45
  console.log('Creating ephemeral MySQL database...');
42
- const db = await (0, index_1.createDB)(options);
43
- console.log(`A MySQL database has been successfully created with the following parameters:\n\nMySQL Version: ${db.mysql.version} (${db.mysql.versionIsInstalledOnSystem ? 'installed on this system' : 'not installed on this system - downloaded from the MySQL CDN'}) \nUsername: ${db.username} \nDatabase Name: ${db.dbName} \nPort: ${db.port} \nX Plugin Port: ${db.xPort} \nSocket: ${db.socket} \nX Plugin Socket: ${db.xSocket}\n`);
44
- if (process.platform === 'win32') {
45
- //The connection information logs will be different for Windows compared to other platforms.
46
- //Windows uses mysqlsh instead of mysql to invoke the client shell, needs a --sql flag to be put into SQL mode, and also does not have a protocol flag.
47
- //Also according to https://bugs.mysql.com/bug.php?id=106852, you cannot log into a MySQL database with a named pipe for the first connection so a socket connection suggestion
48
- //should only be displayed for non-Windows platforms.
49
- console.log(`If you want to use the MySQL CLI client to connect to the database, you can use the following command: \nmysqlsh --sql -u ${db.username} -P ${db.port}\nIf prompted for a password, leave the password field blank. The database does not have a password set.`);
50
- }
51
- else {
52
- 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}\nIf prompted for a password, leave the password field blank. The database does not have a password set.`);
53
- }
46
+ (0, index_1.createDB)(options).then(db => {
47
+ console.log(`A MySQL database has been successfully created with the following parameters:\n\nMySQL Version: ${db.mysql.version} (${db.mysql.versionIsInstalledOnSystem ? 'installed on this system' : 'not installed on this system - downloaded from the MySQL CDN'}) \nUsername: ${db.username} \nDatabase Name: ${db.dbName} \nPort: ${db.port} \nX Plugin Port: ${db.xPort} \nSocket: ${db.socket} \nX Plugin Socket: ${db.xSocket}\n`);
48
+ if (process.platform === 'win32') {
49
+ //The connection information logs will be different for Windows compared to other platforms.
50
+ //Windows uses mysqlsh instead of mysql to invoke the client shell, needs a --sql flag to be put into SQL mode, and also does not have a protocol flag.
51
+ //Also according to https://bugs.mysql.com/bug.php?id=106852, you cannot log into a MySQL database with a named pipe for the first connection so a socket connection suggestion
52
+ //should only be displayed for non-Windows platforms.
53
+ console.log(`If you want to use the MySQL CLI client to connect to the database, you can use the following command: \nmysqlsh --sql -u ${db.username} -P ${db.port}\nIf prompted for a password, leave the password field blank. The database does not have a password set.`);
54
+ }
55
+ else {
56
+ 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}\nIf prompted for a password, leave the password field blank. The database does not have a password set.`);
57
+ }
58
+ });
54
59
  }
55
60
  main();
@@ -7,5 +7,12 @@ export declare const LOG_LEVELS: {
7
7
  readonly WARN: 1;
8
8
  readonly ERROR: 2;
9
9
  };
10
- export declare const INTERNAL_OPTIONS: readonly ["_DO_NOT_USE_deleteDBAfterStopped", "_DO_NOT_USE_dbPath", "_DO_NOT_USE_binaryDirectoryPath", "_DO_NOT_USE_beforeSignalCleanup", "_DO_NOT_USE_afterSignalCleanup"];
10
+ declare const internalOptions: {
11
+ deleteDBAfterStopped: string;
12
+ dbPath: string;
13
+ binaryDirectoryPath: string;
14
+ cli: string;
15
+ };
16
+ export declare function getInternalEnvVariable(envVar: keyof typeof internalOptions): string;
11
17
  export declare const OPTION_TYPE_CHECKS: OptionTypeChecks;
18
+ export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OPTION_TYPE_CHECKS = exports.INTERNAL_OPTIONS = exports.LOG_LEVELS = exports.DEFAULT_OPTIONS_KEYS = exports.DEFAULT_OPTIONS_GENERATOR = exports.MIN_SUPPORTED_MYSQL = void 0;
3
+ exports.OPTION_TYPE_CHECKS = exports.LOG_LEVELS = exports.DEFAULT_OPTIONS_KEYS = exports.DEFAULT_OPTIONS_GENERATOR = exports.MIN_SUPPORTED_MYSQL = void 0;
4
+ exports.getInternalEnvVariable = getInternalEnvVariable;
4
5
  const crypto_1 = require("crypto");
5
6
  const path_1 = require("path");
6
7
  const os_1 = require("os");
@@ -20,12 +21,7 @@ const DEFAULT_OPTIONS_GENERATOR = () => ({
20
21
  xPort: 0,
21
22
  downloadRetries: 10,
22
23
  initSQLString: '',
23
- arch: process.arch,
24
- _DO_NOT_USE_deleteDBAfterStopped: true,
25
- //mysqlmsn = MySQL Memory Server Node.js
26
- _DO_NOT_USE_dbPath: (0, path_1.normalize)(`${(0, os_1.tmpdir)()}/mysqlmsn/dbs/${(0, crypto_1.randomUUID)().replace(/-/g, '')}`),
27
- _DO_NOT_USE_binaryDirectoryPath: `${(0, os_1.tmpdir)()}/mysqlmsn/binaries`,
28
- _DO_NOT_USE_cli: false
24
+ arch: process.arch
29
25
  });
30
26
  exports.DEFAULT_OPTIONS_GENERATOR = DEFAULT_OPTIONS_GENERATOR;
31
27
  exports.DEFAULT_OPTIONS_KEYS = Object.freeze(Object.keys((0, exports.DEFAULT_OPTIONS_GENERATOR)()));
@@ -34,7 +30,16 @@ exports.LOG_LEVELS = {
34
30
  'WARN': 1,
35
31
  'ERROR': 2
36
32
  };
37
- exports.INTERNAL_OPTIONS = ['_DO_NOT_USE_deleteDBAfterStopped', '_DO_NOT_USE_dbPath', '_DO_NOT_USE_binaryDirectoryPath', '_DO_NOT_USE_beforeSignalCleanup', '_DO_NOT_USE_afterSignalCleanup'];
33
+ const internalOptions = {
34
+ deleteDBAfterStopped: 'true',
35
+ //mysqlmsn = MySQL Memory Server Node.js
36
+ dbPath: (0, path_1.normalize)(`${(0, os_1.tmpdir)()}/mysqlmsn/dbs/${(0, crypto_1.randomUUID)().replace(/-/g, '')}`),
37
+ binaryDirectoryPath: `${(0, os_1.tmpdir)()}/mysqlmsn/binaries`,
38
+ cli: 'false'
39
+ };
40
+ function getInternalEnvVariable(envVar) {
41
+ return process.env['mysqlmsn_internal_DO_NOT_USE_' + envVar] || internalOptions[envVar];
42
+ }
38
43
  const allowedArches = ['x64', 'arm64', undefined];
39
44
  exports.OPTION_TYPE_CHECKS = {
40
45
  version: {
@@ -106,25 +111,5 @@ exports.OPTION_TYPE_CHECKS = {
106
111
  check: (opt) => allowedArches.includes(opt),
107
112
  errorMessage: `Option arch must be either of the following: ${allowedArches.join(', ')}`,
108
113
  definedType: 'string'
109
- },
110
- _DO_NOT_USE_deleteDBAfterStopped: {
111
- check: (opt) => opt === undefined || typeof opt === 'boolean',
112
- errorMessage: 'Option _DO_NOT_USE_deleteDBAfterStopped must be either undefined or a boolean.',
113
- definedType: 'boolean'
114
- },
115
- _DO_NOT_USE_dbPath: {
116
- check: (opt) => opt === undefined || typeof opt === 'string',
117
- errorMessage: 'Option _DO_NOT_USE_dbPath must be either undefined or a string.',
118
- definedType: 'string'
119
- },
120
- _DO_NOT_USE_binaryDirectoryPath: {
121
- check: (opt) => opt === undefined || typeof opt === 'string',
122
- errorMessage: 'Option _DO_NOT_USE_binaryDirectoryPath must be either undefined or a string.',
123
- definedType: 'string'
124
- },
125
- _DO_NOT_USE_cli: {
126
- check: (opt) => opt === undefined || typeof opt === 'boolean',
127
- errorMessage: 'Option _DO_NOT_USE_cli must be either undefined or a boolean.',
128
- definedType: 'boolean'
129
114
  }
130
115
  };
package/dist/src/index.js CHANGED
@@ -48,11 +48,6 @@ const constants_1 = require("./constants");
48
48
  async function createDB(opts) {
49
49
  const suppliedOpts = opts || {};
50
50
  const suppliedOptsKeys = Object.keys(suppliedOpts);
51
- for (const opt of constants_1.INTERNAL_OPTIONS) {
52
- if (suppliedOptsKeys.includes(opt)) {
53
- console.warn(`[ mysql-memory-server - Options WARN ]: Creating MySQL database with option ${opt}. This is considered unstable and should not be used externally. Please consider removing this option.`);
54
- }
55
- }
56
51
  const options = (0, constants_1.DEFAULT_OPTIONS_GENERATOR)();
57
52
  for (const opt of suppliedOptsKeys) {
58
53
  if (!constants_1.DEFAULT_OPTIONS_KEYS.includes(opt)) {
@@ -74,11 +69,6 @@ async function createDB(opts) {
74
69
  if (throwUnsupportedError) {
75
70
  throw `A version of MySQL is installed on your system that is not supported by this package. If you want to download a MySQL binary instead of getting this error, please set the option "ignoreUnsupportedSystemVersion" to true.`;
76
71
  }
77
- if (options.version && (0, semver_1.lt)(options.version, constants_1.MIN_SUPPORTED_MYSQL)) {
78
- //The difference between the throw here and the throw above is this throw is because the selected "version" is not supported.
79
- //The throw above is because the system-installed MySQL is out of date and "ignoreUnsupportedSystemVersion" is not set to true.
80
- throw `The selected version of MySQL (${options.version}) is not currently supported by this package. Please choose a different version to use.`;
81
- }
82
72
  logger.log('Version currently installed:', version);
83
73
  if (version === null || (options.version && !(0, semver_1.satisfies)(version.version, options.version)) || unsupportedMySQLIsInstalled) {
84
74
  let binaryInfo;
@@ -88,6 +78,11 @@ async function createDB(opts) {
88
78
  logger.log('Using MySQL binary version:', binaryInfo.version, 'from URL:', binaryInfo.url);
89
79
  }
90
80
  catch (e) {
81
+ if (options.version && (0, semver_1.lt)((0, semver_1.coerce)(options.version), constants_1.MIN_SUPPORTED_MYSQL)) {
82
+ //The difference between the throw here and the throw above is this throw is because the selected "version" is not supported.
83
+ //The throw above is because the system-installed MySQL is out of date and "ignoreUnsupportedSystemVersion" is not set to true.
84
+ throw `The selected version of MySQL (${options.version}) is not currently supported by this package. Please choose a different version to use.`;
85
+ }
91
86
  logger.error(e);
92
87
  if (options.version) {
93
88
  throw `A MySQL version ${options.version} binary could not be found that supports your OS (${os.platform()} | ${os.version()} | ${os.release()}) and CPU architecture (${os.arch()}). Please check you have the latest version of mysql-memory-server. If the latest version still doesn't support the version you want to use, feel free to make a pull request to add support!`;
@@ -46,6 +46,7 @@ const path_1 = require("path");
46
46
  const crypto_1 = require("crypto");
47
47
  const child_process_1 = require("child_process");
48
48
  const FileLock_1 = require("./FileLock");
49
+ const constants_1 = require("../constants");
49
50
  function getZipData(entry) {
50
51
  return new Promise((resolve, reject) => {
51
52
  entry.getDataAsync((data, err) => {
@@ -208,7 +209,7 @@ function extractBinary(url, archiveLocation, extractedLocation, logger) {
208
209
  function downloadBinary(binaryInfo, options, logger) {
209
210
  return new Promise(async (resolve, reject) => {
210
211
  const { url, version } = binaryInfo;
211
- const dirpath = options._DO_NOT_USE_binaryDirectoryPath;
212
+ const dirpath = (0, constants_1.getInternalEnvVariable)('binaryDirectoryPath');
212
213
  logger.log('Binary path:', dirpath);
213
214
  await fsPromises.mkdir(dirpath, { recursive: true });
214
215
  const lastDashIndex = url.lastIndexOf('-');
@@ -49,6 +49,7 @@ const path_1 = require("path");
49
49
  const FileLock_1 = require("./FileLock");
50
50
  const signal_exit_1 = require("signal-exit");
51
51
  const crypto_1 = require("crypto");
52
+ const constants_1 = require("../constants");
52
53
  class Executor {
53
54
  constructor(logger) {
54
55
  _Executor_instances.add(this);
@@ -118,13 +119,13 @@ class Executor {
118
119
  this.version = installedMySQLBinary.version;
119
120
  this.versionInstalledOnSystem = installedMySQLBinary.installedOnSystem;
120
121
  this.removeExitHandler = (0, signal_exit_1.onExit)(() => {
121
- if (options._DO_NOT_USE_cli) {
122
+ if ((0, constants_1.getInternalEnvVariable)('cli') === 'true') {
122
123
  console.log('\nShutting down the ephemeral MySQL database and cleaning all related files...');
123
124
  }
124
125
  this.DBDestroySignal.abort();
125
- if (options._DO_NOT_USE_deleteDBAfterStopped) {
126
+ if ((0, constants_1.getInternalEnvVariable)('deleteDBAfterStopped') === 'true') {
126
127
  try {
127
- fs.rmSync(options._DO_NOT_USE_dbPath, { recursive: true, maxRetries: 50, force: true });
128
+ fs.rmSync((0, constants_1.getInternalEnvVariable)('dbPath'), { recursive: true, maxRetries: 50, force: true });
128
129
  }
129
130
  catch (e) {
130
131
  this.logger.error('An error occurred while deleting database directory path:', e);
@@ -139,12 +140,12 @@ class Executor {
139
140
  this.logger.error('An error occurred while deleting database binary:', e);
140
141
  }
141
142
  }
142
- if (options._DO_NOT_USE_cli) {
143
+ if ((0, constants_1.getInternalEnvVariable)('cli') === 'true') {
143
144
  console.log('Shutdown and cleanup is complete.');
144
145
  }
145
146
  });
146
147
  let retries = 0;
147
- const datadir = (0, path_1.normalize)(`${options._DO_NOT_USE_dbPath}/data`);
148
+ const datadir = (0, path_1.normalize)(`${(0, constants_1.getInternalEnvVariable)('dbPath')}/data`);
148
149
  do {
149
150
  await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_setupDataDirectories).call(this, options, installedMySQLBinary.path, datadir, true);
150
151
  this.logger.log('Setting up directories was successful');
@@ -153,7 +154,7 @@ class Executor {
153
154
  this.logger.log('Using port:', port, 'and MySQLX port:', mySQLXPort, 'on retry:', retries);
154
155
  try {
155
156
  this.logger.log('Starting MySQL process');
156
- const resolved = await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_startMySQLProcess).call(this, options, port, mySQLXPort, datadir, options._DO_NOT_USE_dbPath, installedMySQLBinary.path);
157
+ const resolved = await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_startMySQLProcess).call(this, options, port, mySQLXPort, datadir, (0, constants_1.getInternalEnvVariable)('dbPath'), installedMySQLBinary.path);
157
158
  this.logger.log('Starting process was successful');
158
159
  return resolved;
159
160
  }
@@ -253,7 +254,7 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
253
254
  if (portIssue || xPortIssue) {
254
255
  this.logger.log('Error log when exiting for port in use error:', errorLog);
255
256
  try {
256
- await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_deleteDatabaseDirectory).call(this, options._DO_NOT_USE_dbPath);
257
+ await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_deleteDatabaseDirectory).call(this, (0, constants_1.getInternalEnvVariable)('dbPath'));
257
258
  }
258
259
  catch (e) {
259
260
  this.logger.error(e);
@@ -262,7 +263,7 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
262
263
  return reject('Port is already in use');
263
264
  }
264
265
  try {
265
- if (options._DO_NOT_USE_deleteDBAfterStopped) {
266
+ if ((0, constants_1.getInternalEnvVariable)('deleteDBAfterStopped') === 'true') {
266
267
  await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_deleteDatabaseDirectory).call(this, dbPath);
267
268
  }
268
269
  }
@@ -477,7 +478,7 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
477
478
  initText += `\n${options.initSQLString}`;
478
479
  }
479
480
  this.logger.log('Writing init file');
480
- await fsPromises.writeFile(`${options._DO_NOT_USE_dbPath}/init.sql`, initText, { encoding: 'utf8' });
481
+ await fsPromises.writeFile(`${(0, constants_1.getInternalEnvVariable)('dbPath')}/init.sql`, initText, { encoding: 'utf8' });
481
482
  this.logger.log('Finished writing init file');
482
483
  };
483
484
  exports.default = Executor;
@@ -15,10 +15,6 @@ export type ServerOptions = {
15
15
  downloadRetries?: number | undefined;
16
16
  initSQLString?: string | undefined;
17
17
  arch?: "arm64" | "x64" | undefined;
18
- _DO_NOT_USE_deleteDBAfterStopped?: boolean | undefined;
19
- _DO_NOT_USE_dbPath?: string | undefined;
20
- _DO_NOT_USE_binaryDirectoryPath?: string | undefined;
21
- _DO_NOT_USE_cli?: boolean | undefined;
22
18
  };
23
19
  export type InternalServerOptions = {
24
20
  version?: string | undefined;
@@ -35,10 +31,6 @@ export type InternalServerOptions = {
35
31
  downloadRetries: number;
36
32
  initSQLString: string;
37
33
  arch: string;
38
- _DO_NOT_USE_deleteDBAfterStopped: boolean;
39
- _DO_NOT_USE_dbPath: string;
40
- _DO_NOT_USE_binaryDirectoryPath: string;
41
- _DO_NOT_USE_cli: boolean;
42
34
  };
43
35
  export type ExecutorOptions = {
44
36
  logLevel: LOG_LEVEL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql-memory-server",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Spin up an ephemeral MySQL database from your JavaScript code",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -31,12 +31,12 @@
31
31
  "@babel/preset-env": "^7.25.9",
32
32
  "@babel/preset-typescript": "^7.25.9",
33
33
  "@types/adm-zip": "^0.5.5",
34
- "@types/node": "^22.9.3",
34
+ "@types/node": "^22.10.6",
35
35
  "@types/semver": "^7.5.8",
36
36
  "babel-jest": "^29.7.0",
37
37
  "jest": "^29.7.0",
38
- "mysql2": "^3.11.3",
39
- "typescript": "^5.7.2"
38
+ "mysql2": "^3.12.0",
39
+ "typescript": "^5.7.3"
40
40
  },
41
41
  "dependencies": {
42
42
  "adm-zip": "^0.5.16",