Chore: remove outdated files

This commit is contained in:
SukkaW 2024-09-08 00:15:57 +08:00
parent f5613c6d3d
commit d4ee25e75a
5 changed files with 25 additions and 49 deletions

View File

@ -32,27 +32,15 @@ export const buildAppleCdn = task(require.main === module, __filename)(async (sp
' - https://github.com/felixonmars/dnsmasq-china-list' ' - https://github.com/felixonmars/dnsmasq-china-list'
]; ];
const ruleset = res.map(domain => `DOMAIN-SUFFIX,${domain}`);
const domainset = res.map(i => `.${i}`); const domainset = res.map(i => `.${i}`);
return Promise.all([ return createRuleset(
createRuleset( span,
span, 'Sukka\'s Ruleset - Apple CDN',
'Sukka\'s Ruleset - Apple CDN', description,
description, new Date(),
new Date(), domainset,
ruleset, 'domainset',
'ruleset', output('apple_cdn', 'domainset')
output('apple_cdn', 'non_ip') );
),
createRuleset(
span,
'Sukka\'s Ruleset - Apple CDN',
description,
new Date(),
domainset,
'domainset',
output('apple_cdn', 'domainset')
)
]);
}); });

View File

@ -10,11 +10,9 @@ import { task } from './trace';
import { SHARED_DESCRIPTION } from './lib/constants'; import { SHARED_DESCRIPTION } from './lib/constants';
import { fdir as Fdir } from 'fdir'; import { fdir as Fdir } from 'fdir';
import { appendArrayInPlace } from './lib/append-array-in-place'; import { appendArrayInPlace } from './lib/append-array-in-place';
import { removeFiles } from './lib/misc';
import { OUTPUT_CLASH_DIR, OUTPUT_SINGBOX_DIR, OUTPUT_SURGE_DIR, SOURCE_DIR } from './constants/dir'; import { OUTPUT_CLASH_DIR, OUTPUT_SINGBOX_DIR, OUTPUT_SURGE_DIR, SOURCE_DIR } from './constants/dir';
const MAGIC_COMMAND_SKIP = '# $ custom_build_script'; const MAGIC_COMMAND_SKIP = '# $ custom_build_script';
const MAGIC_COMMAND_RM = '# $ custom_no_output';
const MAGIC_COMMAND_TITLE = '# $ meta_title '; const MAGIC_COMMAND_TITLE = '# $ meta_title ';
const MAGIC_COMMAND_DESCRIPTION = '# $ meta_description '; const MAGIC_COMMAND_DESCRIPTION = '# $ meta_description ';
@ -68,7 +66,6 @@ export const buildCommon = task(require.main === module, __filename)(async (span
}); });
const $skip = Symbol('skip'); const $skip = Symbol('skip');
const $rm = Symbol('rm');
const processFile = (span: Span, sourcePath: string) => { const processFile = (span: Span, sourcePath: string) => {
// console.log('Processing', sourcePath); // console.log('Processing', sourcePath);
@ -80,9 +77,6 @@ const processFile = (span: Span, sourcePath: string) => {
try { try {
for await (const line of readFileByLine(sourcePath)) { for await (const line of readFileByLine(sourcePath)) {
if (line.startsWith(MAGIC_COMMAND_RM)) {
return $rm;
}
if (line.startsWith(MAGIC_COMMAND_SKIP)) { if (line.startsWith(MAGIC_COMMAND_SKIP)) {
return $skip; return $skip;
} }
@ -121,14 +115,6 @@ function transformDomainset(parentSpan: Span, sourcePath: string, relativePath:
const clashFileBasename = relativePath.slice(0, -path.extname(relativePath).length); const clashFileBasename = relativePath.slice(0, -path.extname(relativePath).length);
if (res === $rm) {
return removeFiles([
path.resolve(OUTPUT_SURGE_DIR, relativePath),
path.resolve(OUTPUT_CLASH_DIR, `${clashFileBasename}.txt`),
path.resolve(OUTPUT_SINGBOX_DIR, `${clashFileBasename}.json`)
]);
}
const [title, descriptions, lines] = res; const [title, descriptions, lines] = res;
const deduped = domainDeduper(lines); const deduped = domainDeduper(lines);
@ -170,14 +156,6 @@ async function transformRuleset(parentSpan: Span, sourcePath: string, relativePa
const clashFileBasename = relativePath.slice(0, -path.extname(relativePath).length); const clashFileBasename = relativePath.slice(0, -path.extname(relativePath).length);
if (res === $rm) {
return removeFiles([
path.resolve(OUTPUT_SURGE_DIR, relativePath),
path.resolve(OUTPUT_CLASH_DIR, `${clashFileBasename}.txt`),
path.resolve(OUTPUT_SINGBOX_DIR, `${clashFileBasename}.json`)
]);
}
const [title, descriptions, lines] = res; const [title, descriptions, lines] = res;
let description: string[]; let description: string[];

View File

@ -1,7 +1,8 @@
import { OUTPUT_CLASH_DIR, OUTPUT_SURGE_DIR } from './constants/dir'; import { OUTPUT_CLASH_DIR, OUTPUT_SURGE_DIR, PUBLIC_DIR } from './constants/dir';
import { compareAndWriteFile } from './lib/create-file'; import { compareAndWriteFile } from './lib/create-file';
import { task } from './trace'; import { task } from './trace';
import path from 'node:path'; import path from 'node:path';
import fsp from 'node:fs/promises';
const DEPRECATED_FILES = [ const DEPRECATED_FILES = [
['non_ip/global_plus', 'This file has been merged with non_ip/global'], ['non_ip/global_plus', 'This file has been merged with non_ip/global'],
@ -9,8 +10,20 @@ const DEPRECATED_FILES = [
['domainset/reject_phishing', 'This file has been merged with domainset/reject'] ['domainset/reject_phishing', 'This file has been merged with domainset/reject']
]; ];
const REMOVED_FILES = [
'Internal/cdn.txt',
'List/domainset/steam.conf',
'List/internal/appprofile.php',
'Clash/domainset/steam.txt',
'sing-box/domainset/steam.json'
];
export const buildDeprecateFiles = task(require.main === module, __filename)((span) => span.traceChildAsync('create deprecated files', async (childSpan) => { export const buildDeprecateFiles = task(require.main === module, __filename)((span) => span.traceChildAsync('create deprecated files', async (childSpan) => {
const promises: Array<Promise<unknown>> = []; const promises: Array<Promise<unknown>> = REMOVED_FILES
.map(f => fsp.rm(
path.join(PUBLIC_DIR, f),
{ force: true, recursive: true }
));
for (const [filePath, description] of DEPRECATED_FILES) { for (const [filePath, description] of DEPRECATED_FILES) {
const surgeFile = path.resolve(OUTPUT_SURGE_DIR, `${filePath}.conf`); const surgeFile = path.resolve(OUTPUT_SURGE_DIR, `${filePath}.conf`);

View File

@ -71,8 +71,6 @@ process.on('unhandledRejection', (reason) => {
const buildCloudMounterRulesPromise = downloadPreviousBuildPromise.then(() => buildCloudMounterRules(rootSpan)); const buildCloudMounterRulesPromise = downloadPreviousBuildPromise.then(() => buildCloudMounterRules(rootSpan));
const buildDeprecateFilesPromise = downloadPreviousBuildPromise.then(() => buildDeprecateFiles(rootSpan));
await Promise.all([ await Promise.all([
downloadPreviousBuildPromise, downloadPreviousBuildPromise,
buildCommonPromise, buildCommonPromise,
@ -93,10 +91,10 @@ process.on('unhandledRejection', (reason) => {
buildMicrosoftCdnPromise, buildMicrosoftCdnPromise,
buildSSPanelUIMAppProfilePromise, buildSSPanelUIMAppProfilePromise,
buildCloudMounterRulesPromise, buildCloudMounterRulesPromise,
buildDeprecateFilesPromise,
downloadMockAssetsPromise downloadMockAssetsPromise
]); ]);
await buildDeprecateFiles(rootSpan);
await buildPublic(rootSpan); await buildPublic(rootSpan);
rootSpan.stop(); rootSpan.stop();

View File

@ -1,4 +1,3 @@
# $ custom_no_output
# $ custom_build_script -- will be included in download.conf # $ custom_build_script -- will be included in download.conf
# Steam # Steam