mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Chore: remove fs-extra
This commit is contained in:
parent
afb954e2d8
commit
57a306c592
@ -2,7 +2,6 @@ const listDir = require('@sukka/listdir');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const fsp = require('fs/promises');
|
const fsp = require('fs/promises');
|
||||||
const { copy } = require('fs-extra');
|
|
||||||
const { task } = require('./lib/trace-runner');
|
const { task } = require('./lib/trace-runner');
|
||||||
|
|
||||||
const rootPath = path.resolve(__dirname, '../');
|
const rootPath = path.resolve(__dirname, '../');
|
||||||
@ -19,7 +18,11 @@ const folderAndFilesToBeDeployed = [
|
|||||||
|
|
||||||
const buildPublicHtml = task(__filename, async () => {
|
const buildPublicHtml = task(__filename, async () => {
|
||||||
await fsp.mkdir(publicPath, { recursive: true });
|
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, {
|
const list = await listDir(publicPath, {
|
||||||
ignoreHidden: true,
|
ignoreHidden: true,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
const { copy } = require('fs-extra');
|
const fsp = require('fs/promises');
|
||||||
const { resolve: pathResolve } = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const { processHosts, processFilterRules } = require('./lib/parse-filter');
|
const { processHosts, processFilterRules } = require('./lib/parse-filter');
|
||||||
const createTrie = require('./lib/trie');
|
const createTrie = require('./lib/trie');
|
||||||
@ -97,7 +97,7 @@ const buildRejectDomainSet = task(__filename, async () => {
|
|||||||
let previousSize = domainSets.size;
|
let previousSize = domainSets.size;
|
||||||
console.log(`Import ${previousSize} rules from Hosts / AdBlock Filter Rules!`);
|
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);
|
const l = processLine(line);
|
||||||
if (l) {
|
if (l) {
|
||||||
domainSets.add(l);
|
domainSets.add(l);
|
||||||
@ -107,7 +107,7 @@ const buildRejectDomainSet = task(__filename, async () => {
|
|||||||
previousSize = domainSets.size - previousSize;
|
previousSize = domainSets.size - previousSize;
|
||||||
console.log(`Import ${previousSize} rules from reject_sukka.conf!`);
|
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')) {
|
if (line.startsWith('DOMAIN-KEYWORD')) {
|
||||||
const [, ...keywords] = line.split(',');
|
const [, ...keywords] = line.split(',');
|
||||||
domainKeywordsSet.add(keywords.join(',').trim());
|
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);
|
const l = processLine(line);
|
||||||
if (l && l[0] === '.') {
|
if (l && l[0] === '.') {
|
||||||
domainSuffixSet.add(l.slice(1));
|
domainSuffixSet.add(l.slice(1));
|
||||||
@ -217,15 +217,19 @@ const buildRejectDomainSet = task(__filename, async () => {
|
|||||||
new Date(),
|
new Date(),
|
||||||
domainset,
|
domainset,
|
||||||
'domainset',
|
'domainset',
|
||||||
pathResolve(__dirname, '../List/domainset/reject.conf'),
|
path.resolve(__dirname, '../List/domainset/reject.conf'),
|
||||||
pathResolve(__dirname, '../Clash/domainset/reject.txt')
|
path.resolve(__dirname, '../Clash/domainset/reject.txt')
|
||||||
),
|
),
|
||||||
compareAndWriteFile(
|
compareAndWriteFile(
|
||||||
rejectDomainsStats.map(([domain, count]) => `${domain}${' '.repeat(100 - domain.length)}${count}`),
|
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 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 }
|
||||||
|
)
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
const { fetch } = require('undici');
|
const { fetch } = require('undici');
|
||||||
const tar = require('tar');
|
const tar = require('tar');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const fsp = fs.promises;
|
const fsp = require('fs/promises');
|
||||||
const { copy } = require('fs-extra');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { tmpdir } = require('os');
|
const { tmpdir } = require('os');
|
||||||
const { Readable } = require('stream');
|
const { Readable } = require('stream');
|
||||||
@ -72,10 +71,10 @@ const downloadPreviousBuild = task(__filename, async () => {
|
|||||||
await Promise.all(filesList.map(async p => {
|
await Promise.all(filesList.map(async p => {
|
||||||
const src = path.join(extractedPath, 'ruleset.skk.moe-master', p);
|
const src = path.join(extractedPath, 'ruleset.skk.moe-master', p);
|
||||||
if (await fileExists(src)) {
|
if (await fileExists(src)) {
|
||||||
return copy(
|
return fsp.cp(
|
||||||
src,
|
src,
|
||||||
path.join(__dirname, '..', p),
|
path.join(__dirname, '..', p),
|
||||||
{ overwrite: true }
|
{ force: true, recursive: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -21,7 +21,6 @@
|
|||||||
"ci-info": "^3.9.0",
|
"ci-info": "^3.9.0",
|
||||||
"cidr-tools-wasm": "^0.0.11",
|
"cidr-tools-wasm": "^0.0.11",
|
||||||
"eslint": "^8.51.0",
|
"eslint": "^8.51.0",
|
||||||
"fs-extra": "^11.1.1",
|
|
||||||
"gorhill-publicsuffixlist": "github:gorhill/publicsuffixlist.js",
|
"gorhill-publicsuffixlist": "github:gorhill/publicsuffixlist.js",
|
||||||
"jest-worker": "^29.7.0",
|
"jest-worker": "^29.7.0",
|
||||||
"mnemonist": "^0.39.5",
|
"mnemonist": "^0.39.5",
|
||||||
|
|||||||
25
pnpm-lock.yaml
generated
25
pnpm-lock.yaml
generated
@ -34,9 +34,6 @@ dependencies:
|
|||||||
eslint:
|
eslint:
|
||||||
specifier: ^8.51.0
|
specifier: ^8.51.0
|
||||||
version: 8.51.0
|
version: 8.51.0
|
||||||
fs-extra:
|
|
||||||
specifier: ^11.1.1
|
|
||||||
version: 11.1.1
|
|
||||||
gorhill-publicsuffixlist:
|
gorhill-publicsuffixlist:
|
||||||
specifier: github:gorhill/publicsuffixlist.js
|
specifier: github:gorhill/publicsuffixlist.js
|
||||||
version: github.com/gorhill/publicsuffixlist.js/3a1bc623073079184ff76933b88b7bf4f5d48978
|
version: github.com/gorhill/publicsuffixlist.js/3a1bc623073079184ff76933b88b7bf4f5d48978
|
||||||
@ -969,15 +966,6 @@ packages:
|
|||||||
/flatted@3.2.7:
|
/flatted@3.2.7:
|
||||||
resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==}
|
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:
|
/fs-minipass@2.1.0:
|
||||||
resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==}
|
resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==}
|
||||||
engines: {node: '>= 8'}
|
engines: {node: '>= 8'}
|
||||||
@ -1199,14 +1187,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==}
|
resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==}
|
||||||
dev: true
|
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:
|
/levn@0.4.1:
|
||||||
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
|
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
|
||||||
engines: {node: '>= 0.8.0'}
|
engines: {node: '>= 0.8.0'}
|
||||||
@ -1687,11 +1667,6 @@ packages:
|
|||||||
'@fastify/busboy': 2.0.0
|
'@fastify/busboy': 2.0.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/universalify@2.0.0:
|
|
||||||
resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==}
|
|
||||||
engines: {node: '>= 10.0.0'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/uri-js@4.4.1:
|
/uri-js@4.4.1:
|
||||||
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
|
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user