@verdnatura/myt 1.5.15 → 1.5.17
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/README.md +1 -1
- package/lib/dumper.js +2 -2
- package/myt-dump.js +17 -4
- package/myt.js +16 -10
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -221,7 +221,7 @@ Exports database structure and fixtures from remote into hidden files located
|
|
|
221
221
|
in *dump* folder. If no remote is specified *production* is used.
|
|
222
222
|
|
|
223
223
|
```text
|
|
224
|
-
$ myt dump [<remote>]
|
|
224
|
+
$ myt dump [<remote>] [-l|--lock]
|
|
225
225
|
```
|
|
226
226
|
|
|
227
227
|
### fixtures
|
package/lib/dumper.js
CHANGED
|
@@ -35,7 +35,7 @@ module.exports = class Dumper {
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
async dumpFixtures(tables, replace) {
|
|
38
|
+
async dumpFixtures(tables, replace, args) {
|
|
39
39
|
const fixturesArgs = [
|
|
40
40
|
'--no-create-info',
|
|
41
41
|
'--skip-triggers',
|
|
@@ -45,7 +45,7 @@ module.exports = class Dumper {
|
|
|
45
45
|
'--skip-set-charset',
|
|
46
46
|
'--skip-comments',
|
|
47
47
|
'--skip-tz-utc'
|
|
48
|
-
];
|
|
48
|
+
].concat(args);
|
|
49
49
|
|
|
50
50
|
if (replace)
|
|
51
51
|
fixturesArgs.push('--replace');
|
package/myt-dump.js
CHANGED
|
@@ -6,18 +6,30 @@ const Dumper = require('./lib/dumper');
|
|
|
6
6
|
class Dump extends Command {
|
|
7
7
|
static usage = {
|
|
8
8
|
description: 'Dumps structure and fixtures from remote',
|
|
9
|
+
params: {
|
|
10
|
+
lock: 'Whether to lock tables on dump'
|
|
11
|
+
},
|
|
9
12
|
operand: 'remote'
|
|
10
13
|
};
|
|
11
14
|
|
|
12
15
|
static opts = {
|
|
13
16
|
default: {
|
|
14
17
|
remote: 'production'
|
|
15
|
-
}
|
|
18
|
+
},
|
|
19
|
+
alias: {
|
|
20
|
+
lock: 'l'
|
|
21
|
+
},
|
|
22
|
+
boolean: [
|
|
23
|
+
'lock'
|
|
24
|
+
]
|
|
16
25
|
};
|
|
17
26
|
|
|
18
27
|
async run(myt, opts) {
|
|
19
28
|
const dumper = new Dumper(opts);
|
|
20
29
|
await dumper.init('.dump.sql');
|
|
30
|
+
const baseArgs = [
|
|
31
|
+
`--lock-tables=${opts.lock ? 'true' : 'false'}`
|
|
32
|
+
];
|
|
21
33
|
|
|
22
34
|
console.log('Dumping structure.');
|
|
23
35
|
let dumpArgs = [
|
|
@@ -28,12 +40,13 @@ class Dump extends Command {
|
|
|
28
40
|
'--events',
|
|
29
41
|
'--skip-triggers',
|
|
30
42
|
'--databases'
|
|
31
|
-
];
|
|
43
|
+
].concat(baseArgs);
|
|
44
|
+
|
|
32
45
|
dumpArgs = dumpArgs.concat(opts.schemas);
|
|
33
46
|
await dumper.runDump('docker-dump.sh', dumpArgs);
|
|
34
47
|
|
|
35
48
|
console.log('Dumping fixtures.');
|
|
36
|
-
await dumper.dumpFixtures(opts.fixtures);
|
|
49
|
+
await dumper.dumpFixtures(opts.fixtures, false, baseArgs);
|
|
37
50
|
|
|
38
51
|
console.log('Dumping privileges.');
|
|
39
52
|
const privs = opts.privileges;
|
|
@@ -43,7 +56,7 @@ class Dump extends Command {
|
|
|
43
56
|
'--skip-triggers',
|
|
44
57
|
'--insert-ignore',
|
|
45
58
|
'--complete-insert'
|
|
46
|
-
];
|
|
59
|
+
].concat(baseArgs);
|
|
47
60
|
if (privs.where) args.push('--where', privs.where);
|
|
48
61
|
args = args.concat(['mysql'], privs.tables);
|
|
49
62
|
|
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdnatura/myt",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.17",
|
|
4
4
|
"author": "Verdnatura Levante SL",
|
|
5
5
|
"description": "MySQL version control",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@sqltools/formatter": "^1.2.5",
|
|
16
16
|
"colors": "^1.4.0",
|
|
17
|
-
"ejs": "^3.1.
|
|
17
|
+
"ejs": "^3.1.9",
|
|
18
18
|
"fs-extra": "^8.1.0",
|
|
19
19
|
"getopts": "^2.3.0",
|
|
20
20
|
"ini": "^1.3.8",
|
|
21
21
|
"mysql2": "^2.3.3",
|
|
22
22
|
"nodegit": "^0.27.0",
|
|
23
|
-
"require-yaml": "0.0.1",
|
|
23
|
+
"require-yaml": "^0.0.1",
|
|
24
24
|
"sha.js": "^2.4.11"
|
|
25
25
|
},
|
|
26
26
|
"main": "index.js",
|