import type { GenerateContext } from '../types' import { lintInstaller } from './lint' import { apiInstaller } from './api' import { localeInstaller } from './locale' import { nginxInstaller } from './nginx' import { unocssInstaller } from './unocss' // Turning this into a const allows the list to be iterated over for programatically creating prompt options // Should increase extensability in the future export const availablePackages = [ 'lint', 'api', 'locale', 'nginx', 'unocss', ] as const export type AvailablePackages = typeof availablePackages[number] export type Installer = ( context: GenerateContext, ) => Promise export type PkgInstallerMap = { [pkg in AvailablePackages]: { inUse: boolean installer: Installer }; } export const buildPkgInstallerMap = ( packages: AvailablePackages[], ): PkgInstallerMap => ({ lint: { inUse: packages.includes('lint'), installer: lintInstaller, }, api: { inUse: packages.includes('api'), installer: apiInstaller, }, locale: { inUse: packages.includes('locale'), installer: localeInstaller, }, nginx: { inUse: packages.includes('nginx'), installer: nginxInstaller, }, unocss: { inUse: packages.includes('unocss'), installer: unocssInstaller, }, })