build-deprecate-files.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. import { OUTPUT_CLASH_DIR, OUTPUT_SURGE_DIR } from './constants/dir';
  2. import { compareAndWriteFile } from './lib/create-file';
  3. import { task } from './trace';
  4. import path from 'node:path';
  5. const DEPRECATED_FILES = [
  6. ['non_ip/global_plus', 'This file has been merged with non_ip/global'],
  7. ['domainset/reject_sukka', 'This file has been merged with domainset/reject'],
  8. ['domainset/reject_phishing', 'This file has been merged with domainset/reject']
  9. ];
  10. export const buildDeprecateFiles = task(require.main === module, __filename)((span) => span.traceChildAsync('create deprecated files', async (childSpan) => {
  11. const promises: Array<Promise<unknown>> = [];
  12. for (const [filePath, description] of DEPRECATED_FILES) {
  13. const surgeFile = path.resolve(OUTPUT_SURGE_DIR, `${filePath}.conf`);
  14. const clashFile = path.resolve(OUTPUT_CLASH_DIR, `${filePath}.txt`);
  15. const content = [
  16. '#########################################',
  17. '# Sukka\'s Ruleset - Deprecated',
  18. `# ${description}`,
  19. '################## EOF ##################'
  20. ];
  21. promises.push(
  22. compareAndWriteFile(childSpan, content, surgeFile),
  23. compareAndWriteFile(childSpan, content, clashFile)
  24. );
  25. }
  26. return Promise.all(promises);
  27. }));