2021-02-27 07:30:11 +01:00
|
|
|
const chalk = require('chalk');
|
|
|
|
|
2021-05-07 21:22:25 +02:00
|
|
|
exports.command = ['list'];
|
|
|
|
exports.aliases = ['l'];
|
|
|
|
exports.describe = 'Lists all available packages';
|
2021-02-27 07:30:11 +01:00
|
|
|
|
|
|
|
const msg_format = {
|
2021-05-07 21:22:25 +02:00
|
|
|
color: p => `${chalk[p.installed ? 'green':'red']('•')} ${p.language} ${p.language_version}`,
|
|
|
|
monochrome: p => `${p.language} ${p.language_version} ${p.installed ? '(INSTALLED)': ''}`,
|
|
|
|
json: JSON.stringify
|
|
|
|
};
|
2021-04-23 01:43:21 +02:00
|
|
|
|
2021-05-07 21:22:25 +02:00
|
|
|
exports.handler = async ({ axios }) => {
|
|
|
|
const packages = await axios.get('/api/v2/packages');
|
2021-03-05 07:40:47 +01:00
|
|
|
|
2021-03-13 11:09:30 +01:00
|
|
|
const pkg_msg = packages.data
|
2021-02-27 07:30:11 +01:00
|
|
|
.map(msg_format.color)
|
|
|
|
.join('\n');
|
|
|
|
|
|
|
|
console.log(pkg_msg);
|
2021-04-23 01:43:21 +02:00
|
|
|
}
|