8000 chore(build): add a validation step for angularFiles · angular/angular.js@e29d7a7 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit e29d7a7

Browse files
committed
chore(build): add a validation step for angularFiles
1 parent 05d3ed0 commit e29d7a7

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-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
@@ -339,6 +341,56 @@ module.exports = function(grunt) {
339341
grunt.task.run('shell:npm-install');
340342
}
341343

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

355407
grunt.registerTask('minify', ['bower','clean', 'build', 'minall']);
356408
grunt.registerTask('webserver', ['connect:devserver']);
357-
grunt.registerTask('package', ['bower','clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']);
409+
grunt.registerTask('package', ['bower', 'validate-angular-files','clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']);
358410
grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'jshint', 'jscs']);
359411
grunt.registerTask('default', ['package']);
360412
};

angularFiles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var angularFiles = {
8585
],
8686

8787
'angularLoader': [
88-
'stringify.js',
88+
'src/stringify.js',
8989
'src/minErr.js',
9090
'src/loader.js'
9191
],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"dgeni": "^0.4.0",
3131
"dgeni-packages": "^0.11.0",
3232
"event-stream": "~3.1.0",
33+
"glob": "^6.0.1",
3334
"grunt": "~0.4.2",
3435
"grunt-bump": "~0.0.13",
3536
"grunt-contrib-clean": "~0.6.0",

0 commit comments

Comments
 (0)
0