mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Chore: refactor build phase
This commit is contained in:
@@ -18,13 +18,14 @@ const { isIP } = require('net');
|
||||
.filter(ip => typeof ip === 'string' && isIP(ip) !== 0);
|
||||
console.timeEnd('* Download bogus-nxdomain-list')
|
||||
|
||||
const filePath = path.resolve(__dirname, '../List/ip/reject.conf');
|
||||
const filePath = path.resolve(__dirname, '../Source/ip/reject.conf');
|
||||
const resultPath = path.resolve(__dirname, '../List/ip/reject.conf');
|
||||
const content = (await fs.promises.readFile(filePath, 'utf-8'))
|
||||
.replace(
|
||||
'# --- [Anti Bogus Domain Replace Me] ---',
|
||||
res.map(ip => `IP-CIDR,${ip}/32,no-resolve`).join('\n')
|
||||
);
|
||||
|
||||
await fs.promises.writeFile(filePath, content, 'utf-8');
|
||||
await fs.promises.writeFile(resultPath, content, 'utf-8');
|
||||
console.timeEnd('Total Time - build-anti-bogus-domain');
|
||||
})();
|
||||
|
||||
@@ -23,14 +23,15 @@ const path = require('path');
|
||||
return false;
|
||||
})
|
||||
|
||||
const filePath = path.resolve(__dirname, '../List/non_ip/cdn.conf');
|
||||
const filePath = path.resolve(__dirname, '../Source/non_ip/cdn.conf');
|
||||
const resultPath = path.resolve(__dirname, '../List/non_ip/cdn.conf');
|
||||
const content = (await fs.promises.readFile(filePath, 'utf-8'))
|
||||
.replace(
|
||||
'# --- [AWS S3 Replace Me] ---',
|
||||
S3OSSDomains.map(domain => `DOMAIN-SUFFIX,${domain}`).join('\n')
|
||||
);
|
||||
|
||||
await fs.promises.writeFile(filePath, content, 'utf-8');
|
||||
await fs.promises.writeFile(resultPath, content, 'utf-8');
|
||||
|
||||
console.timeEnd('Total Time - build-cdn-conf');
|
||||
})();
|
||||
|
||||
@@ -1,18 +1,32 @@
|
||||
const listDir = require('@sukka/listdir');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const fse = require('fs-extra');
|
||||
|
||||
const rootPath = path.resolve(__dirname, '../');
|
||||
const publicPath = path.resolve(__dirname, '../public');
|
||||
|
||||
const folderAndFilesToBeDeployed = [
|
||||
'Assets',
|
||||
'List',
|
||||
'Modules',
|
||||
'Script',
|
||||
'LICENSE',
|
||||
'README.md'
|
||||
];
|
||||
|
||||
(async () => {
|
||||
const list = await listDir(rootPath, {
|
||||
await fse.ensureDir(publicPath);
|
||||
await Promise.all(folderAndFilesToBeDeployed.map(dir => fse.copy(path.resolve(rootPath, dir), path.resolve(publicPath, dir))));
|
||||
|
||||
const list = await listDir(publicPath, {
|
||||
ignoreHidden: true,
|
||||
ignorePattern: /node_modules|Build|.DS_Store|\.(json|html|md|js)|LICENSE/
|
||||
});
|
||||
|
||||
const html = template(list);
|
||||
|
||||
await fs.promises.writeFile(path.join(rootPath, 'index.html'), html, 'utf-8');
|
||||
await fs.promises.writeFile(path.join(publicPath, 'index.html'), html, 'utf-8');
|
||||
})();
|
||||
|
||||
/**
|
||||
@@ -46,7 +60,7 @@ function template(urlList) {
|
||||
<main class="container">
|
||||
<h1>Sukka Surge Ruleset Server</h1>
|
||||
<p>Made by <a href="https://skk.moe">Sukka</a> | <a href="https://github.com/SukkaW/Surge/">Source @ GitHub</a> | Licensed under <a href="https://github.com/SukkaW/Surge/blob/master/LICENSE" target="_blank">AGPL-3.0</a></p>
|
||||
<p>Last Updated: ${new Date().toISOString()}</p>
|
||||
<p>Last Build: ${new Date().toISOString()}</p>
|
||||
<hr>
|
||||
<br>
|
||||
<ul>
|
||||
@@ -33,7 +33,7 @@ const threads = isCI ? cpuCount : cpuCount / 2;
|
||||
let previousSize = domainSets.size;
|
||||
console.log(`Import ${previousSize} rules from hosts files!`);
|
||||
|
||||
await fsPromises.readFile(pathResolve(__dirname, '../List/domainset/reject_sukka.conf'), { encoding: 'utf-8' }).then(data => {
|
||||
await fsPromises.readFile(pathResolve(__dirname, '../Source/domainset/reject_sukka.conf'), { encoding: 'utf-8' }).then(data => {
|
||||
data.split('\n').forEach(line => {
|
||||
const trimmed = line.trim();
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user