New build infra: Build for Clash (#11)

This commit is contained in:
Sukka
2023-09-11 00:51:35 +08:00
committed by GitHub
parent fa7e2f775c
commit df4a10e180
45 changed files with 661 additions and 237 deletions

View File

@@ -16,6 +16,7 @@ const { domainDeduper } = require('./lib/domain-deduper');
const createKeywordFilter = require('./lib/aho-corasick');
const { readFileByLine } = require('./lib/fetch-remote-text-by-line');
const domainSorter = require('./lib/stable-sort-domain');
const { surgeDomainsetToClashDomainset } = require('./lib/clash');
/** Whitelists */
const filterRuleWhitelistDomainSets = new Set(PREDEFINED_WHITELIST);
@@ -196,26 +197,38 @@ const domainSuffixSet = new Set();
return acc;
}, {});
const description = [
'License: AGPL 3.0',
'Homepage: https://ruleset.skk.moe',
'GitHub: https://github.com/SukkaW/Surge',
'',
'The domainset supports AD blocking, tracking protection, privacy protection, anti-phishing, anti-mining',
'',
'Build from:',
...HOSTS.map(host => ` - ${host[0]}`),
...ADGUARD_FILTERS.map(filter => ` - ${Array.isArray(filter) ? filter[0] : filter}`)
];
const domainset = dudupedDominArray.sort(domainSorter);
await Promise.all([
compareAndWriteFile(
withBannerArray(
'Sukka\'s Surge Rules - Reject Base',
[
'License: AGPL 3.0',
'Homepage: https://ruleset.skk.moe',
'GitHub: https://github.com/SukkaW/Surge',
'',
'The domainset supports AD blocking, tracking protection, privacy protection, anti-phishing, anti-mining',
'',
'Build from:',
...HOSTS.map(host => ` - ${host[0]}`),
...ADGUARD_FILTERS.map(filter => ` - ${Array.isArray(filter) ? filter[0] : filter}`)
],
'Sukka\'s Ruleset - Reject Base',
description,
new Date(),
dudupedDominArray.sort(domainSorter)
domainset
),
pathResolve(__dirname, '../List/domainset/reject.conf')
),
compareAndWriteFile(
withBannerArray(
'Sukka\'s Ruleset - Reject Base',
description,
new Date(),
surgeDomainsetToClashDomainset(domainset)
),
pathResolve(__dirname, '../Clash/domainset/reject.txt')
),
fs.promises.writeFile(
pathResolve(__dirname, '../List/internal/reject-stats.txt'),
Object.entries(rejectDomainsStats)