diff --git a/Build/build-public.js b/Build/build-public.js index 81a8fb960..56739533b 100644 --- a/Build/build-public.js +++ b/Build/build-public.js @@ -2,7 +2,6 @@ const listDir = require('@sukka/listdir'); const path = require('path'); const fs = require('fs'); const fsp = require('fs/promises'); -const { copy } = require('fs-extra'); const { task } = require('./lib/trace-runner'); const rootPath = path.resolve(__dirname, '../'); @@ -19,7 +18,11 @@ const folderAndFilesToBeDeployed = [ const buildPublicHtml = task(__filename, async () => { await fsp.mkdir(publicPath, { recursive: true }); - await Promise.all(folderAndFilesToBeDeployed.map(dir => copy(path.resolve(rootPath, dir), path.resolve(publicPath, dir)))); + await Promise.all(folderAndFilesToBeDeployed.map(dir => fsp.cp( + path.resolve(rootPath, dir), + path.resolve(publicPath, dir), + { force: true, recursive: true } + ))); const list = await listDir(publicPath, { ignoreHidden: true, diff --git a/Build/build-reject-domainset.js b/Build/build-reject-domainset.js index 8fca7f39a..9de264da7 100644 --- a/Build/build-reject-domainset.js +++ b/Build/build-reject-domainset.js @@ -1,6 +1,6 @@ // @ts-check -const { copy } = require('fs-extra'); -const { resolve: pathResolve } = require('path'); +const fsp = require('fs/promises'); +const path = require('path'); const { processHosts, processFilterRules } = require('./lib/parse-filter'); const createTrie = require('./lib/trie'); @@ -97,7 +97,7 @@ const buildRejectDomainSet = task(__filename, async () => { let previousSize = domainSets.size; console.log(`Import ${previousSize} rules from Hosts / AdBlock Filter Rules!`); - for await (const line of readFileByLine(pathResolve(__dirname, '../Source/domainset/reject_sukka.conf'))) { + for await (const line of readFileByLine(path.resolve(__dirname, '../Source/domainset/reject_sukka.conf'))) { const l = processLine(line); if (l) { domainSets.add(l); @@ -107,7 +107,7 @@ const buildRejectDomainSet = task(__filename, async () => { previousSize = domainSets.size - previousSize; console.log(`Import ${previousSize} rules from reject_sukka.conf!`); - for await (const line of readFileByLine(pathResolve(__dirname, '../Source/non_ip/reject.conf'))) { + for await (const line of readFileByLine(path.resolve(__dirname, '../Source/non_ip/reject.conf'))) { if (line.startsWith('DOMAIN-KEYWORD')) { const [, ...keywords] = line.split(','); domainKeywordsSet.add(keywords.join(',').trim()); @@ -117,7 +117,7 @@ const buildRejectDomainSet = task(__filename, async () => { } } - for await (const line of readFileByLine(pathResolve(__dirname, '../List/domainset/reject_phishing.conf'))) { + for await (const line of readFileByLine(path.resolve(__dirname, '../List/domainset/reject_phishing.conf'))) { const l = processLine(line); if (l && l[0] === '.') { domainSuffixSet.add(l.slice(1)); @@ -217,15 +217,19 @@ const buildRejectDomainSet = task(__filename, async () => { new Date(), domainset, 'domainset', - pathResolve(__dirname, '../List/domainset/reject.conf'), - pathResolve(__dirname, '../Clash/domainset/reject.txt') + path.resolve(__dirname, '../List/domainset/reject.conf'), + path.resolve(__dirname, '../Clash/domainset/reject.txt') ), compareAndWriteFile( rejectDomainsStats.map(([domain, count]) => `${domain}${' '.repeat(100 - domain.length)}${count}`), - pathResolve(__dirname, '../List/internal/reject-stats.txt') + path.resolve(__dirname, '../List/internal/reject-stats.txt') ), // Copy reject_sukka.conf for backward compatibility - copy(pathResolve(__dirname, '../Source/domainset/reject_sukka.conf'), pathResolve(__dirname, '../List/domainset/reject_sukka.conf')) + fsp.cp( + path.resolve(__dirname, '../Source/domainset/reject_sukka.conf'), + path.resolve(__dirname, '../List/domainset/reject_sukka.conf'), + { force: true, recursive: true } + ) ]); }); diff --git a/Build/download-previous-build.js b/Build/download-previous-build.js index 4bdb189c8..0e359b432 100644 --- a/Build/download-previous-build.js +++ b/Build/download-previous-build.js @@ -1,8 +1,7 @@ const { fetch } = require('undici'); const tar = require('tar'); const fs = require('fs'); -const fsp = fs.promises; -const { copy } = require('fs-extra'); +const fsp = require('fs/promises'); const path = require('path'); const { tmpdir } = require('os'); const { Readable } = require('stream'); @@ -72,10 +71,10 @@ const downloadPreviousBuild = task(__filename, async () => { await Promise.all(filesList.map(async p => { const src = path.join(extractedPath, 'ruleset.skk.moe-master', p); if (await fileExists(src)) { - return copy( + return fsp.cp( src, path.join(__dirname, '..', p), - { overwrite: true } + { force: true, recursive: true } ); } })); diff --git a/package.json b/package.json index d7b0a0432..5e760ca63 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "ci-info": "^3.9.0", "cidr-tools-wasm": "^0.0.11", "eslint": "^8.51.0", - "fs-extra": "^11.1.1", "gorhill-publicsuffixlist": "github:gorhill/publicsuffixlist.js", "jest-worker": "^29.7.0", "mnemonist": "^0.39.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a0e1a1fb4..af6261834 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,9 +34,6 @@ dependencies: eslint: specifier: ^8.51.0 version: 8.51.0 - fs-extra: - specifier: ^11.1.1 - version: 11.1.1 gorhill-publicsuffixlist: specifier: github:gorhill/publicsuffixlist.js version: github.com/gorhill/publicsuffixlist.js/3a1bc623073079184ff76933b88b7bf4f5d48978 @@ -969,15 +966,6 @@ packages: /flatted@3.2.7: resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} - /fs-extra@11.1.1: - resolution: {integrity: sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==} - engines: {node: '>=14.14'} - dependencies: - graceful-fs: 4.2.10 - jsonfile: 6.1.0 - universalify: 2.0.0 - dev: false - /fs-minipass@2.1.0: resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} engines: {node: '>= 8'} @@ -1199,14 +1187,6 @@ packages: resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} dev: true - /jsonfile@6.1.0: - resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} - dependencies: - universalify: 2.0.0 - optionalDependencies: - graceful-fs: 4.2.10 - dev: false - /levn@0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} @@ -1687,11 +1667,6 @@ packages: '@fastify/busboy': 2.0.0 dev: false - /universalify@2.0.0: - resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==} - engines: {node: '>= 10.0.0'} - dev: false - /uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: