Skip to content

Commit d2058d9

Browse files
matskopetebacondarwin
authored andcommitted
chore(build): add a validation step for angularFiles
Closes angular#13553
1 parent 053f4e2 commit d2058d9

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

Gruntfile.js

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ var files = require('./angularFiles').files;
44
var util = require('./lib/grunt/utils.js');
55
var versionInfo = require('./lib/versions/version-info');
66
var path = require('path');
7+
var fs = require('fs');
78
var e2e = require('./test/e2e/tools');
9+
var glob = require("glob");
810

911
module.exports = function(grunt) {
1012
//grunt plugins
@@ -327,6 +329,56 @@ module.exports = function(grunt) {
327329
grunt.task.run('shell:npm-install');
328330
}
329331

332+
grunt.registerTask('validate-angular-files', function() {
333+
var combinedFiles = Object.assign({}, files.angularModules);
334+
combinedFiles.ng = files.angularSrc;
335+
combinedFiles.angularLoader = files.angularLoader;
336+
337+
var errorsDetected = false;
338+
var directories = [];
339+
var detectedFiles = {
340+
"src/ng/rootElement.js": true
341+
};
342+
343+
for (var section in combinedFiles) {
344+
var sectionFiles = combinedFiles[section];
345+
346+
if (section != "angularLoader") {
347+
directories.push("src/" + section);
348+
}
349+
350+
console.log("Validating " + sectionFiles.length + " files from the \"" + section + "\" module");
351+
352+
sectionFiles.forEach(function(file) {
353+
detectedFiles[file] = true;
354+
355+
if (!fs.existsSync(file)) {
356+
grunt.log.error(file + " does not exist in the local file structure");
357+
errorsDetected = true;
358+
}
359+
});
360+
}
361+
362+
directories.forEach(function(directory) {
363+
glob.sync(directory + "/**/*").forEach(function(filePath) {
364+
if (!fs.lstatSync(filePath).isDirectory()) {
365+
var fileName = path.basename(filePath);
366+
var isHiddenFile = fileName[0] == ".";
367+
if (!isHiddenFile && !detectedFiles[filePath]) {
368+
grunt.log.error(filePath + " exists in the local file structure but isn't used by any module");
369+
errorsDetected = true;
370+
}
371+
}
372+
});
373+
});
374+
375+
if (errorsDetected) {
376+
throw new Error("Not all files were properly detected the local file structure");
377+
} else {
378+
console.log("All files were detected successfully!");
379+
}
380+
});
381+
330382
//alias tasks
331383
grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', 'package','test:unit','test:promises-aplus', 'tests:docs', 'test:protractor']);
332384
grunt.registerTask('test:jqlite', 'Run the unit tests with Karma' , ['tests:jqlite']);
@@ -342,7 +394,7 @@ module.exports = function(grunt) {
342394

343395
grunt.registerTask('minify', ['bower','clean', 'build', 'minall']);
344396
grunt.registerTask('webserver', ['connect:devserver']);
345-
grunt.registerTask('package', ['bower','clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']);
397+
grunt.registerTask('package', ['bower', 'validate-angular-files','clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']);
346398
grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'jshint', 'jscs']);
347399
grunt.registerTask('default', ['package']);
348400
};

angularFiles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var angularFiles = {
7979
],
8080

8181
'angularLoader': [
82-
'stringify.js',
82+
'src/stringify.js',
8383
'src/minErr.js',
8484
'src/loader.js'
8585
],

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy