UNPKG

@nestjs/cli

Version:

Nest - modern, fast, powerful node.js web framework (@cli)

30 lines (29 loc) 1.29 kB
import { NodeWorkflow } from '@angular-devkit/schematics/tools/index.js'; import { AbstractCollection } from './abstract.collection.js'; export class CustomCollection extends AbstractCollection { getSchematics() { const workflow = new NodeWorkflow(process.cwd(), {}); const collection = workflow.engine.createCollection(this.collection); const collectionDescriptions = [ collection.description, ...(collection.baseDescriptions ?? []), ]; const usedNames = new Set(); const schematics = []; for (const collectionDesc of collectionDescriptions) { const schematicsDescs = Object.entries(collectionDesc.schematics); for (const [name, { description, aliases = [] }] of schematicsDescs) { if (usedNames.has(name)) { continue; } usedNames.add(name); const alias = aliases.find((a) => !usedNames.has(a)) ?? name; for (const alias of aliases) { usedNames.add(alias); } schematics.push({ name, alias, description }); } } return schematics.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0); } }