import { PlataBuild } from "++/libs/build" import type { Command } from "commander" export const main = async () => { if (Plata.ProjectJson.plata_no_setup !== undefined) { console.log('Plata não configurada remova o plata_no_setup do package.json') process.exit(0) } const args = process.argv.slice(process.argv.indexOf('+')) let cli: Command | null = null switch (Plata.ProjectJson.plata_type ?? 'api') { case 'api': cli = await (require('++/bin/extras/create-api-cli') as CreateCli.ImportedCreateCli).cli break case 'lib': cli = await (require('++/bin/extras/create-lib-cli') as CreateCli.ImportedCreateCli).cli break case 'cluster': cli = await (require('++/bin/extras/create-cluster-cli') as CreateCli.ImportedCreateCli).cli break default: console.log(`${Plata.ProjectJson.plata_type} not supported`) process.exit(0) break } const config = await PlataBuild.getBuildConfig() if (config.errorID !== undefined) { console.log(`⚠️ - Não foi possivel carregar a config - ${config.errorID}`) return cli.parseAsync(args) } if (config.plugins?.length) { for (let i = 0; i < config.plugins.length; i++) { const plugin = config.plugins[i]; if (plugin.cliCreate !== undefined) { cli = await plugin.cliCreate(cli) } } console.log(`✅ - Plugins carregados`) } await cli.parseAsync(args) process.exit(0) }