mirror of
https://github.com/sern-handler/cli
synced 2026-06-26 09:42:22 +00:00
29 lines
813 B
JavaScript
29 lines
813 B
JavaScript
import axios from 'axios';
|
|
import { getLang } from '../utilities/getLang.js';
|
|
async function gimmechoices() {
|
|
const lang =
|
|
(await getLang()) === 'typescript' ? 'TypeScript' : 'JavaScript';
|
|
const link = `https://api.github.com/repos/sern-handler/awesome-plugins/contents/${lang}`;
|
|
|
|
const resp = await axios.default.get(link).catch(() => null);
|
|
if (!resp) return { title: 'No plugins found!', value: '', disabled: true };
|
|
const { data } = resp;
|
|
const choices = data.map(
|
|
(/** @type {{ name: string; download_url: string; }} */ e) => ({
|
|
title: e.name,
|
|
value: e.download_url,
|
|
})
|
|
);
|
|
return choices;
|
|
}
|
|
|
|
export async function pluginsQ() {
|
|
return {
|
|
name: 'list',
|
|
type: 'autocompleteMultiselect',
|
|
message: 'What plugins do you want to install?',
|
|
choices: await gimmechoices(),
|
|
min: 1,
|
|
};
|
|
}
|