Comparing version 1.1.6 to 1.1.7
@@ -64,7 +64,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
GitCommand.prototype.alwaysUseColor = function () { | ||
GitCommand.prototype.useColor = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.push({ base: 'git config color.ui always --replace-all' }).execute()]; | ||
case 0: return [4 /*yield*/, this.push({ base: 'git config color.ui always' }).execute()]; | ||
case 1: | ||
@@ -78,2 +78,15 @@ _a.sent(); | ||
}; | ||
GitCommand.prototype.disableColor = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.push({ base: 'git config color.ui auto' }).execute()]; | ||
case 1: | ||
_a.sent(); | ||
this.clear(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
GitCommand.prototype.execute = function () { | ||
@@ -80,0 +93,0 @@ return __awaiter(this, void 0, void 0, function () { |
@@ -41,2 +41,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var request_confirmation_1 = require("../../../Terminal/User Interactions/request-confirmation"); | ||
var selective_1 = require("./selective"); | ||
var AddMainPage = /** @class */ (function () { | ||
@@ -54,2 +55,8 @@ function AddMainPage(app, t) { | ||
} | ||
}, | ||
{ | ||
name: 'Add selectively', | ||
"function": { | ||
base: 'git add' | ||
} | ||
} | ||
@@ -87,4 +94,5 @@ ]; | ||
case 0: return [3 /*break*/, 3]; | ||
case 1: return [3 /*break*/, 7]; | ||
} | ||
return [3 /*break*/, 7]; | ||
return [3 /*break*/, 8]; | ||
case 2: | ||
@@ -105,3 +113,8 @@ { | ||
case 6: return [2 /*return*/, this]; | ||
case 7: return [2 /*return*/, null]; | ||
case 7: | ||
{ | ||
return [2 /*return*/, new selective_1.SelectiveAddPage(this.app, this.t)]; | ||
} | ||
_b.label = 8; | ||
case 8: return [2 /*return*/, null]; | ||
} | ||
@@ -108,0 +121,0 @@ }); |
@@ -47,2 +47,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var switch_branch_1 = require("./switch-branch"); | ||
var pull_1 = require("./pull"); | ||
var MainPage = /** @class */ (function () { | ||
@@ -80,2 +81,8 @@ function MainPage(app, t) { | ||
{ | ||
name: 'Pull', | ||
"function": { | ||
base: 'git pull' | ||
} | ||
}, | ||
{ | ||
name: 'New branch', | ||
@@ -110,5 +117,5 @@ "function": { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var response, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
@@ -118,5 +125,6 @@ if (!this.app.gitInfo.gitFolderPath()) { | ||
} | ||
return [4 /*yield*/, this.app.gitCommand.alwaysUseColor()]; | ||
return [4 /*yield*/, this.app.gitCommand.useColor()]; | ||
case 1: | ||
_a.sent(); | ||
_b.sent(); | ||
this.t.interactor.clear(); | ||
this.t.interactor | ||
@@ -143,27 +151,55 @@ .clear() | ||
case 2: | ||
response = _a.sent(); | ||
switch (response.index) { | ||
case -1: { | ||
return [2 /*return*/, null]; | ||
} | ||
case 0: { | ||
return [2 /*return*/, new status_1.StatusPage(this.app, this.t)]; | ||
} | ||
case 1: { | ||
return [2 /*return*/, new Add_1.AddMainPage(this.app, this.t)]; | ||
} | ||
case 2: { | ||
return [2 /*return*/, new commit_1.CommitPage(this.app, this.t)]; | ||
} | ||
case 3: { | ||
return [2 /*return*/, new push_1.PushPage(this.app, this.t)]; | ||
} | ||
case 4: { | ||
return [2 /*return*/, new new_branch_1.NewBranchPage(this.app, this.t)]; | ||
} | ||
case 5: { | ||
return [2 /*return*/, new switch_branch_1.SwitchBranchPage(this.app, this.t)]; | ||
} | ||
response = _b.sent(); | ||
_a = response.index; | ||
switch (_a) { | ||
case -1: return [3 /*break*/, 3]; | ||
case 0: return [3 /*break*/, 5]; | ||
case 1: return [3 /*break*/, 6]; | ||
case 2: return [3 /*break*/, 7]; | ||
case 3: return [3 /*break*/, 8]; | ||
case 4: return [3 /*break*/, 9]; | ||
case 5: return [3 /*break*/, 10]; | ||
case 6: return [3 /*break*/, 11]; | ||
} | ||
return [2 /*return*/, this]; | ||
return [3 /*break*/, 12]; | ||
case 3: return [4 /*yield*/, this.app.gitCommand.disableColor()]; | ||
case 4: | ||
_b.sent(); | ||
return [2 /*return*/, null]; | ||
case 5: | ||
{ | ||
return [2 /*return*/, new status_1.StatusPage(this.app, this.t)]; | ||
} | ||
_b.label = 6; | ||
case 6: | ||
{ | ||
return [2 /*return*/, new Add_1.AddMainPage(this.app, this.t)]; | ||
} | ||
_b.label = 7; | ||
case 7: | ||
{ | ||
return [2 /*return*/, new commit_1.CommitPage(this.app, this.t)]; | ||
} | ||
_b.label = 8; | ||
case 8: | ||
{ | ||
return [2 /*return*/, new push_1.PushPage(this.app, this.t)]; | ||
} | ||
_b.label = 9; | ||
case 9: | ||
{ | ||
return [2 /*return*/, new pull_1.PullPage(this.app, this.t)]; | ||
} | ||
_b.label = 10; | ||
case 10: | ||
{ | ||
return [2 /*return*/, new new_branch_1.NewBranchPage(this.app, this.t)]; | ||
} | ||
_b.label = 11; | ||
case 11: | ||
{ | ||
return [2 /*return*/, new switch_branch_1.SwitchBranchPage(this.app, this.t)]; | ||
} | ||
_b.label = 12; | ||
case 12: return [2 /*return*/, this]; | ||
} | ||
@@ -170,0 +206,0 @@ }); |
@@ -37,21 +37,148 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
exports.__esModule = true; | ||
var SelectTree = /** @class */ (function () { | ||
function SelectTree(t, config) { | ||
var _this = this; | ||
this.t = t; | ||
this.reactions = {}; | ||
this.selected = 0; | ||
this.reactions = { | ||
3: { | ||
action: function () { process.exit(); } | ||
}, | ||
27: { | ||
91: { | ||
65: { | ||
action: function () { | ||
_this.current.line = _this.current.line - 1 < 0 ? _this.visibleBranches.length - 1 : _this.current.line - 1; | ||
_this.current.branch = _this.visibleBranches[_this.current.line]; | ||
return false; | ||
} | ||
}, | ||
66: { | ||
action: function () { | ||
if (_this.current.line == -1) { | ||
_this.current.line = 0; | ||
_this.current.branch = _this.visibleBranches[_this.current.line]; | ||
} | ||
else { | ||
_this.current.line = _this.current.line + 1 > _this.visibleBranches.length - 1 ? -1 : _this.current.line + 1; | ||
_this.current.branch = _this.visibleBranches[_this.current.line]; | ||
} | ||
return false; | ||
} | ||
}, | ||
67: { | ||
action: function () { | ||
if (_this.current.branch.selected && _this.current.branch.sub) | ||
return false; | ||
_this.current.branch.open = !_this.current.branch.open; | ||
// if (this.current.branch.sub && this.current.branch.open) { | ||
// this.current.branch = this.current.branch.sub[0] | ||
// this.numberOfLines(this.config.tree) | ||
// this.current.line = this.getLineForBranch(this.current.branch) | ||
// } | ||
return false; | ||
} | ||
}, | ||
68: { | ||
action: function () { | ||
if (_this.current.branch.upperBranch) { | ||
_this.current.branch = _this.current.branch.upperBranch; | ||
_this.current.line = _this.getLineForBranch(_this.current.branch); | ||
//this.current.branch.open = false | ||
} | ||
return false; | ||
} | ||
} | ||
} | ||
}, | ||
13: { | ||
action: function () { | ||
if (_this.current.line == -1) | ||
return true; | ||
if (_this.current.branch.selected) { | ||
_this.setSelectAllForBranch(_this.current.branch, false); | ||
var upperBranch = _this.current.branch.upperBranch; | ||
while (upperBranch) { | ||
upperBranch.selected = false; | ||
upperBranch = upperBranch.upperBranch; | ||
} | ||
} | ||
else { | ||
_this.setSelectAllForBranch(_this.current.branch, true); | ||
if (_this.current.branch.sub && _this.current.branch.open) { | ||
_this.current.branch.open = false; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
}; | ||
this.current = { | ||
line: 0, | ||
branch: null | ||
}; | ||
this.visibleBranches = []; | ||
this.config = config; | ||
this.current.branch = this.config.tree; | ||
this.initialSelected = this.getAllSelectedEndBranches(this.config.tree); | ||
} | ||
SelectTree.prototype.setSelectAllForBranch = function (branch, shouldSelect) { | ||
var e_1, _a; | ||
branch.selected = shouldSelect; | ||
if (branch.sub) { | ||
try { | ||
for (var _b = __values(branch.sub), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var subBranch = _c.value; | ||
this.setSelectAllForBranch(subBranch, shouldSelect); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
}; | ||
SelectTree.prototype.run = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, reactResponse; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var response, reactResponse, selected, unselected, currentSelected, currentSelected_1, currentSelected_1_1, selectedBranch, _a, _b, initiallySelectedBranch; | ||
var e_2, _c, e_3, _d; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
this.t.interactor.hideCaret(); | ||
this.t.interactor.saveCursorSpot(); | ||
this.t.interactor.saveCursorSpot() | ||
.clear(); | ||
response = null; | ||
reactResponse = null; | ||
_a.label = 1; | ||
_e.label = 1; | ||
case 1: | ||
@@ -63,5 +190,41 @@ if (!!response) return [3 /*break*/, 3]; | ||
case 2: | ||
reactResponse = _a.sent(); | ||
if (reactResponse.finished) { | ||
response = {}; | ||
reactResponse = _e.sent(); | ||
if (reactResponse.finished) { // NEED TO FIGURE OUT WHAT TO RETURN | ||
selected = []; | ||
unselected = []; | ||
currentSelected = this.getAllSelectedEndBranches(this.config.tree); | ||
try { | ||
for (currentSelected_1 = (e_2 = void 0, __values(currentSelected)), currentSelected_1_1 = currentSelected_1.next(); !currentSelected_1_1.done; currentSelected_1_1 = currentSelected_1.next()) { | ||
selectedBranch = currentSelected_1_1.value; | ||
if (!this.initialSelected.includes(selectedBranch)) { | ||
selected.push(selectedBranch); | ||
} | ||
} | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (currentSelected_1_1 && !currentSelected_1_1.done && (_c = currentSelected_1["return"])) _c.call(currentSelected_1); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
try { | ||
for (_a = (e_3 = void 0, __values(this.initialSelected)), _b = _a.next(); !_b.done; _b = _a.next()) { | ||
initiallySelectedBranch = _b.value; | ||
if (!currentSelected.includes(initiallySelectedBranch)) { | ||
unselected.push(initiallySelectedBranch); | ||
} | ||
} | ||
} | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
try { | ||
if (_b && !_b.done && (_d = _a["return"])) _d.call(_a); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
response = { | ||
selectedItems: selected, | ||
unselectedItems: unselected | ||
}; | ||
} | ||
@@ -74,4 +237,147 @@ return [3 /*break*/, 1]; | ||
}; | ||
SelectTree.prototype.numberOfLines = function (branch) { | ||
var e_4, _a; | ||
this.visibleBranches.push(branch); | ||
if (branch.open && branch.sub) { | ||
var count = 0; | ||
try { | ||
for (var _b = __values(branch.sub), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var subBranch = _c.value; | ||
count += this.numberOfLines(subBranch); | ||
} | ||
} | ||
catch (e_4_1) { e_4 = { error: e_4_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); | ||
} | ||
finally { if (e_4) throw e_4.error; } | ||
} | ||
return count; | ||
} | ||
else { | ||
return 1; | ||
} | ||
}; | ||
SelectTree.prototype.getLineForBranch = function (branch) { | ||
var e_5, _a; | ||
try { | ||
for (var _b = __values(this.visibleBranches.entries()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var _d = __read(_c.value, 2), index = _d[0], value = _d[1]; | ||
if (value == branch) { | ||
return index; | ||
} | ||
} | ||
} | ||
catch (e_5_1) { e_5 = { error: e_5_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); | ||
} | ||
finally { if (e_5) throw e_5.error; } | ||
} | ||
return 0; | ||
}; | ||
SelectTree.prototype.getAllSelectedEndBranches = function (branch) { | ||
var e_6, _a, e_7, _b; | ||
if (branch.sub) { | ||
var branches = []; | ||
try { | ||
for (var _c = __values(branch.sub), _d = _c.next(); !_d.done; _d = _c.next()) { | ||
var subBranch = _d.value; | ||
var selectedBranches = this.getAllSelectedEndBranches(subBranch); | ||
try { | ||
for (var selectedBranches_1 = (e_7 = void 0, __values(selectedBranches)), selectedBranches_1_1 = selectedBranches_1.next(); !selectedBranches_1_1.done; selectedBranches_1_1 = selectedBranches_1.next()) { | ||
var selectedBranch = selectedBranches_1_1.value; | ||
branches.push(selectedBranch); | ||
} | ||
} | ||
catch (e_7_1) { e_7 = { error: e_7_1 }; } | ||
finally { | ||
try { | ||
if (selectedBranches_1_1 && !selectedBranches_1_1.done && (_b = selectedBranches_1["return"])) _b.call(selectedBranches_1); | ||
} | ||
finally { if (e_7) throw e_7.error; } | ||
} | ||
} | ||
} | ||
catch (e_6_1) { e_6 = { error: e_6_1 }; } | ||
finally { | ||
try { | ||
if (_d && !_d.done && (_a = _c["return"])) _a.call(_c); | ||
} | ||
finally { if (e_6) throw e_6.error; } | ||
} | ||
return branches; | ||
} | ||
else { | ||
if (branch.selected) { | ||
return [branch]; | ||
} | ||
return []; | ||
} | ||
}; | ||
SelectTree.prototype.renderBranch = function (branch, depth) { | ||
var e_8, _a; | ||
if (branch == this.current.branch) { | ||
if (branch.selected) { | ||
this.t.interactor | ||
.write(this.t.interactor.color.red('REMOVE > ')) | ||
.write(' '.repeat(depth)) | ||
.write(this.t.interactor.color.red((branch.open && branch.sub ? '-' : branch.sub ? '+' : ' ') + ' ' + branch.name)); | ||
} | ||
else { | ||
this.t.interactor | ||
.write(this.t.interactor.color.yellow('ADD > ')) | ||
.write(' '.repeat(depth)) | ||
.write(this.t.interactor.color.yellow((branch.open && branch.sub ? '-' : branch.sub ? '+' : ' ') + ' ' + branch.name)); | ||
} | ||
} | ||
else if (branch.selected) { | ||
this.t.interactor | ||
.write(this.t.interactor.color.green('ADDED ')) | ||
.write(' '.repeat(depth)) | ||
.write(this.t.interactor.color.green((branch.open && branch.sub ? '-' : branch.sub ? '+' : ' ') + ' ' + branch.name)); | ||
} | ||
else { | ||
this.t.interactor | ||
.write(' ') | ||
.write(' '.repeat(depth)) | ||
.write((branch.open && branch.sub ? '-' : branch.sub ? '+' : ' ') + ' ' + branch.name); | ||
} | ||
this.t.interactor.newLine(); | ||
if (branch.open && branch.sub) { | ||
try { | ||
for (var _b = __values(branch.sub), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var subBranch = _c.value; | ||
this.renderBranch(subBranch, depth + 1); | ||
} | ||
} | ||
catch (e_8_1) { e_8 = { error: e_8_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); | ||
} | ||
finally { if (e_8) throw e_8.error; } | ||
} | ||
} | ||
}; | ||
SelectTree.prototype.render = function () { | ||
this.t.interactor.restoreCursorSpot(); | ||
this.t.interactor.restoreCursorSpot() | ||
.clear(); | ||
this.visibleBranches = []; | ||
this.numberOfLines(this.config.tree); | ||
this.t.interactor | ||
.write(this.t.interactor.color.green('Selectively add or remove file from git.')).newLine(); | ||
this.renderBranch(this.config.tree, 0); | ||
this.t.interactor | ||
.newLine(); | ||
if (this.current.line == -1) { | ||
this.t.interactor | ||
.write(this.t.interactor.color.yellow(' > Done')); | ||
} | ||
else { | ||
this.t.interactor | ||
.write(' Done'); | ||
} | ||
}; | ||
@@ -78,0 +384,0 @@ SelectTree.prototype.react = function () { |
{ | ||
"name": "agita", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"main": "bin/index.js", | ||
@@ -5,0 +5,0 @@ "author": "Joel Huggett", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
151263
35
3249