MCPcopy Index your code
hub / github.com/labring/FastGPT / checkMetaCoverage

Function checkMetaCoverage

document/script/checkDocRefs.js:200–249  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198}
199
200function checkMetaCoverage() {
201 const errors = [];
202
203 (function walk(dir) {
204 const entries = fs.readdirSync(dir, { withFileTypes: true });
205
206 for (const entry of entries) {
207 if (!entry.isFile() || !isMetaFile(entry.name)) continue;
208 const metaPath = path.join(dir, entry.name);
209 let meta;
210 try {
211 meta = JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
212 } catch (e) {
213 errors.push({ file: metaPath, missing: [], parseError: e.message });
214 continue;
215 }
216 const pages = Array.isArray(meta.pages) ? meta.pages : [];
217
218 const declared = new Set();
219 const wildcards = new Set();
220 for (const p of pages) {
221 if (typeof p !== 'string') continue;
222 if (/^---.*---$/.test(p)) continue;
223 if (p.startsWith('...')) {
224 wildcards.add(p.slice(3));
225 continue;
226 }
227 declared.add(p);
228 }
229
230 const expected = collectExpectedSlugs(dir);
231 const missing = [];
232 for (const slug of expected) {
233 const topLevel = slug.split('/')[0];
234 if (wildcards.has(topLevel)) continue;
235 if (declared.has(slug)) continue;
236 missing.push(slug);
237 }
238 if (missing.length > 0) errors.push({ file: metaPath, missing });
239 }
240
241 for (const entry of entries) {
242 if (entry.isDirectory() && !entry.name.startsWith('.')) {
243 walk(path.join(dir, entry.name));
244 }
245 }
246 })(CONTENT_DIR);
247
248 return errors;
249}
250
251function main() {
252 const args = process.argv.slice(2).filter(Boolean);

Callers 1

mainFunction · 0.85

Calls 12

isMetaFileFunction · 0.85
collectExpectedSlugsFunction · 0.85
walkFunction · 0.85
testMethod · 0.80
joinMethod · 0.45
parseMethod · 0.45
pushMethod · 0.45
startsWithMethod · 0.45
addMethod · 0.45
sliceMethod · 0.45
splitMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected