UNPKG

nestia

Version:
75 lines (73 loc) 2.81 kB
#!/usr/bin/env node "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const USAGE = `Wrong command has been detected. Use like below: npx nestia [command] [options?] 1. npx nestia start <directory> 2. npx nestia template <directory> 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) { console.error(desc); process.exit(-1); } function main() { return __awaiter(this, void 0, void 0, function* () { const type = process.argv[2]; const argv = process.argv.slice(3); if (type === "start") { yield (yield import("./NestiaStarter.js")).NestiaStarter.clone((msg) => halt(msg !== null && msg !== void 0 ? msg : USAGE))(argv); } else if (type === "template") { yield (yield import("./NestiaTemplate.js")).NestiaTemplate.clone((msg) => halt(msg !== null && msg !== void 0 ? msg : USAGE))(argv); } else if (type === "setup") { try { yield import("comment-json"); yield import("inquirer"); yield import("commander"); } catch (_a) { halt(`nestia has not been installed. Run "npm i -D nestia" before.`); } yield (yield import("./NestiaSetupWizard.js")).NestiaSetupWizard.setup(); } else if (type === "dependencies" || type === "init" || type === "sdk" || type === "swagger" || type === "e2e" || type === "all") { const location = "@nestia/sdk/lib/executable/sdk"; try { require.resolve(location); } catch (_b) { halt(`@nestia/sdk has not been installed. Run "npx nestia setup" before.`); } yield import(location); } else halt(USAGE); }); } main().catch((exp) => { console.log(exp.message); process.exit(-1); }); //# sourceMappingURL=index.js.map