Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

chore(GruntFile): check angularFiles (update) #13569

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ module.exports = function(grunt) {
},
"promises-aplus-adapter": {
dest:'tmp/promises-aplus-adapter++.js',
src:['src/ng/q.js','lib/promises-aplus/promises-aplus-test-adapter.js']
src:['src/ng/q.js', 'lib/promises-aplus/promises-aplus-test-adapter.js']
}
},

Expand Down Expand Up @@ -339,8 +339,10 @@ module.exports = function(grunt) {
grunt.task.run('shell:npm-install');
}



//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', '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']);
grunt.registerTask('test:jquery', 'Run the jQuery unit tests with Karma', ['tests:jquery']);
grunt.registerTask('test:modules', 'Run the Karma module tests with Karma', ['build', 'tests:modules']);
Expand All @@ -350,11 +352,11 @@ module.exports = function(grunt) {
grunt.registerTask('test:travis-protractor', 'Run the end to end tests with Protractor for Travis CI builds', ['connect:testserver', 'protractor:travis']);
grunt.registerTask('test:ci-protractor', 'Run the end to end tests with Protractor for Jenkins CI builds', ['webdriver', 'connect:testserver', 'protractor:jenkins']);
grunt.registerTask('test:e2e', 'Alias for test:protractor', ['test:protractor']);
grunt.registerTask('test:promises-aplus',['build:promises-aplus-adapter','shell:promises-aplus-tests']);
grunt.registerTask('test:promises-aplus',['build:promises-aplus-adapter', 'shell:promises-aplus-tests']);

grunt.registerTask('minify', ['bower','clean', 'build', 'minall']);
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']);
};
3 changes: 2 additions & 1 deletion angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var angularFiles = {
'src/ng/q.js',
'src/ng/raf.js',
'src/ng/rootScope.js',
'src/ng/rootElement.js',
'src/ng/sanitizeUri.js',
'src/ng/sce.js',
'src/ng/sniffer.js',
Expand Down Expand Up @@ -85,7 +86,7 @@ var angularFiles = {
],

'angularLoader': [
'stringify.js',
'src/stringify.js',
'src/minErr.js',
'src/loader.js'
],
Expand Down
58 changes: 58 additions & 0 deletions lib/grunt/validate-angular-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use strict';

var path = require('path');
var fs = require('fs');
var glob = require("glob");
var _ = require('lodash');
var files = require('../../angularFiles').files;

module.exports = function(grunt) {

grunt.registerTask('validate-angular-files', function() {
var combinedFiles = _.clone(files.angularModules);
combinedFiles.ng = files.angularSrc;
combinedFiles.angularLoader = files.angularLoader;

var errorsDetected = false;
var directories = [];
var detectedFiles = {};

for (var section in combinedFiles) {
var sectionFiles = combinedFiles[section];

if (section != "angularLoader") {
directories.push("src/" + section);
}

grunt.log.debug("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 in the local file structure.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message is not 100% accurate (as the errors might be due to files in the local file structure not being used).

} else {
grunt.log.ok("All files were detected successfully!");
}
});
};
73 changes: 43 additions & 30 deletions npm-shrinkwrap.clean.json
Original file line number Diff line number Diff line change
Expand Up @@ -5865,6 +5865,49 @@
}
}
},
"glob": {
"version": "6.0.1",
"dependencies": {
"inflight": {
"version": "1.0.4",
"dependencies": {
"wrappy": {
"version": "1.0.1"
}
}
},
"inherits": {
"version": "2.0.1"
},
"minimatch": {
"version": "3.0.0",
"dependencies": {
"brace-expansion": {
"version": "1.1.2",
"dependencies": {
"balanced-match": {
"version": "0.3.0"
},
"concat-map": {
"version": "0.0.1"
}
}
}
}
},
"once": {
"version": "1.3.3",
"dependencies": {
"wrappy": {
"version": "1.0.1"
}
}
},
"path-is-absolute": {
"version": "1.0.0"
}
}
},
"grunt": {
"version": "0.4.5",
"dependencies": {
Expand Down Expand Up @@ -9219,14 +9262,6 @@
},
"async-each": {
"version": "0.1.6"
},
"fsevents": {
"version": "0.3.5",
"dependencies": {
"nan": {
"version": "1.5.3"
}
}
}
}
},
Expand Down Expand Up @@ -10394,28 +10429,6 @@
},
"ultron": {
"version": "1.0.1"
},
"bufferutil": {
"version": "1.1.0",
"dependencies": {
"bindings": {
"version": "1.2.1"
},
"nan": {
"version": "1.8.4"
}
}
},
"utf-8-validate": {
"version": "1.1.0",
"dependencies": {
"bindings": {
"version": "1.2.1"
},
"nan": {
"version": "1.8.4"
}
}
}
}
},
Expand Down
Loading