import * as plugins from './mod.plugins.js'; import { logger } from '../gitzone.logging.js'; export const run = async () => { const smartInteract = new plugins.smartinteract.SmartInteract([ { name: `registryUrls`, message: `What are the comma separated registry URLs?`, type: `input`, default: `https://registry.npmjs.org`, validate: (stringInput) => { return stringInput !== '' && !process.env.CI; }, }, { name: `oldPackageName`, message: `Whats the name of the OLD package?`, type: `input`, default: ``, validate: (stringInput) => { return stringInput !== '' && !process.env.CI; }, }, { name: `newPackageName`, message: `Whats the name of the NEW package?`, type: `input`, default: ``, validate: (stringInput) => { return stringInput !== '' && !process.env.CI; }, }, ]); const answerBucket = await smartInteract.runQueue(); const registryUrls = answerBucket.getAnswerFor(`registryUrls`).split(','); const oldPackageName = answerBucket.getAnswerFor(`oldPackageName`); const newPackageName = answerBucket.getAnswerFor(`newPackageName`); logger.log('info', `Deprecating package ${oldPackageName} in favour of ${newPackageName}`); const smartshellInstance = new plugins.smartshell.Smartshell({ executor: 'bash', }); for (const registryUrl of registryUrls) { await smartshellInstance.exec( `npm deprecate ${oldPackageName}@* ` + `"${oldPackageName} has been deprecated in favour of ${newPackageName} - please upgrade asap!!!" --registry ${registryUrl}`, ); } };