浏览代码

Chore: remove outdated files

SukkaW 1 年之前
父节点
当前提交
d4ee25e75a
共有 5 个文件被更改,包括 25 次插入49 次删除
  1. 9 21
      Build/build-apple-cdn.ts
  2. 0 22
      Build/build-common.ts
  3. 15 2
      Build/build-deprecate-files.ts
  4. 1 3
      Build/index.ts
  5. 0 1
      Source/domainset/steam.conf

+ 9 - 21
Build/build-apple-cdn.ts

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

+ 0 - 22
Build/build-common.ts

@@ -10,11 +10,9 @@ import { task } from './trace';
 import { SHARED_DESCRIPTION } from './lib/constants';
 import { fdir as Fdir } from 'fdir';
 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';
 
 const MAGIC_COMMAND_SKIP = '# $ custom_build_script';
-const MAGIC_COMMAND_RM = '# $ custom_no_output';
 const MAGIC_COMMAND_TITLE = '# $ meta_title ';
 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 $rm = Symbol('rm');
 
 const processFile = (span: Span, sourcePath: string) => {
   // console.log('Processing', sourcePath);
@@ -80,9 +77,6 @@ const processFile = (span: Span, sourcePath: string) => {
 
     try {
       for await (const line of readFileByLine(sourcePath)) {
-        if (line.startsWith(MAGIC_COMMAND_RM)) {
-          return $rm;
-        }
         if (line.startsWith(MAGIC_COMMAND_SKIP)) {
           return $skip;
         }
@@ -121,14 +115,6 @@ function transformDomainset(parentSpan: Span, sourcePath: string, relativePath:
 
         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 deduped = domainDeduper(lines);
 
@@ -170,14 +156,6 @@ async function transformRuleset(parentSpan: Span, sourcePath: string, relativePa
 
       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;
 
       let description: string[];

+ 15 - 2
Build/build-deprecate-files.ts

@@ -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 { task } from './trace';
 import path from 'node:path';
+import fsp from 'node:fs/promises';
 
 const DEPRECATED_FILES = [
   ['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']
 ];
 
+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) => {
-  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) {
     const surgeFile = path.resolve(OUTPUT_SURGE_DIR, `${filePath}.conf`);

+ 1 - 3
Build/index.ts

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

+ 0 - 1
Source/domainset/steam.conf

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