feat: refs #6758 add realms functionality
This commit is contained in:
parent
6318a58f24
commit
efb048bbe9
29
myt-run.js
29
myt-run.js
|
@ -47,6 +47,7 @@ class Run extends Command {
|
|||
waitingDb: 'Waiting for MySQL init process.',
|
||||
mockingDate: 'Mocking date functions.',
|
||||
applyingFixtures: 'Applying fixtures.',
|
||||
applyingRealms: (realm) => console.log(`Applying '${realm}' realm fixtures.`),
|
||||
creatingTriggers: 'Creating triggers.'
|
||||
};
|
||||
|
||||
|
@ -185,11 +186,19 @@ class Run extends Command {
|
|||
]
|
||||
for (const file of fixturesFiles) {
|
||||
if (!await fs.exists(`${dumpDir}/${file}.sql`)) continue;
|
||||
await ct.exec(null, 'docker-import.sh',
|
||||
[`/workspace/dump/${file}`],
|
||||
'spawn',
|
||||
true
|
||||
);
|
||||
await execFile(`dump/${file}`)
|
||||
}
|
||||
|
||||
// Apply realms
|
||||
|
||||
if(opts.realm) {
|
||||
this.emit('applyingRealms', opts.realm);
|
||||
const realmDir = `realms/${opts.realm}`;
|
||||
let realmFiles = await fs.readdir(`${dumpDir}/${realmDir}`);
|
||||
realmFiles = realmFiles.map(file => path.parse(file).name);
|
||||
for (const file of realmFiles) {
|
||||
await execFile(`${realmDir}/${file}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Create triggers
|
||||
|
@ -216,6 +225,14 @@ class Run extends Command {
|
|||
} catch (e) {}
|
||||
throw err;
|
||||
}
|
||||
|
||||
async function execFile(path){
|
||||
await ct.exec(null, 'docker-import.sh',
|
||||
[`/workspace/${path}` ],
|
||||
'spawn',
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,3 +240,5 @@ module.exports = Run;
|
|||
|
||||
if (require.main === module)
|
||||
new Myt().cli(Run);
|
||||
|
||||
|
||||
|
|
3
myt.js
3
myt.js
|
@ -21,7 +21,8 @@ class Myt {
|
|||
workspace: 'The base directory of the project',
|
||||
debug: 'Whether to enable debug mode',
|
||||
version: 'Display the version number and exit',
|
||||
help: 'Display this help message'
|
||||
help: 'Display this help message',
|
||||
realm: 'Name of fixture realm to use',
|
||||
}
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,3 +12,4 @@ RUN echo "[LOG] Import finished." \
|
|||
&& rm -rf dump
|
||||
|
||||
COPY fixtures.*.sql dump/
|
||||
COPY realms realms/
|
||||
|
|
Loading…
Reference in New Issue