UNPKG

@enspirit/emb

Version:

A replacement for our Makefile-for-monorepos

37 lines (36 loc) 1.32 kB
import { printTable } from '@oclif/table'; import { FlavoredCommand, getContext, TABLE_DEFAULTS } from '../../index.js'; import { ResourceFactory } from '../../../monorepo/resources/ResourceFactory.js'; export default class ResourcesIndex extends FlavoredCommand { static description = 'List resources.'; static enableJsonFlag = true; static examples = ['<%= config.bin %> <%= command.id %>']; static flags = {}; async run() { const { flags } = await this.parse(ResourcesIndex); const { monorepo } = await getContext(); const resources = await Promise.all(monorepo.resources.map(async (config) => { const component = monorepo.component(config.component); const builder = ResourceFactory.factor(config.type, { config, monorepo, component, }); return { ...config, reference: await builder.getReference(), }; })); if (!flags.json) { printTable({ ...TABLE_DEFAULTS, columns: ['name', 'type', 'reference', 'id'], data: resources, sort: { name: 'asc', }, }); } return resources; } }