You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by db...@apache.org on 2015/06/18 01:45:42 UTC
cordova-coho git commit: CB-9109 Switched to using a repository's
.ratignore file instead of the ratExcludes property inside of coho.
Repository: cordova-coho
Updated Branches:
refs/heads/master e14bfda08 -> 1cb0b39ed
CB-9109 Switched to using a repository's .ratignore file instead of the ratExcludes property inside of coho.
Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/1cb0b39e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/1cb0b39e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/1cb0b39e
Branch: refs/heads/master
Commit: 1cb0b39eda6f76a49a798085f2433884dde024b2
Parents: e14bfda
Author: Dmitry Blotsky <dm...@gmail.com>
Authored: Tue Jun 16 18:29:54 2015 -0700
Committer: Dmitry Blotsky <dm...@gmail.com>
Committed: Wed Jun 17 12:47:39 2015 -0700
----------------------------------------------------------------------
src/audit-license-headers.js | 67 ++++++++++++++++++++++++-------
src/repoutil.js | 84 ++++++---------------------------------
2 files changed, 64 insertions(+), 87 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/1cb0b39e/src/audit-license-headers.js
----------------------------------------------------------------------
diff --git a/src/audit-license-headers.js b/src/audit-license-headers.js
index 131db8b..a48c332 100644
--- a/src/audit-license-headers.js
+++ b/src/audit-license-headers.js
@@ -18,6 +18,7 @@ under the License.
*/
var fs = require('fs');
+var os = require('os');
var path = require('path');
var chalk = require('chalk');
var shelljs = require('shelljs');
@@ -27,6 +28,7 @@ var executil = require('./executil');
var flagutil = require('./flagutil');
var repoutil = require('./repoutil');
+// constants
var COMMON_RAT_EXCLUDES = [
'*.wav',
'*.webloc',
@@ -44,11 +46,27 @@ var COMMON_RAT_EXCLUDES = [
'*.xcworkspacedata',
'*.xccheckout',
'*.xcscheme',
- ];
+];
+
+var RAT_IGNORE_PATH = '.ratignore';
+var RATIGNORE_COMMENT_PREFIX = '#';
+
+var RAT_NAME = 'apache-rat-0.10';
+var RAT_URL = 'https://dist.apache.org/repos/dist/release/creadur/apache-rat-0.10/apache-rat-0.10-bin.tar.gz';
+
+function startsWith(string, prefix) {
+ return string.indexOf(prefix) === 0;
+}
+
+function isComment(pattern) {
+ return startsWith(pattern.trim(), RATIGNORE_COMMENT_PREFIX);
+}
module.exports = function*() {
+
var opt = flagutil.registerRepoFlag(optimist);
- opt = flagutil.registerHelpFlag(opt);
+ opt = flagutil.registerHelpFlag(opt);
+
opt.usage('Uses Apache RAT to audit source files for license headers.\n' +
'\n' +
'Usage: $0 audit-license-headers --repo=name [-r repos]')
@@ -58,39 +76,58 @@ module.exports = function*() {
optimist.showHelp();
process.exit(1);
}
+
var repos = flagutil.computeReposFromFlag(argv.r, {includeModules: true});
+
// Check that RAT command exists.
- var ratName = 'apache-rat-0.10';
- var ratUrl = "https://dist.apache.org/repos/dist/release/creadur/apache-rat-0.10/apache-rat-0.10-bin.tar.gz";
var ratPath;
yield repoutil.forEachRepo([repoutil.getRepoById('coho')], function*() {
- ratPath = path.join(process.cwd(), ratName, ratName+'.jar');
+ ratPath = path.join(process.cwd(), RAT_NAME, RAT_NAME+'.jar');
});
+
if (!fs.existsSync(ratPath)) {
console.log('RAT tool not found, downloading to: ' + ratPath);
yield repoutil.forEachRepo([repoutil.getRepoById('coho')], function*() {
if (shelljs.which('curl')) {
- yield executil.execHelper(['sh', '-c', 'curl "' + ratUrl + '" | tar xz']);
+ yield executil.execHelper(['sh', '-c', 'curl "' + RAT_URL + '" | tar xz']);
} else {
- yield executil.execHelper(['sh', '-c', 'wget -O - "' + ratUrl + '" | tar xz']);
+ yield executil.execHelper(['sh', '-c', 'wget -O - "' + RAT_URL + '" | tar xz']);
}
});
if (!fs.existsSync(ratPath)) {
apputil.fatal('Download failed.');
}
}
- console.log(chalk.red('Note: ignore filters exist and often need updating within coho.'));
- console.log(chalk.red('Look at audit-license-headers.js (COMMON_RAT_EXCLUDES) as well as repo.ratExcludes property'));
+
+ console.log(chalk.red('Note: ignore filters reside in a repo\'s .ratignore and in COMMON_RAT_EXCLUDES in audit-license-headers.js.'));
+
+ // NOTE:
+ // the CWD in a callback is the directory for its respective repo
yield repoutil.forEachRepo(repos, function*(repo) {
- var allExcludes = COMMON_RAT_EXCLUDES;
- if (repo.ratExcludes) {
- allExcludes = allExcludes.concat(repo.ratExcludes);
+
+ var excludePatterns = COMMON_RAT_EXCLUDES;
+
+ // read in exclude patterns from repo's .ratignore, one pattern per line
+ if (fs.existsSync(RAT_IGNORE_PATH)) {
+
+ var ratignoreFile = fs.readFileSync(RAT_IGNORE_PATH);
+ var ratignoreLines = ratignoreFile.toString().trim().split(os.EOL);
+
+ // add only non-empty and non-comment lines
+ ratignoreLines.forEach(function (line) {
+ if (line.length > 0 && !isComment(line)) {
+ excludePatterns.push(line);
+ }
+ });
}
+
+ // add flags for excludes
var excludeFlags = [];
- allExcludes.forEach(function(e) {
- excludeFlags.push('-e', e);
+ excludePatterns.forEach(function (pattern) {
+ excludeFlags.push('-e', pattern);
});
+
+ // run Rat
yield executil.execHelper(executil.ARGS('java -jar', ratPath, '-d', '.').concat(excludeFlags));
});
}
-
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/1cb0b39e/src/repoutil.js
----------------------------------------------------------------------
diff --git a/src/repoutil.js b/src/repoutil.js
index 143c2a0..4693c4b 100644
--- a/src/repoutil.js
+++ b/src/repoutil.js
@@ -28,26 +28,14 @@ var platformRepos = [
id: 'android',
repoName: 'cordova-android',
jiraComponentName: 'Android',
- cordovaJsPaths: ['bin/templates/project/assets/www/cordova.js'],
- ratExcludes: [
- '*.properties',
- 'bin',
- 'gen',
- 'proguard-project.txt'
- ]
+ cordovaJsPaths: ['bin/templates/project/assets/www/cordova.js']
}, {
title: 'iOS',
id: 'ios',
repoName: 'cordova-ios',
jiraComponentName: 'iOS',
cordovaJsPaths: ['CordovaLib/cordova.js'],
- versionFilePaths: [path.join('CordovaLib', 'VERSION')],
- ratExcludes: [
- // yes, not .gitignore
- 'gitignore',
- // licenses for both below are in the cordova-ios LICENSE file
- 'NSData+Base64.h',
- 'NSData+Base64.m' ]
+ versionFilePaths: [path.join('CordovaLib', 'VERSION')]
}, {
title: 'BlackBerry',
id: 'blackberry',
@@ -65,12 +53,7 @@ var platformRepos = [
cordovaJsSrcName: 'cordova.windows.js',
cordovaJsPaths: ['template/www/cordova.js'],
versionFilePaths: ['VERSION'],
- packageFilePaths: ['package.json'],
- ratExcludes: [
- 'base.js', // WinJS base.js is using MIT license
- '*.appx',
- '*.appxbundle'
- ]
+ packageFilePaths: ['package.json']
}, {
title: 'Windows Phone 8.0',
id: 'wp8',
@@ -104,13 +87,7 @@ var platformRepos = [
id: 'amazon-fireos',
repoName: 'cordova-amazon-fireos',
jiraComponentName: 'Amazon FireOS',
- cordovaJsPaths: ['framework/assets/www/cordova.js'],
- ratExcludes: [
- '*.properties',
- 'bin',
- 'gen',
- 'proguard-project.txt'
- ]
+ cordovaJsPaths: ['framework/assets/www/cordova.js']
}, {
title: 'Browser',
id: 'browser',
@@ -161,12 +138,7 @@ var nonPlatformRepos = [
title: 'MobileSpec',
id: 'mobile-spec',
repoName: 'cordova-mobile-spec',
- jiraComponentName: 'mobile-spec',
- ratExcludes: [
- 'jasmine.*',
- 'html',
- 'uubench.js',
- ]
+ jiraComponentName: 'mobile-spec'
}, {
title: 'Hello World App',
id: 'app-hello-world',
@@ -247,13 +219,7 @@ var pluginRepos = [
id: 'plugin-globalization',
repoName: 'cordova-plugin-globalization',
jiraComponentName: 'Plugin Globalization',
- inactive: true,
- ratExcludes: [
- // zlib/libpng approved by Apache legal
- // http://www.apache.org/legal/resolved.html
- 'tokenizer.cpp',
- 'tokenizer.h'
- ]
+ inactive: true
}, {
title: 'Plugin - InAppBrowser',
id: 'plugin-inappbrowser',
@@ -277,13 +243,7 @@ var pluginRepos = [
id: 'plugin-network-information',
repoName: 'cordova-plugin-network-information',
jiraComponentName: 'Plugin Network Information',
- inactive: true,
- ratExcludes: [
- // Apple license is BSD compatible:
- // http://markmail.org/message/3ok5cottuxt5wpub
- 'CDVReachability.m',
- 'CDVReachability.h'
- ]
+ inactive: true
}, {
title: 'Plugin - Splash Screen',
id: 'plugin-splashscreen',
@@ -295,13 +255,7 @@ var pluginRepos = [
id: 'plugin-vibration',
repoName: 'cordova-plugin-vibration',
jiraComponentName: 'Plugin Vibration',
- inactive: true,
- ratExcludes: [
- // zlib/libpng approved by Apache legal
- // http://www.apache.org/legal/resolved.html
- 'tokenizer.cpp',
- 'tokenizer.h'
- ]
+ inactive: true
}, {
title: 'Plugin - Statusbar',
id: 'plugin-statusbar',
@@ -340,29 +294,18 @@ var toolRepos = [
title: 'Cordova CLI',
id: 'cli',
repoName: 'cordova-cli',
- jiraComponentName: 'CLI',
- ratExcludes: [
- '*.txt',
- 'cordova.cmd'
- ]
+ jiraComponentName: 'CLI'
}, {
title: 'Cordova Plugman',
id: 'plugman',
repoName: 'cordova-plugman',
- jiraComponentName: 'Plugman',
- ratExcludes: [
- 'help.txt'
- ]
+ jiraComponentName: 'Plugman'
}, {
title: 'Cordova Lib',
id: 'lib',
repoName: 'cordova-lib',
jiraComponentName: 'CordovaLib',
- path: 'cordova-lib',
- ratExcludes: [
- 'fixtures',
- 'platformsConfig.json'
- ]
+ path: 'cordova-lib'
}, {
title: 'Cordova Serve',
id: 'serve',
@@ -374,10 +317,7 @@ var toolRepos = [
title: 'Cordova JS',
id: 'js',
repoName: 'cordova-js',
- jiraComponentName: 'CordovaJS',
- ratExcludes: [
- 'tasks/vendor'
- ]
+ jiraComponentName: 'CordovaJS'
}, {
title: 'Cordova Coho',
id: 'coho',
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org