Commit e6fcb14b authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Reorganiza configs y tasks de grunt

parent caf313ab
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
module.exports = function(grunt) {

	var path = require('path'),

		rootPath = grunt.config('redmicConfig.rootPath'),
		depPath = grunt.config('redmicConfig.depPath'),
		distPath = grunt.config('redmicConfig.distPath'),
		pkg = grunt.config('pkg');

	grunt.config('shell.buildApp', {
		options: {
			stdout: true
		},
		command: function() {

			var profile = pkg.dojoBuild,
				scriptPath = path.join(depPath, 'dojo/dojo.js'),
				releaseDir = path.join(rootPath, distPath),
				nodeParams = ' --optimize_for_size --max_old_space_size=3000 --gc_interval=100 ',
				buildParams = ' load=build --profile "' + profile + '" --releaseDir "' + releaseDir + '"';

			return [
				'echo "\nBuilding application with ' + profile + ' to ' + releaseDir + '\n"',
				'node' + nodeParams + scriptPath + buildParams,
				'echo "\nBuild complete"'
			].join('; ');
		}
	});
};
+19 −0
Original line number Diff line number Diff line
module.exports = function(grunt) {

	var srcPath = grunt.config('redmicConfig.srcPath'),
		publicPath = srcPath.split('/')[0],
		stylesPath = publicPath + '/style';

	grunt.config('shell.buildStyles', {
		options: {
			stdout: true
		},
		command: function() {

			return [
				'cd ' + stylesPath,
				'grunt'
			].join('; ');
		}
	});
};
+91 −1
Original line number Diff line number Diff line
@@ -23,10 +23,100 @@ module.exports = function(grunt) {
			'leaflet/dist/images/*.png', 'src/app/App.js'
		];

	grunt.config('redmicConfig.resourcesToCleanInBuiltApp', {
	var resourcesToClean = {
		filesToKeep: filesToKeep,
		directories: directoriesToDelete,
		recursiveDirectories: recursiveDirectoriesToDelete,
		files: filesToDelete
	};

	var path = require('path'),

		distPath = grunt.config('redmicConfig.distPath'),
		destDir = grunt.config('redmicConfig.destDir'),
		destPath = path.join(distPath, destDir, '/');

	grunt.config('shell.cleanBuiltApp', {
		options: {
			stdout: true
		},
		command: function() {

			var filesToKeep = resourcesToClean.filesToKeep,
				directoriesToClean = resourcesToClean.directories,
				recursiveDirectoriesToClean = resourcesToClean.recursiveDirectories,
				filesToClean = resourcesToClean.files,

				createDirectoriesToKeepFilesCmd = 'mkdir -p',
				createDirectoriesToRestoreFilesCmd = 'mkdir -p',
				keepFilesCmds = [],
				restoreFilesCmds = [],
				cleanDirectoriesCmd = 'rm -rf',
				cleanRecursiveDirsCmd = 'find ' + destPath + ' -type d',
				cleanFilesCmd = 'find ' + destPath + ' -type f',
				temporalBasePath = path.join(destPath, '.temp'),
				i;

			for (i = 0; i < filesToKeep.length; i++) {
				var fileToKeep = filesToKeep[i],
					fileName = path.basename(fileToKeep),
					filePath = path.dirname(fileToKeep),
					absoluteFileName = path.join(destPath, fileToKeep),
					absoluteFilePath = path.join(destPath, filePath);

				createDirectoriesToRestoreFilesCmd += ' ' + absoluteFilePath;

				var absoluteTemporalPath = path.join(temporalBasePath, i.toString(), filePath),
					absoluteTemporalFileName = path.join(absoluteTemporalPath, fileName);

				createDirectoriesToKeepFilesCmd += ' ' + absoluteTemporalPath;

				var keepCmd = 'mv ' + absoluteFileName + ' ' + absoluteTemporalPath,
					restoreCmd = 'mv ' + absoluteTemporalFileName + ' ' + absoluteFilePath;

				keepFilesCmds.push(keepCmd);
				restoreFilesCmds.push(restoreCmd);
			}

			restoreFilesCmds.push('rm -r ' + temporalBasePath);

			for (i = 0; i < directoriesToClean.length; i++) {
				var directory = directoriesToClean[i];

				cleanDirectoriesCmd += ' ' + destPath + directory;
			}

			var optionPrefix;
			for (i = 0; i < recursiveDirectoriesToClean.length; i++) {
				var recursiveDirectory = recursiveDirectoriesToClean[i];

				optionPrefix = (!i ? '' : ' -o');

				cleanRecursiveDirsCmd += optionPrefix + ' -name "' + recursiveDirectory + '" -exec rm -rf {} +';
			}

			for (i = 0; i < filesToClean.length; i++) {
				var file = filesToClean[i];

				optionPrefix = (!i ? '' : ' -o');

				cleanFilesCmd += optionPrefix + ' -name "' + file + '" -delete';
			}

			var appDir = destPath + 'app',
				cleanUnusedAppFilesCmd = 'find ' + appDir + ' -maxdepth 1 -type f -name "*.js" -delete';

			return [
				'echo "\nCleaning build and debug resources from built application at ' + destPath + '\n"',
				createDirectoriesToKeepFilesCmd,
				keepFilesCmds.join('; '),
				cleanDirectoriesCmd,
				cleanRecursiveDirsCmd,
				createDirectoriesToRestoreFilesCmd,
				restoreFilesCmds.join('; '),
				cleanFilesCmd,
				cleanUnusedAppFilesCmd
			].join('; ');
		}
	});
};
+20 −0
Original line number Diff line number Diff line
module.exports = function(grunt) {

	grunt.config('shell.checkGlobalDependences', {
		options: {
			stdout: true
		},
		command: [
			'type yarn'
		].join(' && ')
	});

	grunt.config('shell.installDependences', {
		options: {
			stdout: true
		},
		command: [
			'yarn install --prod=false'
		].join('; ')
	});
};
+85 −0
Original line number Diff line number Diff line
module.exports = function(grunt) {

	grunt.config('shell.test-functional-local-parallel', {
		command: function() {

			var serverUrlParam = grunt.option('serverUrl'),
				userParam = grunt.option('user'),
				passParam = grunt.option('pass'),
				serverPort = 9000,
				gruntCommand = 'grunt test-functional-local --headless',

				publicZoneGroups = 'catalog,catalogDetails,viewers,products',
				administrativeZoneGroup = 'administrative,!administrative/taxonomy',
				taxonomyZoneGroup = 'administrative/taxonomy',
				dataLoaderAndAdministrativeDetailsZoneGroup = 'administrativeDetails,dataLoader',
				maintenanceAndAdminDomainsZoneGroup = 'maintenance,!maintenance/domains/taxon' +
					',!maintenance/domains/observations',
				taxonAndObservationDomainsZoneGroup = 'maintenance/domains/observations,maintenance/domains/taxon',

				portParam = ' --ownServerPort=',

				guestCommonTestsParams = ' --role=guest --suitesGroups=',

				guestTestsParams = guestCommonTestsParams + publicZoneGroups,

				specificParamsList = [],
				specificParams,

				userCommonTestsParams = ' --role=administrator --user=' + userParam + ' --pass=' + passParam +
					' --suitesGroups=',

				userZoneGroupsList = [
					publicZoneGroups, administrativeZoneGroup, taxonomyZoneGroup,
					dataLoaderAndAdministrativeDetailsZoneGroup, maintenanceAndAdminDomainsZoneGroup,
					taxonAndObservationDomainsZoneGroup
				],

				commonGuestZoneGroups = guestCommonTestsParams + 'common',
				commonUserZoneGroups = userCommonTestsParams + 'common',

				cmds = [],
				commandsGrunt = '';

			if (serverUrlParam) {
				gruntCommand += ' --serverUrl="' + serverUrlParam + '"';
			}

			for (var i = 0; i < userZoneGroupsList.length; i++) {
				specificParamsList.push(userCommonTestsParams + userZoneGroupsList[i]);
			}

			commandsGrunt = gruntCommand + commonGuestZoneGroups + portParam + serverPort + ' ; ';
			serverPort += 3;

			commandsGrunt += gruntCommand + commonUserZoneGroups + portParam + serverPort + ' ; ';
			serverPort += 3;

			commandsGrunt += gruntCommand + guestTestsParams + portParam + serverPort + ' ; ';
			serverPort += 3;

			var firstPartSpecificParamsList = Math.floor(specificParamsList.length / 2);

			for (i = 0; i < firstPartSpecificParamsList; i++) {
				specificParams = specificParamsList[i];

				cmds.push(gruntCommand + specificParams + portParam + serverPort);
				serverPort += 3;
			}

			commandsGrunt += cmds.join(' & ') + ' ; ';
			cmds = [];

			for (i = firstPartSpecificParamsList; i < specificParamsList.length; i++) {
				specificParams = specificParamsList[i];

				cmds.push(gruntCommand + specificParams + portParam + serverPort);
				serverPort += 3;
			}

			commandsGrunt += cmds.join(' & ');

			return commandsGrunt;
		}
	});
};
Loading