You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ko...@apache.org on 2014/09/22 13:54:13 UTC

[2/2] git commit: [OLINGO-440] create md5 and sha files automatically

[OLINGO-440] create md5 and sha files automatically


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/commit/cb209714
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/tree/cb209714
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/diff/cb209714

Branch: refs/heads/master
Commit: cb209714d2a1029855b2b6f9198076b4d8b0c486
Parents: abde56f
Author: Sven Kobler <sv...@sap.com>
Authored: Mon Sep 22 13:52:29 2014 +0200
Committer: Sven Kobler <sv...@sap.com>
Committed: Mon Sep 22 13:53:48 2014 +0200

----------------------------------------------------------------------
 odatajs/.gitignore                        |   4 +-
 odatajs/grunt-config/custom-tasks/rat.js  |  23 ++++++
 odatajs/grunt-config/custom-tasks/sign.js | 104 +++++++++++++++++++++++++
 odatajs/grunt-config/rat-config.js        |  63 ---------------
 odatajs/grunt-config/rat.js               |  65 ++++++++++++++++
 odatajs/grunt-config/release.js           |  23 +++++-
 odatajs/grunt-config/sign.js              |  39 ++++++++++
 7 files changed, 252 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/cb209714/odatajs/.gitignore
----------------------------------------------------------------------
diff --git a/odatajs/.gitignore b/odatajs/.gitignore
index 40682f2..16af8ff 100644
--- a/odatajs/.gitignore
+++ b/odatajs/.gitignore
@@ -4,10 +4,10 @@ localgrunt.config
 demo/scripts/odatajs-4.0.0-beta-01*
 
 # build artefacts
-build
+build/
 
 # nodejs temporary objects
-node_modules
+node_modules/
 
 # C.net server temporary objects
 bin/

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/cb209714/odatajs/grunt-config/custom-tasks/rat.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat.js b/odatajs/grunt-config/custom-tasks/rat.js
new file mode 100644
index 0000000..5c758af
--- /dev/null
+++ b/odatajs/grunt-config/custom-tasks/rat.js
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+ 
+//rat is written as like a npm module so include the /rat/tasks folder
+module.exports = function(grunt) {
+  require('./rat/tasks/rat.js')(grunt);
+};

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/cb209714/odatajs/grunt-config/custom-tasks/sign.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/sign.js b/odatajs/grunt-config/custom-tasks/sign.js
new file mode 100644
index 0000000..d7959d3
--- /dev/null
+++ b/odatajs/grunt-config/custom-tasks/sign.js
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+ 
+module.exports = function(grunt) {
+
+    grunt.registerMultiTask('sign', function() {
+        var self = this;
+
+        var path = require('path');
+        var fs = require( "fs" );
+
+        
+        var globalDone = this.async();
+        
+        var options = this.options({ types : [] });
+        var workLoad = [];
+        
+        // fill workLoad
+        for(var i = 0; i < this.files.length; i++) {
+          for(var ii = 0; ii < this.files[i].src.length; ii++) {
+            for (var iii = 0; iii < options.types.length; iii++) {
+                workLoad.push({
+                    src :this.files[i].src[ii],
+                    type: options.types[iii]
+                });
+            }
+          }
+        }
+        
+        function process() {
+            if(workLoad.length <= 0) {
+                globalDone();
+                return;
+            }
+
+            var workItem = workLoad.pop();
+            // make source file releative to cwd, since cwd is used as workdir from spawn
+            var fileName =  path.relative(self.data.cwd,workItem.src);
+            var taskOptions,pipeTo;
+            console.log (fileName);
+            if ( workItem.type === 'md5' ) {
+                grunt.log.writeln('Signing ('+workItem.type+')' + fileName + " ...");
+                pipeTo = workItem.src+'.md5';
+                taskOptions = { 
+                    cmd : 'openssl', 
+                    //args: ['dgst','-md5','-out',fileName+'.md5',fileName],
+                    args: ['dgst','-md5',fileName],
+                    opts : { cwd :self.data.cwd }
+                };
+            } else if ( workItem.type === 'sha' ) {  
+                grunt.log.writeln('Signing ('+workItem.type+')' + fileName + " ...");
+                //gpg --print-md SHA512 odatajs-4.0.0-beta-01-RC02-doc.zip
+                pipeTo = workItem.src+'.sha';
+                taskOptions = { 
+                    cmd : 'gpg', 
+                    args: ['--print-md','SHA512',fileName],
+                    opts : { cwd :self.data.cwd }
+                };
+            } else {
+                grunt.fail.warn('Unknown sign type: "'+ workItem.type + '"', 1);
+            }
+
+            var task = grunt.util.spawn(taskOptions, function done(err,result) {
+                    if (err) {
+                        grunt.fail.warn('Sign: '+err);
+                    }
+                });
+            //console.log('pipeTo'+pipeTo);
+            //console.log('task'+JSON.stringify(task));
+            var outStream = fs.createWriteStream(pipeTo/* ,{flags: 'w'}*/);
+            
+            /*task.stdout.on('data', function(data) {
+                outStream.write(data.toString());
+                //console.log('1'+data.toString());
+            });*/
+            task.stdout.pipe(outStream, { end: false });
+            task.on('close', function (code) {
+                grunt.log.ok('Signed ('+workItem.type+'):' + workItem.src);
+                grunt.log.ok('with code ' + code);
+                process();
+            });
+            
+        }
+
+        process();
+    });
+};
+

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/cb209714/odatajs/grunt-config/rat-config.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/rat-config.js b/odatajs/grunt-config/rat-config.js
deleted file mode 100644
index f797a45..0000000
--- a/odatajs/grunt-config/rat-config.js
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.
- */
-module.exports = function(grunt) {
-  grunt.config('rat', {
-    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"}},
-      ]
-    },
-    "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"}},
-      ]
-    },
-    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" }}
-      ]
-    },
-  });
-
-  grunt.loadTasks('grunt-config/custom-tasks/rat/tasks');
-};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/cb209714/odatajs/grunt-config/rat.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/rat.js b/odatajs/grunt-config/rat.js
new file mode 100644
index 0000000..716a8c6
--- /dev/null
+++ b/odatajs/grunt-config/rat.js
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+module.exports = function(grunt) {
+  
+  
+  grunt.config('rat', {
+    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"}},
+      ]
+    },
+    "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"}},
+      ]
+    },
+    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" }}
+      ]
+    },
+  });
+
+  
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/cb209714/odatajs/grunt-config/release.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/release.js b/odatajs/grunt-config/release.js
index 67f704f..935404d 100644
--- a/odatajs/grunt-config/release.js
+++ b/odatajs/grunt-config/release.js
@@ -30,7 +30,7 @@ module.exports = function(grunt) {
     return hay.indexOf(needle) > -1;
   }
 
-  
+   
 
   // clean
   grunt.config.merge( { 
@@ -166,16 +166,31 @@ module.exports = function(grunt) {
     },
   });
 
+  
+  
+  /*
+  //sign
+  grunt.config.merge( { 
+    sign : {
+      'release-lib': { // just the lib
+        options: {archive: './../dist/<%= artifactname %>/<%= artifactname %>-lib.zip'},
+        files: [{expand: true, cwd: './../dist/<%= artifactname %>/lib', src: ['**'],  dest: '/'}]
+      },
+    }
+  });
+*/
 
   grunt.loadNpmTasks('grunt-contrib-compress');
 
   //tasks
-  grunt.registerTask('dist',[
+  grunt.registerTask('release',[
     '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']);
+    'rat:dist', // check the license headers
+    'compress:release-lib','compress:release-doc','compress:release-sources',
+     'sign:release'
+    ]);
 };
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/cb209714/odatajs/grunt-config/sign.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/sign.js b/odatajs/grunt-config/sign.js
new file mode 100644
index 0000000..5c6d4bd
--- /dev/null
+++ b/odatajs/grunt-config/sign.js
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+module.exports = function(grunt) {
+
+  
+  
+  //sign
+  grunt.config.merge( { 
+    'sign' : {
+      'release' : {
+        options: { types : ['md5', 'sha']},
+        expand : true,
+        cwd : './../dist/<%= artifactname %>/',
+        src : [ 
+          '<%= artifactname %>-lib.zip',
+          '<%= artifactname %>-doc.zip',
+          '<%= artifactname %>-sources.zip'
+        ]
+      }
+    }
+  });
+};
+