diff --git a/Logo.js b/Logo.js new file mode 100644 index 0000000..b8b424f --- /dev/null +++ b/Logo.js @@ -0,0 +1,38 @@ +/* + * This file is a part of "NMIG" - the database migration tool. + * + * Copyright 2016 Anatoly Khaytovich + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program (please see the "LICENSE.md" file). + * If not, see . + * + * @author Anatoly Khaytovich + */ +'use strict'; + +/** + * Render the logo. + * + * @returns {undefined} + */ +module.exports = function() { + const logo = '\n\t/\\_ |\\ /\\/\\ /\\___' + + '\n\t| \\ | |\\ | | | __' + + '\n\t| |\\\\| || | | | \\_ \\' + + '\n\t| | \\| || | | |__/ |' + + '\n\t\\| \\/ /_|/______/' + + '\n\n\tNMIG - the database migration tool' + + '\n\tCopyright 2016 Anatoly Khaytovich \n\n'; + + console.log(logo); +}; diff --git a/migration/fmtp/BootProcessor.js b/migration/fmtp/BootProcessor.js new file mode 100644 index 0000000..1aca661 --- /dev/null +++ b/migration/fmtp/BootProcessor.js @@ -0,0 +1,56 @@ +/* + * This file is a part of "NMIG" - the database migration tool. + * + * Copyright 2016 Anatoly Khaytovich + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program (please see the "LICENSE.md" file). + * If not, see . + * + * @author Anatoly Khaytovich + */ +'use strict'; + +/** + * Boot the migration. + * + * @param {Conversion} self + * + * @returns {Promise} + */ +module.exports = function(self) { + return new Promise(resolve => { + const logo = '\n\t/\\_ |\\ /\\/\\ /\\___' + + '\n\t| \\ | |\\ | | | __' + + '\n\t| |\\\\| || | | | \\_ \\' + + '\n\t| | \\| || | | |__/ |' + + '\n\t\\| \\/ /_|/______/' + + '\n\n\tNMIG - the database migration tool' + + '\n\tCopyright 2016 Anatoly Khaytovich \n\n' + + '\t--[boot] The configuration has been just loaded.' + + '\n\t--[boot] NMIG is ready to start.\n\t--[boot] Proceed? [Y/n]'; + + console.log(logo); + process + .stdin + .resume() + .setEncoding(self._encoding) + .on('data', stdin => { + if (stdin.indexOf('Y') !== -1) { + resolve(); + } else { + console.log('\t--[boot] Migration aborted.\n'); + process.exit(); + } + }); + }); +}; diff --git a/migration/fmtp/CommentsProcessor.js b/migration/fmtp/CommentsProcessor.js index de6accc..307776b 100644 --- a/migration/fmtp/CommentsProcessor.js +++ b/migration/fmtp/CommentsProcessor.js @@ -151,9 +151,10 @@ module.exports = function(self, tableName) { return new Promise(resolve => { const msg = '\t--[CommentsProcessor] Creates comments for table "' + self._schema + '"."' + tableName + '"...'; log(self, msg, self._dicTables[tableName].tableLogPath); - const tableCommentsPromise = processTableComments(self, tableName); - const columnsCommentsPromise = processColumnsComments(self, tableName); - Promise.all([tableCommentsPromise, columnsCommentsPromise]).then(() => resolve()); + Promise.all([ + processTableComments(self, tableName), + processColumnsComments(self, tableName) + ]).then(() => resolve()); }); }); }; diff --git a/migration/fmtp/Main.js b/migration/fmtp/Main.js index 44b4b1f..154448a 100644 --- a/migration/fmtp/Main.js +++ b/migration/fmtp/Main.js @@ -31,6 +31,7 @@ const dataPoolManager = require('./DataPoolManager'); const directoriesManager = require('./DirectoriesManager'); const loadStructureToMigrate = require('./StructureLoader'); const pipeData = require('./DataPipeManager'); +const boot = require('./BootProcessor'); /** * Runs migration according to user's configuration. @@ -40,10 +41,10 @@ const pipeData = require('./DataPipeManager'); * @returns {undefined} */ module.exports = function(config) { - console.log('\n\tNMIG - the database migration tool\n\tCopyright 2016 Anatoly Khaytovich \n\t Boot...'); const self = new Conversion(config); - - readDataTypesMap(self).then( + boot(self).then(() => { + return readDataTypesMap(self); + }).then( () => { return directoriesManager.createLogsDirectory(self); },