@verdnatura/myt 1.5.15 → 1.5.16
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/myt.js +16 -10
- package/package.json +1 -1
package/myt.js
CHANGED
|
@@ -17,7 +17,6 @@ class Myt {
|
|
|
17
17
|
params: {
|
|
18
18
|
remote: 'Name of remote to use',
|
|
19
19
|
workspace: 'The base directory of the project',
|
|
20
|
-
socket: 'Wether to connect to database via socket',
|
|
21
20
|
debug: 'Wether to enable debug mode',
|
|
22
21
|
version: 'Display the version number and exit',
|
|
23
22
|
help: 'Display this help message'
|
|
@@ -28,7 +27,6 @@ class Myt {
|
|
|
28
27
|
alias: {
|
|
29
28
|
remote: 'r',
|
|
30
29
|
workspace: 'w',
|
|
31
|
-
socket: 'k',
|
|
32
30
|
debug: 'd',
|
|
33
31
|
version: 'v',
|
|
34
32
|
help: 'h'
|
|
@@ -205,34 +203,42 @@ class Myt {
|
|
|
205
203
|
|
|
206
204
|
let dbConfig;
|
|
207
205
|
try {
|
|
208
|
-
const
|
|
206
|
+
const iniData = ini.parse(await fs.readFile(iniPath, 'utf8')).client;
|
|
207
|
+
const iniConfig = {};
|
|
208
|
+
for (const key in iniData) {
|
|
209
|
+
const value = iniData[key];
|
|
210
|
+
const newKey = key.replace(/-/g, '_');
|
|
211
|
+
iniConfig[newKey] = value !== undefined ? value : true;
|
|
212
|
+
}
|
|
209
213
|
dbConfig = {
|
|
210
214
|
host: iniConfig.host,
|
|
211
215
|
port: iniConfig.port,
|
|
212
216
|
user: iniConfig.user,
|
|
213
217
|
password: iniConfig.password,
|
|
214
|
-
multipleStatements: true
|
|
215
|
-
|
|
218
|
+
multipleStatements: true
|
|
219
|
+
};
|
|
220
|
+
if (iniConfig.enable_cleartext_plugin) {
|
|
221
|
+
dbConfig.authPlugins = {
|
|
216
222
|
mysql_clear_password() {
|
|
217
223
|
return () => iniConfig.password + '\0';
|
|
218
224
|
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
221
227
|
if (iniConfig.ssl_ca) {
|
|
222
228
|
dbConfig.ssl = {
|
|
223
229
|
ca: await fs.readFile(`${opts.mytDir}/${iniConfig.ssl_ca}`),
|
|
224
230
|
rejectUnauthorized: iniConfig.ssl_verify_server_cert != undefined
|
|
225
231
|
}
|
|
226
232
|
}
|
|
233
|
+
if (iniConfig.socket) {
|
|
234
|
+
dbConfig.socketPath = iniConfig.socket;
|
|
235
|
+
}
|
|
227
236
|
} catch(err) {
|
|
228
237
|
const newErr = Error(`Cannot process the ini file, check that the syntax is correct: ${iniPath}`);
|
|
229
238
|
newErr.stack += `\nCaused by: ${err.stack}`;
|
|
230
239
|
throw newErr;
|
|
231
240
|
}
|
|
232
241
|
|
|
233
|
-
if (opts.socket)
|
|
234
|
-
dbConfig.socketPath = '/var/run/mysqld/mysqld.sock';
|
|
235
|
-
|
|
236
242
|
Object.assign(opts, {
|
|
237
243
|
iniFile,
|
|
238
244
|
dbConfig
|