mysql-memory-server 1.8.0 → 1.8.1
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 +1 -29
- package/dist/src/index.js +5 -5
- package/package.json +1 -1
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
|
-
#####
|
|
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,8 +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.
|
package/dist/src/index.js
CHANGED
|
@@ -74,11 +74,6 @@ async function createDB(opts) {
|
|
|
74
74
|
if (throwUnsupportedError) {
|
|
75
75
|
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
76
|
}
|
|
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
77
|
logger.log('Version currently installed:', version);
|
|
83
78
|
if (version === null || (options.version && !(0, semver_1.satisfies)(version.version, options.version)) || unsupportedMySQLIsInstalled) {
|
|
84
79
|
let binaryInfo;
|
|
@@ -88,6 +83,11 @@ async function createDB(opts) {
|
|
|
88
83
|
logger.log('Using MySQL binary version:', binaryInfo.version, 'from URL:', binaryInfo.url);
|
|
89
84
|
}
|
|
90
85
|
catch (e) {
|
|
86
|
+
if (options.version && (0, semver_1.lt)((0, semver_1.coerce)(options.version), constants_1.MIN_SUPPORTED_MYSQL)) {
|
|
87
|
+
//The difference between the throw here and the throw above is this throw is because the selected "version" is not supported.
|
|
88
|
+
//The throw above is because the system-installed MySQL is out of date and "ignoreUnsupportedSystemVersion" is not set to true.
|
|
89
|
+
throw `The selected version of MySQL (${options.version}) is not currently supported by this package. Please choose a different version to use.`;
|
|
90
|
+
}
|
|
91
91
|
logger.error(e);
|
|
92
92
|
if (options.version) {
|
|
93
93
|
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!`;
|