Skip to content

Commit

Permalink
Update CDN Hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Sep 15, 2023
1 parent 573c0f5 commit 6e83927
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
41 changes: 23 additions & 18 deletions Build/download-previous-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { Readable } = require('stream');
const { pipeline } = require('stream/promises');
const { readFileByLine } = require('./lib/fetch-remote-text-by-line');
const { isCI } = require('ci-info');
const { task } = require('./lib/trace-runner');
const { task, traceAsync } = require('./lib/trace-runner');

const fileExists = (path) => {
return fs.promises.access(path, fs.constants.F_OK)
Expand All @@ -31,7 +31,7 @@ const downloadPreviousBuild = task(__filename, async () => {
line.startsWith('Modules/')
) && !line.endsWith('/')
) {
allFileExists = await fileExists(join(__dirname, '..', line));
allFileExists = fs.existsSync(join(__dirname, '..', line));
filesList.push(line);

if (!allFileExists) {
Expand All @@ -47,35 +47,40 @@ const downloadPreviousBuild = task(__filename, async () => {
return;
}

console.log('Download previous build.');

const extractedPath = join(tmpdir(), `sukka-surge-last-build-extracted-${Date.now()}`);

const [resp] = await Promise.all([
fetch('https://codeload.github.com/sukkaw/surge/tar.gz/gh-pages'),
fse.ensureDir(extractedPath)
]);

await pipeline(
Readable.fromWeb(resp.body),
tar.x({
cwd: extractedPath,
filter(p) {
const dir = p.split('/')[1];
return dir === 'List' || dir === 'Modules' || dir === 'Clash';
}
})
await traceAsync(
'Download and extract previous build',
() => Promise.all([
fetch('https://codeload.github.com/sukkaw/surge/tar.gz/gh-pages'),
fse.ensureDir(extractedPath)
]).then(([resp]) => pipeline(
Readable.fromWeb(resp.body),
tar.x({
cwd: extractedPath,
filter(p) {
const dir = p.split('/')[1];
return dir === 'List' || dir === 'Modules' || dir === 'Clash';
}
})
))
);

console.log('Files list:', filesList);

await Promise.all(filesList.map(async p => {
const src = join(extractedPath, 'Surge-gh-pages', p);
if (await fileExists(src)) {
const dst = join(__dirname, '..', p);
console.log('Copy', { src, dst });
return fse.copy(
src,
join(__dirname, '..', p),
{ overwrite: true }
);
}

console.log('File not exists:', src);
}));

await fs.promises.unlink(extractedPath).catch(() => { });
Expand Down
15 changes: 15 additions & 0 deletions Source/domainset/cdn.conf
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ embed-ssl.wistia.com
.alonestreaming.com
.thisiscdn.com
cdn.vidible.tv
.video-cdn.net
# vimeo
player.vimeo.com
.vimeocdn.com
Expand Down Expand Up @@ -658,6 +659,7 @@ player-frontend.cnevids.com
w.chatlio.com
snippet.maze.co
.transcend-cdn.com
imgssl.constantcontact.com

c.navattic.com
js.navattic.com
Expand Down Expand Up @@ -929,6 +931,8 @@ assets.video.yahoo.net
yep.video.yahoo.com
# CookieLaw
.cdn.cookielaw.org
# CookieBot
cookie-cdn.cookiepro.com
# Cloudflare
static.dash.cloudflare.com
info.cloudflare.com
Expand Down Expand Up @@ -969,6 +973,7 @@ steamcdn-a.akamaihd.net
# TikTok
.ibytedtos.com
.bytedapm.com
.ttwstatic.com
# eBay
.ebayimg.com
.ebaystatic.com
Expand Down Expand Up @@ -1517,6 +1522,12 @@ images.idgesg.net
.staticworld.net
# Indiegogo
.iggcdn.com
# dynamicyield.com
static.dynamicyield.com
st.dynamicyield.com
st-eu.dynamicyield.com
cdn.dynamicyield.com
cdn-eu.dynamicyield.com
# Others
api.mintlify.com
content-prod-live.cert.starbucks.com
Expand Down Expand Up @@ -1858,3 +1869,7 @@ assets.dnsfilter.com
images.emojiterra.com
cdn.osxdaily.com
user-uploads.perchance.org
img.riskified.com
cdn.pathfactory.com
cdn-app.pathfactory.com
.prcdn.co

0 comments on commit 6e83927

Please sign in to comment.