UNPKG

poyka

Version:

A framework for interactively creating, extending and maintaining web application as never easier before while doing it in elegant design patterns.

94 lines 4.56 kB
"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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.InsideExistingProject_Angular = void 0; const decova_terminal_1 = require("decova-terminal"); const path_1 = __importDefault(require("path")); const chalk_1 = __importDefault(require("chalk")); class InsideExistingProject_Angular { static _NewProject() { return __awaiter(this, void 0, void 0, function* () { let prjName = yield decova_terminal_1.CurrentTerminal.AskForTextAsync('Project Name?'); let prjDir = path_1.default.join(process.cwd(), prjName); console.log(chalk_1.default.bgCyan.black(`An Angular app will be created @ [${prjDir}]`)); yield decova_terminal_1.CurrentTerminal.AskForTextAsync(`>>> Press Enter to create [${prjName}] project`); decova_terminal_1.CurrentTerminal.Exec(`ng new ${prjName}`); }); } static _Serve() { return __awaiter(this, void 0, void 0, function* () { decova_terminal_1.CurrentTerminal.Exec(`ng serve`); }); } static _KillCurrentServer() { return __awaiter(this, void 0, void 0, function* () { const findCurrentServerProcess = () => { decova_terminal_1.CurrentTerminal.Exec('netstat -ano | findstr LISTENING | findstr :4200'); }; const killProcess = (pid) => { decova_terminal_1.CurrentTerminal.Exec(`taskkill /pid ${pid} /f`); }; findCurrentServerProcess(); let pid = yield decova_terminal_1.CurrentTerminal.AskForTextAsync("PID to kill?"); killProcess(pid); }); } static _Generate() { return __awaiter(this, void 0, void 0, function* () { let ops = { component: "component", service: "service", module: "module", directive: "directive" }; let op = yield decova_terminal_1.CurrentTerminal.McqAsync("Generate what?", ops); let name = yield decova_terminal_1.CurrentTerminal.AskForTextAsync(`${op} Name?`); yield decova_terminal_1.CurrentTerminal.AskForTextAsync(`>>> Press Enter to create [${name}] ${op}`); decova_terminal_1.CurrentTerminal.Exec(`ng g ${op} ${name}`); }); } static _installBootstrap() { return __awaiter(this, void 0, void 0, function* () { decova_terminal_1.CurrentTerminal.Exec('ng add @ng-bootstrap/schematics'); }); } static TakeControl() { return __awaiter(this, void 0, void 0, function* () { let ops = { generate: "Generate", installBootstrap: "Install Bootstrap", newProject: "New Project", serve: "Serve Solution", killCurrentServer: "Kill current server" }; let op = yield decova_terminal_1.CurrentTerminal.McqAsync('Action?', ops); switch (op) { case ops.generate: this._Generate(); break; case ops.installBootstrap: this._installBootstrap(); break; case ops.newProject: this._NewProject(); break; case ops.serve: this._Serve(); break; case ops.killCurrentServer: this._KillCurrentServer(); break; } }); } } exports.InsideExistingProject_Angular = InsideExistingProject_Angular; //# sourceMappingURL=InsideExistingProject_Angular.js.map