#!/usr/bin/env node const USAGE = `Wrong command has been detected. Use like below: npx nestia [command] [options?] 1. npx nestia start 2. npx nestia template 3. npx nestia setup 4. npx nestia dependencies 5. npx nestia init 6. npx nestia sdk 7. npx nestia swagger 9. npx nestia e2e 10. npx nestia all `; function halt(desc: string): never { console.error(desc); process.exit(-1); } async function main(): Promise { const type: string | undefined = process.argv[2]; const argv: string[] = process.argv.slice(3); if (type === "start") { await ( await import("./NestiaStarter.js") ).NestiaStarter.clone((msg) => halt(msg ?? USAGE))(argv); } else if (type === "template") { await ( await import("./NestiaTemplate.js") ).NestiaTemplate.clone((msg) => halt(msg ?? USAGE))(argv); } else if (type === "setup") { try { await import("comment-json"); await import("inquirer"); await import("commander"); } catch { halt(`nestia has not been installed. Run "npm i -D nestia" before.`); } await (await import("./NestiaSetupWizard.js")).NestiaSetupWizard.setup(); } else if ( type === "dependencies" || type === "init" || type === "sdk" || type === "swagger" || type === "e2e" || type === "all" ) { const location: string = "@nestia/sdk/lib/executable/sdk"; try { require.resolve(location); } catch { halt( `@nestia/sdk has not been installed. Run "npx nestia setup" before.`, ); } await import(location); } else halt(USAGE); } main().catch((exp) => { console.log(exp.message); process.exit(-1); });