2021-04-10 06:10:18 +02:00
|
|
|
const chalk = require('chalk');
|
|
|
|
|
2021-05-08 02:57:37 +02:00
|
|
|
exports.command = ['uninstall <language> [language_version]'];
|
2021-05-07 21:22:25 +02:00
|
|
|
exports.aliases = ['u'];
|
|
|
|
exports.describe = 'Uninstalls the named package';
|
2021-04-10 06:10:18 +02:00
|
|
|
|
|
|
|
const msg_format = {
|
2021-05-07 21:22:25 +02:00
|
|
|
color: p => `${p.language ? chalk.green.bold('✓') : chalk.red.bold('❌')} Uninstallation ${p.language ? 'succeeded' : 'failed: ' + p.message}`,
|
|
|
|
monochrome: p => `Uninstallation ${p.language ? 'succeeded' : 'failed: ' + p.message}`,
|
|
|
|
json: JSON.stringify
|
|
|
|
};
|
2021-04-10 06:10:18 +02:00
|
|
|
|
2021-05-08 02:57:37 +02:00
|
|
|
exports.handler = async ({ axios, language, language_version }) => {
|
2021-05-07 21:22:25 +02:00
|
|
|
try {
|
2021-05-08 02:57:37 +02:00
|
|
|
const request = {
|
2021-05-08 02:41:41 +02:00
|
|
|
language,
|
2021-05-08 02:57:37 +02:00
|
|
|
version: language_version || '*'
|
|
|
|
};
|
|
|
|
const uninstall = await axios.delete(`/api/v2/packages`, {data: request});
|
2021-04-23 01:43:21 +02:00
|
|
|
|
2021-04-11 03:15:14 +02:00
|
|
|
console.log(msg_format.color(uninstall.data));
|
2021-05-07 21:22:25 +02:00
|
|
|
} catch ({ response }) {
|
2021-04-10 06:10:18 +02:00
|
|
|
console.error(response.data.message)
|
|
|
|
}
|
2021-04-23 01:43:21 +02:00
|
|
|
}
|