mysql-memory-server 1.14.0 → 1.15.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 +4 -4
- package/dist/src/TypeCheckers.d.ts +3 -0
- package/dist/src/TypeCheckers.js +11 -0
- package/dist/src/cli.js +5 -4
- package/dist/src/constants.d.ts +42 -40
- package/dist/src/constants.js +22 -18
- package/dist/src/index.js +12 -8
- package/dist/src/libraries/Downloader.js +4 -3
- package/dist/src/libraries/Executor.d.ts +4 -4
- package/dist/src/libraries/Executor.js +21 -13
- package/dist/src/libraries/FileLock.js +3 -3
- package/dist/src/libraries/Version.d.ts +1 -1
- package/dist/src/libraries/Version.js +26 -15
- package/dist/types/index.d.ts +5 -9
- package/package.json +9 -14
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.45, 8.1.0 - 8.4.
|
|
18
|
+
- ```mysql-memory-server``` can download and run MySQL versions (inclusive) 5.7.19 - 5.7.44, 8.0.0 - 8.0.45, 8.1.0 - 8.4.11, and 9.0.1 - 9.7.2 (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.
|
|
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.15.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.
|
|
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.15.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.
|
|
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.15.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.15.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
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSupportedOS = isSupportedOS;
|
|
4
|
+
exports.isValidOption = isValidOption;
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
function isSupportedOS(os) {
|
|
7
|
+
return os in constants_1.MYSQL_MIN_OS_SUPPORT;
|
|
8
|
+
}
|
|
9
|
+
function isValidOption(name) {
|
|
10
|
+
return name in constants_1.OPTION_TYPE_CHECKS;
|
|
11
|
+
}
|
package/dist/src/cli.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const index_1 = require("./index");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
|
+
const TypeCheckers_1 = require("./TypeCheckers");
|
|
6
7
|
function main() {
|
|
7
8
|
const definedOptions = process.argv.filter((option) => option.startsWith('--'));
|
|
8
9
|
const options = {};
|
|
9
10
|
process.env.mysqlmsn_internal_DO_NOT_USE_cli = 'true';
|
|
10
11
|
for (const opt of definedOptions) {
|
|
11
|
-
|
|
12
|
+
const optionName = opt.slice(2);
|
|
13
|
+
if (!(0, TypeCheckers_1.isValidOption)(optionName)) {
|
|
12
14
|
console.error(`Option ${opt} is not a valid option.`);
|
|
13
15
|
return;
|
|
14
16
|
}
|
|
@@ -18,7 +20,6 @@ function main() {
|
|
|
18
20
|
console.error(`Option ${opt} must have a value.`);
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
|
-
const optionName = opt.slice(2);
|
|
22
23
|
const optionType = constants_1.OPTION_TYPE_CHECKS[optionName].definedType;
|
|
23
24
|
//Try to convert the options to their correct types.
|
|
24
25
|
//We do not need to do any proper type validation here as the library will make sure everything is correct.
|
|
@@ -39,7 +40,7 @@ function main() {
|
|
|
39
40
|
options[optionName] = parseInt(optionValue);
|
|
40
41
|
}
|
|
41
42
|
else {
|
|
42
|
-
options[
|
|
43
|
+
options[optionName] = optionValue;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
console.log('Creating ephemeral MySQL database...');
|
|
@@ -55,6 +56,6 @@ function main() {
|
|
|
55
56
|
else {
|
|
56
57
|
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
|
}
|
|
58
|
-
});
|
|
59
|
+
}).catch(error => console.error('ERROR:', error));
|
|
59
60
|
}
|
|
60
61
|
main();
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -15,80 +15,82 @@ 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 [
|
|
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.0.45', '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', '8.4.8', '8.4.9', '8.4.10', '8.4.11', '9.0.1', '9.1.0', '9.2.0', '9.3.0', '9.4.0', '9.5.0', '9.6.0', '9.7.0', '9.7.1', '9.7.2'];
|
|
19
19
|
export declare const MYSQL_ARCH_SUPPORT: {
|
|
20
20
|
readonly darwin: {
|
|
21
|
-
readonly arm64:
|
|
22
|
-
readonly x64:
|
|
21
|
+
readonly arm64: '8.0.26 - 9.7.2';
|
|
22
|
+
readonly x64: '5.7.19 - 9.7.2';
|
|
23
23
|
};
|
|
24
24
|
readonly linux: {
|
|
25
|
-
readonly arm64:
|
|
26
|
-
readonly x64:
|
|
25
|
+
readonly arm64: '8.0.31 - 9.7.2';
|
|
26
|
+
readonly x64: '5.7.19 - 9.7.2';
|
|
27
27
|
};
|
|
28
28
|
readonly win32: {
|
|
29
|
-
readonly x64:
|
|
29
|
+
readonly x64: '5.7.19 - 9.7.2';
|
|
30
|
+
readonly arm64: '0.0.0';
|
|
30
31
|
};
|
|
31
32
|
};
|
|
32
33
|
export declare const MYSQL_MIN_OS_SUPPORT: {
|
|
33
34
|
readonly win32: {
|
|
34
|
-
readonly x:
|
|
35
|
+
readonly x: '0.0.0';
|
|
35
36
|
};
|
|
36
37
|
readonly linux: {
|
|
37
|
-
readonly x:
|
|
38
|
+
readonly x: '0.0.0';
|
|
38
39
|
};
|
|
39
40
|
readonly darwin: {
|
|
40
|
-
readonly '5.7.19 - 5.7.23 || 8.0.1 - 8.0.3 || 8.0.11 - 8.0.12':
|
|
41
|
-
readonly '5.7.24 - 5.7.29 || 8.0.4 || 8.0.13 - 8.0.18':
|
|
42
|
-
readonly '5.7.30 - 5.7.31 || 8.0.19 - 8.0.22':
|
|
43
|
-
readonly '8.0.0':
|
|
44
|
-
readonly '8.0.23 - 8.0.27':
|
|
45
|
-
readonly '8.0.28 - 8.0.31':
|
|
46
|
-
readonly '8.0.32 - 8.0.34':
|
|
47
|
-
readonly '8.0.35 - 8.0.39 || 8.1.0 - 8.4.2 || 9.0.1':
|
|
48
|
-
readonly '8.0.40 - 8.0.45 || 8.4.3 - 8.4.
|
|
41
|
+
readonly '5.7.19 - 5.7.23 || 8.0.1 - 8.0.3 || 8.0.11 - 8.0.12': '16.0.0';
|
|
42
|
+
readonly '5.7.24 - 5.7.29 || 8.0.4 || 8.0.13 - 8.0.18': '17.0.0';
|
|
43
|
+
readonly '5.7.30 - 5.7.31 || 8.0.19 - 8.0.22': '18.0.0';
|
|
44
|
+
readonly '8.0.0': '13.0.0';
|
|
45
|
+
readonly '8.0.23 - 8.0.27': '19.0.0';
|
|
46
|
+
readonly '8.0.28 - 8.0.31': '20.0.0';
|
|
47
|
+
readonly '8.0.32 - 8.0.34': '21.0.0';
|
|
48
|
+
readonly '8.0.35 - 8.0.39 || 8.1.0 - 8.4.2 || 9.0.1': '22.0.0';
|
|
49
|
+
readonly '8.0.40 - 8.0.45 || 8.4.3 - 8.4.11 || 9.1.0 - 9.7.2': '23.0.0';
|
|
49
50
|
};
|
|
50
51
|
};
|
|
51
52
|
export declare const DMR_MYSQL_VERSIONS = "8.0.0 - 8.0.2";
|
|
52
53
|
export declare const RC_MYSQL_VERSIONS = "8.0.3 - 8.0.4";
|
|
53
54
|
export declare const MYSQL_MACOS_VERSIONS_IN_FILENAME: {
|
|
54
|
-
readonly '5.7.19 - 5.7.20 || 8.0.1 - 8.0.3':
|
|
55
|
-
readonly '5.7.21 - 5.7.23 || 8.0.4 - 8.0.12':
|
|
56
|
-
readonly '5.7.24 - 5.7.31 || 8.0.13 - 8.0.18':
|
|
57
|
-
readonly '8.0.0':
|
|
58
|
-
readonly '8.0.19 - 8.0.23':
|
|
59
|
-
readonly '8.0.24 - 8.0.28':
|
|
60
|
-
readonly '8.0.30 - 8.0.31':
|
|
61
|
-
readonly '8.0.32 - 8.0.35 || 8.1.0 - 8.2.0':
|
|
62
|
-
readonly '8.0.36 - 8.0.40 || 8.3.0 - 8.4.3 || 9.0.1 - 9.1.0':
|
|
63
|
-
readonly '8.0.41 - 8.0.45 || 8.4.4 - 8.4.
|
|
55
|
+
readonly '5.7.19 - 5.7.20 || 8.0.1 - 8.0.3': 'macos10.12';
|
|
56
|
+
readonly '5.7.21 - 5.7.23 || 8.0.4 - 8.0.12': 'macos10.13';
|
|
57
|
+
readonly '5.7.24 - 5.7.31 || 8.0.13 - 8.0.18': 'macos10.14';
|
|
58
|
+
readonly '8.0.0': 'osx10.11';
|
|
59
|
+
readonly '8.0.19 - 8.0.23': 'macos10.15';
|
|
60
|
+
readonly '8.0.24 - 8.0.28': 'macos11';
|
|
61
|
+
readonly '8.0.30 - 8.0.31': 'macos12';
|
|
62
|
+
readonly '8.0.32 - 8.0.35 || 8.1.0 - 8.2.0': 'macos13';
|
|
63
|
+
readonly '8.0.36 - 8.0.40 || 8.3.0 - 8.4.3 || 9.0.1 - 9.1.0': 'macos14';
|
|
64
|
+
readonly '8.0.41 - 8.0.45 || 8.4.4 - 8.4.11 || 9.2.0 - 9.7.2': 'macos15';
|
|
64
65
|
};
|
|
65
66
|
export declare const MYSQL_LINUX_GLIBC_VERSIONS: {
|
|
66
67
|
readonly x64: {
|
|
67
|
-
readonly '5.7.19 - 8.0.20':
|
|
68
|
-
readonly '8.0.21 - 9.5.0':
|
|
69
|
-
readonly '9.6.0':
|
|
68
|
+
readonly '5.7.19 - 8.0.20': '2.12';
|
|
69
|
+
readonly '8.0.21 - 8.4.10 || 9.0.1 - 9.5.0': '2.17';
|
|
70
|
+
readonly '8.4.11 || 9.6.0 - 9.7.2': '2.28';
|
|
70
71
|
};
|
|
71
72
|
readonly arm64: {
|
|
72
|
-
readonly '5.7.19 - 8.0.20':
|
|
73
|
-
readonly '8.0.21 - 8.0.41 || 8.1.0 - 8.4.4 || 9.0.1 - 9.2.0':
|
|
74
|
-
readonly '8.0.42 - 8.0.45 || 8.4.5 - 8.4.
|
|
73
|
+
readonly '5.7.19 - 8.0.20': '2.12';
|
|
74
|
+
readonly '8.0.21 - 8.0.41 || 8.1.0 - 8.4.4 || 9.0.1 - 9.2.0': '2.17';
|
|
75
|
+
readonly '8.0.42 - 8.0.45 || 8.4.5 - 8.4.11 || 9.3.0 - 9.7.2': '2.28';
|
|
75
76
|
};
|
|
76
77
|
};
|
|
77
78
|
export declare const MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE: {
|
|
78
|
-
readonly '5.7.19 - 8.0.15':
|
|
79
|
-
readonly '8.0.16 - 8.0.20':
|
|
80
|
-
readonly '8.0.21 - 9.
|
|
79
|
+
readonly '5.7.19 - 8.0.15': 'no';
|
|
80
|
+
readonly '8.0.16 - 8.0.20': 'no-glibc-tag';
|
|
81
|
+
readonly '8.0.21 - 9.7.2': 'glibc-tag';
|
|
81
82
|
};
|
|
82
83
|
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";
|
|
83
84
|
export declare const MYSQL_LINUX_FILE_EXTENSIONS: {
|
|
84
85
|
readonly x64: {
|
|
85
|
-
readonly '5.7.19 - 8.0.11':
|
|
86
|
-
readonly '8.0.12 - 9.
|
|
86
|
+
readonly '5.7.19 - 8.0.11': 'gz';
|
|
87
|
+
readonly '8.0.12 - 9.7.2': 'xz';
|
|
87
88
|
};
|
|
88
89
|
readonly arm64: {
|
|
89
|
-
readonly '8.0.31 - 8.0.32':
|
|
90
|
-
readonly '8.0.33 - 9.
|
|
90
|
+
readonly '8.0.31 - 8.0.32': 'gz';
|
|
91
|
+
readonly '8.0.33 - 9.7.2': 'xz';
|
|
91
92
|
};
|
|
92
93
|
};
|
|
93
94
|
export declare const MYSQL_LINUX_MINIMAL_REBUILD_VERSIONS = "8.0.26";
|
|
95
|
+
export declare const MYSQL_ALPINE_VERSION_RANGE = "8.4.0 - 8.4.11 || 9.0.1 - 9.6.0";
|
|
94
96
|
export {};
|
package/dist/src/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.MYSQL_ALPINE_VERSION_RANGE = 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
6
|
const fs_1 = require("fs");
|
|
@@ -18,7 +18,7 @@ exports.DEFAULT_OPTIONS = {
|
|
|
18
18
|
xPort: 0,
|
|
19
19
|
downloadRetries: 10,
|
|
20
20
|
initSQLString: '',
|
|
21
|
-
arch: process.arch,
|
|
21
|
+
arch: process.arch === 'arm64' ? 'arm64' : process.arch === 'x64' ? 'x64' : 'unsupported',
|
|
22
22
|
xEnabled: 'FORCE',
|
|
23
23
|
initSQLFilePath: ''
|
|
24
24
|
};
|
|
@@ -111,7 +111,7 @@ exports.OPTION_TYPE_CHECKS = {
|
|
|
111
111
|
xEnabled: {
|
|
112
112
|
check: (opt) => opt === undefined || pluginActivationStates.includes(opt),
|
|
113
113
|
errorMessage: `xEnabled must be either undefined or one of the following: ${pluginActivationStates.join(', ')}`,
|
|
114
|
-
definedType: '
|
|
114
|
+
definedType: 'string'
|
|
115
115
|
},
|
|
116
116
|
initSQLFilePath: {
|
|
117
117
|
check: (opt) => opt === undefined || (typeof opt === 'string' && (0, fs_1.existsSync)(opt)),
|
|
@@ -128,20 +128,22 @@ exports.DOWNLOADABLE_MYSQL_VERSIONS = [
|
|
|
128
128
|
'8.0.0', '8.0.1', '8.0.2', '8.0.3', '8.0.4',
|
|
129
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', '8.0.45',
|
|
130
130
|
'8.1.0', '8.2.0', '8.3.0',
|
|
131
|
-
'8.4.0', '8.4.2', '8.4.3', '8.4.4', '8.4.5', '8.4.6', '8.4.7', '8.4.8',
|
|
132
|
-
'9.0.1', '9.1.0', '9.2.0', '9.3.0', '9.4.0', '9.5.0', '9.6.0'
|
|
131
|
+
'8.4.0', '8.4.2', '8.4.3', '8.4.4', '8.4.5', '8.4.6', '8.4.7', '8.4.8', '8.4.9', '8.4.10', '8.4.11',
|
|
132
|
+
'9.0.1', '9.1.0', '9.2.0', '9.3.0', '9.4.0', '9.5.0', '9.6.0',
|
|
133
|
+
'9.7.0', '9.7.1', '9.7.2'
|
|
133
134
|
];
|
|
134
135
|
exports.MYSQL_ARCH_SUPPORT = {
|
|
135
136
|
darwin: {
|
|
136
|
-
arm64: '8.0.26 - 9.
|
|
137
|
-
x64: '5.7.19 - 9.
|
|
137
|
+
arm64: '8.0.26 - 9.7.2',
|
|
138
|
+
x64: '5.7.19 - 9.7.2'
|
|
138
139
|
},
|
|
139
140
|
linux: {
|
|
140
|
-
arm64: '8.0.31 - 9.
|
|
141
|
-
x64: '5.7.19 - 9.
|
|
141
|
+
arm64: '8.0.31 - 9.7.2',
|
|
142
|
+
x64: '5.7.19 - 9.7.2'
|
|
142
143
|
},
|
|
143
144
|
win32: {
|
|
144
|
-
x64: '5.7.19 - 9.
|
|
145
|
+
x64: '5.7.19 - 9.7.2',
|
|
146
|
+
arm64: '0.0.0' // There aren't any arm64 MySQL binaries for Windows on ARM provided by Oracle. As a result, this is set to 0.0.0 to indicate no support for arm64 on win32.
|
|
145
147
|
}
|
|
146
148
|
};
|
|
147
149
|
exports.MYSQL_MIN_OS_SUPPORT = {
|
|
@@ -161,7 +163,7 @@ exports.MYSQL_MIN_OS_SUPPORT = {
|
|
|
161
163
|
'8.0.28 - 8.0.31': '20.0.0',
|
|
162
164
|
'8.0.32 - 8.0.34': '21.0.0',
|
|
163
165
|
'8.0.35 - 8.0.39 || 8.1.0 - 8.4.2 || 9.0.1': '22.0.0',
|
|
164
|
-
'8.0.40 - 8.0.45 || 8.4.3 - 8.4.
|
|
166
|
+
'8.0.40 - 8.0.45 || 8.4.3 - 8.4.11 || 9.1.0 - 9.7.2': '23.0.0'
|
|
165
167
|
}
|
|
166
168
|
};
|
|
167
169
|
exports.DMR_MYSQL_VERSIONS = '8.0.0 - 8.0.2';
|
|
@@ -176,7 +178,7 @@ exports.MYSQL_MACOS_VERSIONS_IN_FILENAME = {
|
|
|
176
178
|
'8.0.30 - 8.0.31': 'macos12',
|
|
177
179
|
'8.0.32 - 8.0.35 || 8.1.0 - 8.2.0': 'macos13',
|
|
178
180
|
'8.0.36 - 8.0.40 || 8.3.0 - 8.4.3 || 9.0.1 - 9.1.0': 'macos14',
|
|
179
|
-
'8.0.41 - 8.0.45 || 8.4.4 - 8.4.
|
|
181
|
+
'8.0.41 - 8.0.45 || 8.4.4 - 8.4.11 || 9.2.0 - 9.7.2': 'macos15'
|
|
180
182
|
};
|
|
181
183
|
exports.MYSQL_LINUX_GLIBC_VERSIONS = {
|
|
182
184
|
//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.
|
|
@@ -185,29 +187,31 @@ exports.MYSQL_LINUX_GLIBC_VERSIONS = {
|
|
|
185
187
|
//Neither glibc versions for the above MySQL versions have an arm64 minimal install.
|
|
186
188
|
x64: {
|
|
187
189
|
'5.7.19 - 8.0.20': '2.12',
|
|
188
|
-
'8.0.21 - 9.5.0': '2.17',
|
|
189
|
-
'9.6.0': '2.28'
|
|
190
|
+
'8.0.21 - 8.4.10 || 9.0.1 - 9.5.0': '2.17',
|
|
191
|
+
'8.4.11 || 9.6.0 - 9.7.2': '2.28'
|
|
190
192
|
},
|
|
191
193
|
arm64: {
|
|
192
194
|
'5.7.19 - 8.0.20': '2.12',
|
|
193
195
|
'8.0.21 - 8.0.41 || 8.1.0 - 8.4.4 || 9.0.1 - 9.2.0': '2.17',
|
|
194
|
-
'8.0.42 - 8.0.45 || 8.4.5 - 8.4.
|
|
196
|
+
'8.0.42 - 8.0.45 || 8.4.5 - 8.4.11 || 9.3.0 - 9.7.2': '2.28'
|
|
195
197
|
}
|
|
196
198
|
};
|
|
197
199
|
exports.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE = {
|
|
198
200
|
'5.7.19 - 8.0.15': 'no',
|
|
199
201
|
'8.0.16 - 8.0.20': 'no-glibc-tag',
|
|
200
|
-
'8.0.21 - 9.
|
|
202
|
+
'8.0.21 - 9.7.2': 'glibc-tag'
|
|
201
203
|
};
|
|
202
204
|
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
|
|
203
205
|
exports.MYSQL_LINUX_FILE_EXTENSIONS = {
|
|
204
206
|
x64: {
|
|
205
207
|
'5.7.19 - 8.0.11': 'gz',
|
|
206
|
-
'8.0.12 - 9.
|
|
208
|
+
'8.0.12 - 9.7.2': 'xz'
|
|
207
209
|
},
|
|
208
210
|
arm64: {
|
|
209
211
|
'8.0.31 - 8.0.32': 'gz',
|
|
210
|
-
'8.0.33 - 9.
|
|
212
|
+
'8.0.33 - 9.7.2': 'xz'
|
|
211
213
|
}
|
|
212
214
|
};
|
|
213
215
|
exports.MYSQL_LINUX_MINIMAL_REBUILD_VERSIONS = '8.0.26';
|
|
216
|
+
//https://github.com/Sebastian-Webster/mysql-server-musl-binaries only has support for v8.4.x (up to 8.4.11) and 9.x (excluding 9.7.x, up to 9.6.0) binaries
|
|
217
|
+
exports.MYSQL_ALPINE_VERSION_RANGE = '8.4.0 - 8.4.11 || 9.0.1 - 9.6.0';
|
package/dist/src/index.js
CHANGED
|
@@ -13,20 +13,24 @@ const constants_1 = require("./constants");
|
|
|
13
13
|
const LinuxOSRelease_1 = __importDefault(require("./libraries/LinuxOSRelease"));
|
|
14
14
|
async function createDB(opts) {
|
|
15
15
|
const suppliedOpts = opts || {};
|
|
16
|
-
const suppliedOptsKeys = Object.keys(suppliedOpts);
|
|
17
16
|
const options = { ...constants_1.DEFAULT_OPTIONS };
|
|
18
|
-
for (const opt
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
for (const opt in suppliedOpts) {
|
|
18
|
+
const optKey = opt;
|
|
19
|
+
const optValue = suppliedOpts[optKey];
|
|
20
|
+
if (!constants_1.DEFAULT_OPTIONS_KEYS.includes(optKey)) {
|
|
21
|
+
throw `Option ${optKey} is not a valid option.`;
|
|
21
22
|
}
|
|
22
|
-
if (!constants_1.OPTION_TYPE_CHECKS[
|
|
23
|
+
if (!constants_1.OPTION_TYPE_CHECKS[optKey].check(suppliedOpts[optKey])) {
|
|
23
24
|
//Supplied option failed the check
|
|
24
|
-
throw `${constants_1.OPTION_TYPE_CHECKS[
|
|
25
|
+
throw `${constants_1.OPTION_TYPE_CHECKS[optKey].errorMessage} | Received value: ${optValue} (type: ${typeof optValue})`;
|
|
25
26
|
}
|
|
26
|
-
if (
|
|
27
|
-
options[
|
|
27
|
+
if (optValue !== undefined) {
|
|
28
|
+
options[optKey] = optValue;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
31
|
+
if (options.arch === 'unsupported') {
|
|
32
|
+
throw "mysql-memory-server can only execute arm64 and x64 versions of MySQL. Your CPU architecture has been detected as one that isn't either one of those. If that is wrong, please report a bug on GitHub. If you would like to forcefully execute an arm64 or x64 MySQL binary on this system even when your CPU architecture isn't one of those, please refer to the documentation for the 'options.arch' option to set the binary architecture to execute.";
|
|
33
|
+
}
|
|
30
34
|
const logger = new Logger_1.default(options.logLevel);
|
|
31
35
|
const executor = new Executor_1.default(logger);
|
|
32
36
|
const version = await executor.getMySQLVersion(options.version);
|
|
@@ -253,6 +253,7 @@ function extractBinary(url, archiveLocation, extractedLocation, binaryInfo, logg
|
|
|
253
253
|
}
|
|
254
254
|
function downloadBinary(binaryInfo, options, logger) {
|
|
255
255
|
return new Promise(async (resolve, reject) => {
|
|
256
|
+
logger.log('Downloading binary with BinaryInfo object:', binaryInfo);
|
|
256
257
|
const { url, version } = binaryInfo;
|
|
257
258
|
const dirpath = `${os_1.default.tmpdir()}/mysqlmsn/binaries`;
|
|
258
259
|
logger.log('Binary path:', dirpath);
|
|
@@ -316,7 +317,7 @@ function downloadBinary(binaryInfo, options, logger) {
|
|
|
316
317
|
}
|
|
317
318
|
// If we got a 404 error while downloading a binary from Oracle and have not retried with the Downloads URL yet
|
|
318
319
|
// then retry with the Downloads URL. Otherwise, reject.
|
|
319
|
-
if (e
|
|
320
|
+
if (typeof e === 'string' && e.includes('status code 404')) {
|
|
320
321
|
if (binaryInfo.hostedByOracle && useDownloadsURL === false) {
|
|
321
322
|
useDownloadsURL = true;
|
|
322
323
|
downloadTries--;
|
|
@@ -342,7 +343,7 @@ function downloadBinary(binaryInfo, options, logger) {
|
|
|
342
343
|
catch (e) {
|
|
343
344
|
logger.error('An error occurred while releasing lock after downloadRetries exhaustion. The error was:', e);
|
|
344
345
|
}
|
|
345
|
-
logger.error(
|
|
346
|
+
logger.error(`downloadRetries have been exceeded for download from URL ${downloadURL}. Aborting download.`);
|
|
346
347
|
return reject(e);
|
|
347
348
|
}
|
|
348
349
|
else {
|
|
@@ -390,7 +391,7 @@ function downloadBinary(binaryInfo, options, logger) {
|
|
|
390
391
|
}
|
|
391
392
|
// If we got a 404 error while downloading a binary from Oracle and have not retried with the Downloads URL yet
|
|
392
393
|
// then retry with the Downloads URL. Otherwise, reject.
|
|
393
|
-
if (e
|
|
394
|
+
if (typeof e === 'string' && e.includes('status code 404')) {
|
|
394
395
|
if (binaryInfo.hostedByOracle && useDownloadsURL === false) {
|
|
395
396
|
useDownloadsURL = true;
|
|
396
397
|
downloadTries--;
|
|
@@ -4,12 +4,12 @@ declare class Executor {
|
|
|
4
4
|
#private;
|
|
5
5
|
logger: Logger;
|
|
6
6
|
DBDestroySignal: AbortController;
|
|
7
|
-
|
|
7
|
+
killedFromPortIssue: boolean;
|
|
8
|
+
databasePath: string;
|
|
9
|
+
versionSupportsMySQLX: boolean;
|
|
8
10
|
version: string;
|
|
9
11
|
versionInstalledOnSystem: boolean;
|
|
10
|
-
|
|
11
|
-
databasePath: string;
|
|
12
|
-
killedFromPortIssue: boolean;
|
|
12
|
+
removeExitHandler: () => void;
|
|
13
13
|
constructor(logger: Logger);
|
|
14
14
|
getMySQLVersion(preferredVersion?: string): Promise<DownloadedMySQLVersion | null>;
|
|
15
15
|
startMySQL(options: InternalServerOptions, installedMySQLBinary: DownloadedMySQLVersion): Promise<MySQLDB>;
|
|
@@ -55,6 +55,12 @@ class Executor {
|
|
|
55
55
|
constructor(logger) {
|
|
56
56
|
_Executor_instances.add(this);
|
|
57
57
|
this.DBDestroySignal = new AbortController();
|
|
58
|
+
this.killedFromPortIssue = false;
|
|
59
|
+
this.databasePath = ''; // This is a placeholder value and gets set to the correct value in startMySQL().
|
|
60
|
+
this.versionSupportsMySQLX = true; // This value gets changed in startMySQL() if the version does not support MySQLX.
|
|
61
|
+
this.version = ''; // This is a placeholder value and gets set to the correct value in startMySQL().
|
|
62
|
+
this.versionInstalledOnSystem = true; // This value gets changed in startMySQL() to false if the version is not installed on the system.
|
|
63
|
+
this.removeExitHandler = () => { }; // This field contains a placeholder function and the real function gets set in startMySQL().
|
|
58
64
|
this.logger = logger;
|
|
59
65
|
}
|
|
60
66
|
getMySQLVersion(preferredVersion) {
|
|
@@ -185,11 +191,9 @@ class Executor {
|
|
|
185
191
|
if (retries <= options.portRetries) {
|
|
186
192
|
this.logger.warn(`Tried a port that is already in use. Now retrying... ${retries}/${options.portRetries} possible retries.`);
|
|
187
193
|
}
|
|
188
|
-
else {
|
|
189
|
-
throw `The port has been retried ${options.portRetries} times and a free port could not be found.\nEither try again, or if this is a common issue, increase options.portRetries.`;
|
|
190
|
-
}
|
|
191
194
|
}
|
|
192
195
|
} while (retries <= options.portRetries);
|
|
196
|
+
throw `The port has been retried ${options.portRetries} times and a free port could not be found.\nEither try again, or if this is a common issue, increase options.portRetries.`;
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
199
|
_Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_executeFile(command, args) {
|
|
@@ -201,6 +205,10 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
|
|
|
201
205
|
}, _Executor_killProcess = async function _Executor_killProcess(childProcess) {
|
|
202
206
|
// If the process has already been killed, return true
|
|
203
207
|
const pid = childProcess.pid;
|
|
208
|
+
if (pid === undefined) {
|
|
209
|
+
// According to https://nodejs.org/api/child_process.html#subprocesspid, if pid is undefined, the process failed to spawn, and thus we can return true as it is not running.
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
204
212
|
try {
|
|
205
213
|
process.kill(pid, 0);
|
|
206
214
|
}
|
|
@@ -355,7 +363,7 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
|
|
|
355
363
|
if (code) {
|
|
356
364
|
let errorMessage = '';
|
|
357
365
|
if (os.platform() === 'win32' && code === 3221225781) {
|
|
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.
|
|
366
|
+
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.15.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}".`;
|
|
359
367
|
}
|
|
360
368
|
else {
|
|
361
369
|
errorMessage = `The database exited early with code ${code}. The error log was:\n${errorLog}\nThe error string was: "${errorString}".`;
|
|
@@ -459,21 +467,21 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
|
|
|
459
467
|
throw 'Tried to copy libaio into lib folder and MySQL is still failing to initialize. Please check the console for more information.';
|
|
460
468
|
}
|
|
461
469
|
if (binary.installedOnSystem) {
|
|
462
|
-
throw 'libaio could not be found while running system-installed MySQL. libaio must be installed on this system for MySQL to run. To learn more, please check out https://
|
|
470
|
+
throw 'libaio could not be found while running system-installed MySQL. libaio must be installed on this system for MySQL to run. To learn more, please check out https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.15.0/docs/SUPPORTED_MYSQL_DOWNLOADS.md#required-dependencies';
|
|
463
471
|
}
|
|
464
472
|
// If the below code is running, the version of MySQL that is trying to be executed was downloaded from the CDN by this package and libaio has not yet been attempted to be copied
|
|
465
|
-
if (LinuxOSRelease_1.default.NAME === 'Ubuntu' && LinuxOSRelease_1.default.VERSION_ID >= '24.04') {
|
|
473
|
+
if (LinuxOSRelease_1.default.NAME === 'Ubuntu' && typeof LinuxOSRelease_1.default.VERSION_ID === 'string' && LinuxOSRelease_1.default.VERSION_ID >= '24.04') {
|
|
466
474
|
const { error: lderror, stdout, stderr: ldstderr } = await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_executeFile).call(this, 'ldconfig', ['-p']);
|
|
467
475
|
if (lderror || ldstderr) {
|
|
468
476
|
this.logger.error('The following libaio error occurred:', stderr);
|
|
469
477
|
this.logger.error('After the libaio error, an ldconfig error occurred:', lderror || ldstderr);
|
|
470
|
-
throw 'The ldconfig command failed to run. This command was ran to find libaio1t64 because libaio1t64 could not be found on the system. libaio1t64 is needed for MySQL to run. Do you have ldconfig and libaio1t64 installed? Learn more at https://
|
|
478
|
+
throw 'The ldconfig command failed to run. This command was ran to find libaio1t64 because libaio1t64 could not be found on the system. libaio1t64 is needed for MySQL to run. Do you have ldconfig and libaio1t64 installed? Learn more at https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.15.0/docs/SUPPORTED_MYSQL_DOWNLOADS.md#required-dependencies';
|
|
471
479
|
}
|
|
472
480
|
const libaioFound = stdout.split('\n').filter(lib => lib.includes('libaio.so.1t64'));
|
|
473
481
|
if (!libaioFound.length) {
|
|
474
482
|
this.logger.error('Error from launching MySQL:', stderr);
|
|
475
483
|
this.logger.error('Could not find libaio1t64 in this list:', libaioFound);
|
|
476
|
-
throw 'An error occurred while launching MySQL because libaio1t64 is not installed on your system. Please install libaio1t64 and then use mysql-memory-server again. To learn more, please check out https://
|
|
484
|
+
throw 'An error occurred while launching MySQL because libaio1t64 is not installed on your system. Please install libaio1t64 and then use mysql-memory-server again. To learn more, please check out https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.15.0/docs/SUPPORTED_MYSQL_DOWNLOADS.md#required-dependencies. Check error in console for more information.';
|
|
477
485
|
}
|
|
478
486
|
const libaioEntry = libaioFound[0];
|
|
479
487
|
const libaioPathIndex = libaioEntry.indexOf('=>');
|
|
@@ -486,7 +494,7 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
|
|
|
486
494
|
else {
|
|
487
495
|
copyPath = (0, path_1.resolve)(`${binaryFilepath}/../../lib/private/libaio.so.1`);
|
|
488
496
|
}
|
|
489
|
-
let lockRelease;
|
|
497
|
+
let lockRelease = undefined;
|
|
490
498
|
while (true) {
|
|
491
499
|
try {
|
|
492
500
|
lockRelease = await (0, FileLock_1.lockFile)(copyPath);
|
|
@@ -515,12 +523,12 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
|
|
|
515
523
|
//If the lock was already acquired by some other process, this process would have already waited for the lock, so no copying needs to be done since it's already happened.
|
|
516
524
|
//If the lock failed to acquire for some other reason, the error would've already been thrown.
|
|
517
525
|
this.logger.log('libaio copy path:', copyPath, '| libaio symlink path:', libaioSymlinkPath, '| libaio actual path:', libaioPath);
|
|
518
|
-
let
|
|
526
|
+
let copyErrorOccurred = false;
|
|
519
527
|
try {
|
|
520
528
|
await fsPromises.copyFile(libaioPath, copyPath);
|
|
521
529
|
}
|
|
522
530
|
catch (e) {
|
|
523
|
-
|
|
531
|
+
copyErrorOccurred = true;
|
|
524
532
|
this.logger.error('An error occurred while copying libaio1t64 to lib folder:', e);
|
|
525
533
|
try {
|
|
526
534
|
await fsPromises.rm(copyPath, { force: true });
|
|
@@ -536,7 +544,7 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
|
|
|
536
544
|
catch (e) {
|
|
537
545
|
this.logger.error('Error unlocking libaio file:', e);
|
|
538
546
|
}
|
|
539
|
-
if (
|
|
547
|
+
if (copyErrorOccurred) {
|
|
540
548
|
throw 'An error occurred while copying libaio1t64 to the MySQL lib folder. Please check the console for more details.';
|
|
541
549
|
}
|
|
542
550
|
}
|
|
@@ -547,7 +555,7 @@ _Executor_instances = new WeakSet(), _Executor_executeFile = function _Executor_
|
|
|
547
555
|
await __classPrivateFieldGet(this, _Executor_instances, "m", _Executor_setupDataDirectories).call(this, options, binary, datadir, false);
|
|
548
556
|
return;
|
|
549
557
|
}
|
|
550
|
-
throw 'You do not have libaio1 installed. Please install the libaio1 package for the downloaded MySQL binary to run. Learn more here: https://
|
|
558
|
+
throw 'You do not have libaio1 installed. Please install the libaio1 package for the downloaded MySQL binary to run. Learn more here: https://github.com/Sebastian-Webster/mysql-memory-server-nodejs/blob/v1.15.0/docs/SUPPORTED_MYSQL_DOWNLOADS.md#required-dependencies';
|
|
551
559
|
}
|
|
552
560
|
throw stderr;
|
|
553
561
|
}
|
|
@@ -23,7 +23,7 @@ async function waitForLock(path, options) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
catch (e) {
|
|
26
|
-
if (e
|
|
26
|
+
if (e?.code === 'ENOENT') {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
@@ -53,7 +53,7 @@ async function lockFile(path) {
|
|
|
53
53
|
return setupMTimeEditor(lockPath);
|
|
54
54
|
}
|
|
55
55
|
catch (e) {
|
|
56
|
-
if (e
|
|
56
|
+
if (e?.code === 'EEXIST') {
|
|
57
57
|
try {
|
|
58
58
|
const stat = await promises_1.default.stat(lockPath);
|
|
59
59
|
if (Date.now() - stat.mtime.getTime() > mtimeLimit) {
|
|
@@ -64,7 +64,7 @@ async function lockFile(path) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
catch (e) {
|
|
67
|
-
if (e
|
|
67
|
+
if (e?.code === 'ENOENT') {
|
|
68
68
|
//This will run if the lock gets released after the EEXIST error is thrown but before the stat is checked.
|
|
69
69
|
//If this is the case, the lock acquisition should be retried.
|
|
70
70
|
return await lockFile(path);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { BinaryInfo } from "../../types";
|
|
2
|
-
export default function getBinaryURL(versionToGet: string, currentArch:
|
|
2
|
+
export default function getBinaryURL(versionToGet: string | undefined, currentArch: "arm64" | "x64"): BinaryInfo;
|
|
@@ -38,15 +38,16 @@ const os = __importStar(require("os"));
|
|
|
38
38
|
const semver_1 = require("semver");
|
|
39
39
|
const constants_1 = require("../constants");
|
|
40
40
|
const LinuxOSRelease_1 = __importStar(require("./LinuxOSRelease"));
|
|
41
|
+
const TypeCheckers_1 = require("../TypeCheckers");
|
|
41
42
|
function getBinaryURL(versionToGet = "x", currentArch) {
|
|
42
43
|
let selectedVersions = constants_1.DOWNLOADABLE_MYSQL_VERSIONS.filter(version => (0, semver_1.satisfies)(version, versionToGet));
|
|
43
44
|
if (selectedVersions.length === 0) {
|
|
44
45
|
throw `mysql-memory-server does not support downloading a version of MySQL that fits the following version requirement: ${versionToGet}. This package only supports downloads of MySQL for MySQL >= ${constants_1.DOWNLOADABLE_MYSQL_VERSIONS[0]} <= ${constants_1.DOWNLOADABLE_MYSQL_VERSIONS[constants_1.DOWNLOADABLE_MYSQL_VERSIONS.length - 1]}. Please check for typos, choose a different version of MySQL to use, or make an issue or pull request on GitHub if you belive this is a bug.`;
|
|
45
46
|
}
|
|
46
47
|
const currentOS = os.platform();
|
|
47
|
-
|
|
48
|
-
if (!OSVersionSupport)
|
|
48
|
+
if (!(0, TypeCheckers_1.isSupportedOS)(currentOS))
|
|
49
49
|
throw `MySQL and/or mysql-memory-server does not support your operating system. Please make sure you are running the latest version of mysql-memory-server or try running on a different operating system or report an issue on GitHub if you believe this is a bug.`;
|
|
50
|
+
const OSVersionSupport = constants_1.MYSQL_MIN_OS_SUPPORT[currentOS];
|
|
50
51
|
const OSSupportVersionRanges = Object.keys(OSVersionSupport);
|
|
51
52
|
selectedVersions = selectedVersions.filter(possibleVersion => {
|
|
52
53
|
const OSKey = OSSupportVersionRanges.find(item => (0, semver_1.satisfies)(possibleVersion, item));
|
|
@@ -56,19 +57,21 @@ function getBinaryURL(versionToGet = "x", currentArch) {
|
|
|
56
57
|
throw `No version of MySQL could be found that supports your operating system and fits the following version requirement: ${versionToGet}. Please check for typos, choose a different version of MySQL to run, or if you think this is a bug, please report this on GitHub.`;
|
|
57
58
|
}
|
|
58
59
|
const archSupport = constants_1.MYSQL_ARCH_SUPPORT[currentOS][currentArch];
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
throw 'mysql-memory-server has detected you are running Windows on ARM. MySQL does not support Windows on ARM. To get this package working, please try setting the "arch" option to "x64".';
|
|
62
|
-
throw `MySQL and/or mysql-memory-server does not support the CPU architecture you want to use (${currentArch}). Please make sure you are using the latest version of mysql-memory-server or try using a different architecture, or if you believe this is a bug, please report this on GitHub.`;
|
|
63
|
-
}
|
|
60
|
+
if (currentOS === 'win32' && currentArch === 'arm64')
|
|
61
|
+
throw 'mysql-memory-server has detected you are running Windows on ARM. MySQL does not support Windows on ARM. To get this package working, please try setting the "arch" option to "x64" to run the x64 version of MySQL instead.';
|
|
64
62
|
selectedVersions = selectedVersions.filter(possibleVersion => (0, semver_1.satisfies)(possibleVersion, archSupport));
|
|
65
63
|
if (selectedVersions.length === 0) {
|
|
66
|
-
throw `No version of MySQL could be found that supports the CPU architecture ${currentArch === os.arch() ? 'for your system' : 'you have chosen'} (${currentArch}). Please try choosing a different version of MySQL, or if you believe this is a bug, please report this on GitHub.`;
|
|
64
|
+
throw `No version of MySQL could be found that is version "${versionToGet}" and supports the CPU architecture ${currentArch === os.arch() ? 'for your system' : 'you have chosen'} (${currentArch}). Please try choosing a different version of MySQL, or if you believe this is a bug, please report this on GitHub.`;
|
|
67
65
|
}
|
|
68
66
|
const versionsBeforeOSVersionCheck = selectedVersions.slice();
|
|
69
67
|
const coercedOSRelease = (0, semver_1.coerce)(os.release());
|
|
68
|
+
if (coercedOSRelease === null) {
|
|
69
|
+
throw 'Your OS version could not be coerced to SemVer. Please report this as a bug on GitHub.';
|
|
70
|
+
}
|
|
70
71
|
selectedVersions = selectedVersions.filter(possibleVersion => {
|
|
71
72
|
const OSVersionKey = OSSupportVersionRanges.find(item => (0, semver_1.satisfies)(possibleVersion, item));
|
|
73
|
+
if (OSVersionKey === undefined)
|
|
74
|
+
return false;
|
|
72
75
|
return !(0, semver_1.lt)(coercedOSRelease, OSVersionSupport[OSVersionKey]);
|
|
73
76
|
});
|
|
74
77
|
if (selectedVersions.length === 0) {
|
|
@@ -83,7 +86,7 @@ function getBinaryURL(versionToGet = "x", currentArch) {
|
|
|
83
86
|
throw `Your operating system is too out of date to run a version of MySQL that fits the following requirement: ${versionToGet}. The oldest version for your operating system that you would need to get a version that satisfies the version requirement is ${minVersion} but your current operating system is ${coercedOSRelease.version}. Please try changing your MySQL version requirement, updating your OS to a newer version, or if you believe this is a bug, please report this on GitHub.`;
|
|
84
87
|
}
|
|
85
88
|
if (process.platform === 'linux') {
|
|
86
|
-
if (LinuxOSRelease_1.default.NAME === 'Ubuntu' && LinuxOSRelease_1.default.VERSION_ID >= '24.04') {
|
|
89
|
+
if (LinuxOSRelease_1.default.NAME === 'Ubuntu' && typeof LinuxOSRelease_1.default.VERSION_ID === 'string' && LinuxOSRelease_1.default.VERSION_ID >= '24.04') {
|
|
87
90
|
//Since Ubuntu >= 24.04 uses libaio1t64 instead of libaio, this package has to copy libaio1t64 into a folder that MySQL looks in for dynamically linked libraries with the filename "libaio.so.1".
|
|
88
91
|
//I have not been able to find a suitable folder for libaio1t64 to be copied into for MySQL < 8.0.4, so here we are filtering all versions lower than 8.0.4 since they fail to launch in Ubuntu 24.04.
|
|
89
92
|
//If there is a suitable filepath for libaio1t64 to be copied into for MySQL < 8.0.4 then this check can be removed and these older MySQL versions can run on Ubuntu.
|
|
@@ -95,10 +98,9 @@ function getBinaryURL(versionToGet = "x", currentArch) {
|
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
else if (LinuxOSRelease_1.isOnAlpineLinux) {
|
|
98
|
-
|
|
99
|
-
selectedVersions = selectedVersions.filter(v => (0, semver_1.satisfies)(v, '8.4.x') || (0, semver_1.satisfies)(v, '9.x'));
|
|
101
|
+
selectedVersions = selectedVersions.filter(v => (0, semver_1.satisfies)(v, constants_1.MYSQL_ALPINE_VERSION_RANGE));
|
|
100
102
|
if (selectedVersions.length === 0) {
|
|
101
|
-
throw
|
|
103
|
+
throw `mysql-memory-server has detected you are running this package on Alpine Linux. The source for MySQL with musl libc only provides binaries for the following version ranges: "${constants_1.MYSQL_ALPINE_VERSION_RANGE}" and as such only those versions can be used with this package. Please use a version within those ranges.`;
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
106
|
}
|
|
@@ -115,6 +117,9 @@ function getBinaryURL(versionToGet = "x", currentArch) {
|
|
|
115
117
|
else if (currentOS === 'darwin') {
|
|
116
118
|
const MySQLmacOSVersionNameKeys = Object.keys(constants_1.MYSQL_MACOS_VERSIONS_IN_FILENAME);
|
|
117
119
|
const macOSVersionNameKey = MySQLmacOSVersionNameKeys.find(range => (0, semver_1.satisfies)(selectedVersion, range));
|
|
120
|
+
if (macOSVersionNameKey === undefined) {
|
|
121
|
+
throw 'Could not find macOSVersionNameKey while getting binary URL. Please report this as a bug on GitHub.';
|
|
122
|
+
}
|
|
118
123
|
fileLocation = `${(0, semver_1.major)(selectedVersion)}.${(0, semver_1.minor)(selectedVersion)}/mysql-${selectedVersion}${isRC ? '-rc' : isDMR ? '-dmr' : ''}-${constants_1.MYSQL_MACOS_VERSIONS_IN_FILENAME[macOSVersionNameKey]}-${currentArch === 'x64' ? 'x86_64' : 'arm64'}.tar.gz`;
|
|
119
124
|
}
|
|
120
125
|
else if (LinuxOSRelease_1.isOnAlpineLinux) {
|
|
@@ -125,19 +130,25 @@ function getBinaryURL(versionToGet = "x", currentArch) {
|
|
|
125
130
|
const glibcObject = constants_1.MYSQL_LINUX_GLIBC_VERSIONS[currentArch];
|
|
126
131
|
const glibcVersionKeys = Object.keys(glibcObject);
|
|
127
132
|
const glibcVersionKey = glibcVersionKeys.find(range => (0, semver_1.satisfies)(selectedVersion, range));
|
|
133
|
+
if (glibcVersionKey === undefined) {
|
|
134
|
+
throw 'Could not find glibcVersionKey while getting binary URL. Please report this as a bug on GitHub.';
|
|
135
|
+
}
|
|
128
136
|
const glibcVersion = glibcObject[glibcVersionKey];
|
|
129
137
|
const minimalInstallAvailableKeys = Object.keys(constants_1.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE);
|
|
130
138
|
const minimalInstallAvailableKey = minimalInstallAvailableKeys.find(range => (0, semver_1.satisfies)(selectedVersion, range));
|
|
139
|
+
if (minimalInstallAvailableKey === undefined) {
|
|
140
|
+
throw 'Could not find minimalInstallAvailableKey while getting binary URL. Please report this as a bug on GitHub.';
|
|
141
|
+
}
|
|
131
142
|
const minimalInstallAvailable = constants_1.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE[minimalInstallAvailableKey];
|
|
132
143
|
const fileExtensionObject = constants_1.MYSQL_LINUX_FILE_EXTENSIONS[currentArch];
|
|
133
144
|
const fileExtensionKeys = Object.keys(fileExtensionObject);
|
|
134
145
|
const fileExtensionKey = fileExtensionKeys.find(range => (0, semver_1.satisfies)(selectedVersion, range));
|
|
146
|
+
if (fileExtensionKey === undefined) {
|
|
147
|
+
throw 'Could not find fileExtensionKey while getting binary URL. Please report this as a bug on GitHub.';
|
|
148
|
+
}
|
|
135
149
|
const fileExtension = constants_1.MYSQL_LINUX_FILE_EXTENSIONS[currentArch][fileExtensionKey];
|
|
136
150
|
fileLocation = `${(0, semver_1.major)(selectedVersion)}.${(0, semver_1.minor)(selectedVersion)}/mysql-${selectedVersion}${isRC ? '-rc' : isDMR ? '-dmr' : ''}-linux-${minimalInstallAvailable !== 'no-glibc-tag' ? `glibc${glibcVersion}-` : ''}${currentArch === 'x64' ? 'x86_64' : 'aarch64'}${minimalInstallAvailable !== 'no' && (process.arch !== 'arm64' ? true : (0, semver_1.satisfies)(selectedVersion, constants_1.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE_ARM64)) ? `-minimal${(0, semver_1.satisfies)(selectedVersion, constants_1.MYSQL_LINUX_MINIMAL_REBUILD_VERSIONS) ? '-rebuild' : ''}` : ''}.tar.${fileExtension}`;
|
|
137
151
|
}
|
|
138
|
-
else {
|
|
139
|
-
throw 'You are running this package on an unsupported OS. Please use either Windows, macOS, or a Linux-based OS.';
|
|
140
|
-
}
|
|
141
152
|
return {
|
|
142
153
|
version: selectedVersion,
|
|
143
154
|
url: fileLocation,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type InternalServerOptions = {
|
|
|
33
33
|
xPort: number;
|
|
34
34
|
downloadRetries: number;
|
|
35
35
|
initSQLString: string;
|
|
36
|
-
arch:
|
|
36
|
+
arch: "arm64" | "x64" | "unsupported";
|
|
37
37
|
xEnabled: PluginActivationState;
|
|
38
38
|
initSQLFilePath: string;
|
|
39
39
|
};
|
|
@@ -67,24 +67,20 @@ export type BinaryInfo = {
|
|
|
67
67
|
hostedByOracle: boolean;
|
|
68
68
|
xPluginSupported: boolean;
|
|
69
69
|
};
|
|
70
|
+
type OptionTypeChecksDefinedTypeHelper<T> = T extends string ? "string" : T extends boolean ? "boolean" : T extends number ? "number" : never;
|
|
70
71
|
export type OptionTypeChecks = {
|
|
71
72
|
[key in keyof Required<ServerOptions>]: {
|
|
72
73
|
check: (opt: any) => boolean;
|
|
73
74
|
errorMessage: string;
|
|
74
|
-
definedType:
|
|
75
|
+
definedType: OptionTypeChecksDefinedTypeHelper<ServerOptions[key]>;
|
|
75
76
|
};
|
|
76
77
|
};
|
|
77
|
-
export type LinuxEtcOSRelease = {
|
|
78
|
-
PRETTY_NAME?: string;
|
|
78
|
+
export type LinuxEtcOSRelease = Record<string, string> & {
|
|
79
79
|
NAME?: string;
|
|
80
80
|
VERSION_ID?: string;
|
|
81
|
-
VERSION?: string;
|
|
82
|
-
VERSION_CODENAME?: string;
|
|
83
|
-
ID?: string;
|
|
84
|
-
ID_LIKE?: string;
|
|
85
|
-
UBUNTU_CODENAME?: string;
|
|
86
81
|
};
|
|
87
82
|
export type JSRuntimeVersion = {
|
|
88
83
|
runtimeName: string;
|
|
89
84
|
runtimeVersion: string;
|
|
90
85
|
};
|
|
86
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mysql-memory-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"test": "jest --verbose --colors",
|
|
20
20
|
"test:ci": "jest tests/ci --setupFilesAfterEnv ./ciSetup.js --verbose --colors",
|
|
21
|
-
"os-compat:ci": "jest tests/versions.test.
|
|
21
|
+
"os-compat:ci": "jest tests/versions.test.js --setupFilesAfterEnv ./ciSetup.js --verbose --colors"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=16.6.0",
|
|
@@ -27,20 +27,15 @@
|
|
|
27
27
|
"author": "Sebastian-Webster",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"@types/semver": "^7.7.1",
|
|
36
|
-
"babel-jest": "^30.2.0",
|
|
37
|
-
"jest": "^30.2.0",
|
|
38
|
-
"mysql2": "^3.16.2",
|
|
39
|
-
"typescript": "^5.9.3"
|
|
30
|
+
"@types/node": "^26.2.0",
|
|
31
|
+
"@types/semver": "^7.8.0",
|
|
32
|
+
"jest": "^30.4.2",
|
|
33
|
+
"mysql2": "^3.23.2",
|
|
34
|
+
"typescript": "^7.0.2"
|
|
40
35
|
},
|
|
41
36
|
"dependencies": {
|
|
42
|
-
"adm-zip": "^0.
|
|
43
|
-
"semver": "^7.
|
|
37
|
+
"adm-zip": "^0.6.0",
|
|
38
|
+
"semver": "^7.8.5",
|
|
44
39
|
"signal-exit": "^4.1.0"
|
|
45
40
|
},
|
|
46
41
|
"repository": {
|