#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,
|
||||||
|
|
29
myvc.js
29
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,8 +198,10 @@ 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}`);
|
||||||
|
|
||||||
|
let dbConfig;
|
||||||
|
try {
|
||||||
const iniConfig = ini.parse(await fs.readFile(iniPath, 'utf8')).client;
|
const iniConfig = ini.parse(await fs.readFile(iniPath, 'utf8')).client;
|
||||||
const dbConfig = {
|
dbConfig = {
|
||||||
host: iniConfig.host,
|
host: iniConfig.host,
|
||||||
port: iniConfig.port,
|
port: iniConfig.port,
|
||||||
user: iniConfig.user,
|
user: iniConfig.user,
|
||||||
|
@ -200,13 +213,18 @@ class MyVC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (iniConfig.ssl_ca) {
|
if (iniConfig.ssl_ca) {
|
||||||
dbConfig.ssl = {
|
dbConfig.ssl = {
|
||||||
ca: await fs.readFile(`${opts.myvcDir}/${iniConfig.ssl_ca}`),
|
ca: await fs.readFile(`${opts.myvcDir}/${iniConfig.ssl_ca}`),
|
||||||
rejectUnauthorized: iniConfig.ssl_verify_server_cert != undefined
|
rejectUnauthorized: iniConfig.ssl_verify_server_cert != undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch(err) {
|
||||||
|
const newErr = Error(`Cannot process the ini file, check that the syntax is correct: ${iniPath}`);
|
||||||
|
newErr.stack += `\nCaused by: ${err.stack}`;
|
||||||
|
throw newErr;
|
||||||
|
}
|
||||||
|
|
||||||
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