#4191 Bug fixes
This commit is contained in:
parent
8c3badaa75
commit
fa8552c54f
|
@ -39,7 +39,7 @@ class Push {
|
||||||
const conn = await myvc.dbConnect();
|
const conn = await myvc.dbConnect();
|
||||||
this.conn = conn;
|
this.conn = conn;
|
||||||
|
|
||||||
if (opts.commit == null && opts.remote == 'local')
|
if (opts.remote == 'local')
|
||||||
opts.commit = true;
|
opts.commit = true;
|
||||||
|
|
||||||
// Obtain exclusive lock
|
// Obtain exclusive lock
|
||||||
|
@ -557,6 +557,9 @@ class Routine {
|
||||||
const type = typeMap[split[1]];
|
const type = typeMap[split[1]];
|
||||||
const name = split[2];
|
const name = split[2];
|
||||||
|
|
||||||
|
if (split.length !== 3 || !type)
|
||||||
|
throw new Error(`Wrong routine path for '${path}', check that the sql file is located in the correct directory`);
|
||||||
|
|
||||||
Object.assign(this, {
|
Object.assign(this, {
|
||||||
path,
|
path,
|
||||||
mark: change.mark,
|
mark: change.mark,
|
||||||
|
|
59
myvc.js
59
myvc.js
|
@ -9,6 +9,7 @@ const ini = require('ini');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const mysql = require('mysql2/promise');
|
const mysql = require('mysql2/promise');
|
||||||
const nodegit = require('nodegit');
|
const nodegit = require('nodegit');
|
||||||
|
const { networkInterfaces } = require('os');
|
||||||
const camelToSnake = require('./lib').camelToSnake;
|
const camelToSnake = require('./lib').camelToSnake;
|
||||||
|
|
||||||
class MyVC {
|
class MyVC {
|
||||||
|
@ -49,6 +50,11 @@ class MyVC {
|
||||||
};
|
};
|
||||||
const opts = this.getopts(baseOpts);
|
const opts = this.getopts(baseOpts);
|
||||||
|
|
||||||
|
if (opts.debug) {
|
||||||
|
console.warn('Debug mode enabled.'.yellow);
|
||||||
|
console.log('Global options:'.magenta, opts);
|
||||||
|
}
|
||||||
|
|
||||||
if (opts.version)
|
if (opts.version)
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|
||||||
|
@ -93,12 +99,17 @@ class MyVC {
|
||||||
}
|
}
|
||||||
|
|
||||||
const commandOpts = this.getopts(allOpts);
|
const commandOpts = this.getopts(allOpts);
|
||||||
|
if (opts.debug)
|
||||||
|
console.log('Command options:'.magenta, commandOpts);
|
||||||
Object.assign(opts, commandOpts);
|
Object.assign(opts, commandOpts);
|
||||||
|
|
||||||
const operandToOpt = command.usage.operand;
|
const operandToOpt = command.usage.operand;
|
||||||
if (opts._.length >= 2 && operandToOpt)
|
if (opts._.length >= 2 && operandToOpt)
|
||||||
opts[operandToOpt] = opts._[1];
|
opts[operandToOpt] = opts._[1];
|
||||||
|
|
||||||
|
if (opts.debug)
|
||||||
|
console.log('Final options:'.magenta, opts);
|
||||||
|
|
||||||
if (opts.help) {
|
if (opts.help) {
|
||||||
this.showHelp(command.localOpts, command.usage, commandName);
|
this.showHelp(command.localOpts, command.usage, commandName);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
@ -145,9 +156,9 @@ class MyVC {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.name == 'Error' && !opts.debug) {
|
if (err.name == 'Error' && !opts.debug) {
|
||||||
console.error('Error:'.gray, err.message.red);
|
console.error('Error:'.gray, err.message.red);
|
||||||
process.exit(1);
|
console.log(`You can get more details about the error by passing the 'debug' option.`.yellow);
|
||||||
} else
|
} else
|
||||||
throw err;
|
console.log(err.stack.magenta);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parameter(parameter, value) {
|
function parameter(parameter, value) {
|
||||||
|
@ -187,26 +198,33 @@ class MyVC {
|
||||||
if (!await fs.pathExists(iniPath))
|
if (!await fs.pathExists(iniPath))
|
||||||
throw new Error(`Database config file not found: ${iniPath}`);
|
throw new Error(`Database config file not found: ${iniPath}`);
|
||||||
|
|
||||||
const iniConfig = ini.parse(await fs.readFile(iniPath, 'utf8')).client;
|
let dbConfig;
|
||||||
const dbConfig = {
|
try {
|
||||||
host: iniConfig.host,
|
const iniConfig = ini.parse(await fs.readFile(iniPath, 'utf8')).client;
|
||||||
port: iniConfig.port,
|
dbConfig = {
|
||||||
user: iniConfig.user,
|
host: iniConfig.host,
|
||||||
password: iniConfig.password,
|
port: iniConfig.port,
|
||||||
multipleStatements: true,
|
user: iniConfig.user,
|
||||||
authPlugins: {
|
password: iniConfig.password,
|
||||||
mysql_clear_password() {
|
multipleStatements: true,
|
||||||
return () => iniConfig.password + '\0';
|
authPlugins: {
|
||||||
|
mysql_clear_password() {
|
||||||
|
return () => iniConfig.password + '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (iniConfig.ssl_ca) {
|
||||||
|
dbConfig.ssl = {
|
||||||
|
ca: await fs.readFile(`${opts.myvcDir}/${iniConfig.ssl_ca}`),
|
||||||
|
rejectUnauthorized: iniConfig.ssl_verify_server_cert != undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
} catch(err) {
|
||||||
|
const newErr = Error(`Cannot process the ini file, check that the syntax is correct: ${iniPath}`);
|
||||||
if (iniConfig.ssl_ca) {
|
newErr.stack += `\nCaused by: ${err.stack}`;
|
||||||
dbConfig.ssl = {
|
throw newErr;
|
||||||
ca: await fs.readFile(`${opts.myvcDir}/${iniConfig.ssl_ca}`),
|
|
||||||
rejectUnauthorized: iniConfig.ssl_verify_server_cert != undefined
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.socket)
|
if (opts.socket)
|
||||||
dbConfig.socketPath = '/var/run/mysqld/mysqld.sock';
|
dbConfig.socketPath = '/var/run/mysqld/mysqld.sock';
|
||||||
|
|
||||||
|
@ -255,7 +273,8 @@ class MyVC {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!res.tableExists) {
|
if (!res.tableExists) {
|
||||||
const structure = await fs.readFile(`${__dirname}/structure.sql`, 'utf8');
|
const structure = await fs.readFile(
|
||||||
|
`${__dirname}/structure.sql`, 'utf8');
|
||||||
await conn.query(structure);
|
await conn.query(structure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "myvc",
|
"name": "myvc",
|
||||||
"version": "1.4.7",
|
"version": "1.4.8",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "MySQL Version Control",
|
"description": "MySQL Version Control",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
"type": "git"
|
"type": "git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"myvc": "^1.4.7"
|
"myvc": "^1.4.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue