chore: cleanup, ci workflows and formatting (#127064)

* ci: setup workflows, dependabot, labeler and commit linting

* docs: update README, community files and issue templates

* chore: configure prettier, editorconfig and format codebase

* chore: restore changes lost during rebase

* docs: adjust url for new logo

* fix: align badges

* chore: resolve conflicts and re-add temp lint
This commit is contained in:
2^1 2026-03-10 00:45:12 +01:00 • committed by GitHub
commit 807efd502d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 6790 additions and 3547 deletions

View file

@ -6,7 +6,7 @@ const { WebCache, VersionResolveError } = require('./WebCache');
/**
* LocalWebCache - Fetches a WhatsApp Web version from a local file store
* @param {object} options - options
* @param {string} options.path - Path to the directory where cached versions are saved, default is: "./.wwebjs_cache/"
* @param {string} options.path - Path to the directory where cached versions are saved, default is: "./.wwebjs_cache/"
* @param {boolean} options.strict - If true, will throw an error if the requested version can't be fetched. If false, will resolve to the latest version.
*/
class LocalWebCache extends WebCache {
@ -19,12 +19,14 @@ class LocalWebCache extends WebCache {
async resolve(version) {
const filePath = path.join(this.path, `${version}.html`);
try {
return fs.readFileSync(filePath, 'utf-8');
}
catch (err) {
if (this.strict) throw new VersionResolveError(`Couldn't load version ${version} from the cache`);
} catch (err) {
if (this.strict)
throw new VersionResolveError(
`Couldn't load version ${version} from the cache`,
);
return null;
}
}

View file

@ -11,7 +11,10 @@ class RemoteWebCache extends WebCache {
constructor(options = {}) {
super();
if (!options.remotePath) throw new Error('webVersionCache.remotePath is required when using the remote cache');
if (!options.remotePath)
throw new Error(
'webVersionCache.remotePath is required when using the remote cache',
);
this.remotePath = options.remotePath;
this.strict = options.strict || false;
}
@ -28,8 +31,11 @@ class RemoteWebCache extends WebCache {
console.error(`Error fetching version ${version} from remote`, err);
}
if (this.strict) throw new VersionResolveError(`Couldn't load version ${version} from the archive`);
return null;
if (this.strict)
throw new VersionResolveError(
`Couldn't load version ${version} from the archive`,
);
return null;
}
async persist() {
@ -37,4 +43,4 @@ class RemoteWebCache extends WebCache {
}
}
module.exports = RemoteWebCache;
module.exports = RemoteWebCache;

View file

@ -2,13 +2,15 @@
* Default implementation of a web version cache that does nothing.
*/
class WebCache {
async resolve() { return null; }
async persist() { }
async resolve() {
return null;
}
async persist() {}
}
class VersionResolveError extends Error { }
class VersionResolveError extends Error {}
module.exports = {
WebCache,
VersionResolveError
};
VersionResolveError,
};

View file

@ -4,17 +4,17 @@ const { WebCache } = require('./WebCache');
const createWebCache = (type, options) => {
switch (type) {
case 'remote':
return new RemoteWebCache(options);
case 'local':
return new LocalWebCache(options);
case 'none':
return new WebCache();
default:
throw new Error(`Invalid WebCache type ${type}`);
case 'remote':
return new RemoteWebCache(options);
case 'local':
return new LocalWebCache(options);
case 'none':
return new WebCache();
default:
throw new Error(`Invalid WebCache type ${type}`);
}
};
module.exports = {
createWebCache,
};
};