Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sefinek committed Mar 8, 2024
1 parent 4117329 commit 6ae3a4e
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 79 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require('dotenv').config();
const cluster = require('node:cluster');
const { availableParallelism } = require('node:os');
const path = require('node:path');
const createDir = require('./scripts/functions/createDir.js');
const createDir = require('./scripts/utils/createDir.js');

if (!process.env.NODE_ENV || !process.env.DOMAIN || !process.env.PORT) {
throw new Error('Environment variables are null or undefined');
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sefinek-blocklist-collection",
"version": "0.14.0",
"version": "1.0.0",
"description": "The best lists for your DNS server or ad blocker (Pi-hole, AdGuard, etc.). Your first and last reliable source, with no false positives and its own whitelist.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-everything-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

const fs = require('fs').promises;
const path = require('path');
const date = require('./functions/date.js');
const date = require('./utils/date.js');

const defaultFolder = path.join(__dirname, '..', 'blocklist', 'template');
const generatedFolder = path.join(__dirname, '..', 'blocklist', 'generated');
Expand Down
6 changes: 2 additions & 4 deletions scripts/functions/process.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const path = require('node:path');

module.exports = async (convert, files, relativePath, folderPath) => {
module.exports = async (convert, allFiles, path, relativePath, folderPath) => {
try {
const subdirectories = files.filter(file => file.isDirectory());
const subdirectories = allFiles.filter(file => file.isDirectory());
await Promise.all(subdirectories.map(async subdirectory => {
const nextRelativePath = path.join(relativePath, subdirectory.name);
await convert(path.join(folderPath, subdirectory.name), nextRelativePath);
Expand Down
18 changes: 18 additions & 0 deletions scripts/functions/txtFilter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = async (format, path, fs, relativePath, folderPath) => {
const generatedPath = path.join(__dirname, `../../blocklist/generated/${format}`, relativePath);
try {
await fs.access(generatedPath);
} catch (err) {
await fs.mkdir(generatedPath, { recursive: true });
}

const allFiles = await fs.readdir(folderPath, { withFileTypes: true });
const txtFiles = allFiles.filter(file => file.isFile() && file.name.endsWith('.txt'));

return {
format,
allFiles,
txtFiles,
generatedPath,
};
};
19 changes: 5 additions & 14 deletions scripts/generate/0.0.0.0.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
const { promises: fs } = require('node:fs');
const path = require('node:path');
const date = require('../functions/date.js');
const sha256 = require('../functions/sha512.js');
const date = require('../utils/date.js');
const sha256 = require('../utils/sha512.js');
const txtFilter = require('../functions/txtFilter.js');
const process = require('../functions/process.js');

const format = '0.0.0.0';

const convert = async (folderPath = path.join(__dirname, '../../blocklist/template'), relativePath = '') => {
const generatedPath = path.join(__dirname, `../../blocklist/generated/${format}`, relativePath);
try {
await fs.access(generatedPath);
} catch (err) {
await fs.mkdir(generatedPath, { recursive: true });
}

const files = await fs.readdir(folderPath, { withFileTypes: true });
const txtFiles = files.filter(file => file.isFile() && file.name.endsWith('.txt'));
const { format, allFiles, txtFiles, generatedPath } = await txtFilter('0.0.0.0', path, fs, relativePath, folderPath);

await Promise.all(txtFiles.map(async file => {
const thisFileName = path.join(folderPath, file.name);
Expand All @@ -39,7 +30,7 @@ const convert = async (folderPath = path.join(__dirname, '../../blocklist/templa
console.log(`✔️ ${cacheHash || file.name} ++ ${fullNewFile}`);
}));

await process(convert, files, relativePath, folderPath);
await process(convert, allFiles, path, relativePath, folderPath);
};

const run = async () => {
Expand Down
19 changes: 5 additions & 14 deletions scripts/generate/127.0.0.1.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
const { promises: fs } = require('node:fs');
const path = require('node:path');
const date = require('../functions/date.js');
const sha256 = require('../functions/sha512.js');
const date = require('../utils/date.js');
const sha256 = require('../utils/sha512.js');
const txtFilter = require('../functions/txtFilter.js');
const process = require('../functions/process.js');

const format = '127.0.0.1';

const convert = async (folderPath = path.join(__dirname, '../../blocklist/template'), relativePath = '') => {
const generatedPath = path.join(__dirname, `../../blocklist/generated/${format}`, relativePath);
try {
await fs.access(generatedPath);
} catch (err) {
await fs.mkdir(generatedPath, { recursive: true });
}

const files = await fs.readdir(folderPath, { withFileTypes: true });
const txtFiles = files.filter(file => file.isFile() && file.name.endsWith('.txt'));
const { format, allFiles, txtFiles, generatedPath } = await txtFilter('127.0.0.1', path, fs, relativePath, folderPath);

await Promise.all(txtFiles.map(async file => {
const thisFileName = path.join(folderPath, file.name);
Expand All @@ -39,7 +30,7 @@ const convert = async (folderPath = path.join(__dirname, '../../blocklist/templa
console.log(`✔️ ${cacheHash || file.name} ++ ${fullNewFile}`);
}));

await process(convert, files, relativePath, folderPath);
await process(convert, allFiles, path, relativePath, folderPath);
};

const run = async () => {
Expand Down
19 changes: 5 additions & 14 deletions scripts/generate/adguard.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
const { promises: fs } = require('node:fs');
const path = require('node:path');
const date = require('../functions/date.js');
const sha256 = require('../functions/sha512.js');
const date = require('../utils/date.js');
const sha256 = require('../utils/sha512.js');
const txtFilter = require('../functions/txtFilter.js');
const process = require('../functions/process.js');

const format = 'adguard';

const convert = async (folderPath = path.join(__dirname, '../../blocklist/template'), relativePath = '') => {
const generatedPath = path.join(__dirname, `../../blocklist/generated/${format}`, relativePath);
try {
await fs.access(generatedPath);
} catch (err) {
await fs.mkdir(generatedPath, { recursive: true });
}

const files = await fs.readdir(folderPath, { withFileTypes: true });
const txtFiles = files.filter(file => file.isFile() && file.name.endsWith('.txt'));
const { format, allFiles, txtFiles, generatedPath } = await txtFilter('adguard', path, fs, relativePath, folderPath);

await Promise.all(txtFiles.map(async file => {
const thisFileName = path.join(folderPath, file.name);
Expand Down Expand Up @@ -45,7 +36,7 @@ const convert = async (folderPath = path.join(__dirname, '../../blocklist/templa
console.log(`✔️ ${cacheHash || file.name} ++ ${fullNewFile}`);
}));

await process(convert, files, relativePath, folderPath);
await process(convert, allFiles, path, relativePath, folderPath);
};

const run = async () => {
Expand Down
19 changes: 5 additions & 14 deletions scripts/generate/dnsmasq.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
const { promises: fs } = require('node:fs');
const path = require('node:path');
const date = require('../functions/date.js');
const sha256 = require('../functions/sha512.js');
const date = require('../utils/date.js');
const sha256 = require('../utils/sha512.js');
const txtFilter = require('../functions/txtFilter.js');
const process = require('../functions/process.js');

const format = 'dnsmasq';

const convert = async (folderPath = path.join(__dirname, '../../blocklist/template'), relativePath = '') => {
const generatedPath = path.join(__dirname, `../../blocklist/generated/${format}`, relativePath);
try {
await fs.access(generatedPath);
} catch (err) {
await fs.mkdir(generatedPath, { recursive: true });
}

const files = await fs.readdir(folderPath, { withFileTypes: true });
const txtFiles = files.filter(file => file.isFile() && file.name.endsWith('.txt'));
const { format, allFiles, txtFiles, generatedPath } = await txtFilter('dnsmasq', path, fs, relativePath, folderPath);

await Promise.all(txtFiles.map(async file => {
const thisFileName = path.join(folderPath, file.name);
Expand Down Expand Up @@ -46,7 +37,7 @@ const convert = async (folderPath = path.join(__dirname, '../../blocklist/templa
console.log(`✔️ ${cacheHash || file.name} ++ ${fullNewFile}`);
}));

await process(convert, files, relativePath, folderPath);
await process(convert, allFiles, path, relativePath, folderPath);
};

const run = async () => {
Expand Down
19 changes: 5 additions & 14 deletions scripts/generate/noip.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
const { promises: fs } = require('node:fs');
const path = require('node:path');
const date = require('../functions/date.js');
const sha256 = require('../functions/sha512.js');
const date = require('../utils/date.js');
const sha256 = require('../utils/sha512.js');
const txtFilter = require('../functions/txtFilter.js');
const process = require('../functions/process.js');

const format = 'noip';

const convert = async (folderPath = path.join(__dirname, '../../blocklist/template'), relativePath = '') => {
const generatedPath = path.join(__dirname, `../../blocklist/generated/${format}`, relativePath);
try {
await fs.access(generatedPath);
} catch (err) {
await fs.mkdir(generatedPath, { recursive: true });
}

const files = await fs.readdir(folderPath, { withFileTypes: true });
const txtFiles = files.filter(file => file.isFile() && file.name.endsWith('.txt'));
const { format, allFiles, txtFiles, generatedPath } = await txtFilter('noip', path, fs, relativePath, folderPath);

await Promise.all(txtFiles.map(async file => {
const thisFileName = path.join(folderPath, file.name);
Expand Down Expand Up @@ -46,7 +37,7 @@ const convert = async (folderPath = path.join(__dirname, '../../blocklist/templa
console.log(`✔️ ${cacheHash || file.name} ++ ${fullNewFile}`);
}));

await process(convert, files, relativePath, folderPath);
await process(convert, allFiles, path, fs, relativePath, folderPath);
};

const run = async () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 6ae3a4e

Please sign in to comment.