mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Refactor: simplify build infra
This commit is contained in:
@@ -6,6 +6,7 @@ import { task, traceAsync, traceSync } from './lib/trace-runner';
|
||||
|
||||
import { exclude } from 'fast-cidr-tools';
|
||||
import picocolors from 'picocolors';
|
||||
import { createMemoizedPromise } from './lib/memo-promise';
|
||||
|
||||
// https://github.com/misakaio/chnroutes2/issues/25
|
||||
const EXCLUDE_CIDRS = [
|
||||
@@ -17,17 +18,21 @@ const INCLUDE_CIDRS = [
|
||||
'211.99.96.0/19' // wy.com.cn
|
||||
];
|
||||
|
||||
export const buildChnCidr = task(import.meta.path, async () => {
|
||||
export const getChnCidrPromise = createMemoizedPromise(async () => {
|
||||
const cidr = await traceAsync(
|
||||
picocolors.gray('download chnroutes2'),
|
||||
async () => processLineFromReadline(await fetchRemoteTextAndReadByLine('https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt')),
|
||||
picocolors.gray
|
||||
);
|
||||
const filteredCidr = traceSync(
|
||||
return traceSync(
|
||||
picocolors.gray('processing chnroutes2'),
|
||||
() => exclude([...cidr, ...INCLUDE_CIDRS], EXCLUDE_CIDRS, true),
|
||||
picocolors.gray
|
||||
);
|
||||
});
|
||||
|
||||
export const buildChnCidr = task(import.meta.path, async () => {
|
||||
const filteredCidr = await getChnCidrPromise();
|
||||
|
||||
// Can not use SHARED_DESCRIPTION here as different license
|
||||
const description = [
|
||||
|
||||
Reference in New Issue
Block a user