diff --git a/Gruntfile.js b/Gruntfile.js index 018f08b16f1c..82d5b224b8bf 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,7 +4,9 @@ var files = require('./angularFiles').files; var util = require('./lib/grunt/utils.js'); var versionInfo = require('./lib/versions/version-info'); var path = require('path'); +var fs = require('fs'); var e2e = require('./test/e2e/tools'); +var glob = require("glob"); module.exports = function(grunt) { //grunt plugins @@ -339,6 +341,56 @@ module.exports = function(grunt) { grunt.task.run('shell:npm-install'); } + grunt.registerTask('validate-angular-files', function() { + var combinedFiles = Object.assign({}, files.angularModules); + combinedFiles.ng = files.angularSrc; + combinedFiles.angularLoader = files.angularLoader; + + var errorsDetected = false; + var directories = []; + var detectedFiles = { + "src/ng/rootElement.js": true + }; + + for (var section in combinedFiles) { + var sectionFiles = combinedFiles[section]; + + if (section != "angularLoader") { + directories.push("src/" + section); + } + + console.log("Validating " + sectionFiles.length + " files from the \"" + section + "\" module"); + + sectionFiles.forEach(function(file) { + detectedFiles[file] = true; + + if (!fs.existsSync(file)) { + grunt.log.error(file + " does not exist in the local file structure"); + errorsDetected = true; + } + }); + } + + directories.forEach(function(directory) { + glob.sync(directory + "/**/*").forEach(function(filePath) { + if (!fs.lstatSync(filePath).isDirectory()) { + var fileName = path.basename(filePath); + var isHiddenFile = fileName[0] == "."; + if (!isHiddenFile && !detectedFiles[filePath]) { + grunt.log.error(filePath + " exists in the local file structure but isn't used by any module"); + errorsDetected = true; + } + } + }); + }); + + if (errorsDetected) { + throw new Error("Not all files were properly detected the local file structure"); + } else { + console.log("All files were detected successfully!"); + } + }); + //alias tasks grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', 'package','test:unit','test:promises-aplus', 'tests:docs', 'test:protractor']); grunt.registerTask('test:jqlite', 'Run the unit tests with Karma' , ['tests:jqlite']); @@ -354,7 +406,7 @@ module.exports = function(grunt) { grunt.registerTask('minify', ['bower','clean', 'build', 'minall']); grunt.registerTask('webserver', ['connect:devserver']); - grunt.registerTask('package', ['bower','clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']); + grunt.registerTask('package', ['bower', 'validate-angular-files','clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']); grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'jshint', 'jscs']); grunt.registerTask('default', ['package']); }; diff --git a/angularFiles.js b/angularFiles.js index dbb05d1a7624..6be3f249bb2f 100755 --- a/angularFiles.js +++ b/angularFiles.js @@ -86,7 +86,7 @@ var angularFiles = { ], 'angularLoader': [ - 'stringify.js', + 'src/stringify.js', 'src/minErr.js', 'src/loader.js' ], diff --git a/package.json b/package.json index f3dbf0a08238..9db78ae98768 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "dgeni": "^0.4.0", "dgeni-packages": "^0.11.0", "event-stream": "~3.1.0", + "glob": "^6.0.1", "grunt": "~0.4.2", "grunt-bump": "~0.0.13", "grunt-contrib-clean": "~0.6.0",