import { exec } from 'node:child_process'; import * as path from 'path'; async function deprecateAllOldVersion(packageName: string) { const data = await ( await fetch(`https://nexus-hosted.wb.ru/repository/npm/${packageName}`) ).json(); const versions = (Object.entries(data.time) as Array<[string, string]>) .filter(([v]) => { const regex = /^\d+\.\d+\.\d+-\d+\.\d+$/; return !regex.test(v) && v.split('.').length > 1; }) .sort((a, b) => { return new Date(a[1]) > new Date(b[1]) ? 1 : -1; }); const deprecationMessage = 'Вышла новая версия дизайн системы пожалуйста обновитесь.'; versions.forEach(([v], idx) => { if (idx !== versions.length - 1) { const npmCommand = `npm deprecate ${packageName}@${v} "${deprecationMessage}"`; exec( npmCommand, { cwd: path.join(__dirname, '../..') }, (error, stdout, stderr) => { if (error) { console.error(`Error: ${error.message}`); return; } if (stderr) { console.error(`Stderr: ${stderr}`); return; } console.log(`Deprecate ${packageName}@${v}`); } ); } }); } deprecateAllOldVersion('@dpa/ritm-intro'); deprecateAllOldVersion('@dpa/react-frame-intro');