mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
docs: Update docs URLs and skip URL checking for hidden nodes (no-changelog) (#8865)
This commit is contained in:
parent
cef7c24b77
commit
f8442858e0
1
.github/scripts/package.json
vendored
1
.github/scripts/package.json
vendored
|
@ -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": "*"
|
||||
|
|
40
.github/scripts/validate-docs-links.js
vendored
40
.github/scripts/validate-docs-links.js
vendored
|
@ -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);
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -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/"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -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/"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue