diff --git a/.github/scripts/package.json b/.github/scripts/package.json index 5798df6321..cd67711fa4 100644 --- a/.github/scripts/package.json +++ b/.github/scripts/package.json @@ -5,6 +5,7 @@ "debug": "4.3.4", "glob": "10.3.10", "p-limit": "3.1.0", + "picocolors": "1.0.0", "semver": "7.5.4", "tempfile": "5.0.0", "typescript": "*" diff --git a/.github/scripts/validate-docs-links.js b/.github/scripts/validate-docs-links.js index 2335b62eed..1c11e75f7f 100644 --- a/.github/scripts/validate-docs-links.js +++ b/.github/scripts/validate-docs-links.js @@ -9,15 +9,22 @@ const path = require('path'); const https = require('https'); const glob = require('glob'); const pLimit = require('p-limit'); +const picocolors = require('picocolors'); const Lookup = require('cacheable-lookup').default; const agent = new https.Agent({ keepAlive: true, keepAliveMsecs: 5000 }); new Lookup().install(agent); const limiter = pLimit(concurrency); -const validateUrl = async (kind, name, documentationUrl) => +const validateUrl = async (packageName, kind, type) => new Promise((resolve, reject) => { + const name = type.displayName; + const documentationUrl = + kind === 'credentials' + ? type.documentationUrl + : type.codex?.resources?.primaryDocumentation?.[0]?.url; if (!documentationUrl) resolve([name, null]); + const url = new URL( /^https?:\/\//.test(documentationUrl) ? documentationUrl @@ -33,28 +40,30 @@ const validateUrl = async (kind, name, documentationUrl) => agent, }, (res) => { - debug('✓', kind, name); + debug(picocolors.green('✓'), packageName, kind, name); resolve([name, res.statusCode]); }, ) - .on('error', (e) => reject(e)) + .on('error', (e) => { + debug(picocolors.red('✘'), packageName, kind, name); + reject(e); + }) .end(); }); -const checkLinks = async (baseDir, kind) => { +const checkLinks = async (packageName, kind) => { + const baseDir = path.resolve(__dirname, '../../packages', packageName); let types = require(path.join(baseDir, `dist/types/${kind}.json`)); if (kind === 'nodes') - types = types.filter(({ codex }) => !!codex?.resources?.primaryDocumentation); - debug(kind, types.length); + types = types.filter( + ({ codex, hidden }) => !!codex?.resources?.primaryDocumentation && !hidden, + ); + debug(packageName, kind, types.length); const statuses = await Promise.all( types.map((type) => limiter(() => { - const documentationUrl = - kind === 'credentials' - ? type.documentationUrl - : type.codex?.resources?.primaryDocumentation?.[0]?.url; - return validateUrl(kind, type.displayName, documentationUrl); + return validateUrl(packageName, kind, type); }), ), ); @@ -66,15 +75,16 @@ const checkLinks = async (baseDir, kind) => { if (statusCode !== 200) invalidUrls.push(name); } - if (missingDocs.length) console.log('Documentation URL missing for %s', kind, missingDocs); - if (invalidUrls.length) console.log('Documentation URL invalid for %s', kind, invalidUrls); + if (missingDocs.length) + console.log('Documentation URL missing in %s for %s', packageName, kind, missingDocs); + if (invalidUrls.length) + console.log('Documentation URL invalid in %s for %s', packageName, kind, invalidUrls); if (missingDocs.length || invalidUrls.length) exitCode = 1; }; (async () => { for (const packageName of packages) { - const baseDir = path.resolve(__dirname, '../../packages', packageName); - await Promise.all([checkLinks(baseDir, 'credentials'), checkLinks(baseDir, 'nodes')]); + await Promise.all([checkLinks(packageName, 'credentials'), checkLinks(packageName, 'nodes')]); if (exitCode !== 0) process.exit(exitCode); } })(); diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlookTrigger.node.json b/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlookTrigger.node.json index 8d0e83cf5c..66c21892ae 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlookTrigger.node.json +++ b/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlookTrigger.node.json @@ -11,7 +11,7 @@ ], "primaryDocumentation": [ { - "url": "https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.microsoftOutlookTrigger/" + "url": "https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.microsoftoutlooktrigger/" } ] }, diff --git a/packages/nodes-base/nodes/OpenAi/OpenAi.node.json b/packages/nodes-base/nodes/OpenAi/OpenAi.node.json index 3757298600..330794a0d5 100644 --- a/packages/nodes-base/nodes/OpenAi/OpenAi.node.json +++ b/packages/nodes-base/nodes/OpenAi/OpenAi.node.json @@ -11,7 +11,7 @@ ], "primaryDocumentation": [ { - "url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.openai/" + "url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-langchain.openai/" } ] },