Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"options": {
"parser": "markdown"
}
},
{
"files": "*.js",
"options": {
"printWidth": 120
}
}
],
"endOfLine": "lf"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@ import { getChains } from '@api3/dapi-management';

const supportedMainnets = getChains()
.filter((chain) => chain.stage === 'active')
.map((chain) => CHAINS.find((api3Chain) => api3Chain.id === chain.id)!)
.map((chain) => CHAINS.find((api3Chain) => api3Chain.id === chain.id))
.filter((chain) => !chain.testnet)
.filter((chain) => chain.alias !== 'oev-network')
.map((chain) => chain.name)
.sort((a, b) => a.localeCompare(b));

test('the auction length section lists all the supported chains', () => {
const docPath = path.join(
process.cwd(),
'docs',
'oev-searchers',
'in-depth',
'oev-auctioneer.md'
);
const content = fs.readFileSync(docPath, 'utf8');

const content = readMarkdownFile();
const chains = extractContentBetweenMarkers(content, 'chain-auction-length-table')
.split('\n')
.filter(Boolean) // Get rid of blank lines
Expand All @@ -31,7 +23,15 @@ test('the auction length section lists all the supported chains', () => {
expect(chains).toStrictEqual(supportedMainnets);
});

function extractContentBetweenMarkers(content: string, key: string) {
function readMarkdownFile() {
const docPath = path.join(process.cwd(), 'docs', 'oev-searchers', 'in-depth', 'oev-auctioneer.md');
if (!fs.existsSync(docPath)) {
throw new Error(`Could not find file "oev-auctioneer.md" at "${docPath}"`);
}
return fs.readFileSync(docPath, 'utf8');
}

function extractContentBetweenMarkers(content, key) {
const beginMarker = `<!-- BEGIN:${key} -->`;
const endMarker = `<!-- END:${key} -->`;
const beginIndex = content.indexOf(beginMarker);
Expand Down
28 changes: 6 additions & 22 deletions libs/link-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ function tempCB(dirPath, dirs, files) {
// Load and display ignore list
var fs = require('fs');
const { link } = require('fs-extra');
var ignore = JSON.parse(
fs.readFileSync('./libs/link-validator-ignore.json', 'utf8')
);
var ignore = JSON.parse(fs.readFileSync('./libs/link-validator-ignore.json', 'utf8'));
console.log(colors.bold('| > Ignore list'));
ignore.forEach((element) => {
console.log('|', colors.bold.yellow(element));
Expand Down Expand Up @@ -119,14 +117,9 @@ async function testLink(url, filePath, ignoreTimeout) {
//console.log('> Target URL:', url);

// Look for urlAnchor in response.data.
if (
urlAnchor &&
response.data.indexOf('href="' + urlAnchor + '"') === -1
) {
if (urlAnchor && response.data.indexOf('href="' + urlAnchor + '"') === -1) {
//console.log(colors.red('> Anchor was NOT found in the response data.'));
throw new Error(
'Did not find anchor in the response data: ' + urlAnchor
);
throw new Error('Did not find anchor in the response data: ' + urlAnchor);
}
// else {
//console.log('> Anchor was found in the response data.');
Expand All @@ -150,11 +143,7 @@ async function testLink(url, filePath, ignoreTimeout) {
return 0;
} catch (error) {
// If a timeout try one more time
if (
!ignoreTimeout &&
error.code == 'ECONNABORTED' &&
error.toString().indexOf('Error: timeout') > -1
) {
if (!ignoreTimeout && error.code == 'ECONNABORTED' && error.toString().indexOf('Error: timeout') > -1) {
testLink(url, filePath, true);
} else {
process.stdout.write(colors.bold.red('X'));
Expand All @@ -165,8 +154,7 @@ async function testLink(url, filePath, ignoreTimeout) {
}

async function run(task) {
(console.log('Checking (' + task + ')', Object.keys(linksObj).length),
'links.');
(console.log('Checking (' + task + ')', Object.keys(linksObj).length), 'links.');
for (var key in linksObj) {
if (linksObj.hasOwnProperty(key)) {
let fail = await testLink(key, linksObj[key], false);
Expand Down Expand Up @@ -202,11 +190,7 @@ function loadLinks() {
// If the URL starts with an anchor (#) tag
// or is to the root (/)
// do nothing
} else if (
url &&
url.indexOf('http://') === -1 &&
url.indexOf('https://') === -1
) {
} else if (url && url.indexOf('http://') === -1 && url.indexOf('https://') === -1) {
// These are internal links within the docs
url = baseURL + url;

Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"docs:serve": "vitepress serve docs --port 8082",
"format": "prettier --write --cache \"./**/*.{js,vue,md,json,yaml}\" --log-level silent",
"format:check": "prettier --check --cache \"./**/*.{js,vue,md,json,yaml}\"",
"lint": "pnpm format:check && pnpm lint:tsc",
"lint:tsc": "pnpm tsc",
"lint": "pnpm format:check",
"test": "vitest run",
"generate-llms-files": "node scripts/generate-llms-files.js",
"prepare": "husky",
Expand All @@ -30,7 +29,6 @@
"medium-zoom": "^1.1.0",
"oust": "^2.0.4",
"prettier": "^3.6.2",
"typescript": "^5.9.2",
"vitepress": "1.6.4",
"vitest": "^3.2.4",
"walk-sync": "^3.0.0"
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

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

13 changes: 3 additions & 10 deletions scripts/generate-llms-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ function generateLlmsFullTxt() {
for (const link of links) {
const match = link.match(/- \[(.*?)\]\((.*?)\)/);
if (match) {
const url = match[2]
.replace('https://docs.api3.org', '')
.replace('.html', '.md');
const url = match[2].replace('https://docs.api3.org', '').replace('.html', '.md');
const filePath = path.join(docsDir, url);
if (fs.existsSync(filePath)) {
let fileContent = fs.readFileSync(filePath, 'utf-8');
Expand All @@ -103,15 +101,10 @@ function generateLlmsFullTxt() {
if (pageHeaderIndex === -1) {
throw new Error(`Could not find PageHeader in ${filePath}`);
}
fileContent = fileContent.substring(
pageHeaderIndex + pageHeader.length
);
fileContent = fileContent.substring(pageHeaderIndex + pageHeader.length);
const titleMatch = fileContent.match(/# (.*)/);
if (titleMatch && pageHeaderValue) {
fileContent = fileContent.replace(
/# (.*)/,
`# ${titleMatch[1]} (${pageHeaderValue})`
);
fileContent = fileContent.replace(/# (.*)/, `# ${titleMatch[1]} (${pageHeaderValue})`);
}
fullContent += fileContent + '\n\n';
}
Expand Down
19 changes: 0 additions & 19 deletions tsconfig.json

This file was deleted.

6 changes: 1 addition & 5 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ export default defineConfig({
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return id
.toString()
.split('node_modules/')[1]
.split('/')[0]
.toString();
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
},
},
Expand Down