You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ripple.apache.org by ti...@apache.org on 2015/05/12 05:02:09 UTC

incubator-ripple git commit: Adds 'jake rat' task to run Apache RAT, which verifies license headers in the project are valid (that is, license headers exist in all files that need them, and are recognized and of a type acceptable in an Apache project).

Repository: incubator-ripple
Updated Branches:
  refs/heads/master b463abc5a -> 7ba34149c


Adds 'jake rat' task to run Apache RAT, which verifies license headers in the project are valid (that is, license headers exist in all files that need them, and are recognized and of a type acceptable in an Apache project).


Project: http://git-wip-us.apache.org/repos/asf/incubator-ripple/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ripple/commit/7ba34149
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ripple/tree/7ba34149
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ripple/diff/7ba34149

Branch: refs/heads/master
Commit: 7ba34149c7f55b83f757d4a3a05792ed683df345
Parents: b463abc
Author: Tim Barham <ti...@microsoft.com>
Authored: Tue May 12 12:48:43 2015 +1000
Committer: Tim Barham <ti...@microsoft.com>
Committed: Tue May 12 12:58:49 2015 +1000

----------------------------------------------------------------------
 .gitignore   |  1 +
 Jakefile     |  3 +++
 build/rat.js | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 package.json |  3 ++-
 4 files changed, 86 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/7ba34149/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 1ebd44a..2e3967f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,4 @@ npm-debug.log
 test/assets/cov/results.html
 thirdparty/jasmine
 ripple-emulator-*.*
+apache-rat-0.10/
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/7ba34149/Jakefile
----------------------------------------------------------------------
diff --git a/Jakefile b/Jakefile
index 2505940..0bb58f6 100644
--- a/Jakefile
+++ b/Jakefile
@@ -72,3 +72,6 @@ desc('creates an archive - jake archive[clean:<value>,sign:<value>,tag:<tagname>
 task('archive', [], function () {
     require('./build/archive')(Array.prototype.slice.apply(arguments));
 });
+
+desc('Runs Apache RAT to audit source file license headers');
+task('rat', [], require('./build/rat'));

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/7ba34149/build/rat.js
----------------------------------------------------------------------
diff --git a/build/rat.js b/build/rat.js
new file mode 100644
index 0000000..e8bc682
--- /dev/null
+++ b/build/rat.js
@@ -0,0 +1,80 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+var child_process = require('child_process'),
+    fs = require('fs'),
+    path = require('path'),
+    shelljs = require('shelljs');
+
+module.exports = function () {
+    var ratName = 'apache-rat-0.10';
+    var ratPath = path.join(process.cwd(), ratName, ratName + '.jar');
+
+    if (!fs.existsSync(ratPath)) {
+        console.log('Downloading Apache RAT...');
+        var ratUrl = "https://dist.apache.org/repos/dist/release/creadur/apache-rat-0.10/apache-rat-0.10-bin.tar.gz";
+        if (shelljs.which('curl')) {
+            child_process.spawnSync('sh', ['-c', 'curl "' + ratUrl + '" | tar xz']);
+        } else {
+            child_process.spawnSync('sh', ['-c', 'wget -O - "' + ratUrl + '" | tar xz']);
+        }
+        if (!fs.existsSync(ratPath)) {
+            throw new Error('Downloading RAT failed');
+        }
+    }
+
+    // Generate RAT exclude flags from list of excluded file patterns
+    var excludeFlags = [];
+    [
+        'node_modules',
+        'theme.css',
+        '.*',
+        'bower.json',
+        'apache-rat-0.10',
+        '*.txt',
+        'pkg',
+        'manifest.json',
+        'jquery.js',
+        'jasmine',
+        '3d.js',
+        'Math.uuid.js',
+        'draw.js',
+        'jXHR.js',
+        'jquery.js',
+        'jquery.tooltip.js',
+        'jquery.ui.js'
+    ].forEach(function (excluded) {
+        excludeFlags.push('-e', excluded);
+    });
+
+    console.log('Running Apache RAT...');
+    var result = child_process.spawnSync('java', ['-jar', ratPath, '-d', '.'].concat(excludeFlags));
+    if (result.status === 0) {
+        process.stdout.write(result.stdout);
+    } else {
+        var err = 'Running RAT failed with exit code: ' + result.status;
+        if (result.stderr) {
+            err += '\n' + result.stderr;
+        }
+        require('colors');
+        console.error(err.red);
+    }
+};

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/7ba34149/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 53f1bb8..03b604e 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,8 @@
     "jsdom": "3.1.0",
     "jWorkflow": "0.x.x",
     "semver": "^4.3.1",
-    "xmlhttprequest": "1.4.2"
+    "xmlhttprequest": "1.4.2",
+    "shelljs": "^0.4.0"
   },
   "files": [
     "README.md",