diff --git a/src/cli.ts b/src/cli.ts index 0bfcd7c..0c91d85 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -39,7 +39,7 @@ async function main() { } console.log('Creating ephemeral MySQL database...') const db = await createDB(options); - console.log(`A MySQL database has been successfully created with the following parameters:\n\nUsername: ${db.username} \nDatabase Name: ${db.dbName} \nPort: ${db.port} \nX Plugin Port: ${db.xPort} \nSocket: ${db.socket} \nX Plugin Socket: ${db.xSocket}\n`) + console.log(`A MySQL database has been successfully created with the following parameters:\n\nMySQL Version: ${db.version} \nUsername: ${db.username} \nDatabase Name: ${db.dbName} \nPort: ${db.port} \nX Plugin Port: ${db.xPort} \nSocket: ${db.socket} \nX Plugin Socket: ${db.xSocket}\n`) if (process.platform === 'win32') { //The connection information logs will be different for Windows compared to other platforms. //Windows uses mysqlsh instead of mysql to invoke the client shell, needs a --sql flag to be put into SQL mode, and also does not have a protocol flag. diff --git a/src/index.ts b/src/index.ts index 6c6fb05..9718ea0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -78,9 +78,9 @@ export async function createDB(opts?: ServerOptions) { } logger.log('Running downloaded binary') - return await executor.startMySQL(options, binaryFilepath) + return await executor.startMySQL(options, {path: binaryFilepath, version: binaryInfo.version}) } else { logger.log(version) - return await executor.startMySQL(options, version.path) + return await executor.startMySQL(options, version) } } \ No newline at end of file diff --git a/src/libraries/Executor.ts b/src/libraries/Executor.ts index 239c30e..2d9d001 100644 --- a/src/libraries/Executor.ts +++ b/src/libraries/Executor.ts @@ -14,7 +14,8 @@ import { randomUUID } from "crypto"; class Executor { logger: Logger; DBDestroySignal = new AbortController(); - removeExitHandler: () => void + removeExitHandler: () => void; + version: string; constructor(logger: Logger) { this.logger = logger; @@ -190,6 +191,7 @@ class Executor { xSocket, dbName: options.dbName, username: options.username, + version: this.version, stop: () => { return new Promise(async (resolve, reject) => { resolveFunction = resolve; @@ -420,7 +422,8 @@ class Executor { this.logger.log('Finished writing init file') } - async startMySQL(options: InternalServerOptions, binaryFilepath: string): Promise { + async startMySQL(options: InternalServerOptions, installedMySQLBinary: InstalledMySQLVersion): Promise { + this.version = installedMySQLBinary.version this.removeExitHandler = onExit(() => { if (options._DO_NOT_USE_beforeSignalCleanupMessage) { console.log(options._DO_NOT_USE_beforeSignalCleanupMessage) @@ -436,7 +439,7 @@ class Executor { } } - const binaryPathToDelete = this.#returnBinaryPathToDelete(binaryFilepath, options) + const binaryPathToDelete = this.#returnBinaryPathToDelete(installedMySQLBinary.path, options) if (binaryPathToDelete) { try { fs.rmSync(binaryPathToDelete, {force: true, recursive: true, maxRetries: 50}) @@ -455,7 +458,7 @@ class Executor { const datadir = normalizePath(`${options._DO_NOT_USE_dbPath}/data`) do { - await this.#setupDataDirectories(options, binaryFilepath, datadir, true); + await this.#setupDataDirectories(options, installedMySQLBinary.path, datadir, true); this.logger.log('Setting up directories was successful') const port = options.port || GenerateRandomPort() @@ -464,7 +467,7 @@ class Executor { try { this.logger.log('Starting MySQL process') - const resolved = await this.#startMySQLProcess(options, port, mySQLXPort, datadir, options._DO_NOT_USE_dbPath, binaryFilepath) + const resolved = await this.#startMySQLProcess(options, port, mySQLXPort, datadir, options._DO_NOT_USE_dbPath, installedMySQLBinary.path) this.logger.log('Starting process was successful') return resolved } catch (e) { diff --git a/types/index.ts b/types/index.ts index 1b27f58..f545dfb 100644 --- a/types/index.ts +++ b/types/index.ts @@ -63,6 +63,7 @@ export type MySQLDB = { xSocket: string, dbName: string, username: string, + version: string, stop: () => Promise }