This is an automated email from the ASF dual-hosted git repository. hainenber pushed a commit to branch chore/reduce-googleapis-dep-bloat in repository https://gitbox.apache.org/repos/asf/superset.git
commit 843de8b424c19838140766bd6acebfba421bcf14 Author: hainenber <[email protected]> AuthorDate: Fri Feb 20 19:57:38 2026 +0700 build(deps): replace monolithic `googleapis` with lightweight`@googleapis/sheet` sub-package Signed-off-by: hainenber <[email protected]> --- superset-frontend/package-lock.json | 48 +++---- superset-frontend/package.json | 5 +- .../scripts/eslint-metrics-uploader.js | 144 --------------------- .../scripts/oxlint-metrics-uploader.js | 7 +- 4 files changed, 31 insertions(+), 173 deletions(-) diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json index e6b6f27aa5f..d92715f0ad0 100644 --- a/superset-frontend/package-lock.json +++ b/superset-frontend/package-lock.json @@ -29,6 +29,7 @@ "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", "@fontsource/ibm-plex-mono": "^5.2.7", + "@googleapis/sheets": "^13.0.1", "@luma.gl/constants": "~9.2.5", "@luma.gl/core": "~9.2.5", "@luma.gl/engine": "~9.2.5", @@ -93,7 +94,7 @@ "geostyler-openlayers-parser": "^4.3.0", "geostyler-style": "7.5.0", "geostyler-wfs-parser": "^2.0.3", - "googleapis": "^171.4.0", + "google-auth-library": "^10.5.0", "immer": "^11.1.4", "interweave": "^13.1.1", "jquery": "^4.0.0", @@ -4063,6 +4064,18 @@ "url": "https://github.com/sponsors/ayuhito" } }, + "node_modules/@googleapis/sheets": { + "version": "13.0.1", + "resolved": "https://registry.npmjs.org/@googleapis/sheets/-/sheets-13.0.1.tgz", + "integrity": "sha512-XTYObncN5Rqexc0uITZIN9OWTEyE/ZR2S6c7wAniqHe2oGXW9gcHR9f9hQwPMHFUTHjH7Jkj8SLdt0O0u37y2A==", + "license": "Apache-2.0", + "dependencies": { + "googleapis-common": "^8.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/@hapi/address": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/@hapi/address/-/address-5.1.1.tgz", @@ -27031,9 +27044,9 @@ } }, "node_modules/gcp-metadata": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-7.0.1.tgz", - "integrity": "sha512-UcO3kefx6dCcZkgcTGgVOTFb7b1LlQ02hY1omMjjrrBzkajRMCFgYOjs7J71WqnuG1k2b+9ppGL7FsOfhZMQKQ==", + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-8.1.2.tgz", + "integrity": "sha512-zV/5HKTfCeKWnxG0Dmrw51hEWFGfcF2xiXqcA3+J90WDuP0SvoiSO5ORvcBsifmx/FoIjgQN3oNOGaQ5PhLFkg==", "license": "Apache-2.0", "dependencies": { "gaxios": "^7.0.0", @@ -28218,15 +28231,15 @@ } }, "node_modules/google-auth-library": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-10.2.0.tgz", - "integrity": "sha512-gy/0hRx8+Ye0HlUm3GrfpR4lbmJQ6bJ7F44DmN7GtMxxzWSojLzx0Bhv/hj7Wlj7a2On0FcT8jrz8Y1c1nxCyg==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-10.5.0.tgz", + "integrity": "sha512-7ABviyMOlX5hIVD60YOfHw4/CxOfBhyduaYB+wbFWCWoni4N7SLcV46hrVRktuBbZjFC9ONyqamZITN7q3n32w==", "license": "Apache-2.0", "dependencies": { "base64-js": "^1.3.0", "ecdsa-sig-formatter": "^1.0.11", "gaxios": "^7.0.0", - "gcp-metadata": "^7.0.0", + "gcp-metadata": "^8.0.0", "google-logging-utils": "^1.0.0", "gtoken": "^8.0.0", "jws": "^4.0.0" @@ -28236,27 +28249,14 @@ } }, "node_modules/google-logging-utils": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-1.1.1.tgz", - "integrity": "sha512-rcX58I7nqpu4mbKztFeOAObbomBbHU2oIb/d3tJfF3dizGSApqtSwYJigGCooHdnMyQBIw8BrWyK96w3YXgr6A==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-1.1.3.tgz", + "integrity": "sha512-eAmLkjDjAFCVXg7A1unxHsLf961m6y17QFqXqAXGj/gVkKFrEICfStRfwUlGNfeCEjNRa32JEWOUTlYXPyyKvA==", "license": "Apache-2.0", "engines": { "node": ">=14" } }, - "node_modules/googleapis": { - "version": "171.4.0", - "resolved": "https://registry.npmjs.org/googleapis/-/googleapis-171.4.0.tgz", - "integrity": "sha512-xybFL2SmmUgIifgsbsRQYRdNrSAYwxWZDmkZTGjUIaRnX5jPqR8el/cEvo6rCqh7iaZx6MfEPS/lrDgZ0bymkg==", - "license": "Apache-2.0", - "dependencies": { - "google-auth-library": "^10.2.0", - "googleapis-common": "^8.0.0" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/googleapis-common": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/googleapis-common/-/googleapis-common-8.0.0.tgz", diff --git a/superset-frontend/package.json b/superset-frontend/package.json index 965f6d347ab..1d421a24224 100644 --- a/superset-frontend/package.json +++ b/superset-frontend/package.json @@ -110,6 +110,7 @@ "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", "@fontsource/ibm-plex-mono": "^5.2.7", + "@googleapis/sheets": "^13.0.1", "@luma.gl/constants": "~9.2.5", "@luma.gl/core": "~9.2.5", "@luma.gl/engine": "~9.2.5", @@ -174,7 +175,7 @@ "geostyler-openlayers-parser": "^4.3.0", "geostyler-style": "7.5.0", "geostyler-wfs-parser": "^2.0.3", - "googleapis": "^171.4.0", + "google-auth-library": "^10.5.0", "immer": "^11.1.4", "interweave": "^13.1.1", "jquery": "^4.0.0", @@ -186,11 +187,11 @@ "markdown-to-jsx": "^9.7.4", "match-sorter": "^6.3.4", "memoize-one": "^5.2.1", - "pretty-ms": "^9.3.0", "mousetrap": "^1.6.5", "mustache": "^4.2.0", "nanoid": "^5.1.6", "ol": "^10.8.0", + "pretty-ms": "^9.3.0", "query-string": "9.3.1", "re-resizable": "^6.11.2", "react": "^17.0.2", diff --git a/superset-frontend/scripts/eslint-metrics-uploader.js b/superset-frontend/scripts/eslint-metrics-uploader.js deleted file mode 100644 index 0b38e590bac..00000000000 --- a/superset-frontend/scripts/eslint-metrics-uploader.js +++ /dev/null @@ -1,144 +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. - */ -const { google } = require('googleapis'); - -const { SPREADSHEET_ID } = process.env; -const SERVICE_ACCOUNT_KEY = JSON.parse(process.env.SERVICE_ACCOUNT_KEY); - -const auth = new google.auth.GoogleAuth({ - credentials: SERVICE_ACCOUNT_KEY, - scopes: ['https://www.googleapis.com/auth/spreadsheets'], -}); - -const sheets = google.sheets({ version: 'v4', auth }); -const DATETIME = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, ''); - -async function writeToGoogleSheet(data, range, headers, append = false) { - const request = { - spreadsheetId: SPREADSHEET_ID, - range, - valueInputOption: 'USER_ENTERED', - resource: { values: append ? data : [headers, ...data] }, - }; - - const method = append ? 'append' : 'update'; - await sheets.spreadsheets.values[method](request); -} - -// Process ESLint results and prepare data for Google Sheets -module.exports = async results => { - const enrichedRules = { - 'react-prefer-function-component/react-prefer-function-component': { - description: 'We prefer function components to class-based components', - }, - 'react/jsx-filename-extension': { - description: - 'We prefer Typescript - all JSX files should be converted to TSX', - }, - 'react/forbid-component-props': { - description: - 'We prefer Emotion for styling rather than `className` or `style` props', - }, - // Ignore thie rule here - the messages in eslintrc_metrics.js are sufficient descriptions, broken down by file type. - 'no-restricted-imports': { - description: - "This rule catches several things that shouldn't be used anymore. LESS, antD, etc. See individual occurrence messages for details", - }, - 'no-console': { - description: - "We don't want a bunch of console noise, but you can use the `logger` from `@superset-ui/core` when there's a reason to.", - }, - }; - - // Consolidate data processing into a single loop for efficiency - const metricsByRule = {}; - let occurrencesData = []; - - results.forEach(result => { - result.messages.forEach(({ ruleId, line, column, message }) => { - const ruleData = metricsByRule[ruleId] || { count: 0 }; - ruleData.count += 1; - metricsByRule[ruleId] = ruleData; - - occurrencesData.push({ - rule: ruleId, - message, - file: result.filePath, - line, - column, - ts: DATETIME, - }); - }); - }); - - // Transform data for Google Sheets - const metricsData = Object.entries(metricsByRule).map(([rule, { count }]) => [ - 'ESLint', - rule, - enrichedRules[rule]?.description || 'N/A', - `${count}`, - DATETIME, - ]); - - occurrencesData = occurrencesData.map( - ({ rule, message, file, line, column }) => [ - rule, - enrichedRules[rule]?.description || 'N/A', - message, - file, - `${line}`, - `${column}`, - DATETIME, - ], - ); - - const aggregatedHistoryHeaders = [ - 'Process', - 'Rule', - 'Description', - 'Count', - 'Timestamp', - ]; - const eslintBacklogHeaders = [ - 'Rule', - 'Rule Description', - 'ESLint Message', - 'File', - 'Line', - 'Column', - 'Timestamp', - ]; - - try { - await writeToGoogleSheet( - metricsData, - 'Aggregated History!A:E', - aggregatedHistoryHeaders, - true, - ); - - await writeToGoogleSheet( - occurrencesData, - 'ESLint Backlog!A:G', - eslintBacklogHeaders, - ); - } catch (error) { - console.error('Error writing to Google Sheets:', error); - } -}; diff --git a/superset-frontend/scripts/oxlint-metrics-uploader.js b/superset-frontend/scripts/oxlint-metrics-uploader.js index 4db4ff1412a..3a800026690 100644 --- a/superset-frontend/scripts/oxlint-metrics-uploader.js +++ b/superset-frontend/scripts/oxlint-metrics-uploader.js @@ -17,7 +17,8 @@ * under the License. */ const { execSync } = require('child_process'); -const { google } = require('googleapis'); +const { GoogleAuth } = require('google-auth-library'); +const googleSheets = require('@googleapis/sheets'); const { SPREADSHEET_ID } = process.env; const SERVICE_ACCOUNT_KEY = JSON.parse(process.env.SERVICE_ACCOUNT_KEY || '{}'); @@ -25,11 +26,11 @@ const SERVICE_ACCOUNT_KEY = JSON.parse(process.env.SERVICE_ACCOUNT_KEY || '{}'); // Only set up Google Sheets if we have credentials let sheets; if (SERVICE_ACCOUNT_KEY.client_email) { - const auth = new google.auth.GoogleAuth({ + const auth = new GoogleAuth({ credentials: SERVICE_ACCOUNT_KEY, scopes: ['https://www.googleapis.com/auth/spreadsheets'], }); - sheets = google.sheets({ version: 'v4', auth }); + sheets = googleSheets({ version: 'v4', auth }); } const DATETIME = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '');
