feat(reliability): WhatsApp Web version caching (#1847)

* feat: use specific whatsapp web version

* add constants to version updater

* configurable caches

* rename

* typings

* rm extraneous export

* missing from the rename

* rm version resolver

* match readme version

* use try-catch

* only persist if cache miss
This commit is contained in:
Pedro S. Lopez 2023-05-29 02:31:03 -04:00 • committed by GitHub
commit 8ae0c0d484
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 197 additions and 9 deletions

View file

@ -18,15 +18,24 @@ const getCurrentVersion = () => {
}
};
const updateVersion = async (oldVersion, newVersion) => {
const readmePath = '../../README.md';
const readme = fs.readFileSync(readmePath);
const newReadme = readme.toString().replaceAll(oldVersion, newVersion);
const updateInFile = (filePath, oldVersion, newVersion) => {
const originalFile = fs.readFileSync(filePath);
const newFile = originalFile.toString().replaceAll(oldVersion, newVersion);
fs.writeFileSync(readmePath, newReadme);
fs.writeFileSync('./.version', newVersion);
fs.writeFileSync(filePath, newFile);
};
const updateVersion = async (oldVersion, newVersion) => {
const filesToUpdate = [
'../../src/util/Constants.js',
'../../README.md',
];
for (const file of filesToUpdate) {
updateInFile(file, oldVersion, newVersion);
}
fs.writeFileSync('./.version', newVersion);
};
(async () => {