Skip to content

Commit 1324cfa

Browse files
committed
update wiki and its scripts
Squashed commit of the following: commit 0a5c04f Author: Slava Leleka <[email protected]> Date: Tue Feb 4 23:16:51 2025 -0500 fix rollup config commit 9672922 Author: Slava Leleka <[email protected]> Date: Tue Feb 4 23:10:51 2025 -0500 manually update wiki commit 6e02ce1 Author: Slava Leleka <[email protected]> Date: Tue Feb 4 23:10:12 2025 -0500 fix specs commit 0a71aa2 Author: Slava Leleka <[email protected]> Date: Tue Feb 4 23:09:54 2025 -0500 rename few files commit 3aefe2c Author: Slava Leleka <[email protected]> Date: Tue Feb 4 23:09:04 2025 -0500 fix scripts for wiki build
1 parent 0c30a4d commit 1324cfa

14 files changed

+228
-57
lines changed

bamboo-specs/build.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ Build:
3737
pnpm build
3838
pnpm pack && mv adguard-scriptlets-*.tgz scriptlets.tgz
3939
40-
# TODO fix building wiki, ubo changed format of their source
41-
# pnpm wiki
40+
pnpm wiki
4241
- inject-variables:
4342
file: dist/build.txt
4443
scope: RESULT

bamboo-specs/test.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ Build:
3333
3434
pnpm install
3535
36-
# TODO fix building wiki, ubo changed format of their source
37-
# # build docs to lint them later
38-
# # check compatibility table updates and build it and build wiki docs
39-
# pnpm wiki
36+
# build docs to lint them later
37+
# check compatibility table updates and build it and build wiki docs
38+
pnpm wiki
4039
4140
pnpm test
4241
pnpm build

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"lint:md": "markdownlint .",
1818
"lint-staged": "lint-staged",
1919
"wiki": "pnpm wiki:build-table && pnpm wiki:build-docs",
20-
"wiki:build-table": "node ./scripts/check-sources-updates.js && node ./scripts/build-compatibility-table.js",
21-
"wiki:build-docs": "node scripts/build-docs.js",
20+
"wiki:build-table": "tsx ./scripts/check-sources-updates.js && tsx ./scripts/build-compatibility-table.js",
21+
"wiki:build-docs": "tsx scripts/build-docs.js",
2222
"prepublishOnly": "pnpm build",
2323
"increment": "pnpm version patch --no-git-tag-version"
2424
},

rollup.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const commonPlugins = [
2424

2525
const scriptletsListConfig = {
2626
input: {
27-
'scriptlets-list': 'src/scriptlets/scriptlets-list.js',
27+
'scriptlets-list': 'src/scriptlets/scriptlets-list.ts',
2828
},
2929
output: {
3030
dir: 'tmp',

scripts/build-compatibility-table.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
const path = require('node:path');
2-
const fs = require('node:fs');
3-
const { EOL } = require('node:os');
1+
import path from 'node:path';
2+
import fs from 'node:fs';
3+
import { EOL } from 'node:os';
4+
import { fileURLToPath } from 'node:url';
45

5-
const {
6-
REMOVED_MARKER,
7-
WIKI_DIR_PATH,
8-
COMPATIBILITY_TABLE_DATA_PATH,
9-
} = require('./constants');
6+
import { REMOVED_MARKER, WIKI_DIR_PATH, COMPATIBILITY_TABLE_DATA_PATH } from './constants';
107

118
const COMPATIBILITY_TABLE_OUTPUT_FILENAME = 'compatibility-table.md';
129

10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
12+
1313
/**
1414
* Path to **output** wiki compatibility table file
1515
*/

scripts/build-docs.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
const fs = require('node:fs');
2-
const path = require('node:path');
3-
const yaml = require('js-yaml');
4-
const { EOL } = require('node:os');
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import yaml from 'js-yaml';
4+
import { EOL } from 'node:os';
5+
import { fileURLToPath } from 'node:url';
56

6-
const {
7+
import {
78
getDataFromFiles,
89
SCRIPTLET_TYPE,
910
TRUSTED_SCRIPTLET_TYPE,
1011
REDIRECT_TYPE,
11-
DescribingCommentData,
12-
} = require('./helpers');
13-
const {
12+
} from './helpers';
13+
import {
1414
WIKI_DIR_PATH,
1515
scriptletsFilenames,
1616
trustedScriptletsFilenames,
1717
redirectsFilenames,
1818
SCRIPTLETS_SRC_RELATIVE_DIR_PATH,
1919
REDIRECTS_SRC_RELATIVE_DIR_PATH,
20-
} = require('./constants');
20+
} from './constants';
21+
22+
/**
23+
* @typedef {import('./helpers').DescribingCommentData} DescribingCommentData
24+
*/
2125

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

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

32+
const __filename = fileURLToPath(import.meta.url);
33+
const __dirname = path.dirname(__filename);
34+
2835
const staticRedirectsPath = path.resolve(__dirname, STATIC_REDIRECTS_RELATIVE_SOURCE);
2936

3037
const blockingRedirectsPath = path.resolve(

scripts/check-sources-updates.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
/* eslint-disable no-console, camelcase */
2-
const fs = require('node:fs');
3-
const axios = require('axios');
4-
const { EOL } = require('node:os');
2+
import fs from 'node:fs';
3+
import axios from 'axios';
4+
import { EOL } from 'node:os';
55

6-
const {
7-
REMOVED_MARKER,
8-
COMPATIBILITY_TABLE_DATA_PATH,
9-
} = require('./constants');
6+
import { REMOVED_MARKER, COMPATIBILITY_TABLE_DATA_PATH } from './constants';
107

118
/* ************************************************************************
129
*
@@ -225,6 +222,7 @@ async function getCurrentUBOScriptlets() {
225222
*
226223
* @returns {Diff|null} diff
227224
*/
225+
// eslint-disable-next-line no-unused-vars
228226
async function checkForUBOScriptletsUpdates() {
229227
const oldList = getScriptletsFromTable('ubo');
230228
const newList = await getCurrentUBOScriptlets();
@@ -397,17 +395,18 @@ async function checkForABPRedirectsUpdates() {
397395
*/
398396
(async function init() {
399397
const UBORedirectsDiff = await checkForUBORedirectsUpdates();
400-
const UBOScriptletsDiff = await checkForUBOScriptletsUpdates();
398+
// TODO: fix building wiki, ubo changed format of their source. AG-39652
399+
// const UBOScriptletsDiff = await checkForUBOScriptletsUpdates();
401400
const ABPRedirectsDiff = await checkForABPRedirectsUpdates();
402401
const ABPScriptletsDiff = await checkForABPScriptletsUpdates();
403402

404403
if (UBORedirectsDiff) {
405404
markTableWithDiff(UBORedirectsDiff, 'redirects', 'ubo');
406405
}
407406

408-
if (UBOScriptletsDiff) {
409-
markTableWithDiff(UBOScriptletsDiff, 'scriptlets', 'ubo');
410-
}
407+
// if (UBOScriptletsDiff) {
408+
// markTableWithDiff(UBOScriptletsDiff, 'scriptlets', 'ubo');
409+
// }
411410

412411
if (ABPRedirectsDiff) {
413412
markTableWithDiff(ABPRedirectsDiff, 'redirects', 'abp');
@@ -417,7 +416,12 @@ async function checkForABPRedirectsUpdates() {
417416
markTableWithDiff(ABPScriptletsDiff, 'scriptlets', 'abp');
418417
}
419418

420-
const diffs = [UBORedirectsDiff, UBOScriptletsDiff, ABPRedirectsDiff, ABPScriptletsDiff];
419+
const diffs = [
420+
UBORedirectsDiff,
421+
// UBOScriptletsDiff,
422+
ABPRedirectsDiff,
423+
ABPScriptletsDiff,
424+
];
421425

422426
if (diffs.some((diff) => !!diff)) {
423427
const removed = diffs

scripts/compatibility-table.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@
149149
{
150150
"adg": "prevent-bab"
151151
},
152+
{
153+
"adg": "prevent-canvas",
154+
"ubo": "prevent-canvas.js"
155+
},
152156
{
153157
"adg": "prevent-element-src-loading"
154158
},
@@ -351,10 +355,6 @@
351355
{
352356
"ubo": "multiup.js"
353357
},
354-
{
355-
"adg": "prevent-canvas",
356-
"ubo": "prevent-canvas.js"
357-
},
358358
{
359359
"ubo": "trusted-set-cookie-reload.js"
360360
},
@@ -596,4 +596,4 @@
596596
"ubo": "noop-0.5s.mp3"
597597
}
598598
]
599-
}
599+
}

scripts/constants.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ const TRUSTED_SCRIPTLETS_PREFIX = 'trusted-';
3131

3232
// files which are not scriptlets in the source directory
3333
const NON_SCRIPTLETS_FILES = [
34-
'index.js',
35-
'scriptlets.js',
36-
'scriptlets-list.js',
34+
'index.ts',
35+
'scriptlets.ts',
36+
'scriptlets-list.ts',
37+
'scriptlets-names-list.ts',
3738
];
3839

3940
const isUtilityFileName = (filename) => NON_SCRIPTLETS_FILES.includes(filename);
File renamed without changes.

0 commit comments

Comments
 (0)