feat: 初始化画个标仓库 - AI驱动设计系统(BYOK模式) - 224源/371504图标+25海报源+130技能
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 抽查 custom-brand-icons 与 game-icon-pack no-padding 的 SVG 内容
|
||||
*/
|
||||
'use strict';
|
||||
const https = require('https');
|
||||
|
||||
function fetchRaw(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = https.get(url, { timeout: 25000 }, (res) => {
|
||||
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
||||
res.resume(); return resolve(fetchRaw(res.headers.location));
|
||||
}
|
||||
if (res.statusCode !== 200) { reject(new Error('HTTP ' + res.statusCode + ' ' + url)); res.resume(); return; }
|
||||
const chunks = [];
|
||||
res.on('data', (c) => chunks.push(c));
|
||||
res.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
||||
});
|
||||
req.on('error', reject);
|
||||
});
|
||||
}
|
||||
|
||||
(async () => {
|
||||
// 1. custom-brand-icons 抽查:单色还是彩色?viewBox?
|
||||
for (const f of ['cloudflare.svg', 'apple.svg', '2N.svg', 'Hydro-Québec.svg']) {
|
||||
try {
|
||||
const svg = await fetchRaw(`https://cdn.jsdelivr.net/gh/elax46/custom-brand-icons@main/icon-svg/${encodeURIComponent(f)}`);
|
||||
const tag = svg.match(/<svg[^>]*>/);
|
||||
const vm = tag && tag[0].match(/viewBox=["']([^"']+)["']/);
|
||||
const fillCount = (svg.match(/fill="#[0-9a-fA-F]{3,6}"/g) || []).length;
|
||||
const pathCount = (svg.match(/<path/g) || []).length;
|
||||
console.log(`\ncustom-brand-icons/${f}`);
|
||||
console.log(` viewBox: ${vm ? vm[1] : '无'} | 显式色 fill 数: ${fillCount} | path 数: ${pathCount}`);
|
||||
console.log(` 开头 220 字符: ${svg.slice(0, 220).replace(/\n/g, ' ')}`);
|
||||
} catch (e) { console.log(` ❌ ${f}: ${e.message}`); }
|
||||
await new Promise(r => setTimeout(r, 300));
|
||||
}
|
||||
// 2. game-icon-pack no-padding 文件名是否唯一
|
||||
try {
|
||||
const j = JSON.parse(await fetchRaw('https://data.jsdelivr.com/v1/packages/gh/Nieobie/game-icon-pack@main'));
|
||||
const names = [];
|
||||
const walk = (files, prefix) => {
|
||||
for (const f of files || []) {
|
||||
if (f.type === 'file') names.push(f.name.toLowerCase());
|
||||
else walk(f.files || [], prefix + f.name + '/');
|
||||
}
|
||||
};
|
||||
const noPad = j.files.find(f => f.name === 'svg').files.find(d => d.name === 'no-padding');
|
||||
walk(noPad.files || [], '');
|
||||
const dup = names.filter((n, i) => names.indexOf(n) !== i);
|
||||
console.log(`\ngame-icon-pack no-padding 文件数: ${names.length} | 重名数: ${dup.length}`, dup.length ? dup.slice(0, 10).join(',') : '');
|
||||
} catch (e) { console.log('game no-padding: ❌', e.message); }
|
||||
})().catch((e) => { console.error('❌', e.message); process.exit(1); });
|
||||
Reference in New Issue
Block a user