module.exports = function (grunt) {
    'use strict';

    var bootstrapDir = 'views/bootstrap/vendors',
        tdkDir = 'views/tdk/vendors',
        nodeDir = 'node_modules';

    grunt.initConfig({
        clean: {
            vendors: [ bootstrapDir ]
        },
        copy: {
					'bootstrap': {
						files: [{
								expand: true,
								src: [
										nodeDir + '/jquery/dist/*'
								],
								dest: bootstrapDir + '/jquery',
								flatten: true
						}, {
								expand: true,
								src: [
										nodeDir + '/chartjs/chart.js',
										nodeDir + '/chartjs/README.md',
										nodeDir + '/chartjs/LICENSE'
								],
								dest: bootstrapDir + '/chartjs',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/cytoscape/dist/*',
										nodeDir + '/cytoscape-grid-guide/cytoscape-grid-guide.js'
								],
								dest: bootstrapDir + '/cytoscape',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/jqtree/tree.jquery.js',
										nodeDir + '/jqtree/jqtree.css'
								],
								dest: bootstrapDir + '/jqtree',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/noty/js/noty/jquery.noty.js'
								],
								dest: bootstrapDir + '/noty',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/noty/js/noty/themes/*'
								],
								dest: bootstrapDir + '/noty/themes',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/noty/js/noty/layouts/*'
								],
								dest: bootstrapDir + '/noty/layouts',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/select2/dist/js/*'
								],
								dest: bootstrapDir + '/select2/js',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/select2/dist/css/*'
								],
								dest: bootstrapDir + '/select2/css',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/fine-uploader/jquery.fine-uploader/*'
								],
								dest: bootstrapDir + '/fine-uploader',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/jquery-validation/dist/*'
								],
								dest: bootstrapDir + '/jquery-validation',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/flot/source/jquery.canvaswrapper.js',
										nodeDir + '/flot/source/jquery.colorhelpers.js',
										nodeDir + '/flot/source/jquery.flot.*'
								],
								dest: bootstrapDir + '/flot',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/font-awesome/fonts/*'
								],
								dest: bootstrapDir + '/font-awesome/fonts',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/font-awesome/css/*'
								],
								dest: bootstrapDir + '/font-awesome/css',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/fullcalendar/LICENSE.txt',
										nodeDir + '/fullcalendar/dist/*'
								],
								dest: bootstrapDir + '/fullcalendar',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/fullcalendar/dist/locale/*'
								],
								dest: bootstrapDir + '/fullcalendar/locale',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/moment/LICENSE.txt',
										nodeDir + '/moment/min/*'
								],
								dest: bootstrapDir + '/moment',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/moment/dist/locale/*'
								],
								dest: bootstrapDir + '/moment/locale',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/perfect-scrollbar/dist/*'
								],
								dest: bootstrapDir + '/perfect-scrollbar',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/bootstrap-datepicker/dist/js/*'
								],
								dest: bootstrapDir + '/bootstrap-datepicker/js',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/bootstrap-datepicker/dist/css/*'
								],
								dest: bootstrapDir + '/bootstrap-datepicker/css',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/bootstrap-datepicker/dist/locales/*'
								],
								dest: bootstrapDir + '/bootstrap-datepicker/locales',
								flatten: true
						}]
					},
					'coreui': {
						files: [{
								expand: true,
								src: [
										nodeDir + '/jquery/dist/*'
								],
								dest: tdkDir + '/jquery',
								flatten: true
						}, {
								expand: true,
								src: [
										nodeDir + '/@coreui/coreui/dist/js/*'
								],
								dest: tdkDir + '/@coreui/coreui/js',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/@coreui/coreui/dist/css/*'
								],
								dest: tdkDir + '/@coreui/coreui/css',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/@coreui/icons/css/*'
								],
								dest: tdkDir + '/@coreui/icons/css',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/@coreui/icons/fonts/*'
								],
								dest: tdkDir + '/@coreui/icons/fonts',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/popper.js/dist/esm/*'
								],
								dest: tdkDir + '/popper.js',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/perfect-scrollbar/dist/*'
								],
								dest: tdkDir + '/perfect-scrollbar',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/bootstrap/dist/js/*'
								],
								dest: tdkDir + '/bootstrap/js',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/bootstrap/dist/css/*'
								],
								dest: tdkDir + '/bootstrap/css',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/font-awesome/fonts/*'
								],
								dest: tdkDir + '/font-awesome/fonts',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/font-awesome/css/*'
								],
								dest: tdkDir + '/font-awesome/css',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/pace-progressbar/index.js'
								],
								dest: tdkDir + '/pace-progressbar',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/pace-progressbar/themes/*'
								],
								dest: tdkDir + '/pace-progressbar/themes',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/pace-progressbar/templates/*'
								],
								dest: tdkDir + '/pace-progressbar/templates',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/flag-icon-css/css/*'
								],
								dest: tdkDir + '/flag-icon-css/css',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/simple-line-icons/dist/fonts/*'
								],
								dest: tdkDir + '/simple-line-icons/fonts',
								flatten: true
						},{
								expand: true,
								src: [
										nodeDir + '/simple-line-icons/dist/styles/*'
								],
								dest: tdkDir + '/simple-line-icons/css',
								flatten: true
						}]
					},
				}
    });

    grunt.registerTask('createVendorDir', 'Creates the necessary vendor directory', function() {
        // Create the bootstrapDir when it doesn't exists.
        if (!grunt.file.isDir(bootstrapDir)) {
            grunt.file.mkdir(bootstrapDir);

            // Output a success message
            grunt.log.oklns(grunt.template.process(
                'Directory "<%= directory %>" was created successfully.',
                { data: { directory: bootstrapDir } }
            ));
        }
    });

    grunt.registerTask('default', [ 'clean', 'createVendorDir', 'copy' ]);
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
};
