mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-26 23:39:13 +00:00
72ec3836f5
As a means to make it more straightforward when testing.
43 lines
1.1 KiB
TypeScript
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));
|