From 2ba227a0e8dcb6f4d29bfa37c40e81f8caa1a176 Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:27:03 +0330 Subject: [PATCH] Import source: global/scripts/check-no-cdn.mjs Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- global/scripts/check-no-cdn.mjs | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 global/scripts/check-no-cdn.mjs diff --git a/global/scripts/check-no-cdn.mjs b/global/scripts/check-no-cdn.mjs new file mode 100644 index 0000000..b6162b9 --- /dev/null +++ b/global/scripts/check-no-cdn.mjs @@ -0,0 +1,54 @@ +#!/usr/bin/env node +// Fails build if any CDN references are found in dist/ +import { readdirSync, readFileSync, statSync } from 'fs'; +import { join } from 'path'; + +const CDN_PATTERNS = [ + /cdn\./i, + /googleapis\.com/i, + /gstatic\.com/i, + /cloudflare\.com\/ajax/i, + /jsdelivr\.net/i, + /unpkg\.com/i, + /bootstrapcdn/i, + /cdnjs\.cloudflare/i, +]; + +const ALLOWED = [ + 'teknavglobal.com', + 'teknav.ir', + 'x.com', + 'twitter.com', + 'linkedin.com', +]; + +function walk(dir) { + const results = []; + for (const f of readdirSync(dir)) { + const p = join(dir, f); + if (statSync(p).isDirectory()) results.push(...walk(p)); + else if (f.endsWith('.html') || f.endsWith('.js') || f.endsWith('.css')) results.push(p); + } + return results; +} + +let errors = 0; +for (const file of walk('dist')) { + const content = readFileSync(file, 'utf8'); + for (const pattern of CDN_PATTERNS) { + const matches = content.match(new RegExp(pattern.source, 'gi')); + if (matches) { + const filtered = matches.filter(m => !ALLOWED.some(a => m.includes(a))); + if (filtered.length) { + console.error(`[check-no-cdn] ${file}: ${filtered.join(', ')}`); + errors++; + } + } + } +} + +if (errors > 0) { + console.error(`[check-no-cdn] FAILED: ${errors} CDN references found`); + process.exit(1); +} +console.log('[check-no-cdn] clean — no external CDN references found');