@verdnatura/myt 1.7.1 → 1.8.1
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/myt-run.js +35 -26
- package/package.json +7 -3
- package/pnpm-workspace.yaml +2 -0
- package/server/Dockerfile.server +1 -1
package/README.md
CHANGED
|
@@ -296,7 +296,7 @@ Builds and starts local database server container. It only rebuilds the image
|
|
|
296
296
|
when dump have been modified.
|
|
297
297
|
|
|
298
298
|
```text
|
|
299
|
-
$ myt run [<realm>|-m|--realm <string>] [-c|--ci] [-r|--random] [-
|
|
299
|
+
$ myt run [<realm>|-m|--realm <string>] [-c|--ci] [-r|--random] [-p|--persist] [-n|--network <string>]
|
|
300
300
|
```
|
|
301
301
|
|
|
302
302
|
### start
|
package/myt-run.js
CHANGED
|
@@ -20,7 +20,7 @@ class Run extends Command {
|
|
|
20
20
|
ci: 'Workaround for continuous integration system',
|
|
21
21
|
network: 'Docker network to attach container to',
|
|
22
22
|
random: 'Whether to use a random container name and port',
|
|
23
|
-
|
|
23
|
+
persist: 'Whether to not use tmpfs mount for MySQL data',
|
|
24
24
|
keep: 'Keep container on failure',
|
|
25
25
|
realm: 'Name of fixture realm to use'
|
|
26
26
|
},
|
|
@@ -29,17 +29,16 @@ class Run extends Command {
|
|
|
29
29
|
|
|
30
30
|
static opts = {
|
|
31
31
|
alias: {
|
|
32
|
-
ci: 'c',
|
|
33
32
|
network: 'n',
|
|
34
33
|
random: 'r',
|
|
35
|
-
|
|
34
|
+
persist: 'p',
|
|
36
35
|
keep: 'k',
|
|
37
36
|
realm: 'm'
|
|
38
37
|
},
|
|
39
38
|
boolean: [
|
|
40
39
|
'ci',
|
|
41
40
|
'random',
|
|
42
|
-
'
|
|
41
|
+
'persist',
|
|
43
42
|
'keep'
|
|
44
43
|
]
|
|
45
44
|
};
|
|
@@ -47,11 +46,13 @@ class Run extends Command {
|
|
|
47
46
|
static reporter = {
|
|
48
47
|
buildingImage: 'Building container image.',
|
|
49
48
|
runningContainer: 'Running container.',
|
|
50
|
-
waitingDb: 'Waiting for MySQL init process.',
|
|
51
49
|
mockingDate: 'Mocking date functions.',
|
|
52
50
|
applyingFixtures: 'Applying fixtures.',
|
|
53
51
|
applyingRealms: 'Applying realm fixtures.',
|
|
54
|
-
creatingTriggers: 'Creating triggers.'
|
|
52
|
+
creatingTriggers: 'Creating triggers.',
|
|
53
|
+
waitingDb: function(dbConfig) {
|
|
54
|
+
console.log(`Waiting for MySQL: ${dbConfig.host}:${dbConfig.port}`);
|
|
55
|
+
}
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
async run(myt, opts) {
|
|
@@ -116,9 +117,10 @@ class Run extends Command {
|
|
|
116
117
|
} catch (e) {}
|
|
117
118
|
}
|
|
118
119
|
|
|
120
|
+
const {network} = opts;
|
|
119
121
|
if (opts.network)
|
|
120
|
-
runOptions.network =
|
|
121
|
-
if (opts.
|
|
122
|
+
runOptions.network = network;
|
|
123
|
+
if (!opts.persist)
|
|
122
124
|
runOptions.tmpfs = '/var/lib/mysql';
|
|
123
125
|
|
|
124
126
|
Object.assign(runOptions, null, {
|
|
@@ -129,27 +131,34 @@ class Run extends Command {
|
|
|
129
131
|
try {
|
|
130
132
|
const server = new Server(ct, dbConfig);
|
|
131
133
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
} catch (err) {
|
|
147
|
-
await server.rm();
|
|
148
|
-
throw err;
|
|
134
|
+
try {
|
|
135
|
+
const netSettings = await ct.inspect({
|
|
136
|
+
format: '{{json .NetworkSettings}}'
|
|
137
|
+
});
|
|
138
|
+
const ctNetworks = netSettings.Networks;
|
|
139
|
+
|
|
140
|
+
let host;
|
|
141
|
+
if (network) {
|
|
142
|
+
host = network != 'host'
|
|
143
|
+
? ctNetworks[network].IPAddress
|
|
144
|
+
: '127.0.0.1'
|
|
145
|
+
} else {
|
|
146
|
+
host = netSettings.IPAddress
|
|
147
|
+
?? ctNetworks.bridge?.IPAddress
|
|
149
148
|
}
|
|
149
|
+
if (!host)
|
|
150
|
+
throw new Error(`Cannot get database host`);
|
|
151
|
+
|
|
152
|
+
Object.assign(dbConfig, {
|
|
153
|
+
host,
|
|
154
|
+
port: 3306
|
|
155
|
+
});
|
|
156
|
+
} catch (err) {
|
|
157
|
+
await server.rm();
|
|
158
|
+
throw err;
|
|
150
159
|
}
|
|
151
160
|
|
|
152
|
-
this.emit('waitingDb');
|
|
161
|
+
this.emit('waitingDb', dbConfig);
|
|
153
162
|
await server.wait();
|
|
154
163
|
const conn = await myt.createConnection();
|
|
155
164
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdnatura/myt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"author": "Verdnatura Levante SL",
|
|
5
5
|
"description": "MySQL version control",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/verdnatura/myt.git"
|
|
12
|
+
"url": "git+https://github.com/verdnatura/myt.git"
|
|
13
13
|
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20"
|
|
16
|
+
},
|
|
17
|
+
"packageManager": "pnpm@10.28.2",
|
|
14
18
|
"dependencies": {
|
|
15
19
|
"@sqltools/formatter": "^1.2.5",
|
|
16
20
|
"colors": "^1.4.0",
|
|
@@ -19,7 +23,7 @@
|
|
|
19
23
|
"getopts": "^2.3.0",
|
|
20
24
|
"ini": "^4.1.1",
|
|
21
25
|
"mysql2": "^3.3.4",
|
|
22
|
-
"nodegit": "
|
|
26
|
+
"nodegit": "0.28.0-alpha.28",
|
|
23
27
|
"require-yaml": "^0.0.1",
|
|
24
28
|
"sha.js": "^2.4.11",
|
|
25
29
|
"sqlstring": "^2.3.3"
|