papayu/scripts/export-icon.js
Yuriy e76236dc55 Initial commit: papa-yu v2.4.4
- Schema version (x_schema_version, schema_hash) в prompt/trace
- Кеш read/search/logs/env (ContextCache) в plan-цикле
- Контекст-диета: MAX_FILES=8, MAX_FILE_CHARS=20k, MAX_TOTAL_CHARS=120k
- Plan→Apply двухфазность, NO_CHANGES, path sanitization
- Protected paths, content validation, EOL normalization
- Trace (PAPAYU_TRACE), redaction (PAPAYU_TRACE_RAW)
- Preview diff, undo/redo, transactional apply

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-01-31 11:33:19 +03:00

56 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
/**
* Экспорт иконки: SVG → PNG 1024x1024 для сборки Tauri.
* Варианты: ImageMagick (convert/magick), иначе npm install sharp && node scripts/export-icon.js
*/
const path = require('path');
const fs = require('fs');
const { execSync } = require('child_process');
const src = path.join(__dirname, '../src-tauri/icons/icon.svg');
const out = path.join(__dirname, '../src-tauri/icons/icon.png');
if (!fs.existsSync(src)) {
console.error('Не найден файл:', src);
process.exit(1);
}
function tryImageMagick() {
try {
execSync('convert -version', { stdio: 'ignore' });
execSync(`convert -background none -resize 1024x1024 "${src}" "${out}"`, { stdio: 'inherit' });
return true;
} catch (_) {}
try {
execSync('magick -version', { stdio: 'ignore' });
execSync(`magick convert -background none -resize 1024x1024 "${src}" "${out}"`, { stdio: 'inherit' });
return true;
} catch (_) {}
return false;
}
async function run() {
if (tryImageMagick()) {
console.log('Иконка экспортирована (ImageMagick):', out);
return;
}
try {
const sharp = require('sharp');
await sharp(src)
.resize(1024, 1024)
.png()
.toFile(out);
console.log('Иконка экспортирована (sharp):', out);
} catch (e) {
if (e.code === 'MODULE_NOT_FOUND') {
console.error('Установите sharp: npm install --save-dev sharp');
console.error('Или экспортируйте вручную: откройте src-tauri/icons/icon.svg в браузере/редакторе и сохраните как PNG 1024×1024 в icon.png');
} else {
console.error(e.message);
}
process.exit(1);
}
}
run();