mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-12 15:44:06 -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",
|
"debug": "4.3.4",
|
||||||
"glob": "10.3.10",
|
"glob": "10.3.10",
|
||||||
"p-limit": "3.1.0",
|
"p-limit": "3.1.0",
|
||||||
|
"picocolors": "1.0.0",
|
||||||
"semver": "7.5.4",
|
"semver": "7.5.4",
|
||||||
"tempfile": "5.0.0",
|
"tempfile": "5.0.0",
|
||||||
"typescript": "*"
|
"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 https = require('https');
|
||||||
const glob = require('glob');
|
const glob = require('glob');
|
||||||
const pLimit = require('p-limit');
|
const pLimit = require('p-limit');
|
||||||
|
const picocolors = require('picocolors');
|
||||||
const Lookup = require('cacheable-lookup').default;
|
const Lookup = require('cacheable-lookup').default;
|
||||||
|
|
||||||
const agent = new https.Agent({ keepAlive: true, keepAliveMsecs: 5000 });
|
const agent = new https.Agent({ keepAlive: true, keepAliveMsecs: 5000 });
|
||||||
new Lookup().install(agent);
|
new Lookup().install(agent);
|
||||||
const limiter = pLimit(concurrency);
|
const limiter = pLimit(concurrency);
|
||||||
|
|
||||||
const validateUrl = async (kind, name, documentationUrl) =>
|
const validateUrl = async (packageName, kind, type) =>
|
||||||
new Promise((resolve, reject) => {
|
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]);
|
if (!documentationUrl) resolve([name, null]);
|
||||||
|
|
||||||
const url = new URL(
|
const url = new URL(
|
||||||
/^https?:\/\//.test(documentationUrl)
|
/^https?:\/\//.test(documentationUrl)
|
||||||
? documentationUrl
|
? documentationUrl
|
||||||
|
@ -33,28 +40,30 @@ const validateUrl = async (kind, name, documentationUrl) =>
|
||||||
agent,
|
agent,
|
||||||
},
|
},
|
||||||
(res) => {
|
(res) => {
|
||||||
debug('✓', kind, name);
|
debug(picocolors.green('✓'), packageName, kind, name);
|
||||||
resolve([name, res.statusCode]);
|
resolve([name, res.statusCode]);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.on('error', (e) => reject(e))
|
.on('error', (e) => {
|
||||||
|
debug(picocolors.red('✘'), packageName, kind, name);
|
||||||
|
reject(e);
|
||||||
|
})
|
||||||
.end();
|
.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`));
|
let types = require(path.join(baseDir, `dist/types/${kind}.json`));
|
||||||
if (kind === 'nodes')
|
if (kind === 'nodes')
|
||||||
types = types.filter(({ codex }) => !!codex?.resources?.primaryDocumentation);
|
types = types.filter(
|
||||||
debug(kind, types.length);
|
({ codex, hidden }) => !!codex?.resources?.primaryDocumentation && !hidden,
|
||||||
|
);
|
||||||
|
debug(packageName, kind, types.length);
|
||||||
|
|
||||||
const statuses = await Promise.all(
|
const statuses = await Promise.all(
|
||||||
types.map((type) =>
|
types.map((type) =>
|
||||||
limiter(() => {
|
limiter(() => {
|
||||||
const documentationUrl =
|
return validateUrl(packageName, kind, type);
|
||||||
kind === 'credentials'
|
|
||||||
? type.documentationUrl
|
|
||||||
: type.codex?.resources?.primaryDocumentation?.[0]?.url;
|
|
||||||
return validateUrl(kind, type.displayName, documentationUrl);
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -66,15 +75,16 @@ const checkLinks = async (baseDir, kind) => {
|
||||||
if (statusCode !== 200) invalidUrls.push(name);
|
if (statusCode !== 200) invalidUrls.push(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (missingDocs.length) console.log('Documentation URL missing for %s', kind, missingDocs);
|
if (missingDocs.length)
|
||||||
if (invalidUrls.length) console.log('Documentation URL invalid for %s', kind, invalidUrls);
|
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;
|
if (missingDocs.length || invalidUrls.length) exitCode = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
for (const packageName of packages) {
|
for (const packageName of packages) {
|
||||||
const baseDir = path.resolve(__dirname, '../../packages', packageName);
|
await Promise.all([checkLinks(packageName, 'credentials'), checkLinks(packageName, 'nodes')]);
|
||||||
await Promise.all([checkLinks(baseDir, 'credentials'), checkLinks(baseDir, 'nodes')]);
|
|
||||||
if (exitCode !== 0) process.exit(exitCode);
|
if (exitCode !== 0) process.exit(exitCode);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
],
|
],
|
||||||
"primaryDocumentation": [
|
"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": [
|
"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