Skip to content

Commit

Permalink
Merge branch 'master' into feature/AG-12363
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamWr committed Feb 10, 2025
2 parents 9c5488c + 1324cfa commit 24b1ee3
Show file tree
Hide file tree
Showing 14 changed files with 228 additions and 57 deletions.
3 changes: 1 addition & 2 deletions bamboo-specs/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ Build:
pnpm build
pnpm pack && mv adguard-scriptlets-*.tgz scriptlets.tgz
# TODO fix building wiki, ubo changed format of their source
# pnpm wiki
pnpm wiki
- inject-variables:
file: dist/build.txt
scope: RESULT
Expand Down
7 changes: 3 additions & 4 deletions bamboo-specs/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ Build:
pnpm install
# TODO fix building wiki, ubo changed format of their source
# # build docs to lint them later
# # check compatibility table updates and build it and build wiki docs
# pnpm wiki
# build docs to lint them later
# check compatibility table updates and build it and build wiki docs
pnpm wiki
pnpm test
pnpm build
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"lint:md": "markdownlint .",
"lint-staged": "lint-staged",
"wiki": "pnpm wiki:build-table && pnpm wiki:build-docs",
"wiki:build-table": "node ./scripts/check-sources-updates.js && node ./scripts/build-compatibility-table.js",
"wiki:build-docs": "node scripts/build-docs.js",
"wiki:build-table": "tsx ./scripts/check-sources-updates.js && tsx ./scripts/build-compatibility-table.js",
"wiki:build-docs": "tsx scripts/build-docs.js",
"prepublishOnly": "pnpm build",
"increment": "pnpm version patch --no-git-tag-version"
},
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const commonPlugins = [

const scriptletsListConfig = {
input: {
'scriptlets-list': 'src/scriptlets/scriptlets-list.js',
'scriptlets-list': 'src/scriptlets/scriptlets-list.ts',
},
output: {
dir: 'tmp',
Expand Down
16 changes: 8 additions & 8 deletions scripts/build-compatibility-table.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const path = require('node:path');
const fs = require('node:fs');
const { EOL } = require('node:os');
import path from 'node:path';
import fs from 'node:fs';
import { EOL } from 'node:os';
import { fileURLToPath } from 'node:url';

const {
REMOVED_MARKER,
WIKI_DIR_PATH,
COMPATIBILITY_TABLE_DATA_PATH,
} = require('./constants');
import { REMOVED_MARKER, WIKI_DIR_PATH, COMPATIBILITY_TABLE_DATA_PATH } from './constants';

const COMPATIBILITY_TABLE_OUTPUT_FILENAME = 'compatibility-table.md';

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

/**
* Path to **output** wiki compatibility table file
*/
Expand Down
25 changes: 16 additions & 9 deletions scripts/build-docs.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
const fs = require('node:fs');
const path = require('node:path');
const yaml = require('js-yaml');
const { EOL } = require('node:os');
import fs from 'node:fs';
import path from 'node:path';
import yaml from 'js-yaml';
import { EOL } from 'node:os';
import { fileURLToPath } from 'node:url';

const {
import {
getDataFromFiles,
SCRIPTLET_TYPE,
TRUSTED_SCRIPTLET_TYPE,
REDIRECT_TYPE,
DescribingCommentData,
} = require('./helpers');
const {
} from './helpers';
import {
WIKI_DIR_PATH,
scriptletsFilenames,
trustedScriptletsFilenames,
redirectsFilenames,
SCRIPTLETS_SRC_RELATIVE_DIR_PATH,
REDIRECTS_SRC_RELATIVE_DIR_PATH,
} = require('./constants');
} from './constants';

/**
* @typedef {import('./helpers').DescribingCommentData} DescribingCommentData
*/

const STATIC_REDIRECTS_FILENAME = 'static-redirects.yml';
const BLOCKING_REDIRECTS_FILENAME = 'blocking-redirects.yml';

// eslint-disable-next-line max-len
const STATIC_REDIRECTS_RELATIVE_SOURCE = `${REDIRECTS_SRC_RELATIVE_DIR_PATH}/${STATIC_REDIRECTS_FILENAME}`;

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

const staticRedirectsPath = path.resolve(__dirname, STATIC_REDIRECTS_RELATIVE_SOURCE);

const blockingRedirectsPath = path.resolve(
Expand Down
28 changes: 16 additions & 12 deletions scripts/check-sources-updates.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/* eslint-disable no-console, camelcase */
const fs = require('node:fs');
const axios = require('axios');
const { EOL } = require('node:os');
import fs from 'node:fs';
import axios from 'axios';
import { EOL } from 'node:os';

const {
REMOVED_MARKER,
COMPATIBILITY_TABLE_DATA_PATH,
} = require('./constants');
import { REMOVED_MARKER, COMPATIBILITY_TABLE_DATA_PATH } from './constants';

/* ************************************************************************
*
Expand Down Expand Up @@ -225,6 +222,7 @@ async function getCurrentUBOScriptlets() {
*
* @returns {Diff|null} diff
*/
// eslint-disable-next-line no-unused-vars
async function checkForUBOScriptletsUpdates() {
const oldList = getScriptletsFromTable('ubo');
const newList = await getCurrentUBOScriptlets();
Expand Down Expand Up @@ -397,17 +395,18 @@ async function checkForABPRedirectsUpdates() {
*/
(async function init() {
const UBORedirectsDiff = await checkForUBORedirectsUpdates();
const UBOScriptletsDiff = await checkForUBOScriptletsUpdates();
// TODO: fix building wiki, ubo changed format of their source. AG-39652
// const UBOScriptletsDiff = await checkForUBOScriptletsUpdates();
const ABPRedirectsDiff = await checkForABPRedirectsUpdates();
const ABPScriptletsDiff = await checkForABPScriptletsUpdates();

if (UBORedirectsDiff) {
markTableWithDiff(UBORedirectsDiff, 'redirects', 'ubo');
}

if (UBOScriptletsDiff) {
markTableWithDiff(UBOScriptletsDiff, 'scriptlets', 'ubo');
}
// if (UBOScriptletsDiff) {
// markTableWithDiff(UBOScriptletsDiff, 'scriptlets', 'ubo');
// }

if (ABPRedirectsDiff) {
markTableWithDiff(ABPRedirectsDiff, 'redirects', 'abp');
Expand All @@ -417,7 +416,12 @@ async function checkForABPRedirectsUpdates() {
markTableWithDiff(ABPScriptletsDiff, 'scriptlets', 'abp');
}

const diffs = [UBORedirectsDiff, UBOScriptletsDiff, ABPRedirectsDiff, ABPScriptletsDiff];
const diffs = [
UBORedirectsDiff,
// UBOScriptletsDiff,
ABPRedirectsDiff,
ABPScriptletsDiff,
];

if (diffs.some((diff) => !!diff)) {
const removed = diffs
Expand Down
10 changes: 5 additions & 5 deletions scripts/compatibility-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
{
"adg": "prevent-bab"
},
{
"adg": "prevent-canvas",
"ubo": "prevent-canvas.js"
},
{
"adg": "prevent-element-src-loading"
},
Expand Down Expand Up @@ -351,10 +355,6 @@
{
"ubo": "multiup.js"
},
{
"adg": "prevent-canvas",
"ubo": "prevent-canvas.js"
},
{
"ubo": "trusted-set-cookie-reload.js"
},
Expand Down Expand Up @@ -596,4 +596,4 @@
"ubo": "noop-0.5s.mp3"
}
]
}
}
7 changes: 4 additions & 3 deletions scripts/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ const TRUSTED_SCRIPTLETS_PREFIX = 'trusted-';

// files which are not scriptlets in the source directory
const NON_SCRIPTLETS_FILES = [
'index.js',
'scriptlets.js',
'scriptlets-list.js',
'index.ts',
'scriptlets.ts',
'scriptlets-list.ts',
'scriptlets-names-list.ts',
];

const isUtilityFileName = (filename) => NON_SCRIPTLETS_FILES.includes(filename);
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 24b1ee3

Please # to comment.