@verdnatura/myt 1.6.13 → 1.7.0
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 +18 -1
- package/myt-run.js +29 -9
- package/myt.js +1 -1
- package/package.json +1 -1
- package/server/Dockerfile.dump +1 -0
- package/server/Dockerfile.server +1 -1
- package/server/docker-import.sh +1 -1
- package/server/docker-init.sh +1 -1
- package/server/docker.cnf +1 -1
package/README.md
CHANGED
|
@@ -191,6 +191,23 @@ You can create your local fixture and structure files.
|
|
|
191
191
|
* *dump/fixtures.after.sql*
|
|
192
192
|
* *dump/fixtures.local.sql*
|
|
193
193
|
|
|
194
|
+
### Realms
|
|
195
|
+
|
|
196
|
+
You can create your local realms folders.
|
|
197
|
+
|
|
198
|
+
```text
|
|
199
|
+
dump
|
|
200
|
+
`- realms
|
|
201
|
+
|- marvel
|
|
202
|
+
| `- 00-spiderman.sql
|
|
203
|
+
| `- 01-hulk.sql
|
|
204
|
+
`- dc
|
|
205
|
+
`- 00-superman.sql
|
|
206
|
+
`- 01-batman.sql
|
|
207
|
+
`- 02-wonder_woman.sql
|
|
208
|
+
`- 03-flash.sql
|
|
209
|
+
```
|
|
210
|
+
|
|
194
211
|
## Versioning commands
|
|
195
212
|
|
|
196
213
|
### init
|
|
@@ -279,7 +296,7 @@ Builds and starts local database server container. It only rebuilds the image
|
|
|
279
296
|
when dump have been modified.
|
|
280
297
|
|
|
281
298
|
```text
|
|
282
|
-
$ myt run [-c|--ci] [-r|--random] [-t|--tmpfs] [-n|--network <string>]
|
|
299
|
+
$ myt run [<realm>|-m|--realm <string>] [-c|--ci] [-r|--random] [-t|--tmpfs] [-n|--network <string>]
|
|
283
300
|
```
|
|
284
301
|
|
|
285
302
|
### start
|
package/myt-run.js
CHANGED
|
@@ -21,8 +21,10 @@ class Run extends Command {
|
|
|
21
21
|
network: 'Docker network to attach container to',
|
|
22
22
|
random: 'Whether to use a random container name and port',
|
|
23
23
|
tmpfs: 'Whether to use tmpfs mount for MySQL data',
|
|
24
|
-
keep: 'Keep container on failure'
|
|
25
|
-
|
|
24
|
+
keep: 'Keep container on failure',
|
|
25
|
+
realm: 'Name of fixture realm to use'
|
|
26
|
+
},
|
|
27
|
+
operand: 'realm'
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
static opts = {
|
|
@@ -31,7 +33,8 @@ class Run extends Command {
|
|
|
31
33
|
network: 'n',
|
|
32
34
|
random: 'r',
|
|
33
35
|
tmpfs: 't',
|
|
34
|
-
keep: 'k'
|
|
36
|
+
keep: 'k',
|
|
37
|
+
realm: 'm'
|
|
35
38
|
},
|
|
36
39
|
boolean: [
|
|
37
40
|
'ci',
|
|
@@ -47,6 +50,7 @@ class Run extends Command {
|
|
|
47
50
|
waitingDb: 'Waiting for MySQL init process.',
|
|
48
51
|
mockingDate: 'Mocking date functions.',
|
|
49
52
|
applyingFixtures: 'Applying fixtures.',
|
|
53
|
+
applyingRealms: 'Applying realm fixtures.',
|
|
50
54
|
creatingTriggers: 'Creating triggers.'
|
|
51
55
|
};
|
|
52
56
|
|
|
@@ -185,11 +189,19 @@ class Run extends Command {
|
|
|
185
189
|
]
|
|
186
190
|
for (const file of fixturesFiles) {
|
|
187
191
|
if (!await fs.exists(`${dumpDir}/${file}.sql`)) continue;
|
|
188
|
-
await
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
await execFile(`dump/${file}`)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Apply realms
|
|
196
|
+
|
|
197
|
+
if(opts.realm) {
|
|
198
|
+
this.emit('applyingRealms');
|
|
199
|
+
const realmDir = `realms/${opts.realm}`;
|
|
200
|
+
let realmFiles = await fs.readdir(`${dumpDir}/${realmDir}`);
|
|
201
|
+
realmFiles = realmFiles.map(file => path.parse(file).name);
|
|
202
|
+
for (const file of realmFiles) {
|
|
203
|
+
await execFile(`${realmDir}/${file}`)
|
|
204
|
+
}
|
|
193
205
|
}
|
|
194
206
|
|
|
195
207
|
// Create triggers
|
|
@@ -216,10 +228,18 @@ class Run extends Command {
|
|
|
216
228
|
} catch (e) {}
|
|
217
229
|
throw err;
|
|
218
230
|
}
|
|
231
|
+
|
|
232
|
+
async function execFile(path){
|
|
233
|
+
await ct.exec(null, 'docker-import.sh',
|
|
234
|
+
[`/workspace/${path}` ],
|
|
235
|
+
'spawn',
|
|
236
|
+
true
|
|
237
|
+
);
|
|
238
|
+
}
|
|
219
239
|
}
|
|
220
240
|
}
|
|
221
241
|
|
|
222
242
|
module.exports = Run;
|
|
223
243
|
|
|
224
244
|
if (require.main === module)
|
|
225
|
-
new Myt().cli(Run);
|
|
245
|
+
new Myt().cli(Run);
|
package/myt.js
CHANGED
package/package.json
CHANGED
package/server/Dockerfile.dump
CHANGED
package/server/Dockerfile.server
CHANGED
package/server/docker-import.sh
CHANGED
package/server/docker-init.sh
CHANGED
package/server/docker.cnf
CHANGED