Files
renovate/tools/uncache.ts
Jamie Tanna 72ec3836f5 chore: add a tool to decompress cache keys (#43522)
As a means to make it more straightforward when testing.
2026-06-03 15:17:52 +00:00

43 lines
1.1 KiB
TypeScript

/**
* Decompress and unencode values from the Package Cache or Repository Cache.
*
* Usage:
*
* node tools/uncache.ts "$(redis-cli get "datasource-npm:cache-provider-https://registry.npmjs.org/nock")"
* node tools/uncache.ts ~/Downloads/cache.json
* node tools/uncache.ts G0ohAAQi1GVVr/.......
*
* Supports:
*
* - cache values from the Package Cache
* - cache values from the Repository Cache
*/
import fs from 'fs-extra';
import { decompressFromBase64 } from '../lib/util/compress.ts';
const input = process.argv[2];
let toDecode = undefined;
if (input.startsWith('{')) {
const encoded = JSON.parse(input);
toDecode =
// if it's from the Package Cache
encoded.value ??
// if it's from the Repository Cache
encoded.payload;
} else if (await fs.exists(input)) {
const encoded = JSON.parse(await fs.readFile(input, 'utf8'));
toDecode =
// if it's from the Package Cache
encoded.value ??
// if it's from the Repository Cache
encoded.payload;
} else {
toDecode = input;
}
// oxlint-disable-next-line no-console -- intentional: not production code
console.log(await decompressFromBase64(toDecode));