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

mugdha pushed a commit to branch ranger-2.8
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/ranger-2.8 by this push:
     new f2b3f12af RANGER-5302 : Code Coverage changes for React JS script files
f2b3f12af is described below

commit f2b3f12aff349905f99c1f18c4a26cabdbf0b57e
Author: Mugdha Varadkar <[email protected]>
AuthorDate: Wed Jul 9 18:43:16 2025 +0530

    RANGER-5302 : Code Coverage changes for React JS script files
    
    (cherry picked from commit 6c3b1e4354062729abb7c3735d19ac8115049f04)
---
 security-admin/pom.xml                             | 28 +++++++++++
 .../src/main/webapp/react-webapp/package.json      |  3 +-
 .../webapp/react-webapp/update-babel-config.js     | 57 ++++++++++++++++++++++
 3 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/security-admin/pom.xml b/security-admin/pom.xml
index 4c346c0f4..347e8f5eb 100644
--- a/security-admin/pom.xml
+++ b/security-admin/pom.xml
@@ -27,6 +27,8 @@
     <name>Security Admin Web Application</name>
     <description>security-admin-tool java web application</description>
     <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <skipJSCoverage>true</skipJSCoverage>
         <skipJSTests>false</skipJSTests>
     </properties>
     <dependencies>
@@ -1203,6 +1205,32 @@
                             <npmVersion>10.8.2</npmVersion>
                         </configuration>
                     </execution>
+                    <execution>
+                        <id>update-babel-config for react-webapp</id>
+                        <goals>
+                            <goal>npm</goal>
+                        </goals>
+                        <phase>generate-resources</phase>
+                        <configuration>
+                            
<workingDirectory>${project.build.directory}/react-webapp</workingDirectory>
+                            
<installDirectory>${project.build.directory}/react-build</installDirectory>
+                            <arguments>run update-babel-config</arguments>
+                            <skip>${skipJSCoverage}</skip>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>install-babel-coverage for react-webapp</id>
+                        <goals>
+                            <goal>npm</goal>
+                        </goals>
+                        <phase>generate-resources</phase>
+                        <configuration>
+                            
<workingDirectory>${project.build.directory}/react-webapp</workingDirectory>
+                            
<installDirectory>${project.build.directory}/react-build</installDirectory>
+                            <arguments>install --save-dev 
@babel/[email protected] @babel/[email protected] 
babel-plugin-istanbul</arguments>
+                            <skip>${skipJSCoverage}</skip>
+                        </configuration>
+                    </execution>
                     <execution>
                         <id>run npm ci for react-webapp</id>
                         <goals>
diff --git a/security-admin/src/main/webapp/react-webapp/package.json 
b/security-admin/src/main/webapp/react-webapp/package.json
index 3ac961872..65bf96ac1 100644
--- a/security-admin/src/main/webapp/react-webapp/package.json
+++ b/security-admin/src/main/webapp/react-webapp/package.json
@@ -6,7 +6,8 @@
   "scripts": {
     "start": "webpack serve --config ./config/webpack.dev.config.js",
     "build": "webpack --config ./config/webpack.prod.config.js",
-    "test": "echo \"Error: no test specified\" && exit 1"
+    "test": "echo \"Error: no test specified\" && exit 1",
+    "update-babel-config": "node update-babel-config.js"
   },
   "repository": {
     "type": "git",
diff --git a/security-admin/src/main/webapp/react-webapp/update-babel-config.js 
b/security-admin/src/main/webapp/react-webapp/update-babel-config.js
new file mode 100644
index 000000000..a9de2137b
--- /dev/null
+++ b/security-admin/src/main/webapp/react-webapp/update-babel-config.js
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+const fs = require("fs");
+const path = require("path");
+
+const babelConfigPath = path.join(__dirname, "babel.config.json");
+
+// New config to update or create
+const newBabelConfig = {
+  presets: [
+    [
+      "@babel/preset-env",
+      {
+        targets: {
+          esmodules: true
+        }
+      }
+    ],
+    "@babel/preset-react"
+  ],
+  plugins: [
+    [
+      "babel-plugin-istanbul",
+      {
+        exclude: [
+          "**/*.test.{js,jsx,ts,tsx}",
+          "**/node_modules/**",
+          "**/cypress/**"
+        ]
+      }
+    ]
+  ]
+};
+
+fs.writeFileSync(
+  babelConfigPath,
+  JSON.stringify(newBabelConfig, null, 2),
+  "utf8"
+);
+console.log("babel.config.json updated successfully");

Reply via email to