build-deprecate-files.ts 1.4 KB

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