mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
ci: Validate docs urls for langchain nodes as well (no-changelog) (#8271)
This commit is contained in:
committed by
GitHub
parent
23abd8fb49
commit
f208a6e087
9
.github/scripts/package.json
vendored
9
.github/scripts/package.json
vendored
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"cacheable-lookup": "6.1.0",
|
||||
"conventional-changelog": "^4.0.0",
|
||||
"glob": "^10.3.0",
|
||||
"semver": "^7.5.4",
|
||||
"tempfile": "^5.0.0",
|
||||
"debug": "4.3.4",
|
||||
"glob": "10.3.10",
|
||||
"p-limit": "3.1.0",
|
||||
"semver": "7.5.4",
|
||||
"tempfile": "5.0.0",
|
||||
"typescript": "*"
|
||||
}
|
||||
}
|
||||
|
||||
80
.github/scripts/validate-docs-links.js
vendored
Normal file
80
.github/scripts/validate-docs-links.js
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const packages = ['nodes-base', '@n8n/nodes-langchain'];
|
||||
const concurrency = 20;
|
||||
let exitCode = 0;
|
||||
|
||||
const debug = require('debug')('n8n');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
const glob = require('glob');
|
||||
const pLimit = require('p-limit');
|
||||
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) =>
|
||||
new Promise((resolve, reject) => {
|
||||
if (!documentationUrl) resolve([name, null]);
|
||||
const url = new URL(
|
||||
/^https?:\/\//.test(documentationUrl)
|
||||
? documentationUrl
|
||||
: `https://docs.n8n.io/integrations/builtin/${kind}/${documentationUrl.toLowerCase()}/`,
|
||||
);
|
||||
https
|
||||
.request(
|
||||
{
|
||||
hostname: url.hostname,
|
||||
port: 443,
|
||||
path: url.pathname,
|
||||
method: 'HEAD',
|
||||
agent,
|
||||
},
|
||||
(res) => {
|
||||
debug('✓', kind, name);
|
||||
resolve([name, res.statusCode]);
|
||||
},
|
||||
)
|
||||
.on('error', (e) => reject(e))
|
||||
.end();
|
||||
});
|
||||
|
||||
const checkLinks = async (baseDir, kind) => {
|
||||
let types = require(path.join(baseDir, `dist/types/${kind}.json`));
|
||||
if (kind === 'nodes')
|
||||
types = types.filter(({ codex }) => !!codex?.resources?.primaryDocumentation);
|
||||
debug(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);
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const missingDocs = [];
|
||||
const invalidUrls = [];
|
||||
for (const [name, statusCode] of statuses) {
|
||||
if (statusCode === null) missingDocs.push(name);
|
||||
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 || 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')]);
|
||||
if (exitCode !== 0) process.exit(exitCode);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user