olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kobl...@apache.org
Subject [1/6] [OLINGO-429] add headers, extend rat module, remove dependencies
Date Wed, 10 Sep 2014 07:19:09 GMT
Repository: olingo-odata4-js
Updated Branches:
  refs/heads/master cf77b73e5 -> 733b57dd8


http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/custom-tasks/rat/package.json
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat/package.json b/odatajs/grunt-config/custom-tasks/rat/package.json
index 6753173..f5fa8bb 100644
--- a/odatajs/grunt-config/custom-tasks/rat/package.json
+++ b/odatajs/grunt-config/custom-tasks/rat/package.json
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
 {
   "name": "grunt-rat",
   "version": "0.0.1",
@@ -14,6 +32,7 @@
     "chalk": "~0.4.0"
   },
   "devDependencies": {
+    "async": "^0.9.0",
     "grunt": "~0.4.0",
     "xml2js": "^0.4.4"
   },

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/custom-tasks/rat/readme.md
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat/readme.md b/odatajs/grunt-config/custom-tasks/rat/readme.md
index 82051fe..fd2795c 100644
--- a/odatajs/grunt-config/custom-tasks/rat/readme.md
+++ b/odatajs/grunt-config/custom-tasks/rat/readme.md
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
 Download "apache-rat-0.11-bin.zip" from http://creadur.apache.org/rat/download_rat.cgi and
unpack it to 
 "extern-tools/apache-rat-0.11"
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js b/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
index ba9d773..287f1a4 100644
--- a/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
+++ b/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
@@ -16,73 +16,95 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 module.exports = function (grunt) {
   grunt.registerMultiTask('rat', 'Run Apache Rat', function () {
-    var path = require('path');
+    var async = require("async");
     var chalk = require('chalk');
     var childProcess = require('child_process');
-    var xml2js = require('xml2js');
+    var path = require('path');
     var fs = require('fs');
+    var xml2js = require('xml2js');
 
-    var cb = this.async();
-
-
-
-    var options = this.options({ xml : true, tmpDir : './build/tmp'});
-    var dir = this.data.dir;
-    var out = options.tmpDir + '/' + (options.xml ? 'rat.xml' : 'rat.txt');
-
-    var pathToRat =  path.resolve(__dirname,'./../extern-tools/apache-rat-0.11/apache-rat-0.11.jar');
+    var globalCB = this.async();
     
-    if(!fs.existsSync(options.tmpDir)){
-         fs.mkdirSync(options.tmpDir, 0766, function(err){
-           if(err){ 
-             grunt.fail.warn('rat --> ' + 'Output directory could not be created: ' +
options.tmpDir, 1); 
-           }
-         });   
-     }
-
-
-
+    var ratJarFile =  path.resolve(__dirname,'./../extern-tools/apache-rat-0.11/apache-rat-0.11.jar');
+    var options = this.options({ xml : true, dest : './build/tmp'});
 
+    //check output directory
+    if(!fs.existsSync(options.dest)){
+      grunt.file.mkdir(options.dest,0766);
+    }
+    
+    //collect directories which should be checked
+    var checkDirs = [];
+    for(var i = 0; i < this.files.length; i++) {
+      for(var ii = 0; ii < this.files[i].src.length; ii++) {
+        var checkDir = {
+          dir : this.files[i].src[ii],
+          options : {
+            xml : options.xml,
+            dest : options.dest,
+            tag : this.files[i].options.tag,
+            exclude : options.exclude || this.files[i].options.exclude
+          }
+        };
+        checkDirs.push(checkDir);
+      }
+    }
 
-    //sample command java -jar apache-rat-0.10.jar -x -d ./src > ./build/tmp/rat.txt
-    var cmd = 'java -jar ' + pathToRat+ ' ';
-    cmd += options.xml ? ' -x' : '';
-    cmd += ' --force -d ' + dir + ' > ' + out;
+    var processDirectory = function processDirectory(data,cb) {
+      var checkDir = data.dir; 
+      var options = data.options;
+      var outPutFile = options.dest + '/'+ 'rat_' + (options.tag ? options.tag:'') + (options.xml
? '.xml' : '.txt');
+      
+      //sample command java -jar apache-rat-0.10.jar -x -d ./src > ./build/tmp/rat.txt
+      var cmd = 'java -jar ' + ratJarFile+ ' ';
+      cmd += options.xml ? ' -x' : '';
+      cmd += ' --force -d ' + checkDir;
+      //cmd += ' -E ./grunt-config/custom-tasks/rat/.rat-excludes'
+      if (options.exclude)  {
+        for (var i = 0;  i< options.exclude.length; i ++) {
+          cmd += ' -e '+ options.exclude[i];
+        }
+      }
+      cmd +=  ' > ' + outPutFile;
 
-    grunt.verbose.writeln('Directory: '+dir);
+      grunt.verbose.writeln('Command:', chalk.yellow(cmd));
+      var cp = childProcess.exec(cmd, options.execOptions, function (error, stdout, stderr)
{
+        if (error) {
+          grunt.fail.warn('rat --> ' + error, 1); //exit grunt with error code 1
+        }
+        checkOutFile(outPutFile,data,cb);
+      });
+    };
 
-    var cp = childProcess.exec(cmd, options.execOptions, function (err, stdout, stderr) {
-      if (err) {
-        grunt.fail.warn('rat --> ' + err, 1); //exit grunt with error code 1
-      }
-      
-      if (!options.xml) {
-        grunt.fail.warn('rat --> ' + 'No XML output: checkRatLogFile skipped!', 1); 
+    var checkOutFile = function(outFile,data,cb) {
+      //check out files
+      if (path.extname(outFile) !== '.xml') {
+        grunt.log.writeln(chalk.yellow('\nrat --> ' + 'No XML output: ('+outFile+') skipped!\n'));

+        cb();
+        return;
       }
 
-      var xml = grunt.file.read(out);
+      var xml = grunt.file.read(outFile);
       var parser = new xml2js.Parser();
 
       parser.parseString(xml, function (err, result) {
-
           if (err) {
-            grunt.fail.warn('rat --> ' + err, 1); 
+            grunt.fail.warn('rat --> XML parse error: ' + err, 1); 
           }
           
           if (checkRatLogFile(result)) {
-            grunt.fail.warn('rat --> ' + 'Missing or Invalied license header detected
( see "'+out+'")', 1);
+            grunt.fail.warn('rat --> check license error:  ' + 'Missing or Invalied license
header detected ( see "'+outFile+'")', 1);
           }
-
           
+          grunt.log.ok('rat --> check on ' + data.dir + ' ok -> see'  + outFile);
       });
-      cb(); 
-      
-    }.bind(this));
+      cb();
+    };
 
     var checkRatLogFile = function(result) {
-
       var list = result['rat-report']['resource'];
       for (var i = 0; i < list.length; i++ ){
         var item = list[i];
@@ -94,7 +116,7 @@ module.exports = function (grunt) {
         }
       }
       return false;
-    }
+    };
 
     var captureOutput = function (child, output) {
       if (grunt.option('color') === false) {
@@ -106,8 +128,19 @@ module.exports = function (grunt) {
       }
     };
 
-    grunt.verbose.writeln('Command:', chalk.yellow(cmd));
+    //files
+    async.each(checkDirs,
+      function (checkDir,cb) {
+        processDirectory(checkDir,cb);
+      },
+      function(err) {
+        grunt.log.ok('rat --> finished');
+        globalCB();
+      }
+    );
 
+    
+  /*
     captureOutput(cp.stdout, process.stdout);
       captureOutput(cp.stderr, process.stderr);
 
@@ -115,7 +148,7 @@ module.exports = function (grunt) {
       process.stdin.resume();
       process.stdin.setEncoding('utf8');
       process.stdin.pipe(cp.stdin);
-    }
+    }*/
   });
 };
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/rat-config.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/rat-config.js b/odatajs/grunt-config/rat-config.js
index 1793b5e..f797a45 100644
--- a/odatajs/grunt-config/rat-config.js
+++ b/odatajs/grunt-config/rat-config.js
@@ -18,25 +18,46 @@
  */
 module.exports = function(grunt) {
   grunt.config('rat', {
-    options: { xml : true, tmpDir : './build/tmp' },
-    src: {                      
-      dir: './src',
+    dist:  { 
+      options: { 
+        dest : './build/tmp', 
+        exclude: [
+          "node_modules","extern-tools",".gitignore",
+          "DEPENDENCIES","LICENSE","NOTICE",
+          "JSLib.sln","package.json"
+        ] },
+      files: [
+        /*{ src: ['./../dist/<%= artifactname %>/doc'], options:{ tag:"dist-doc"}},generated*/
+        /*{ src: ['./../dist/<%= artifactname %>/lib'], options:{ tag:"dist-lib"}},very
slow*/
+        { src: ['./../dist/<%= artifactname %>/sources'], options:{ tag:"dist-src"}},
+      ]
     },
-    test: {                      
-      dir: './tests'
+    "manual-dist":  { 
+      options: { xml:false, 
+        dest : './build/tmp', 
+        exclude: [
+          "node_modules","extern-tools",".gitignore",
+          "DEPENDENCIES","LICENSE","NOTICE",
+          "JSLib.sln","package.json"
+        ] },
+      files: [
+        /*{ src: ['./../dist/<%= artifactname %>/doc'], options:{ tag:"dist-doc"}},generated*/
+        /*{ src: ['./../dist/<%= artifactname %>/lib'], options:{ tag:"dist-lib"}},very
slow*/
+        { src: ['./../dist/<%= artifactname %>/sources'], options:{ tag:"dist-src"}},
+      ]
     },
-    'src-manual': {                      
-      options: { xml : false, tmpDir : './build/tmp' },
-      dir: './src',
+    manual:  {  // with txt output
+      options: { xml:false, 
+        dest : './build/tmp', 
+        exclude: ["node_modules","extern-tools",".gitignore"] },
+      files: [
+        { src: ['./src'], options:{ tag:"src"}},
+        { src: ['./tests'], options:{ tag:"tests"}},
+        { src: ['./demo'], options:{ tag:"demo"}},
+        { src: ['./grunt-config'], options:{ tag:"grunt-config" }}
+      ]
     },
-    'test-manual': {                      
-      options: { xml : false, tmpDir : './build/tmp' },
-      dir: './tests'
-    },
-
   });
 
- 
   grunt.loadTasks('grunt-config/custom-tasks/rat/tasks');
-  grunt.registerTask('custom-license-check',['rat:src','rat:test']);
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/release.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/release.js b/odatajs/grunt-config/release.js
index 2309510..3333d85 100644
--- a/odatajs/grunt-config/release.js
+++ b/odatajs/grunt-config/release.js
@@ -30,9 +30,11 @@ module.exports = function(grunt) {
     return hay.indexOf(needle) > -1;
   }
 
+  
+
   // clean
   grunt.config.merge( { 
-    'clean': {
+    'npm-clean': {
       'release-dist': {
         options: { force: true },
         src: [ "./../dist/<%= artifactname %>*"]
@@ -60,7 +62,7 @@ module.exports = function(grunt) {
     'copy' : {
       'release-lib' : {
         files: [
-          { expand: true, cwd: 'build', src: ['<%= artifactname %>*.*'], dest: './../dist/<%=
artifactname %>/lib/lib', filter: 'isFile'},
+          { expand: true, cwd: 'build/lib', src: ['<%= artifactname %>*.*'], dest:
'./../dist/<%= artifactname %>/lib/lib', filter: 'isFile'},
           { expand: true, src :'LICENSE',dest: './../dist/<%= artifactname %>/lib',
filter: 'isFile' },
           { expand: true, src :'NOTICE',dest: './../dist/<%= artifactname %>/lib',
filter: 'isFile' },
           { expand: true, src :'DEPENDENCIES',dest: './../dist/<%= artifactname %>/lib',
filter: 'isFile' }
@@ -79,7 +81,7 @@ module.exports = function(grunt) {
             { expand: true, src :'LICENSE',dest: './../dist/<%= artifactname %>/sources',
filter: 'isFile' },
             { expand: true, src :'NOTICE',dest: './../dist/<%= artifactname %>/sources',
filter: 'isFile' },
             { expand: true, src :'DEPENDENCIES',dest: './../dist/<%= artifactname %>/sources',
filter: 'isFile' },
-            { dot: true, expand: true, cwd: './../', src: ['odatajs/**'], dest: './../dist/<%=
artifactname %>/sources',
+            { dot: true, expand: true, cwd: './', src: ['**'], dest: './../dist/<%= artifactname
%>/sources/odatajs',
             filter: function(srcPath)  {
               // no node_modules
               if (srcPath === 'node_modules' || contains(srcPath, 'node_modules\\')|| contains(srcPath,
'node_modules/')) {
@@ -99,20 +101,20 @@ module.exports = function(grunt) {
               }
 
               // no c# files
-              if (srcPath === 'obj' || contains(srcPath, 'odatajs\\obj')|| contains(srcPath,
'odatajs/obj')) {
+              if (srcPath === 'obj' || contains(srcPath, 'obj')|| contains(srcPath, 'obj'))
{
                 return false; 
               }
 
-              if (srcPath === 'bin' || contains(srcPath, 'odatajs\\bin')|| contains(srcPath,
'odatajs/bin')) {
+              if (srcPath === 'bin' || contains(srcPath, 'bin')|| contains(srcPath, 'bin'))
{
                 return false; 
               }
 
-              if (srcPath === 'packages' || contains(srcPath, 'odatajs\\packages')|| contains(srcPath,
'odatajs/packages')) {
+              if (srcPath === 'packages' || contains(srcPath, 'packages')|| contains(srcPath,
'packages')) {
                 return false; 
               }
 
               // no build retults
-              if (srcPath === 'build' || contains(srcPath, 'odatajs\\build')|| contains(srcPath,
'odatajs/build')) {
+              if (srcPath === 'build' || contains(srcPath, 'build')|| contains(srcPath, 'build'))
{
                 return false; 
               }
 
@@ -122,6 +124,12 @@ module.exports = function(grunt) {
               if (endsWith(srcPath, 'localgrunt.config')) {
                 return false; 
               }
+              if (endsWith(srcPath, 'JSLib.suo')) {
+                return false; 
+              }
+              if (endsWith(srcPath, 'JSLib.csproj.user')) {
+                return false; 
+              }
               
               console.log(' + ' + srcPath);
               return true;
@@ -161,10 +169,11 @@ module.exports = function(grunt) {
 
   //tasks
   grunt.registerTask('dist',[
-    'clean:release-dist',
+    'npm-clean:release-dist',
     'build',
     'doc',
     'copy:release-lib','copy:release-doc','copy:release-sources',
+    'rat:dist',
     'compress:release-lib','compress:release-doc','compress:release-sources']);
 };
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/package.json
----------------------------------------------------------------------
diff --git a/odatajs/package.json b/odatajs/package.json
index 36dd3d7..3f66eb4 100644
--- a/odatajs/package.json
+++ b/odatajs/package.json
@@ -4,8 +4,8 @@
   "postfix": "beta-01",
   "releaseCandidate" : "RC01",
 
-  "title": "Olingo OData Client for Java Script",
-  "description": "the Olingo OData Client for Java Script library is a new cross-browser
JavaScript library that enables data-centric web applications by leveraging modern protocols
such as JSON and OData and HTML5-enabled browser features. It's designed to be small, fast
and easy to use.",
+  "title": "Olingo OData Client for JavaScript",
+  "description": "the Olingo OData Client for JavaScript library is a new cross-browser JavaScript
library that enables data-centric web applications by leveraging modern protocols such as
JSON and OData and HTML5-enabled browser features. It's designed to be small, fast and easy
to use.",
   "homepage": "http://olingo.apache.org",
   "main": "index.js",
   "repository": {

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/tests/common/djstest-browser.js
----------------------------------------------------------------------
diff --git a/odatajs/tests/common/djstest-browser.js b/odatajs/tests/common/djstest-browser.js
index 366ca33..c37f7e9 100644
--- a/odatajs/tests/common/djstest-browser.js
+++ b/odatajs/tests/common/djstest-browser.js
@@ -21,7 +21,7 @@
 // Because this code contains a init function to be useable directly inside the browser as
well as in nodejs
 // we define the @namespace djstest here instead of the a @module name djstest
 
-/** Create namespace djstest in window.djstest when this file is loaded as java script by
the browser
+/** Create namespace djstest in window.djstest when this file is loaded as JavaScript by
the browser
  * @namespace djstest
  */
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/tests/common/djstest.js
----------------------------------------------------------------------
diff --git a/odatajs/tests/common/djstest.js b/odatajs/tests/common/djstest.js
index 5dda9ff..5268467 100644
--- a/odatajs/tests/common/djstest.js
+++ b/odatajs/tests/common/djstest.js
@@ -21,7 +21,7 @@
 // Because this code contains a init function to be useable directly inside the browser as
well as in nodejs
 // we define the @namespace djstest here instead of the a @module name djstest
 
-/** Create namespace djstest in window.djstest when this file is loaded as java script by
the browser
+/** Create namespace djstest in window.djstest when this file is loaded as JavaScript by
the browser
  * @namespace djstest
  */
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/tests/e2etest/Test.html
----------------------------------------------------------------------
diff --git a/odatajs/tests/e2etest/Test.html b/odatajs/tests/e2etest/Test.html
index c9b5989..56646c9 100644
--- a/odatajs/tests/e2etest/Test.html
+++ b/odatajs/tests/e2etest/Test.html
@@ -22,8 +22,10 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
     <title>odatajs side-by-side test (V3 & V4)</title>
-    <script type="text/javascript" src="../../demo/scripts/datajs-1.1.2.js"></script>
+    <!--<script type="text/javascript" src="../../demo/scripts/datajs-1.1.2.js"></script>-->
+    <script type="text/javascript" src="http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=datajs&DownloadId=784667&FileTime=130354527569270000&Build=20928"></script>
     <script type="text/javascript" src="../../build/odatajs-4.0.0-beta-01.js"></script>
+    https://datajs.codeplex.com/downloads/get/784666
 </head>
 <body>
     <h3>


Mime
View raw message