mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Chore: drop @sukka/listdir
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { readFileByLine } from './lib/fetch-text-by-line';
|
import { readFileByLine } from './lib/fetch-text-by-line';
|
||||||
import pathFn from 'path';
|
import pathFn from 'path';
|
||||||
import table from 'table';
|
import table from 'table';
|
||||||
import listDir from '@sukka/listdir';
|
import { fdir as Fdir } from 'fdir';
|
||||||
import { green, yellow } from 'picocolors';
|
import { green, yellow } from 'picocolors';
|
||||||
import { processLineFromReadline } from './lib/process-line';
|
import { processLineFromReadline } from './lib/process-line';
|
||||||
import { getHostname } from 'tldts';
|
import { getHostname } from 'tldts';
|
||||||
@@ -37,12 +37,16 @@ const PRESET_MITM_HOSTNAMES = [
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const folderListPath = pathFn.resolve(__dirname, '../List/');
|
const folderListPath = pathFn.resolve(__dirname, '../List/');
|
||||||
const rulesets = await listDir(folderListPath);
|
|
||||||
|
const rulesets = await new Fdir()
|
||||||
|
.withFullPaths()
|
||||||
|
.crawl(folderListPath)
|
||||||
|
.withPromise();
|
||||||
|
|
||||||
const urlRegexPaths: Array<{ origin: string, processed: string }> = [];
|
const urlRegexPaths: Array<{ origin: string, processed: string }> = [];
|
||||||
|
|
||||||
await Promise.all(rulesets.map(async file => {
|
await Promise.all(rulesets.map(async file => {
|
||||||
const content = await processLineFromReadline(readFileByLine(pathFn.join(folderListPath, file)));
|
const content = await processLineFromReadline(readFileByLine(file));
|
||||||
urlRegexPaths.push(
|
urlRegexPaths.push(
|
||||||
...content
|
...content
|
||||||
.filter(i => (
|
.filter(i => (
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import path from 'path';
|
|||||||
import { task } from './trace';
|
import { task } from './trace';
|
||||||
import { treeDir } from './lib/tree-dir';
|
import { treeDir } from './lib/tree-dir';
|
||||||
import type { TreeType, TreeTypeArray } from './lib/tree-dir';
|
import type { TreeType, TreeTypeArray } from './lib/tree-dir';
|
||||||
import listDir from '@sukka/listdir';
|
import { fdir as Fdir } from 'fdir';
|
||||||
import { sort } from './lib/timsort';
|
import { sort } from './lib/timsort';
|
||||||
|
|
||||||
|
import Trie from 'mnemonist/trie';
|
||||||
|
|
||||||
const rootPath = path.resolve(import.meta.dir, '../');
|
const rootPath = path.resolve(import.meta.dir, '../');
|
||||||
const publicPath = path.resolve(import.meta.dir, '../public');
|
const publicPath = path.resolve(import.meta.dir, '../public');
|
||||||
|
|
||||||
@@ -22,13 +24,15 @@ export const buildPublic = task(import.meta.main, import.meta.path)(async (span)
|
|||||||
await span
|
await span
|
||||||
.traceChild('copy public files')
|
.traceChild('copy public files')
|
||||||
.traceAsyncFn(async () => {
|
.traceAsyncFn(async () => {
|
||||||
const filesToBeCopied = (await listDir(
|
const trie = Trie.from(await new Fdir()
|
||||||
rootPath,
|
.withRelativePaths()
|
||||||
{
|
.exclude((dirName) => {
|
||||||
ignoreHidden: true,
|
return dirName === 'node_modules' || dirName === 'Build' || dirName === 'public' || dirName[0] === '.';
|
||||||
ignorePattern: /node_modules|Build|public/
|
})
|
||||||
}
|
.crawl(rootPath)
|
||||||
)).filter(file => folderAndFilesToBeDeployed.some(folderOrFile => file.startsWith(folderOrFile)));
|
.withPromise());
|
||||||
|
|
||||||
|
const filesToBeCopied = folderAndFilesToBeDeployed.flatMap(folderOrFile => trie.find(folderOrFile));
|
||||||
|
|
||||||
return Promise.all(filesToBeCopied.map(file => {
|
return Promise.all(filesToBeCopied.map(file => {
|
||||||
const src = path.resolve(rootPath, file);
|
const src = path.resolve(rootPath, file);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cliqz/adblocker": "^1.27.5",
|
"@cliqz/adblocker": "^1.27.5",
|
||||||
"@gorhill/publicsuffixlist": "3.0.1",
|
"@gorhill/publicsuffixlist": "3.0.1",
|
||||||
"@sukka/listdir": "^0.3.1",
|
|
||||||
"async-retry": "^1.3.3",
|
"async-retry": "^1.3.3",
|
||||||
"async-sema": "^3.1.1",
|
"async-sema": "^3.1.1",
|
||||||
"ci-info": "^4.0.0",
|
"ci-info": "^4.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user