Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3bb9cc4
install compiler from npmjs, switch to esm
jellizaveta Jul 31, 2025
d651a69
fix build
jellizaveta Jul 31, 2025
9add14e
update agtree
jellizaveta Jul 31, 2025
aba2079
fix aglint
jellizaveta Jul 31, 2025
2e001e0
add extension
jellizaveta Jul 31, 2025
b95016e
update lintignore
jellizaveta Aug 1, 2025
ef26a47
update agtree to 3.2.2 version
jellizaveta Aug 5, 2025
10a08d1
update find files
jellizaveta Aug 5, 2025
5fb01be
update validate script
jellizaveta Aug 5, 2025
c40b072
remove jest, add vitest, update wildcard-expander, remove redundant c…
jellizaveta Aug 5, 2025
e11f330
linter
jellizaveta Aug 5, 2025
8f7830d
review
jellizaveta Aug 5, 2025
a839a89
review
jellizaveta Aug 5, 2025
a2b5cf1
fix
jellizaveta Aug 5, 2025
a7555a2
fix node version
jellizaveta Aug 5, 2025
63bddc6
fix build
jellizaveta Aug 5, 2025
a6b2f29
Merge branch 'master' into update_compiler
slvvko Oct 17, 2025
7a1b108
no default export
slvvko Oct 17, 2025
63b1e7a
Merge branch 'master' into update_compiler
slvvko Oct 21, 2025
171231b
update deps
slvvko Oct 21, 2025
48b286f
Merge branch 'master' into update_compiler
slvvko Oct 21, 2025
666c3d3
Merge branch 'master' into update_compiler
slvvko Oct 22, 2025
195c814
Merge branch 'master' into update_compiler
slvvko Oct 23, 2025
1e10e68
update compiler to v3.1.3
slvvko Oct 24, 2025
cce29fd
Merge branch 'master' into update_compiler
slvvko Oct 24, 2025
c2228aa
Merge branch 'master' into update_compiler
slvvko Oct 29, 2025
fe2a0e6
Merge branch 'master' into update_compiler
slvvko Oct 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ module.exports = {
},
'rules': {
'import/no-extraneous-dependencies': 0,
'import/extensions': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
'selector': 'variable',
'format': null,
'filter': {
'regex': '^(__filename|__dirname)$',
'match': true
}
}
],
'@typescript-eslint/comma-dangle': ['error', 'always-multiline'],
'max-len': [
'error',
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-3p.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
cache: 'yarn'

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-adguard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
cache: 'yarn'

- name: Install dependencies
Expand Down
5 changes: 0 additions & 5 deletions jest.config.ts

This file was deleted.

36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,52 @@
"description": "AdGuard filters registry",
"homepage": "https://adguard.com",
"main": "scripts/build/build.js",
"type": "module",
"scripts": {
"auto-build": "bash scripts/auto_build.sh",
"lint": "yarn lint:code && yarn lint:types && yarn lint:md",
"lint:code": "eslint . --ext .js,.ts",
"lint:types": "tsc --noEmit --project tsconfig.json",
"lint:md": "markdownlint **/*.md",
"test": "jest .",
"build": "node scripts/build/build.js",
"test": "vitest run",
"build": "tsx scripts/build/build.js",
"build:patches": "node scripts/build/patches.js",
"validate": "yarn validate:platforms && yarn validate:locales",
"validate:platforms": "node scripts/validation/validate_platforms.js",
"validate:locales": "node scripts/validation/validate_locales.js",
"update-wildcard-domains": "node -r @swc-node/register scripts/wildcard-domain-processor update-wildcard-domains",
"expand-wildcard-domains": "node -r @swc-node/register scripts/wildcard-domain-processor expand-wildcard-domains",
"compress": "node scripts/repository/compress.js"
"validate:platforms": "tsx scripts/validation/validate_platforms.js",
"validate:locales": "tsx scripts/validation/validate_locales.js",
"update-wildcard-domains": "tsx scripts/wildcard-domain-processor update-wildcard-domains",
"expand-wildcard-domains": "tsx scripts/wildcard-domain-processor expand-wildcard-domains",
"compress": "tsx scripts/repository/compress.js"
},
"engines": {
"node": ">=18"
"node": ">=22"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which part of the code requires at least node 22?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adguard/[email protected] expected version ">=22"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think its too strict, probably we can reduce it in agtree as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer not to decrease it in agtree,
especially when node.js v18 is no longer maintained now:
https://nodejs.org/en/about/previous-releases

let's keep it 22

},
"dependencies": {
"@adguard/agtree": "^1.1.8",
"@adguard/agtree": "^3.2.4",
"@adguard/dead-domains-linter": "^1.0.22",
"@adguard/diff-builder": "1.1.2",
"adguard-filters-compiler": "git+https://github.com/AdguardTeam/FiltersCompiler.git#v1.2.8",
"crypto-js": "^4.2.0"
"@adguard/filters-compiler": "3.1.3",
"add": "^2.0.6",
"crypto-js": "^4.2.0",
"zod": "3"
},
"devDependencies": {
"@swc-node/register": "^1.10.0",
"@swc/core": "^1.6.5",
"@swc/jest": "^0.2.36",
"@types/crypto-js": "^4.2.2",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.9",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"@vitest/coverage-v8": "^3.2.4",
"eslint": "^8.54.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-plugin-import": "^2.29.0",
"jest": "^29.7.0",
"markdownlint": "0.34.0",
"markdownlint-cli": "0.41.0",
"simple-git": "^3.21.0",
"tldts": "^6.1.30",
"ts-jest": "^29.1.5",
"ts-node": "^10.9.2",
"typescript": "^5.5.2"
"tsx": "^4.20.3",
"typescript": "^5.5.2",
"vitest": "^3.2.4"
}
}
23 changes: 13 additions & 10 deletions scripts/build/build.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const fs = require('fs');
const path = require('path');
const compiler = require('adguard-filters-compiler');

const customPlatformsConfig = require('./custom_platforms');
const { formatDate } = require('../utils/strings');
const {
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { compile } from '@adguard/filters-compiler';
import { CUSTOM_PLATFORMS_CONFIG } from './custom_platforms.js';
import { formatDate } from '../utils/strings.js';
import {
FOLDER_WITH_NEW_FILTERS,
FOLDER_WITH_OLD_FILTERS,
} = require('./constants');
} from './constants.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

/**
* Parse command-cli parameters -i|--include and -s|--skip
Expand Down Expand Up @@ -72,14 +75,14 @@ const buildFilters = async () => {
await fs.promises.cp(platformsPath, copyPlatformsPath, { recursive: true });
}

await compiler.compile(
await compile(
filtersDir,
logPath,
reportPath,
platformsPath,
includedFilterIDs,
excludedFilterIDs,
customPlatformsConfig,
CUSTOM_PLATFORMS_CONFIG,
);

// For the very first run, we should copy the built platforms into
Expand Down
9 changes: 2 additions & 7 deletions scripts/build/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
const FOLDER_WITH_NEW_FILTERS = 'platforms';
const FOLDER_WITH_OLD_FILTERS = 'temp/platforms';

module.exports = {
FOLDER_WITH_NEW_FILTERS,
FOLDER_WITH_OLD_FILTERS,
};
export const FOLDER_WITH_NEW_FILTERS = 'platforms';
export const FOLDER_WITH_OLD_FILTERS = 'temp/platforms';
2 changes: 1 addition & 1 deletion scripts/build/custom_platforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ const CSS_GENERIC_RULES_PATTERNS = [
'^#\\$#',
];

module.exports = {
export const CUSTOM_PLATFORMS_CONFIG = {
'WINDOWS': {
'platform': 'windows',
'path': 'windows',
Expand Down
13 changes: 6 additions & 7 deletions scripts/build/patches.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* eslint-disable no-console */
/* eslint-disable no-await-in-loop */
const fs = require('fs');
const path = require('path');
const { DiffBuilder } = require('@adguard/diff-builder');

const {
import fs from 'fs';
import path from 'path';
import { DiffBuilder } from '@adguard/diff-builder';
import {
FOLDER_WITH_NEW_FILTERS,
FOLDER_WITH_OLD_FILTERS,
} = require('./constants');
const { findFiles } = require('../utils/find_files');
} from './constants.js';
import { findFiles } from '../utils/find_files.js';

/**
* Parse command-cli parameters -t|--time, -r|--resolution, -i|--include and -s|--skip
Expand Down
7 changes: 3 additions & 4 deletions scripts/checksum/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import MD5 from 'crypto-js/md5';
import Base64 from 'crypto-js/enc-base64';
import CryptoJS from 'crypto-js';

import { splitByLines } from '../utils/splitter';
import { splitByLines } from '../utils/splitter.js';

const CHECKSUM_TAG = 'Checksum';

Expand Down Expand Up @@ -36,7 +35,7 @@ function normalizeContent(content: string): string {
*/
function calculateChecksumMD5(content: string): string {
content = normalizeContent(content);
const checksum = Base64.stringify(MD5(content));
const checksum = CryptoJS.MD5(content).toString(CryptoJS.enc.Base64);

return checksum.trim().replace(/=+$/g, '');
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/repository/compress.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
const simpleGit = require('simple-git');
import simpleGit from 'simple-git';

let commitsToKeep = 10000;

Expand Down
11 changes: 3 additions & 8 deletions scripts/utils/find_files.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-await-in-loop */
const fs = require('fs');
const path = require('path');
import fs from 'fs';
import path from 'path';

/**
* Recursively finds files in a directory that match the provided filter.
Expand All @@ -10,7 +10,7 @@ const path = require('path');
*
* @returns An array of file paths that match the filter.
*/
const findFiles = async (dir, filter) => {
export const findFiles = async (dir, filter) => {
const files = await fs.promises.readdir(dir);
let fileList = [];

Expand All @@ -21,7 +21,6 @@ const findFiles = async (dir, filter) => {

if (stat.isDirectory()) {
const foundFiles = await findFiles(filePath, filter);
// Use concat but not push with spread to prevent stack overflow.
fileList = fileList.concat(foundFiles);
} else if (filter(filePath)) {
fileList = fileList.concat([filePath]);
Expand All @@ -30,7 +29,3 @@ const findFiles = async (dir, filter) => {

return fileList;
};

module.exports = {
findFiles,
};
4 changes: 1 addition & 3 deletions scripts/utils/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @param date
* @returns {string}
*/
const formatDate = (date) => {
export const formatDate = (date) => {
const dd = String(date.getDate()).padStart(2, '0');
const mm = String(date.getMonth() + 1).padStart(2, '0'); // January is 0!
const yyyy = date.getFullYear();
Expand All @@ -14,5 +14,3 @@ const formatDate = (date) => {

return `${dd}-${mm}-${yyyy}_${hours}-${minutes}-${seconds}`;
};

module.exports = { formatDate };
10 changes: 7 additions & 3 deletions scripts/validation/validate_locales.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const path = require('path');
const compiler = require('adguard-filters-compiler');
import path from 'path';
import { fileURLToPath } from 'url';
import { validateLocales } from '@adguard/filters-compiler';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const LOCALES_DIR_PATH = '../../locales';

Expand All @@ -22,7 +26,7 @@ const REQUIRED_LOCALES = [
];

const localesDirPath = path.join(__dirname, LOCALES_DIR_PATH);
const localesValidation = compiler.validateLocales(localesDirPath, REQUIRED_LOCALES);
const localesValidation = validateLocales(localesDirPath, REQUIRED_LOCALES);

if (!localesValidation.ok) {
throw new Error('Invalid locales messages');
Expand Down
16 changes: 10 additions & 6 deletions scripts/validation/validate_platforms.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const path = require('path');
const fs = require('fs');
const compiler = require('adguard-filters-compiler');
const { PATCH_EXTENSION } = require('@adguard/diff-builder');
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
import { validateJSONSchema } from '@adguard/filters-compiler';
import { PATCH_EXTENSION } from '@adguard/diff-builder';

const { FOLDER_WITH_NEW_FILTERS } = require('../build/constants');
import { FOLDER_WITH_NEW_FILTERS } from '../build/constants.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const FILTERS_REQUIRED_AMOUNT = 80;

Expand All @@ -16,7 +20,7 @@ if (!platforms) {

const platformsPath = path.join(__dirname, platforms);

const validationResult = compiler.validateJSONSchema(platformsPath, FILTERS_REQUIRED_AMOUNT);
const validationResult = validateJSONSchema(platformsPath, FILTERS_REQUIRED_AMOUNT);
if (!validationResult) {
throw new Error('Invalid filters json');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getDomains } from '../domain-extractor';
import { describe, it, expect } from 'vitest';
import { getDomains } from '../domain-extractor.js';

describe('getDomains', () => {
it('extracts wildcard domains from the cosmetic rules', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { describe, it, expect } from 'vitest';
import { RuleParser } from '@adguard/agtree/parser';
import { RuleGenerator } from '@adguard/agtree/generator';
import path from 'path';

import { RuleParser } from '@adguard/agtree';
import { expandWildcardDomainsInFilter, expandWildcardsInAst } from '../wildcard-expander';
import { type AliveWildcardDomains } from '../wildcard-domains-updater';
import { readFile } from '../file-utils';
import { expandWildcardDomainsInFilter, expandWildcardsInAst } from '../wildcard-expander.js';
import { type AliveWildcardDomains } from '../wildcard-domains-updater.js';
import { readFile } from '../file-utils.js';

/**
* Expands wildcards in a rule string.
Expand All @@ -30,7 +31,7 @@ export function expandWildcardsInRule(rule: string, wildcardDomains: AliveWildca
return rule;
}

return RuleParser.generate(astWithExpandedWildcards);
return RuleGenerator.generate(astWithExpandedWildcards);
}

describe('platforms-patcher', () => {
Expand Down
Loading