Я хотел бы добавить специальную задачу gulp для экспорта, импорта и создания базы данных Wordpress в моем gulpfile.babel. js для автоматизации моего рабочего процесса.
Я не очень хорошо разбираюсь в рабочих делах и нашел единственное решение для этого случая: https://gist.github.com/rjgamer/86bc0fc89621a42c348e8d22a2f010b1
import shell from "shelljs";
export const dumping = () => {
var command = config.commands.mysqldump + ' -u ' + config.user + ' ' + config.database + ' > ' + config.dumpFilePath;
console.log(command);
var result = shell.exec(command);
if (result.code !== 0) {
console.error('MySQL dump export failed');
} else {
console.log('MySQL dump successful exported');
}
shell.exit(1);
};
export const importing = () => {
var command = config.commands.mysql + ' -u ' + config.user + ' ' + config.database + ' < ' + config.dumpFilePath;
console.log(command);
var result = shell.exec(command);
if (result.code !== 0) {
console.error('MySQL dump import failed');
} else {
console.log('MySQL dump successful imported');
}
shell.exit(1);
};
export const cleandb = () => {
var command = config.commands.mysql + ' -u ' + config.user + ' -Bse "' +
'DROP DATABASE `' + config.database + '`;' +
'CREATE DATABASE `' + config.database + '` CHARACTER SET utf8 COLLATE utf8_bin;"';
console.log(command);
var result = shell.exec(command);
if (result.code !== 0) {
console.error('MySQL clean database failed');
} else {
console.log('MySQL database successful cleaned');
}
shell.exit(1);
};
export const db = series(dumping);
export const importdb = series(importing);
export const deletedb = series(cleandb);
Что вы думаете о который? Кто-нибудь может поделиться с собственным решением?