This is an automated email from the ASF dual-hosted git repository.
mugdha pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push:
new 6c3b1e435 RANGER-5302 : Code Coverage changes for React JS script files
6c3b1e435 is described below
commit 6c3b1e4354062729abb7c3735d19ac8115049f04
Author: Mugdha Varadkar <[email protected]>
AuthorDate: Wed Jul 9 18:43:16 2025 +0530
RANGER-5302 : Code Coverage changes for React JS script files
---
security-admin/pom.xml | 27 ++++++++++
.../src/main/webapp/react-webapp/package.json | 3 +-
.../webapp/react-webapp/update-babel-config.js | 57 ++++++++++++++++++++++
3 files changed, 86 insertions(+), 1 deletion(-)
diff --git a/security-admin/pom.xml b/security-admin/pom.xml
index 7717435e7..c7504da06 100644
--- a/security-admin/pom.xml
+++ b/security-admin/pom.xml
@@ -28,6 +28,7 @@
<description>security-admin-tool java web application</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <skipJSCoverage>true</skipJSCoverage>
</properties>
<dependencies>
<dependency>
@@ -1054,6 +1055,32 @@
<npmVersion>7.10.0</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 0f70f6873..2fa762c35 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");