decova-gotcha
Version:
It's my personal trial for automating daunting tasks
88 lines • 4.9 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
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 });
exports.GotchaRepo = void 0;
const decova_environment_1 = require("decova-environment");
const tsyringe_1 = require("tsyringe");
const TerminalAgent_1 = require("../../../external-sheet/TerminalAgent");
const ExternalResouces_1 = require("../../ExternalResouces");
const CommonMenu_1 = require("../CommonMenu");
const PathMan_1 = require("../PathMan");
let GotchaRepo = class GotchaRepo {
constructor() {
this.srv_PathMan = tsyringe_1.container.resolve(PathMan_1.PathMan);
}
PullAsync() {
return __awaiter(this, void 0, void 0, function* () {
if (!this.srv_PathMan.GotchaMainDir.Exists() ||
!this.srv_PathMan.GotchaMainDir.GetDirectories().xAny(d => d.Name == ".git")) {
yield this.CloneAsync();
}
else {
const entryWorkDir = decova_environment_1.Process.Current.CurrentWorkingDirectory;
this.srv_PathMan.GotchaMainDir.SetAsCurrentDirectory();
TerminalAgent_1.TerminalAgent.HintCurrentDir();
TerminalAgent_1.TerminalAgent.Hint(`Will pull Gotcha's repo to your machine`);
yield TerminalAgent_1.TerminalAgent.AskToRunCommandAsync(`git pull ${ExternalResouces_1.ExternalResources.GitHub_DataRepo}`);
entryWorkDir.SetAsCurrentDirectory();
}
});
}
CloneAsync() {
return __awaiter(this, void 0, void 0, function* () {
const entryWorkDir = decova_environment_1.Process.Current.CurrentWorkingDirectory;
this.srv_PathMan.UserProfileDir.SetAsCurrentDirectory();
yield TerminalAgent_1.TerminalAgent.HintCurrentDir();
yield TerminalAgent_1.TerminalAgent.Hint(`Gonna clone Gotcha's repo`);
yield TerminalAgent_1.TerminalAgent.AskToRunCommandAsync(`git clone ${ExternalResouces_1.ExternalResources.GitHub_DataRepo}`);
entryWorkDir.SetAsCurrentDirectory();
});
}
CommitAsync() {
return __awaiter(this, void 0, void 0, function* () {
const entryWorkDir = decova_environment_1.Process.Current.CurrentWorkingDirectory;
this.srv_PathMan.GotchaMainDir.SetAsCurrentDirectory();
TerminalAgent_1.TerminalAgent.Hint('Will commit your changes');
yield TerminalAgent_1.TerminalAgent.AskToRunCommandAsync(`git commit -m "Auto committed by Gotcha" .`);
entryWorkDir.SetAsCurrentDirectory();
});
}
PushAsync() {
return __awaiter(this, void 0, void 0, function* () {
const entryWorkDir = decova_environment_1.Process.Current.CurrentWorkingDirectory;
this.srv_PathMan.GotchaMainDir.SetAsCurrentDirectory();
TerminalAgent_1.TerminalAgent.Hint(`Will push Gotcha's repo commits`);
yield TerminalAgent_1.TerminalAgent.AskToRunCommandAsync(`git push`);
entryWorkDir.SetAsCurrentDirectory();
});
}
PromptThenCommitAndPushAsync() {
return __awaiter(this, void 0, void 0, function* () {
TerminalAgent_1.TerminalAgent.Hint(`Commit and push changes?`);
let go = yield CommonMenu_1.CommonMenu.ShowContinueSkipAsync('>>>');
if (go) {
yield this.CommitAsync();
yield this.PushAsync();
}
});
}
};
GotchaRepo = __decorate([
(0, tsyringe_1.singleton)()
], GotchaRepo);
exports.GotchaRepo = GotchaRepo;
//# sourceMappingURL=GotchaRepo.js.map