build-deprecate-files.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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(__dirname, '../List');
  10. const outputClashDir = path.resolve(__dirname, '../Clash');
  11. export const buildDeprecateFiles = task(require.main === module, __filename)((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. const content = [
  17. '#########################################',
  18. '# Sukka\'s Ruleset - Deprecated',
  19. `# ${description}`,
  20. '################## EOF ##################'
  21. ];
  22. promises.push(
  23. compareAndWriteFile(childSpan, content, surgeFile),
  24. compareAndWriteFile(childSpan, content, clashFile)
  25. );
  26. }
  27. return Promise.all(promises);
  28. }));