UNPKG

@google-cloud/storage-control

Version:
53 lines 2.14 kB
"use strict"; // Copyright 2026 Google LLC // // Licensed 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 // // https://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. Object.defineProperty(exports, "__esModule", { value: true }); exports.replacements = exports.filesToUpdate = void 0; exports.cleanObjectReferences = cleanObjectReferences; const fs = require("fs"); const path = require("path"); exports.filesToUpdate = [ 'protos/google/storage/v2/storage.proto', ]; exports.replacements = [ { pattern: /\bObject\b/g, replacement: 'StorageObject', }, ]; /** * Cleans up references to Object in storage protos by replacing the reference with the replacement. * This is functionally equivalent to sed -i -E 's,\bObject\b,StorageObject,g' ${filePaths} * @param {string[]} filePaths - An array of file paths to update. * @param {Replacement[]} replacements - An array of replacement objects. */ function cleanObjectReferences(filePaths, replacements) { filePaths.forEach(filePath => { const fullPath = path.join(__dirname, '..', '..', filePath); if (fs.existsSync(fullPath)) { replacements.forEach(({ pattern, replacement }) => { try { const data = fs.readFileSync(fullPath, 'utf8'); const result = data.replace(pattern, replacement); fs.writeFileSync(fullPath, result, 'utf8'); console.log(`Successfully updated: ${fullPath}`); } catch (err) { console.error(`Error processing file ${fullPath}:`, err); } }); } }); } //# sourceMappingURL=proto_utils.js.map