Skip to content

Commit d1e7ade

Browse files
build - v1.9.0
1 parent 1af1fa5 commit d1e7ade

File tree

16 files changed

+528
-277
lines changed

16 files changed

+528
-277
lines changed

dist/src/cli.js

100644100755
File mode changed.

dist/src/constants.d.ts

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { InternalServerOptions, OptionTypeChecks } from "../types";
2-
export declare const MIN_SUPPORTED_MYSQL = "8.0.20";
3-
export declare const DEFAULT_OPTIONS_GENERATOR: () => InternalServerOptions;
2+
export declare const DEFAULT_OPTIONS: InternalServerOptions;
43
export declare const DEFAULT_OPTIONS_KEYS: readonly string[];
54
export declare const LOG_LEVELS: {
65
readonly LOG: 0;
@@ -9,10 +8,81 @@ export declare const LOG_LEVELS: {
98
};
109
declare const internalOptions: {
1110
deleteDBAfterStopped: string;
12-
dbPath: string;
11+
databaseDirectoryPath: string;
1312
binaryDirectoryPath: string;
1413
cli: string;
1514
};
1615
export declare function getInternalEnvVariable(envVar: keyof typeof internalOptions): string;
1716
export declare const OPTION_TYPE_CHECKS: OptionTypeChecks;
17+
export declare const MIN_SUPPORTED_MYSQL = "5.7.19";
18+
export declare const downloadsBaseURL = "https://cdn.mysql.com//Downloads/MySQL-";
19+
export declare const archiveBaseURL = "https://cdn.mysql.com/archives/mysql-";
20+
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.1.0", "8.2.0", "8.3.0", "8.4.0", "8.4.2", "8.4.3", "8.4.4", "9.0.1", "9.1.0", "9.2.0"];
21+
export declare const MYSQL_ARCH_SUPPORT: {
22+
readonly darwin: {
23+
readonly arm64: "8.0.26 - 9.2.0";
24+
readonly x64: "5.7.19 - 9.2.0";
25+
};
26+
readonly linux: {
27+
readonly arm64: "8.0.31 - 9.2.0";
28+
readonly x64: "5.7.19 - 9.2.0";
29+
};
30+
readonly win32: {
31+
readonly x64: "5.7.19 - 9.2.0";
32+
};
33+
};
34+
export declare const MYSQL_MIN_OS_SUPPORT: {
35+
readonly win32: {
36+
readonly x: "0.0.0";
37+
};
38+
readonly linux: {
39+
readonly x: "0.0.0";
40+
};
41+
readonly darwin: {
42+
readonly '5.7.19 - 5.7.23 || 8.0.1 - 8.0.3 || 8.0.11 - 8.0.12': "16.0.0";
43+
readonly '5.7.24 - 5.7.29 || 8.0.4 || 8.0.13 - 8.0.18': "17.0.0";
44+
readonly '5.7.30 - 5.7.31 || 8.0.19 - 8.0.22': "18.0.0";
45+
readonly '8.0.0': "13.0.0";
46+
readonly '8.0.23 - 8.0.27': "19.0.0";
47+
readonly '8.0.28 - 8.0.31': "20.0.0";
48+
readonly '8.0.32 - 8.0.34': "21.0.0";
49+
readonly '8.0.35 - 8.0.39 || 8.1.0 - 8.4.2 || 9.0.1': "22.0.0";
50+
readonly '8.0.40 - 8.0.41 || 8.4.3 - 8.4.4 || 9.1.0 - 9.2.0': "23.0.0";
51+
};
52+
};
53+
export declare const DMR_MYSQL_VERSIONS = "8.0.0 - 8.0.2";
54+
export declare const RC_MYSQL_VERSIONS = "8.0.3 - 8.0.4";
55+
export declare const MYSQL_MACOS_VERSIONS_IN_FILENAME: {
56+
readonly '5.7.19 - 5.7.20 || 8.0.1 - 8.0.3': "macos10.12";
57+
readonly '5.7.21 - 5.7.23 || 8.0.4 - 8.0.12': "macos10.13";
58+
readonly '5.7.24 - 5.7.31 || 8.0.13 - 8.0.18': "macos10.14";
59+
readonly '8.0.0': "osx10.11";
60+
readonly '8.0.19 - 8.0.23': "macos10.15";
61+
readonly '8.0.24 - 8.0.28': "macos11";
62+
readonly '8.0.30 - 8.0.31': "macos12";
63+
readonly '8.0.32 - 8.0.35 || 8.1.0 - 8.2.0': "macos13";
64+
readonly '8.0.36 - 8.0.40 || 8.3.0 - 8.4.3 || 9.0.1 - 9.1.0': "macos14";
65+
readonly '8.0.41 || 8.4.4 || 9.2.0': "macos15";
66+
};
67+
export declare const MYSQL_LINUX_GLIBC_VERSIONS: {
68+
readonly '5.7.19 - 8.0.20': "2.12";
69+
readonly '8.0.21 - 9.2.0': "2.17";
70+
};
71+
export declare const MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE: {
72+
readonly '5.7.19 - 8.0.15': "no";
73+
readonly '8.0.16 - 8.0.20': "no-glibc-tag";
74+
readonly '8.0.21 - 9.2.0': "glibc-tag";
75+
};
76+
export declare const MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE_ARM64 = ">=8.0.33";
77+
export declare const MYSQL_LINUX_FILE_EXTENSIONS: {
78+
readonly x64: {
79+
readonly '5.7.19 - 8.0.11': "gz";
80+
readonly '8.0.12 - 9.2.0': "xz";
81+
};
82+
readonly arm64: {
83+
readonly '8.0.31 - 8.0.32': "gz";
84+
readonly '8.0.33 - 9.2.0': "xz";
85+
};
86+
};
87+
export declare const MYSQL_LINUX_MINIMAL_REBUILD_VERSIONS = "8.0.26";
1888
export {};

dist/src/constants.js

Lines changed: 89 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.OPTION_TYPE_CHECKS = exports.LOG_LEVELS = exports.DEFAULT_OPTIONS_KEYS = exports.DEFAULT_OPTIONS_GENERATOR = exports.MIN_SUPPORTED_MYSQL = void 0;
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.archiveBaseURL = exports.downloadsBaseURL = exports.MIN_SUPPORTED_MYSQL = exports.OPTION_TYPE_CHECKS = exports.LOG_LEVELS = exports.DEFAULT_OPTIONS_KEYS = exports.DEFAULT_OPTIONS = void 0;
44
exports.getInternalEnvVariable = getInternalEnvVariable;
5-
const crypto_1 = require("crypto");
65
const path_1 = require("path");
76
const os_1 = require("os");
87
const semver_1 = require("semver");
9-
exports.MIN_SUPPORTED_MYSQL = '8.0.20';
10-
const DEFAULT_OPTIONS_GENERATOR = () => ({
8+
exports.DEFAULT_OPTIONS = {
119
version: undefined,
1210
dbName: 'dbdata',
1311
logLevel: 'ERROR',
1412
portRetries: 10,
1513
downloadBinaryOnce: true,
16-
lockRetries: 1000,
17-
lockRetryWait: 1000,
14+
lockRetries: 1_000,
15+
lockRetryWait: 1_000,
1816
username: 'root',
1917
ignoreUnsupportedSystemVersion: false,
2018
port: 0,
2119
xPort: 0,
2220
downloadRetries: 10,
2321
initSQLString: '',
2422
arch: process.arch
25-
});
26-
exports.DEFAULT_OPTIONS_GENERATOR = DEFAULT_OPTIONS_GENERATOR;
27-
exports.DEFAULT_OPTIONS_KEYS = Object.freeze(Object.keys((0, exports.DEFAULT_OPTIONS_GENERATOR)()));
23+
};
24+
exports.DEFAULT_OPTIONS_KEYS = Object.freeze(Object.keys(exports.DEFAULT_OPTIONS));
2825
exports.LOG_LEVELS = {
2926
'LOG': 0,
3027
'WARN': 1,
@@ -33,14 +30,14 @@ exports.LOG_LEVELS = {
3330
const internalOptions = {
3431
deleteDBAfterStopped: 'true',
3532
//mysqlmsn = MySQL Memory Server Node.js
36-
dbPath: (0, path_1.normalize)(`${(0, os_1.tmpdir)()}/mysqlmsn/dbs/${(0, crypto_1.randomUUID)().replace(/-/g, '')}`),
33+
databaseDirectoryPath: (0, path_1.normalize)(`${(0, os_1.tmpdir)()}/mysqlmsn/dbs`),
3734
binaryDirectoryPath: `${(0, os_1.tmpdir)()}/mysqlmsn/binaries`,
3835
cli: 'false'
3936
};
4037
function getInternalEnvVariable(envVar) {
4138
return process.env['mysqlmsn_internal_DO_NOT_USE_' + envVar] || internalOptions[envVar];
4239
}
43-
const allowedArches = ['x64', 'arm64', undefined];
40+
const allowedArches = ['x64', 'arm64'];
4441
exports.OPTION_TYPE_CHECKS = {
4542
version: {
4643
check: (opt) => opt === undefined || typeof opt === 'string' && (0, semver_1.valid)((0, semver_1.coerce)(opt)) !== null,
@@ -108,8 +105,88 @@ exports.OPTION_TYPE_CHECKS = {
108105
definedType: 'string'
109106
},
110107
arch: {
111-
check: (opt) => allowedArches.includes(opt),
108+
check: (opt) => opt === undefined || allowedArches.includes(opt),
112109
errorMessage: `Option arch must be either of the following: ${allowedArches.join(', ')}`,
113110
definedType: 'string'
114111
}
115112
};
113+
exports.MIN_SUPPORTED_MYSQL = '5.7.19';
114+
exports.downloadsBaseURL = 'https://cdn.mysql.com//Downloads/MySQL-';
115+
exports.archiveBaseURL = 'https://cdn.mysql.com/archives/mysql-';
116+
// Versions 8.0.29, 8.0.38, 8.4.1, and 9.0.0 have been purposefully left out of this list as MySQL has removed them from the CDN due to critical issues.
117+
exports.DOWNLOADABLE_MYSQL_VERSIONS = [
118+
'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',
119+
'8.0.0', '8.0.1', '8.0.2', '8.0.3', '8.0.4',
120+
'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',
121+
'8.1.0', '8.2.0', '8.3.0',
122+
'8.4.0', '8.4.2', '8.4.3', '8.4.4',
123+
'9.0.1', '9.1.0', '9.2.0'
124+
];
125+
exports.MYSQL_ARCH_SUPPORT = {
126+
darwin: {
127+
arm64: '8.0.26 - 9.2.0',
128+
x64: '5.7.19 - 9.2.0'
129+
},
130+
linux: {
131+
arm64: '8.0.31 - 9.2.0',
132+
x64: '5.7.19 - 9.2.0'
133+
},
134+
win32: {
135+
x64: '5.7.19 - 9.2.0'
136+
}
137+
};
138+
exports.MYSQL_MIN_OS_SUPPORT = {
139+
win32: {
140+
x: '0.0.0' // No minimum version is documented as far as I can tell, so allow any minimum version
141+
},
142+
linux: {
143+
x: '0.0.0' // No minimum version is documented as far as I can tell, so allow any minimum version
144+
},
145+
darwin: {
146+
'5.7.19 - 5.7.23 || 8.0.1 - 8.0.3 || 8.0.11 - 8.0.12': '16.0.0',
147+
'5.7.24 - 5.7.29 || 8.0.4 || 8.0.13 - 8.0.18': '17.0.0',
148+
'5.7.30 - 5.7.31 || 8.0.19 - 8.0.22': '18.0.0',
149+
//5.7.32 - 5.7.44 is not supported for macOS by MySQL. Those versions are not appearing in this list
150+
'8.0.0': '13.0.0',
151+
'8.0.23 - 8.0.27': '19.0.0',
152+
'8.0.28 - 8.0.31': '20.0.0',
153+
'8.0.32 - 8.0.34': '21.0.0',
154+
'8.0.35 - 8.0.39 || 8.1.0 - 8.4.2 || 9.0.1': '22.0.0',
155+
'8.0.40 - 8.0.41 || 8.4.3 - 8.4.4 || 9.1.0 - 9.2.0': '23.0.0'
156+
}
157+
};
158+
exports.DMR_MYSQL_VERSIONS = '8.0.0 - 8.0.2';
159+
exports.RC_MYSQL_VERSIONS = '8.0.3 - 8.0.4';
160+
exports.MYSQL_MACOS_VERSIONS_IN_FILENAME = {
161+
'5.7.19 - 5.7.20 || 8.0.1 - 8.0.3': 'macos10.12',
162+
'5.7.21 - 5.7.23 || 8.0.4 - 8.0.12': 'macos10.13',
163+
'5.7.24 - 5.7.31 || 8.0.13 - 8.0.18': 'macos10.14',
164+
'8.0.0': 'osx10.11',
165+
'8.0.19 - 8.0.23': 'macos10.15',
166+
'8.0.24 - 8.0.28': 'macos11',
167+
'8.0.30 - 8.0.31': 'macos12',
168+
'8.0.32 - 8.0.35 || 8.1.0 - 8.2.0': 'macos13',
169+
'8.0.36 - 8.0.40 || 8.3.0 - 8.4.3 || 9.0.1 - 9.1.0': 'macos14',
170+
'8.0.41 || 8.4.4 || 9.2.0': 'macos15'
171+
};
172+
exports.MYSQL_LINUX_GLIBC_VERSIONS = {
173+
'5.7.19 - 8.0.20': '2.12',
174+
'8.0.21 - 9.2.0': '2.17'
175+
};
176+
exports.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE = {
177+
'5.7.19 - 8.0.15': 'no',
178+
'8.0.16 - 8.0.20': 'no-glibc-tag',
179+
'8.0.21 - 9.2.0': 'glibc-tag'
180+
};
181+
exports.MYSQL_LINUX_MINIMAL_INSTALL_AVAILABLE_ARM64 = '>=8.0.33';
182+
exports.MYSQL_LINUX_FILE_EXTENSIONS = {
183+
x64: {
184+
'5.7.19 - 8.0.11': 'gz',
185+
'8.0.12 - 9.2.0': 'xz'
186+
},
187+
arm64: {
188+
'8.0.31 - 8.0.32': 'gz',
189+
'8.0.33 - 9.2.0': 'xz'
190+
}
191+
};
192+
exports.MYSQL_LINUX_MINIMAL_REBUILD_VERSIONS = '8.0.26';

dist/src/index.js

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,19 @@
11
"use strict";
2-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3-
if (k2 === undefined) k2 = k;
4-
var desc = Object.getOwnPropertyDescriptor(m, k);
5-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6-
desc = { enumerable: true, get: function() { return m[k]; } };
7-
}
8-
Object.defineProperty(o, k2, desc);
9-
}) : (function(o, m, k, k2) {
10-
if (k2 === undefined) k2 = k;
11-
o[k2] = m[k];
12-
}));
13-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14-
Object.defineProperty(o, "default", { enumerable: true, value: v });
15-
}) : function(o, v) {
16-
o["default"] = v;
17-
});
18-
var __importStar = (this && this.__importStar) || (function () {
19-
var ownKeys = function(o) {
20-
ownKeys = Object.getOwnPropertyNames || function (o) {
21-
var ar = [];
22-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23-
return ar;
24-
};
25-
return ownKeys(o);
26-
};
27-
return function (mod) {
28-
if (mod && mod.__esModule) return mod;
29-
var result = {};
30-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31-
__setModuleDefault(result, mod);
32-
return result;
33-
};
34-
})();
352
var __importDefault = (this && this.__importDefault) || function (mod) {
363
return (mod && mod.__esModule) ? mod : { "default": mod };
374
};
385
Object.defineProperty(exports, "__esModule", { value: true });
396
exports.createDB = createDB;
407
const Logger_1 = __importDefault(require("./libraries/Logger"));
41-
const os = __importStar(require("node:os"));
428
const Executor_1 = __importDefault(require("./libraries/Executor"));
439
const semver_1 = require("semver");
4410
const Version_1 = __importDefault(require("./libraries/Version"));
45-
const versions_json_1 = __importDefault(require("./versions.json"));
4611
const Downloader_1 = require("./libraries/Downloader");
4712
const constants_1 = require("./constants");
4813
async function createDB(opts) {
4914
const suppliedOpts = opts || {};
5015
const suppliedOptsKeys = Object.keys(suppliedOpts);
51-
const options = (0, constants_1.DEFAULT_OPTIONS_GENERATOR)();
16+
const options = { ...constants_1.DEFAULT_OPTIONS };
5217
for (const opt of suppliedOptsKeys) {
5318
if (!constants_1.DEFAULT_OPTIONS_KEYS.includes(opt)) {
5419
throw `Option ${opt} is not a valid option.`;
@@ -73,22 +38,7 @@ async function createDB(opts) {
7338
if (version === null || (options.version && !(0, semver_1.satisfies)(version.version, options.version)) || unsupportedMySQLIsInstalled) {
7439
let binaryInfo;
7540
let binaryFilepath;
76-
try {
77-
binaryInfo = (0, Version_1.default)(versions_json_1.default, options.version, options);
78-
logger.log('Using MySQL binary version:', binaryInfo.version, 'from URL:', binaryInfo.url);
79-
}
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-
}
86-
logger.error(e);
87-
if (options.version) {
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!`;
89-
}
90-
throw `A MySQL 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 your OS and CPU architecture, feel free to make a pull request to add support!`;
91-
}
41+
binaryInfo = (0, Version_1.default)(options.version, options.arch);
9242
try {
9343
binaryFilepath = await (0, Downloader_1.downloadBinary)(binaryInfo, options, logger);
9444
}

dist/src/libraries/Downloader.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
import Logger from './Logger';
22
import { BinaryInfo, InternalServerOptions } from '../../types';
3-
export declare function downloadVersions(): Promise<string>;
43
export declare function downloadBinary(binaryInfo: BinaryInfo, options: InternalServerOptions, logger: Logger): Promise<string>;

0 commit comments

Comments
 (0)