mysql-memory-server 1.12.1 → 1.13.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.
package/README.md CHANGED
@@ -15,9 +15,9 @@ Download with your package manager of choice. The package name is `mysql-memory-
15
15
  #### Currently supported MySQL versions
16
16
 
17
17
  - ```mysql-memory-server``` can run MySQL versions 5.7.19 and newer (if the version is already installed on your system)
18
- - ```mysql-memory-server``` can download and run MySQL versions (inclusive) 5.7.19 - 5.7.44, 8.0.0 - 8.0.43, 8.1.0 - 8.4.6, and 9.0.1 - 9.4.0 (if the version is not already installed on your system)
18
+ - ```mysql-memory-server``` can download and run MySQL versions (inclusive) 5.7.19 - 5.7.44, 8.0.0 - 8.0.44, 8.1.0 - 8.4.7, and 9.0.1 - 9.5.0 (if the version is not already installed on your system)
19
19
 
20
- Extra system requirements apply when ```mysql-memory-server``` is downloading MySQL instead of running a version of MySQL that is already installed on the system. To see the requirements and learn more about the supported versions for download, [read the doc](https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.12.1/docs/SUPPORTED_MYSQL_DOWNLOADS.md)
20
+ Extra system requirements apply when ```mysql-memory-server``` is downloading MySQL instead of running a version of MySQL that is already installed on the system. To see the requirements and learn more about the supported versions for download, [read the doc](https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.13.0/docs/SUPPORTED_MYSQL_DOWNLOADS.md)
21
21
 
22
22
  ## Example Usage - Application Code
23
23
 
@@ -102,11 +102,11 @@ Description: Version of MySQL to use for the database. Uses semver for getting t
102
102
 
103
103
  If left undefined:
104
104
  - If the system has MySQL installed, the system-installed version will be used. If the installed version is not supported by this package (currently <5.7.19), an error will be thrown unless `ignoreUnsupportedSystemVersion` is set to `true`.
105
- - If the system does not have MySQL installed, the latest version of MySQL that [this package supports downloading](https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.12.1/docs/SUPPORTED_MYSQL_DOWNLOADS.md) will be downloaded.
105
+ - If the system does not have MySQL installed, the latest version of MySQL that [this package supports downloading](https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.13.0/docs/SUPPORTED_MYSQL_DOWNLOADS.md) will be downloaded.
106
106
 
107
107
  If defined:
108
108
  - If the version is older than 5.7.19, an error will be thrown as this package does not currently support those versions of MySQL.
109
- - If the desired version of MySQL is already installed on the system, the installed version will be used. Otherwise the selected version will be downloaded as long as this package [supports downloading it](https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.12.1/docs/SUPPORTED_MYSQL_DOWNLOADS.md). If this package does not support downloading the selected version, or your system does not [meet the requirements](https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.12.1/docs/SUPPORTED_MYSQL_DOWNLOADS.md) for that version to be ran, an error will be thrown.
109
+ - If the desired version of MySQL is already installed on the system, the installed version will be used. Otherwise the selected version will be downloaded as long as this package [supports downloading it](https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.13.0/docs/SUPPORTED_MYSQL_DOWNLOADS.md). If this package does not support downloading the selected version, or your system does not [meet the requirements](https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.13.0/docs/SUPPORTED_MYSQL_DOWNLOADS.md) for that version to be ran, an error will be thrown.
110
110
 
111
111
  - `dbName: string`
112
112
 
@@ -180,9 +180,13 @@ Description: The number of times to try to download a MySQL binary before giving
180
180
 
181
181
  Default: ""
182
182
 
183
- 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)
183
+ Description: A string with SQL 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. Check the [Init SQL file order of operations](#init-sql-file-order-of-operations) to learn more about what SQL queries are ran and in what order before the database starts accepting connections.
184
184
 
185
- The internal queries that are ran before the queries in ```initSQLString``` are creating the MySQL user with ```options.username``` username if the option's value is not ```root```, and creating a database with the ```options.dbName``` name.
185
+ - `initSQLFilePath: string`
186
+
187
+ Default: ""
188
+
189
+ Description: A path to a UTF-8 .sql file with SQL queries to run before the database starts to accept connections. This option is like the ```initSQLString``` option, instead taking a filepath for SQL statements to execute rather than a string of SQL statements - great for when you need to execute more than just a few SQL statements. Check the [Init SQL file order of operations](#init-sql-file-order-of-operations) to learn more about what SQL queries are ran and in what order before the database starts accepting connections. If a filepath is defined and reading the file fails, then the database creation will fail. The database creation process will not begin if ```initSQLFilePath``` is defined but the path specified does not exist.
186
190
 
187
191
  - `arch: "arm64" | "x64"`
188
192
 
@@ -195,3 +199,11 @@ Description: The MySQL binary architecture to execute. MySQL does not offer serv
195
199
  Default: "FORCE"
196
200
 
197
201
  Description: This option follows the convention set out by the [MySQL Documentation](https://dev.mysql.com/doc/refman/en/plugin-loading.html). If set to "OFF", the MySQL X Plugin will not initialise. If set to "FORCE", the MySQL Server will either start up with the MySQL X Plugin guaranteed to have successfully initialised, or if initialisation fails, the server will fail to start up.
202
+
203
+ ### Init SQL file order of operations:
204
+
205
+ There are some SQL queries executed on the database before the database is ready to be used. This is handled under the hood using the ```--init-file``` MySQL server option. Learn more at the [--init-file MySQL Documentation](https://dev.mysql.com/doc/refman/8.4/en/server-system-variables.html#sysvar_init_file). The following is the order in which the SQL queries are executed in, ordered from first executed to last executed:
206
+
207
+ 1. ```mysql-memory-server``` internal SQL queries - The internal queries that are executed are creating the MySQL user with ```options.username``` username if the option's value is not ```root```, and creating a database with the ```options.dbName``` name.
208
+ 2. The SQL queries provided to the ```initSQLString``` option
209
+ 3. The SQL queries provided to the ```initSQLFilePath``` option
@@ -15,18 +15,18 @@ export declare const OPTION_TYPE_CHECKS: OptionTypeChecks;
15
15
  export declare const MIN_SUPPORTED_MYSQL = "5.7.19";
16
16
  export declare const MySQLCDNDownloadsBaseURL = "https://cdn.mysql.com//Downloads/MySQL-";
17
17
  export declare const MySQLCDNArchivesBaseURL = "https://cdn.mysql.com/archives/mysql-";
18
- export declare const DOWNLOADABLE_MYSQL_VERSIONS: readonly ["5.7.19", "5.7.20", "5.7.21", "5.7.22", "5.7.23", "5.7.24", "5.7.25", "5.7.26", "5.7.27", "5.7.28", "5.7.29", "5.7.30", "5.7.31", "5.7.32", "5.7.33", "5.7.34", "5.7.35", "5.7.36", "5.7.37", "5.7.38", "5.7.39", "5.7.40", "5.7.41", "5.7.42", "5.7.43", "5.7.44", "8.0.0", "8.0.1", "8.0.2", "8.0.3", "8.0.4", "8.0.11", "8.0.12", "8.0.13", "8.0.14", "8.0.15", "8.0.16", "8.0.17", "8.0.18", "8.0.19", "8.0.20", "8.0.21", "8.0.22", "8.0.23", "8.0.24", "8.0.25", "8.0.26", "8.0.27", "8.0.28", "8.0.30", "8.0.31", "8.0.32", "8.0.33", "8.0.34", "8.0.35", "8.0.36", "8.0.37", "8.0.39", "8.0.40", "8.0.41", "8.0.42", "8.0.43", "8.1.0", "8.2.0", "8.3.0", "8.4.0", "8.4.2", "8.4.3", "8.4.4", "8.4.5", "8.4.6", "9.0.1", "9.1.0", "9.2.0", "9.3.0", "9.4.0"];
18
+ export declare const DOWNLOADABLE_MYSQL_VERSIONS: readonly ["5.7.19", "5.7.20", "5.7.21", "5.7.22", "5.7.23", "5.7.24", "5.7.25", "5.7.26", "5.7.27", "5.7.28", "5.7.29", "5.7.30", "5.7.31", "5.7.32", "5.7.33", "5.7.34", "5.7.35", "5.7.36", "5.7.37", "5.7.38", "5.7.39", "5.7.40", "5.7.41", "5.7.42", "5.7.43", "5.7.44", "8.0.0", "8.0.1", "8.0.2", "8.0.3", "8.0.4", "8.0.11", "8.0.12", "8.0.13", "8.0.14", "8.0.15", "8.0.16", "8.0.17", "8.0.18", "8.0.19", "8.0.20", "8.0.21", "8.0.22", "8.0.23", "8.0.24", "8.0.25", "8.0.26", "8.0.27", "8.0.28", "8.0.30", "8.0.31", "8.0.32", "8.0.33", "8.0.34", "8.0.35", "8.0.36", "8.0.37", "8.0.39", "8.0.40", "8.0.41", "8.0.42", "8.0.43", "8.0.44", "8.1.0", "8.2.0", "8.3.0", "8.4.0", "8.4.2", "8.4.3", "8.4.4", "8.4.5", "8.4.6", "8.4.7", "9.0.1", "9.1.0", "9.2.0", "9.3.0", "9.4.0", "9.5.0"];
19
19
  export declare const MYSQL_ARCH_SUPPORT: {
20
20
  readonly darwin: {
21
- readonly arm64: "8.0.26 - 9.4.0";
22
- readonly x64: "5.7.19 - 9.4.0";
21
+ readonly arm64: "8.0.26 - 9.5.0";
22
+ readonly x64: "5.7.19 - 9.5.0";
23
23
  };
24
24
  readonly linux: {
25
- readonly arm64: "8.0.31 - 9.4.0";
26
- readonly x64: "5.7.19 - 9.4.0";
25
+ readonly arm64: "8.0.31 - 9.5.0";
26
+ readonly x64: "5.7.19 - 9.5.0";
27
27
  };
28
28
  readonly win32: {
29
- readonly x64: "5.7.19 - 9.4.0";
29
+ readonly x64: "5.7.19 - 9.5.0";
30
30
  };
31
31
  };
32
32
  export declare const MYSQL_MIN_OS_SUPPORT: {
@@ -45,7 +45,7 @@ export declare const MYSQL_MIN_OS_SUPPORT: {
45
45
  readonly '8.0.28 - 8.0.31': "20.0.0";
46
46
  readonly '8.0.32 - 8.0.34': "21.0.0";
47
47
  readonly '8.0.35 - 8.0.39 || 8.1.0 - 8.4.2 || 9.0.1': "22.0.0";
48
- readonly '8.0.40 - 8.0.43 || 8.4.3 - 8.4.6 || 9.1.0 - 9.4.0': "23.0.0";
48
+ readonly '8.0.40 - 8.0.44 || 8.4.3 - 8.4.7 || 9.1.0 - 9.5.0': "23.0.0";
49
49
  };
50
50
  };
51
51
  export declare const DMR_MYSQL_VERSIONS = "8.0.0 - 8.0.2";
@@ -60,33 +60,33 @@ export declare const MYSQL_MACOS_VERSIONS_IN_FILENAME: {
60
60
  readonly '8.0.30 - 8.0.31': "macos12";
61
61
  readonly '8.0.32 - 8.0.35 || 8.1.0 - 8.2.0': "macos13";
62
62
  readonly '8.0.36 - 8.0.40 || 8.3.0 - 8.4.3 || 9.0.1 - 9.1.0': "macos14";
63
- readonly '8.0.41 - 8.0.43 || 8.4.4 - 8.4.6 || 9.2.0 - 9.4.0': "macos15";
63
+ readonly '8.0.41 - 8.0.44 || 8.4.4 - 8.4.7 || 9.2.0 - 9.5.0': "macos15";
64
64
  };
65
65
  export declare const MYSQL_LINUX_GLIBC_VERSIONS: {
66
66
  readonly x64: {
67
67
  readonly '5.7.19 - 8.0.20': "2.12";
68
- readonly '8.0.21 - 9.4.0': "2.17";
68
+ readonly '8.0.21 - 9.5.0': "2.17";
69
69
  };
70
70
  readonly arm64: {
71
71
  readonly '5.7.19 - 8.0.20': "2.12";
72
72
  readonly '8.0.21 - 8.0.41 || 8.1.0 - 8.4.4 || 9.0.1 - 9.2.0': "2.17";
73
- readonly '8.0.42 - 8.0.43 || 8.4.5 - 8.4.6 || 9.3.0 - 9.4.0': "2.28";
73
+ readonly '8.0.42 - 8.0.44 || 8.4.5 - 8.4.7 || 9.3.0 - 9.5.0': "2.28";
74
74
  };
75
75
  };
76
76
  export declare const MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE: {
77
77
  readonly '5.7.19 - 8.0.15': "no";
78
78
  readonly '8.0.16 - 8.0.20': "no-glibc-tag";
79
- readonly '8.0.21 - 9.4.0': "glibc-tag";
79
+ readonly '8.0.21 - 9.5.0': "glibc-tag";
80
80
  };
81
81
  export declare const MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE_ARM64 = "8.0.33 - 8.0.41 || 8.1.0 - 8.4.4 || 9.0.1 - 9.2.0";
82
82
  export declare const MYSQL_LINUX_FILE_EXTENSIONS: {
83
83
  readonly x64: {
84
84
  readonly '5.7.19 - 8.0.11': "gz";
85
- readonly '8.0.12 - 9.4.0': "xz";
85
+ readonly '8.0.12 - 9.5.0': "xz";
86
86
  };
87
87
  readonly arm64: {
88
88
  readonly '8.0.31 - 8.0.32': "gz";
89
- readonly '8.0.33 - 9.4.0': "xz";
89
+ readonly '8.0.33 - 9.5.0': "xz";
90
90
  };
91
91
  };
92
92
  export declare const MYSQL_LINUX_MINIMAL_REBUILD_VERSIONS = "8.0.26";
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MYSQL_LINUX_MINIMAL_REBUILD_VERSIONS = exports.MYSQL_LINUX_FILE_EXTENSIONS = exports.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE_ARM64 = exports.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE = exports.MYSQL_LINUX_GLIBC_VERSIONS = exports.MYSQL_MACOS_VERSIONS_IN_FILENAME = exports.RC_MYSQL_VERSIONS = exports.DMR_MYSQL_VERSIONS = exports.MYSQL_MIN_OS_SUPPORT = exports.MYSQL_ARCH_SUPPORT = exports.DOWNLOADABLE_MYSQL_VERSIONS = exports.MySQLCDNArchivesBaseURL = exports.MySQLCDNDownloadsBaseURL = exports.MIN_SUPPORTED_MYSQL = exports.OPTION_TYPE_CHECKS = exports.LOG_LEVELS = exports.DEFAULT_OPTIONS_KEYS = exports.DEFAULT_OPTIONS = void 0;
4
4
  exports.getInternalEnvVariable = getInternalEnvVariable;
5
5
  const semver_1 = require("semver");
6
+ const fs_1 = require("fs");
6
7
  exports.DEFAULT_OPTIONS = {
7
8
  version: undefined,
8
9
  dbName: 'dbdata',
@@ -18,7 +19,8 @@ exports.DEFAULT_OPTIONS = {
18
19
  downloadRetries: 10,
19
20
  initSQLString: '',
20
21
  arch: process.arch,
21
- xEnabled: 'FORCE'
22
+ xEnabled: 'FORCE',
23
+ initSQLFilePath: ''
22
24
  };
23
25
  exports.DEFAULT_OPTIONS_KEYS = Object.freeze(Object.keys(exports.DEFAULT_OPTIONS));
24
26
  exports.LOG_LEVELS = {
@@ -110,7 +112,12 @@ exports.OPTION_TYPE_CHECKS = {
110
112
  check: (opt) => opt === undefined || pluginActivationStates.includes(opt),
111
113
  errorMessage: `xEnabled must be either undefined or one of the following: ${pluginActivationStates.join(', ')}`,
112
114
  definedType: 'boolean'
113
- }
115
+ },
116
+ initSQLFilePath: {
117
+ check: (opt) => opt === undefined || (typeof opt === 'string' && (0, fs_1.existsSync)(opt)),
118
+ errorMessage: 'Option initSQLFilePath must be either undefined or a filepath string that points to a file that exists.',
119
+ definedType: 'string'
120
+ },
114
121
  };
115
122
  exports.MIN_SUPPORTED_MYSQL = '5.7.19';
116
123
  exports.MySQLCDNDownloadsBaseURL = 'https://cdn.mysql.com//Downloads/MySQL-';
@@ -119,22 +126,22 @@ exports.MySQLCDNArchivesBaseURL = 'https://cdn.mysql.com/archives/mysql-';
119
126
  exports.DOWNLOADABLE_MYSQL_VERSIONS = [
120
127
  '5.7.19', '5.7.20', '5.7.21', '5.7.22', '5.7.23', '5.7.24', '5.7.25', '5.7.26', '5.7.27', '5.7.28', '5.7.29', '5.7.30', '5.7.31', '5.7.32', '5.7.33', '5.7.34', '5.7.35', '5.7.36', '5.7.37', '5.7.38', '5.7.39', '5.7.40', '5.7.41', '5.7.42', '5.7.43', '5.7.44',
121
128
  '8.0.0', '8.0.1', '8.0.2', '8.0.3', '8.0.4',
122
- '8.0.11', '8.0.12', '8.0.13', '8.0.14', '8.0.15', '8.0.16', '8.0.17', '8.0.18', '8.0.19', '8.0.20', '8.0.21', '8.0.22', '8.0.23', '8.0.24', '8.0.25', '8.0.26', '8.0.27', '8.0.28', '8.0.30', '8.0.31', '8.0.32', '8.0.33', '8.0.34', '8.0.35', '8.0.36', '8.0.37', '8.0.39', '8.0.40', '8.0.41', '8.0.42', '8.0.43',
129
+ '8.0.11', '8.0.12', '8.0.13', '8.0.14', '8.0.15', '8.0.16', '8.0.17', '8.0.18', '8.0.19', '8.0.20', '8.0.21', '8.0.22', '8.0.23', '8.0.24', '8.0.25', '8.0.26', '8.0.27', '8.0.28', '8.0.30', '8.0.31', '8.0.32', '8.0.33', '8.0.34', '8.0.35', '8.0.36', '8.0.37', '8.0.39', '8.0.40', '8.0.41', '8.0.42', '8.0.43', '8.0.44',
123
130
  '8.1.0', '8.2.0', '8.3.0',
124
- '8.4.0', '8.4.2', '8.4.3', '8.4.4', '8.4.5', '8.4.6',
125
- '9.0.1', '9.1.0', '9.2.0', '9.3.0', '9.4.0'
131
+ '8.4.0', '8.4.2', '8.4.3', '8.4.4', '8.4.5', '8.4.6', '8.4.7',
132
+ '9.0.1', '9.1.0', '9.2.0', '9.3.0', '9.4.0', '9.5.0'
126
133
  ];
127
134
  exports.MYSQL_ARCH_SUPPORT = {
128
135
  darwin: {
129
- arm64: '8.0.26 - 9.4.0',
130
- x64: '5.7.19 - 9.4.0'
136
+ arm64: '8.0.26 - 9.5.0',
137
+ x64: '5.7.19 - 9.5.0'
131
138
  },
132
139
  linux: {
133
- arm64: '8.0.31 - 9.4.0',
134
- x64: '5.7.19 - 9.4.0'
140
+ arm64: '8.0.31 - 9.5.0',
141
+ x64: '5.7.19 - 9.5.0'
135
142
  },
136
143
  win32: {
137
- x64: '5.7.19 - 9.4.0'
144
+ x64: '5.7.19 - 9.5.0'
138
145
  }
139
146
  };
140
147
  exports.MYSQL_MIN_OS_SUPPORT = {
@@ -154,7 +161,7 @@ exports.MYSQL_MIN_OS_SUPPORT = {
154
161
  '8.0.28 - 8.0.31': '20.0.0',
155
162
  '8.0.32 - 8.0.34': '21.0.0',
156
163
  '8.0.35 - 8.0.39 || 8.1.0 - 8.4.2 || 9.0.1': '22.0.0',
157
- '8.0.40 - 8.0.43 || 8.4.3 - 8.4.6 || 9.1.0 - 9.4.0': '23.0.0'
164
+ '8.0.40 - 8.0.44 || 8.4.3 - 8.4.7 || 9.1.0 - 9.5.0': '23.0.0'
158
165
  }
159
166
  };
160
167
  exports.DMR_MYSQL_VERSIONS = '8.0.0 - 8.0.2';
@@ -169,7 +176,7 @@ exports.MYSQL_MACOS_VERSIONS_IN_FILENAME = {
169
176
  '8.0.30 - 8.0.31': 'macos12',
170
177
  '8.0.32 - 8.0.35 || 8.1.0 - 8.2.0': 'macos13',
171
178
  '8.0.36 - 8.0.40 || 8.3.0 - 8.4.3 || 9.0.1 - 9.1.0': 'macos14',
172
- '8.0.41 - 8.0.43 || 8.4.4 - 8.4.6 || 9.2.0 - 9.4.0': 'macos15'
179
+ '8.0.41 - 8.0.44 || 8.4.4 - 8.4.7 || 9.2.0 - 9.5.0': 'macos15'
173
180
  };
174
181
  exports.MYSQL_LINUX_GLIBC_VERSIONS = {
175
182
  //8.0.42 - 8.0.43, 8.4.5 - 8.4.6, and 9.3.0 - 9.4.0 with glibc 2.28 does NOT have a minimal install version for x64 but it DOES have arm64 support.
@@ -178,28 +185,28 @@ exports.MYSQL_LINUX_GLIBC_VERSIONS = {
178
185
  //Neither glibc versions for the above MySQL versions have an arm64 minimal install.
179
186
  x64: {
180
187
  '5.7.19 - 8.0.20': '2.12',
181
- '8.0.21 - 9.4.0': '2.17'
188
+ '8.0.21 - 9.5.0': '2.17'
182
189
  },
183
190
  arm64: {
184
191
  '5.7.19 - 8.0.20': '2.12',
185
192
  '8.0.21 - 8.0.41 || 8.1.0 - 8.4.4 || 9.0.1 - 9.2.0': '2.17',
186
- '8.0.42 - 8.0.43 || 8.4.5 - 8.4.6 || 9.3.0 - 9.4.0': '2.28'
193
+ '8.0.42 - 8.0.44 || 8.4.5 - 8.4.7 || 9.3.0 - 9.5.0': '2.28'
187
194
  }
188
195
  };
189
196
  exports.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE = {
190
197
  '5.7.19 - 8.0.15': 'no',
191
198
  '8.0.16 - 8.0.20': 'no-glibc-tag',
192
- '8.0.21 - 9.4.0': 'glibc-tag'
199
+ '8.0.21 - 9.5.0': 'glibc-tag'
193
200
  };
194
- exports.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE_ARM64 = '8.0.33 - 8.0.41 || 8.1.0 - 8.4.4 || 9.0.1 - 9.2.0'; //Not available for < 8.0.33 and 8.0.42 - 8.0.43, 8.4.5 - 8.4.6, and 9.3.0 - 9.4.0
201
+ exports.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE_ARM64 = '8.0.33 - 8.0.41 || 8.1.0 - 8.4.4 || 9.0.1 - 9.2.0'; //Not available for < 8.0.33 and >=8.0.42 <8.1.0, >=8.4.5 <8.5, and >=9.3.0 <10.0.0
195
202
  exports.MYSQL_LINUX_FILE_EXTENSIONS = {
196
203
  x64: {
197
204
  '5.7.19 - 8.0.11': 'gz',
198
- '8.0.12 - 9.4.0': 'xz'
205
+ '8.0.12 - 9.5.0': 'xz'
199
206
  },
200
207
  arm64: {
201
208
  '8.0.31 - 8.0.32': 'gz',
202
- '8.0.33 - 9.4.0': 'xz'
209
+ '8.0.33 - 9.5.0': 'xz'
203
210
  }
204
211
  };
205
212
  exports.MYSQL_LINUX_MINIMAL_REBUILD_VERSIONS = '8.0.26';
@@ -292,9 +292,10 @@ function downloadBinary(binaryInfo, options, logger) {
292
292
  let downloadTries = 0;
293
293
  let useDownloadsURL = false;
294
294
  do {
295
- const downloadURL = binaryInfo.hostedByOracle ? `${useDownloadsURL ? constants_1.MySQLCDNDownloadsBaseURL : constants_1.MySQLCDNArchivesBaseURL}${url}` : await getFileDownloadURLRedirect(url);
295
+ let downloadURL = 'UNINITIALISED';
296
296
  try {
297
297
  downloadTries++;
298
+ downloadURL = binaryInfo.hostedByOracle ? `${useDownloadsURL ? constants_1.MySQLCDNDownloadsBaseURL : constants_1.MySQLCDNArchivesBaseURL}${url}` : await getFileDownloadURLRedirect(url);
298
299
  logger.log(`Starting download for MySQL version ${version} from ${downloadURL}.`);
299
300
  await downloadFromCDN(downloadURL, archivePath, logger);
300
301
  logger.log(`Finished downloading MySQL version ${version} from ${downloadURL}. Now starting binary extraction.`);
@@ -361,13 +362,14 @@ function downloadBinary(binaryInfo, options, logger) {
361
362
  let downloadTries = 0;
362
363
  let useDownloadsURL = false;
363
364
  do {
364
- const downloadURL = binaryInfo.hostedByOracle ? `${useDownloadsURL ? constants_1.MySQLCDNDownloadsBaseURL : constants_1.MySQLCDNArchivesBaseURL}${url}` : await getFileDownloadURLRedirect(url);
365
+ let downloadURL = 'UNINITIALISED';
365
366
  const uuid = (0, crypto_1.randomUUID)();
366
367
  const zipFilepath = `${dirpath}/${uuid}.${fileExtension}`;
367
368
  logger.log('Binary filepath:', zipFilepath);
368
369
  const extractedPath = `${dirpath}/${uuid}`;
369
370
  try {
370
371
  downloadTries++;
372
+ downloadURL = binaryInfo.hostedByOracle ? `${useDownloadsURL ? constants_1.MySQLCDNDownloadsBaseURL : constants_1.MySQLCDNArchivesBaseURL}${url}` : await getFileDownloadURLRedirect(url);
371
373
  logger.log(`Starting download for MySQL version ${version} from ${downloadURL}.`);
372
374
  await downloadFromCDN(downloadURL, zipFilepath, logger);
373
375
  logger.log(`Finished downloading MySQL version ${version} from ${downloadURL}. Now starting binary extraction.`);
@@ -37,7 +37,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
37
37
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
38
38
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
39
39
  };
40
- var _Executor_instances, _Executor_executeFile, _Executor_killProcess, _Executor_returnBinaryPathToDelete, _Executor_startMySQLProcess, _Executor_setupDataDirectories;
40
+ var _Executor_instances, _Executor_executeFile, _Executor_killProcess, _Executor_returnBinaryPathToDelete, _Executor_startMySQLProcess, _Executor_streamAppendToFile, _Executor_setupDataDirectories;
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
42
  const child_process_1 = require("child_process");
43
43
  const semver_1 = require("semver");
@@ -198,14 +198,18 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
198
198
  resolve({ error, stdout, stderr });
199
199
  });
200
200
  });
201
- }, _Executor_killProcess = async function _Executor_killProcess(process) {
201
+ }, _Executor_killProcess = async function _Executor_killProcess(childProcess) {
202
202
  // If the process has already been killed, return true
203
- if (process.kill(0) === false) {
204
- this.logger.warn('Called #killProcess to kill mysqld but it has already been killed.');
203
+ const pid = childProcess.pid;
204
+ try {
205
+ process.kill(pid, 0);
206
+ }
207
+ catch (e) {
208
+ this.logger.warn('#killProcess got called to kill mysqld but it is not running:', e);
205
209
  return true;
206
210
  }
207
211
  if (os.platform() === 'win32') {
208
- const { error, stderr } = await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_executeFile).call(this, 'taskkill', ['/pid', String(process.pid), '/t', '/f']);
212
+ const { error, stderr } = await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_executeFile).call(this, 'taskkill', ['/pid', String(pid), '/t', '/f']);
209
213
  const message = error || stderr;
210
214
  if (!message) {
211
215
  return true;
@@ -217,7 +221,7 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
217
221
  this.logger.error(message, '| Error toString:', message.toString());
218
222
  return false;
219
223
  }
220
- return process.kill('SIGKILL');
224
+ return process.kill(pid, 'SIGKILL');
221
225
  }, _Executor_returnBinaryPathToDelete = function _Executor_returnBinaryPathToDelete(binaryFilepath, options) {
222
226
  if (binaryFilepath.includes(os.tmpdir()) && !options.downloadBinaryOnce) {
223
227
  const splitPath = binaryFilepath.split(os.platform() === 'win32' ? '\\' : '/');
@@ -351,7 +355,7 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
351
355
  if (code) {
352
356
  let errorMessage = '';
353
357
  if (os.platform() === 'win32' && code === 3221225781) {
354
- errorMessage = `The MySQL database exited early with code 3221225781. A possible cause is that the Microsoft Visual C++ Redistributable Package is not installed. Please refer to the following link for this package's requirements on your system - this may help solve this error: https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.12.1/docs/SUPPORTED_MYSQL_DOWNLOADS.md#required-dependencies. If you are sure you have this installed, check the following for more details: The error log was:\n${errorLog}\nThe error string was: "${errorString}".`;
358
+ errorMessage = `The MySQL database exited early with code 3221225781. A possible cause is that the Microsoft Visual C++ Redistributable Package is not installed. Please refer to the following link for this package's requirements on your system - this may help solve this error: https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.13.0/docs/SUPPORTED_MYSQL_DOWNLOADS.md#required-dependencies. If you are sure you have this installed, check the following for more details: The error log was:\n${errorLog}\nThe error string was: "${errorString}".`;
355
359
  }
356
360
  else {
357
361
  errorMessage = `The database exited early with code ${code}. The error log was:\n${errorLog}\nThe error string was: "${errorString}".`;
@@ -414,6 +418,27 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
414
418
  }
415
419
  });
416
420
  });
421
+ }, _Executor_streamAppendToFile = function _Executor_streamAppendToFile(readPath, writePath) {
422
+ return new Promise((resolve, reject) => {
423
+ const rs = fs.createReadStream(readPath, { encoding: 'utf-8' });
424
+ const ws = fs.createWriteStream(writePath, { flags: 'a', encoding: 'utf-8' });
425
+ rs.on('error', (e) => {
426
+ ws.end();
427
+ this.logger.error('Received error from streamAppendToFile read stream:', e);
428
+ reject(e);
429
+ });
430
+ ws.on('error', (e) => {
431
+ rs.close();
432
+ this.logger.error('Received error from streamAppendToFile write stream:', e);
433
+ reject(e);
434
+ });
435
+ rs.on('end', () => {
436
+ rs.close();
437
+ ws.close();
438
+ resolve();
439
+ });
440
+ rs.pipe(ws);
441
+ });
417
442
  }, _Executor_setupDataDirectories = async function _Executor_setupDataDirectories(options, binary, datadir, retry) {
418
443
  const binaryFilepath = binary.path;
419
444
  this.logger.log('Created data directory for database at:', datadir);
@@ -532,10 +557,16 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
532
557
  initText += `\nCREATE USER '${options.username}'@'localhost';\nGRANT ALL ON *.* TO '${options.username}'@'localhost' WITH GRANT OPTION;`;
533
558
  }
534
559
  if (options.initSQLString.length > 0) {
535
- initText += `\n${options.initSQLString}`;
560
+ initText += `\n${options.initSQLString}\n`;
536
561
  }
537
562
  this.logger.log('Writing init file');
538
- await fsPromises.writeFile(`${this.databasePath}/init.sql`, initText, { encoding: 'utf8' });
563
+ const initFilePath = `${this.databasePath}/init.sql`;
564
+ await fsPromises.writeFile(initFilePath, initText, { encoding: 'utf8' });
539
565
  this.logger.log('Finished writing init file');
566
+ if (options.initSQLFilePath) {
567
+ this.logger.log('Appending init.sql file with the contents of the file at path provided by options.initSQLFilePath.');
568
+ await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_streamAppendToFile).call(this, options.initSQLFilePath, initFilePath);
569
+ this.logger.log('Successfully appended init.sql file with the contents of the file at path provided by options.initSQLFilePath.');
570
+ }
540
571
  };
541
572
  exports.default = Executor;
@@ -17,6 +17,7 @@ export type ServerOptions = {
17
17
  initSQLString?: string | undefined;
18
18
  arch?: "arm64" | "x64" | undefined;
19
19
  xEnabled?: PluginActivationState | undefined;
20
+ initSQLFilePath?: string | undefined;
20
21
  };
21
22
  export type InternalServerOptions = {
22
23
  version?: string | undefined;
@@ -34,6 +35,7 @@ export type InternalServerOptions = {
34
35
  initSQLString: string;
35
36
  arch: string;
36
37
  xEnabled: PluginActivationState;
38
+ initSQLFilePath: string;
37
39
  };
38
40
  export type ExecuteFileReturn = {
39
41
  error: ExecFileException | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql-memory-server",
3
- "version": "1.12.1",
3
+ "version": "1.13.0",
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",
@@ -27,20 +27,20 @@
27
27
  "author": "Sebastian-Webster",
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
- "@babel/core": "^7.28.0",
31
- "@babel/preset-env": "^7.28.0",
30
+ "@babel/core": "^7.28.4",
31
+ "@babel/preset-env": "^7.28.3",
32
32
  "@babel/preset-typescript": "^7.27.1",
33
33
  "@types/adm-zip": "^0.5.5",
34
- "@types/node": "^24.1.0",
35
- "@types/semver": "^7.7.0",
36
- "babel-jest": "^30.0.5",
37
- "jest": "^30.0.5",
38
- "mysql2": "^3.14.3",
39
- "typescript": "^5.9.2"
34
+ "@types/node": "^24.9.1",
35
+ "@types/semver": "^7.7.1",
36
+ "babel-jest": "^30.2.0",
37
+ "jest": "^30.2.0",
38
+ "mysql2": "^3.15.3",
39
+ "typescript": "^5.9.3"
40
40
  },
41
41
  "dependencies": {
42
42
  "adm-zip": "^0.5.16",
43
- "semver": "^7.7.2",
43
+ "semver": "^7.7.3",
44
44
  "signal-exit": "^4.1.0"
45
45
  },
46
46
  "repository": {