You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by va...@apache.org on 2023/02/07 15:14:55 UTC

[incubator-hugegraph-toolchain] branch master updated: add license for build files (#430)

This is an automated email from the ASF dual-hosted git repository.

vaughn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-toolchain.git


The following commit(s) were added to refs/heads/master by this push:
     new 76e27327 add license for build files (#430)
76e27327 is described below

commit 76e27327df7bc9aabcf2d74bc98014eb17de938d
Author: wanganjuan <z7...@Outlook.com>
AuthorDate: Tue Feb 7 23:14:49 2023 +0800

    add license for build files (#430)
---
 hugegraph-hubble/hubble-fe/add-license.js | 74 +++++++++++++++++++++++++++++++
 hugegraph-hubble/hubble-fe/package.json   |  5 ++-
 2 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/hugegraph-hubble/hubble-fe/add-license.js b/hugegraph-hubble/hubble-fe/add-license.js
new file mode 100644
index 00000000..b0acf661
--- /dev/null
+++ b/hugegraph-hubble/hubble-fe/add-license.js
@@ -0,0 +1,74 @@
+/*
+ * 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 fs = require('fs')
+var path = require('path')
+const license = `/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements; and to You under the Apache License, Version 2.0.
+ */
+`
+const license_html = `<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more 
+ contributor license agreements; and to You under the Apache License, Version 2.0.
+ -->`
+
+const full_license = `/*
+ * 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.
+ */
+`
+// str 以 key 结尾
+function _endWith(str, key){    
+  var reg = new RegExp(key + '$')  
+  return reg.test(str)
+} 
+function walkSync(currentDirPath, callback){
+  fs.readdirSync(currentDirPath, { withFileTypes: true }).forEach(function(dirent) {
+    var filePath = path.join(currentDirPath, dirent.name)
+    if (dirent.isFile()) {
+      callback(filePath, dirent)
+    } else if (dirent.isDirectory()) {
+      walkSync(filePath, callback)
+    }
+  });
+}
+walkSync('build', function(a, b) {
+  if (_endWith(b.name, '.js') ||  _endWith(b.name, '.html') || _endWith(b.name, '.css')) {
+    var data = fs.readFileSync(a).toString().split('\n')
+    let _license =  _endWith(b.name, '.html') ? license_html : license
+    if (b.name === 'service-worker.js') {
+      _license = full_license
+    }
+    data.splice(0, 0, _license)
+    var text = data.join("\n")
+    fs.writeFileSync(a, text)
+  }
+})
+
diff --git a/hugegraph-hubble/hubble-fe/package.json b/hugegraph-hubble/hubble-fe/package.json
index 182160ba..21a258f1 100644
--- a/hugegraph-hubble/hubble-fe/package.json
+++ b/hugegraph-hubble/hubble-fe/package.json
@@ -49,8 +49,9 @@
   },
   "scripts": {
     "start": "react-app-rewired start",
-    "build": "react-app-rewired build",
-    "test": "react-app-rewired test"
+    "build": "react-app-rewired build && npm run license",
+    "test": "react-app-rewired test",
+    "license": "node add-license.js"
   },
   "browserslist": {
     "production": [