tnp-helpers 16.444.16 → 16.444.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/shared/shared_folder_info.txt +1 -1
- package/browser/esm2022/lib/base/base-git.mjs +620 -0
- package/browser/esm2022/lib/base/base-library-build.mjs +380 -0
- package/browser/esm2022/lib/base/base-linked-projects.mjs +291 -0
- package/browser/esm2022/lib/base/base-npm-helpers.mjs +324 -0
- package/browser/esm2022/lib/base/base-project-resolver.mjs +56 -2
- package/browser/esm2022/lib/base/base-project.mjs +183 -1483
- package/browser/esm2022/lib/base/core-project.mjs +5 -3
- package/browser/esm2022/lib/base/index.mjs +5 -1
- package/browser/esm2022/lib/models.mjs +2 -1
- package/browser/fesm2022/tnp-helpers.mjs +1112 -749
- package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base/base-git.d.ts +115 -0
- package/browser/lib/base/base-library-build.d.ts +46 -0
- package/browser/lib/base/base-linked-projects.d.ts +23 -0
- package/browser/lib/base/base-npm-helpers.d.ts +79 -0
- package/browser/lib/base/base-project-resolver.d.ts +2 -1
- package/browser/lib/base/base-project.d.ts +12 -205
- package/browser/lib/base/core-project.d.ts +12 -3
- package/browser/lib/base/index.d.ts +4 -0
- package/browser/lib/models.d.ts +12 -4
- package/client/esm2022/lib/base/base-git.mjs +620 -0
- package/client/esm2022/lib/base/base-library-build.mjs +380 -0
- package/client/esm2022/lib/base/base-linked-projects.mjs +291 -0
- package/client/esm2022/lib/base/base-npm-helpers.mjs +324 -0
- package/client/esm2022/lib/base/base-project-resolver.mjs +56 -2
- package/client/esm2022/lib/base/base-project.mjs +183 -1483
- package/client/esm2022/lib/base/core-project.mjs +5 -3
- package/client/esm2022/lib/base/index.mjs +5 -1
- package/client/esm2022/lib/models.mjs +2 -1
- package/client/fesm2022/tnp-helpers.mjs +1112 -749
- package/client/fesm2022/tnp-helpers.mjs.map +1 -1
- package/client/lib/base/base-git.d.ts +115 -0
- package/client/lib/base/base-library-build.d.ts +46 -0
- package/client/lib/base/base-linked-projects.d.ts +23 -0
- package/client/lib/base/base-npm-helpers.d.ts +79 -0
- package/client/lib/base/base-project-resolver.d.ts +2 -1
- package/client/lib/base/base-project.d.ts +12 -205
- package/client/lib/base/core-project.d.ts +12 -3
- package/client/lib/base/index.d.ts +4 -0
- package/client/lib/models.d.ts +12 -4
- package/client/package.json +21 -21
- package/lib/base/base-command-line.backend.d.ts +5 -0
- package/lib/base/base-command-line.backend.js +70 -15
- package/lib/base/base-command-line.backend.js.map +1 -1
- package/lib/base/base-git.d.ts +121 -0
- package/lib/base/base-git.js +862 -0
- package/lib/base/base-git.js.map +1 -0
- package/lib/base/base-library-build.d.ts +56 -0
- package/lib/base/base-library-build.js +443 -0
- package/lib/base/base-library-build.js.map +1 -0
- package/lib/base/base-linked-projects.d.ts +23 -0
- package/lib/base/base-linked-projects.js +391 -0
- package/lib/base/base-linked-projects.js.map +1 -0
- package/lib/base/base-npm-helpers.d.ts +78 -0
- package/lib/base/base-npm-helpers.js +404 -0
- package/lib/base/base-npm-helpers.js.map +1 -0
- package/lib/base/base-project-resolver.d.ts +2 -1
- package/lib/base/base-project-resolver.js +39 -4
- package/lib/base/base-project-resolver.js.map +1 -1
- package/lib/base/base-project.d.ts +14 -214
- package/lib/base/base-project.js +106 -1740
- package/lib/base/base-project.js.map +1 -1
- package/lib/base/core-project.d.ts +12 -3
- package/lib/base/core-project.js +8 -4
- package/lib/base/core-project.js.map +1 -1
- package/lib/base/index.d.ts +4 -0
- package/lib/base/index.js +4 -0
- package/lib/base/index.js.map +1 -1
- package/lib/helpers/for-backend/helpers-git.backend.d.ts +3 -1
- package/lib/helpers/for-backend/helpers-git.backend.js +74 -2
- package/lib/helpers/for-backend/helpers-git.backend.js.map +1 -1
- package/lib/helpers/for-browser/angular.helper.js +3 -3
- package/lib/models.d.ts +12 -4
- package/lib/old/base-component.js +3 -3
- package/lib/old/base-formly-component.js +3 -3
- package/lib/old/dual-component-ctrl.js +3 -3
- package/package.json +4 -4
- package/tmp-environment.json +25 -25
- package/websql/esm2022/lib/base/base-git.mjs +620 -0
- package/websql/esm2022/lib/base/base-library-build.mjs +380 -0
- package/websql/esm2022/lib/base/base-linked-projects.mjs +291 -0
- package/websql/esm2022/lib/base/base-npm-helpers.mjs +324 -0
- package/websql/esm2022/lib/base/base-project-resolver.mjs +50 -2
- package/websql/esm2022/lib/base/base-project.mjs +236 -1536
- package/websql/esm2022/lib/base/core-project.mjs +5 -3
- package/websql/esm2022/lib/base/index.mjs +5 -1
- package/websql/esm2022/lib/models.mjs +2 -1
- package/websql/fesm2022/tnp-helpers.mjs +1112 -754
- package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base/base-git.d.ts +115 -0
- package/websql/lib/base/base-library-build.d.ts +46 -0
- package/websql/lib/base/base-linked-projects.d.ts +23 -0
- package/websql/lib/base/base-npm-helpers.d.ts +79 -0
- package/websql/lib/base/base-project-resolver.d.ts +2 -1
- package/websql/lib/base/base-project.d.ts +9 -205
- package/websql/lib/base/core-project.d.ts +12 -3
- package/websql/lib/base/index.d.ts +4 -0
- package/websql/lib/models.d.ts +12 -4
|
@@ -0,0 +1,862 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseGit = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
//#region imports
|
|
6
|
+
//#region @backend
|
|
7
|
+
var tnp_core_1 = require("tnp-core");
|
|
8
|
+
var translate_1 = require("./translate");
|
|
9
|
+
//#endregion
|
|
10
|
+
var base_feature_for_project_1 = require("./base-feature-for-project");
|
|
11
|
+
var index_1 = require("../index");
|
|
12
|
+
var tnp_core_2 = require("tnp-core");
|
|
13
|
+
//#endregion
|
|
14
|
+
var BaseGit = /** @class */ (function (_super) {
|
|
15
|
+
tslib_1.__extends(BaseGit, _super);
|
|
16
|
+
function BaseGit() {
|
|
17
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
18
|
+
}
|
|
19
|
+
//#region methods & getters / unstage all files
|
|
20
|
+
BaseGit.prototype.unstageAllFiles = function () {
|
|
21
|
+
//#region @backendFunc
|
|
22
|
+
index_1.Helpers.git.unstageAllFiles(this.project.location);
|
|
23
|
+
//#endregion
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region methods & getters / revert file changes
|
|
27
|
+
BaseGit.prototype.revertFileChanges = function (fileReletivePath) {
|
|
28
|
+
//#region @backendFunc
|
|
29
|
+
index_1.Helpers.git.revertFileChanges(this.project.location, fileReletivePath);
|
|
30
|
+
//#endregion
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region methods & getters / clone
|
|
34
|
+
BaseGit.prototype.clone = function (url, destinationFolderName, branchName) {
|
|
35
|
+
if (destinationFolderName === void 0) { destinationFolderName = ''; }
|
|
36
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
37
|
+
var clondeFolderpath, error_1;
|
|
38
|
+
return tslib_1.__generator(this, function (_a) {
|
|
39
|
+
switch (_a.label) {
|
|
40
|
+
case 0:
|
|
41
|
+
clondeFolderpath = index_1.Helpers.git.clone({
|
|
42
|
+
cwd: this.project.location,
|
|
43
|
+
url: url,
|
|
44
|
+
destinationFolderName: destinationFolderName,
|
|
45
|
+
});
|
|
46
|
+
if (!branchName) return [3 /*break*/, 4];
|
|
47
|
+
_a.label = 1;
|
|
48
|
+
case 1:
|
|
49
|
+
_a.trys.push([1, 3, , 4]);
|
|
50
|
+
index_1.Helpers.git.checkout(clondeFolderpath, branchName);
|
|
51
|
+
return [4 /*yield*/, index_1.Helpers.git.pullCurrentBranch(clondeFolderpath, {
|
|
52
|
+
askToRetry: true,
|
|
53
|
+
})];
|
|
54
|
+
case 2:
|
|
55
|
+
_a.sent();
|
|
56
|
+
return [3 /*break*/, 4];
|
|
57
|
+
case 3:
|
|
58
|
+
error_1 = _a.sent();
|
|
59
|
+
return [3 /*break*/, 4];
|
|
60
|
+
case 4: return [2 /*return*/, (0, tnp_core_2.crossPlatformPath)([
|
|
61
|
+
clondeFolderpath,
|
|
62
|
+
destinationFolderName || '',
|
|
63
|
+
]).replace(/\/$/g, '')];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region methods & getters / restore last version
|
|
70
|
+
BaseGit.prototype.restoreLastVersion = function (localFilePath) {
|
|
71
|
+
//#region @backendFunc
|
|
72
|
+
return index_1.Helpers.git.restoreLastVersion(this.project.location, localFilePath);
|
|
73
|
+
//#endregion
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region methods & getters / stage all files
|
|
77
|
+
BaseGit.prototype.stageAllFiles = function () {
|
|
78
|
+
//#region @backendFunc
|
|
79
|
+
index_1.Helpers.git.stageAllFiles(this.project.location);
|
|
80
|
+
//#endregion
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region methods & getters / stash
|
|
84
|
+
BaseGit.prototype.stash = function (optinos) {
|
|
85
|
+
//#region @backendFunc
|
|
86
|
+
index_1.Helpers.git.stash(this.project.location, optinos);
|
|
87
|
+
//#endregion
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region methods & getters / stash apply
|
|
91
|
+
BaseGit.prototype.stashApply = function () {
|
|
92
|
+
//#region @backendFunc
|
|
93
|
+
index_1.Helpers.git.stashApply(this.project.location);
|
|
94
|
+
//#endregion
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region methods & getters / fetch
|
|
98
|
+
BaseGit.prototype.fetch = function () {
|
|
99
|
+
//#region @backendFunc
|
|
100
|
+
index_1.Helpers.git.fetch(this.project.location);
|
|
101
|
+
//#endregion
|
|
102
|
+
};
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region methods & getters / reset files
|
|
105
|
+
BaseGit.prototype.resetFiles = function () {
|
|
106
|
+
var _a;
|
|
107
|
+
var relativePathes = [];
|
|
108
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
109
|
+
relativePathes[_i] = arguments[_i];
|
|
110
|
+
}
|
|
111
|
+
//#region @backendFunc
|
|
112
|
+
return (_a = index_1.Helpers.git).resetFiles.apply(_a, tslib_1.__spreadArray([this.project.location], tslib_1.__read(relativePathes), false));
|
|
113
|
+
//#endregion
|
|
114
|
+
};
|
|
115
|
+
Object.defineProperty(BaseGit.prototype, "isInsideGitRepo", {
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region methods & getters / is inside git repo
|
|
118
|
+
get: function () {
|
|
119
|
+
//#region @backendFunc
|
|
120
|
+
return index_1.Helpers.git.isInsideGitRepo(this.project.location);
|
|
121
|
+
//#endregion
|
|
122
|
+
},
|
|
123
|
+
enumerable: false,
|
|
124
|
+
configurable: true
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(BaseGit.prototype, "isWithoutGitRepository", {
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region methods & getters / is without git repository
|
|
129
|
+
get: function () {
|
|
130
|
+
//#region @backendFunc
|
|
131
|
+
return !tnp_core_1.fse.existsSync(tnp_core_2.path.join(this.project.location, '.git'));
|
|
132
|
+
//#endregion
|
|
133
|
+
},
|
|
134
|
+
enumerable: false,
|
|
135
|
+
configurable: true
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(BaseGit.prototype, "isGitRoot", {
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region methods & getters / is git root
|
|
140
|
+
get: function () {
|
|
141
|
+
//#region @backendFunc
|
|
142
|
+
return index_1.Helpers.git.isGitRoot(this.project.location);
|
|
143
|
+
//#endregion
|
|
144
|
+
},
|
|
145
|
+
enumerable: false,
|
|
146
|
+
configurable: true
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(BaseGit.prototype, "originURL", {
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region methods & getters / origin url
|
|
151
|
+
get: function () {
|
|
152
|
+
//#region @backendFunc
|
|
153
|
+
return index_1.Helpers.git.getOriginURL(this.project.location);
|
|
154
|
+
//#endregion
|
|
155
|
+
},
|
|
156
|
+
enumerable: false,
|
|
157
|
+
configurable: true
|
|
158
|
+
});
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region methods & getters / commit
|
|
161
|
+
BaseGit.prototype.commit = function (commitMessage) {
|
|
162
|
+
//#region @backendFunc
|
|
163
|
+
return index_1.Helpers.git.commit(this.project.location, commitMessage);
|
|
164
|
+
//#endregion
|
|
165
|
+
};
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region methods & getters / add and commit
|
|
168
|
+
/**
|
|
169
|
+
* alias to stage all and commit
|
|
170
|
+
*/
|
|
171
|
+
BaseGit.prototype.addAndCommit = function (commitMessage) {
|
|
172
|
+
//#region @backendFunc
|
|
173
|
+
return index_1.Helpers.git.stageAllAndCommit(this.project.location, commitMessage);
|
|
174
|
+
//#endregion
|
|
175
|
+
};
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region methods & getters / stage all and commit
|
|
178
|
+
BaseGit.prototype.stageAllAndCommit = function (commitMessage) {
|
|
179
|
+
//#region @backendFunc
|
|
180
|
+
return index_1.Helpers.git.stageAllAndCommit(this.project.location, commitMessage);
|
|
181
|
+
//#endregion
|
|
182
|
+
};
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region methods & getters / push current branch
|
|
185
|
+
BaseGit.prototype.pushCurrentBranch = function (options) {
|
|
186
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
187
|
+
return tslib_1.__generator(this, function (_a) {
|
|
188
|
+
switch (_a.label) {
|
|
189
|
+
case 0: return [4 /*yield*/, index_1.Helpers.git.pushCurrentBranch(this.project.location, options)];
|
|
190
|
+
case 1:
|
|
191
|
+
//#region @backendFunc
|
|
192
|
+
return [2 /*return*/, _a.sent()];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
Object.defineProperty(BaseGit.prototype, "allOrigins", {
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region methods & getters / all origins
|
|
200
|
+
get: function () {
|
|
201
|
+
//#region @backendFunc
|
|
202
|
+
return index_1.Helpers.git.allOrigins(this.project.location);
|
|
203
|
+
//#endregion
|
|
204
|
+
},
|
|
205
|
+
enumerable: false,
|
|
206
|
+
configurable: true
|
|
207
|
+
});
|
|
208
|
+
Object.defineProperty(BaseGit.prototype, "uncommitedFiles", {
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region methods & getters / uncommited files
|
|
211
|
+
get: function () {
|
|
212
|
+
//#region @backendFunc
|
|
213
|
+
return index_1.Helpers.git.uncommitedFiles(this.project.location);
|
|
214
|
+
//#endregion
|
|
215
|
+
},
|
|
216
|
+
enumerable: false,
|
|
217
|
+
configurable: true
|
|
218
|
+
});
|
|
219
|
+
Object.defineProperty(BaseGit.prototype, "thereAreSomeUncommitedChange", {
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region methods & getters / there are some uncommited change
|
|
222
|
+
get: function () {
|
|
223
|
+
//#region @backendFunc
|
|
224
|
+
return index_1.Helpers.git.checkIfthereAreSomeUncommitedChange(this.project.location);
|
|
225
|
+
//#endregion
|
|
226
|
+
},
|
|
227
|
+
enumerable: false,
|
|
228
|
+
configurable: true
|
|
229
|
+
});
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region methods & getters / there are some uncommited change except
|
|
232
|
+
BaseGit.prototype.thereAreSomeUncommitedChangeExcept = function (filesList) {
|
|
233
|
+
if (filesList === void 0) { filesList = []; }
|
|
234
|
+
//#region @backendFunc
|
|
235
|
+
return index_1.Helpers.git.thereAreSomeUncommitedChangeExcept(filesList, this.project.location);
|
|
236
|
+
//#endregion
|
|
237
|
+
};
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region methods & getters / melt action commits
|
|
240
|
+
BaseGit.prototype.meltActionCommits = function (soft) {
|
|
241
|
+
if (soft === void 0) { soft = false; }
|
|
242
|
+
//#region @backend
|
|
243
|
+
return index_1.Helpers.git.meltActionCommits(this.project.location, soft);
|
|
244
|
+
//#endregion
|
|
245
|
+
};
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region methods & getters / pull current branch
|
|
248
|
+
BaseGit.prototype.pullCurrentBranch = function (options) {
|
|
249
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
250
|
+
return tslib_1.__generator(this, function (_a) {
|
|
251
|
+
switch (_a.label) {
|
|
252
|
+
case 0:
|
|
253
|
+
//#region @backendFunc
|
|
254
|
+
return [4 /*yield*/, index_1.Helpers.git.pullCurrentBranch(this.project.location, tslib_1.__assign({}, options))];
|
|
255
|
+
case 1:
|
|
256
|
+
//#region @backendFunc
|
|
257
|
+
_a.sent();
|
|
258
|
+
return [2 /*return*/];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
Object.defineProperty(BaseGit.prototype, "currentBranchName", {
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region methods & getters / current branch name
|
|
266
|
+
get: function () {
|
|
267
|
+
//#region @backendFunc
|
|
268
|
+
return index_1.Helpers.git.currentBranchName(this.project.location);
|
|
269
|
+
//#endregion
|
|
270
|
+
},
|
|
271
|
+
enumerable: false,
|
|
272
|
+
configurable: true
|
|
273
|
+
});
|
|
274
|
+
Object.defineProperty(BaseGit.prototype, "listOfCurrentGitChanges", {
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region methods & getters / list of current git changes
|
|
277
|
+
get: function () {
|
|
278
|
+
//#region @backendFunc
|
|
279
|
+
return index_1.Helpers.git.getListOfCurrentGitChanges(this.project.location);
|
|
280
|
+
//#endregion
|
|
281
|
+
},
|
|
282
|
+
enumerable: false,
|
|
283
|
+
configurable: true
|
|
284
|
+
});
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region methods & getters / get branches names by
|
|
287
|
+
BaseGit.prototype.getBranchesNamesBy = function (pattern) {
|
|
288
|
+
//#region @backendFunc
|
|
289
|
+
return index_1.Helpers.git.getBranchesNames(this.project.location, pattern);
|
|
290
|
+
//#endregion
|
|
291
|
+
};
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region methods & getters / reset soft HEAD
|
|
294
|
+
BaseGit.prototype.resetSoftHEAD = function (HEAD) {
|
|
295
|
+
if (HEAD === void 0) { HEAD = 1; }
|
|
296
|
+
//#region @backendFunc
|
|
297
|
+
index_1.Helpers.git.resetSoftHEAD(this.project.location, HEAD);
|
|
298
|
+
//#endregion
|
|
299
|
+
};
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region methods & getters / reset hard
|
|
302
|
+
BaseGit.prototype.resetHard = function (options) {
|
|
303
|
+
//#region @backendFunc
|
|
304
|
+
index_1.Helpers.git.resetHard(this.project.location, options);
|
|
305
|
+
//#endregion
|
|
306
|
+
};
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region methods & getters / count commits
|
|
309
|
+
BaseGit.prototype.countComits = function () {
|
|
310
|
+
//#region @backendFunc
|
|
311
|
+
return index_1.Helpers.git.countCommits(this.project.location);
|
|
312
|
+
//#endregion
|
|
313
|
+
};
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region methods & getters / has any commits
|
|
316
|
+
BaseGit.prototype.hasAnyCommits = function () {
|
|
317
|
+
//#region @backendFunc
|
|
318
|
+
return index_1.Helpers.git.hasAnyCommits(this.project.location);
|
|
319
|
+
//#endregion
|
|
320
|
+
};
|
|
321
|
+
Object.defineProperty(BaseGit.prototype, "isInMergeProcess", {
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region methods & getters / is in merge process
|
|
324
|
+
get: function () {
|
|
325
|
+
//#region @backendFunc
|
|
326
|
+
return index_1.Helpers.git.isInMergeProcess(this.project.location);
|
|
327
|
+
//#endregion
|
|
328
|
+
},
|
|
329
|
+
enumerable: false,
|
|
330
|
+
configurable: true
|
|
331
|
+
});
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region methods & getters / last commit date
|
|
334
|
+
BaseGit.prototype.lastCommitDate = function () {
|
|
335
|
+
//#region @backendFunc
|
|
336
|
+
return index_1.Helpers.git.lastCommitDate(this.project.location);
|
|
337
|
+
//#endregion
|
|
338
|
+
};
|
|
339
|
+
//#endregion
|
|
340
|
+
//#region methods & getters / last commit hash
|
|
341
|
+
BaseGit.prototype.lastCommitHash = function () {
|
|
342
|
+
//#region @backendFunc
|
|
343
|
+
return index_1.Helpers.git.lastCommitHash(this.project.location);
|
|
344
|
+
//#endregion
|
|
345
|
+
};
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region methods & getters / last commit message
|
|
348
|
+
BaseGit.prototype.lastCommitMessage = function () {
|
|
349
|
+
//#region @backendFunc
|
|
350
|
+
return index_1.Helpers.git.lastCommitMessage(this.project.location);
|
|
351
|
+
//#endregion
|
|
352
|
+
};
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region methods & getters / penultimate commit hash
|
|
355
|
+
BaseGit.prototype.penultimateCommitHash = function () {
|
|
356
|
+
//#region @backendFunc
|
|
357
|
+
return index_1.Helpers.git.penultimateCommitHash(this.project.location);
|
|
358
|
+
//#endregion
|
|
359
|
+
};
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region methods & getters / check tag exists
|
|
362
|
+
BaseGit.prototype.checkTagExists = function (tag) {
|
|
363
|
+
//#region @backendFunc
|
|
364
|
+
return index_1.Helpers.git.checkTagExists(tag, this.project.location);
|
|
365
|
+
//#endregion
|
|
366
|
+
};
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region methods & getters / checkout
|
|
369
|
+
BaseGit.prototype.checkout = function (branchName, options) {
|
|
370
|
+
//#region @backendFunc
|
|
371
|
+
return index_1.Helpers.git.checkout(this.project.location, branchName, options);
|
|
372
|
+
//#endregion
|
|
373
|
+
};
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region methods & getters / checkout from to
|
|
376
|
+
BaseGit.prototype.checkoutFromTo = function (checkoutFromBranch, branch, origin) {
|
|
377
|
+
if (origin === void 0) { origin = 'origin'; }
|
|
378
|
+
//#region @backendFunc
|
|
379
|
+
return index_1.Helpers.git.checkoutFromTo(checkoutFromBranch, branch, origin, this.project.location);
|
|
380
|
+
//#endregion
|
|
381
|
+
};
|
|
382
|
+
//#endregion
|
|
383
|
+
//#region methods & getters / last tag name for major version
|
|
384
|
+
/**
|
|
385
|
+
*
|
|
386
|
+
* @param majorVersion example: v1, v2 etc.
|
|
387
|
+
* @returns tag name
|
|
388
|
+
*/
|
|
389
|
+
BaseGit.prototype.lastTagNameForMajorVersion = function (majorVersion) {
|
|
390
|
+
//#region @backendFunc
|
|
391
|
+
return index_1.Helpers.git.lastTagNameForMajorVersion(this.project.location, majorVersion);
|
|
392
|
+
//#endregion
|
|
393
|
+
};
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region methods & getters / last tag hash
|
|
396
|
+
BaseGit.prototype.lastTagHash = function () {
|
|
397
|
+
//#region @backendFunc
|
|
398
|
+
return index_1.Helpers.git.lastTagHash(this.project.location);
|
|
399
|
+
//#endregion
|
|
400
|
+
};
|
|
401
|
+
Object.defineProperty(BaseGit.prototype, "remoteOriginUrl", {
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region methods & getters / remote origin url
|
|
404
|
+
get: function () {
|
|
405
|
+
//#region @backendFunc
|
|
406
|
+
return index_1.Helpers.git.getOriginURL(this.project.location);
|
|
407
|
+
//#endregion
|
|
408
|
+
},
|
|
409
|
+
enumerable: false,
|
|
410
|
+
configurable: true
|
|
411
|
+
});
|
|
412
|
+
Object.defineProperty(BaseGit.prototype, "lastTagVersionName", {
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region methods & getters / last tag version name
|
|
415
|
+
get: function () {
|
|
416
|
+
//#region @backendFunc
|
|
417
|
+
return index_1.Helpers.git.lastTagVersionName(this.project.location) || '';
|
|
418
|
+
//#endregion
|
|
419
|
+
},
|
|
420
|
+
enumerable: false,
|
|
421
|
+
configurable: true
|
|
422
|
+
});
|
|
423
|
+
Object.defineProperty(BaseGit.prototype, "stagedFiles", {
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region methods & getters / staged files
|
|
426
|
+
get: function () {
|
|
427
|
+
//#region @backendFunc
|
|
428
|
+
return index_1.Helpers.git.stagedFiles(this.project.location);
|
|
429
|
+
//#endregion
|
|
430
|
+
},
|
|
431
|
+
enumerable: false,
|
|
432
|
+
configurable: true
|
|
433
|
+
});
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region methods & getters / rename origin
|
|
436
|
+
/**
|
|
437
|
+
* TODO does this make any sense
|
|
438
|
+
*/
|
|
439
|
+
BaseGit.prototype.renameOrigin = function (newNameOrUlr) {
|
|
440
|
+
//#region @backendFunc
|
|
441
|
+
if (!newNameOrUlr.endsWith('.git')) {
|
|
442
|
+
newNameOrUlr = newNameOrUlr + '.git';
|
|
443
|
+
}
|
|
444
|
+
var oldOrigin = this.project.git.originURL;
|
|
445
|
+
if (!newNameOrUlr.startsWith('git@') &&
|
|
446
|
+
!newNameOrUlr.startsWith('https://')) {
|
|
447
|
+
newNameOrUlr = oldOrigin.replace(tnp_core_2.path.basename(oldOrigin), newNameOrUlr);
|
|
448
|
+
}
|
|
449
|
+
try {
|
|
450
|
+
this.project.run("git remote rm origin").sync();
|
|
451
|
+
}
|
|
452
|
+
catch (error) { }
|
|
453
|
+
try {
|
|
454
|
+
this.project.run("git remote add origin ".concat(newNameOrUlr)).sync();
|
|
455
|
+
index_1.Helpers.info("Origin changed:\n from: ".concat(oldOrigin, "\n to: ").concat(newNameOrUlr, "\n"));
|
|
456
|
+
}
|
|
457
|
+
catch (e) {
|
|
458
|
+
index_1.Helpers.error("Not able to change origin.. reverting to old", true, true);
|
|
459
|
+
this.project.run("git remote add origin ".concat(oldOrigin)).sync();
|
|
460
|
+
}
|
|
461
|
+
//#endregion
|
|
462
|
+
};
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region getters & methods / translate git commit from args
|
|
465
|
+
/**
|
|
466
|
+
* By default no translation of commit
|
|
467
|
+
*/
|
|
468
|
+
BaseGit.prototype.transalteGitCommitFromArgs = function () {
|
|
469
|
+
return { from: void 0, to: void 0 };
|
|
470
|
+
};
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region getters & methods / us git branches when commiting and pushing
|
|
473
|
+
/**
|
|
474
|
+
* By defult true.. when commit branches will not function.
|
|
475
|
+
* (false is better for simple projects)
|
|
476
|
+
*/
|
|
477
|
+
BaseGit.prototype.useGitBranchesWhenCommitingAndPushing = function () {
|
|
478
|
+
return true;
|
|
479
|
+
};
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region getters & methods / automatically add all changes when pushing to git
|
|
482
|
+
/**
|
|
483
|
+
* usefull when pushing in project with childrens as git repos
|
|
484
|
+
*/
|
|
485
|
+
BaseGit.prototype.automaticallyAddAllChnagesWhenPushingToGit = function () {
|
|
486
|
+
return false;
|
|
487
|
+
};
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region getters & methods / use git branches as metadata for commits
|
|
490
|
+
/**
|
|
491
|
+
* usefull when pushing in project with childrens as git repos
|
|
492
|
+
*/
|
|
493
|
+
BaseGit.prototype.useGitBranchesAsMetadataForCommits = function () {
|
|
494
|
+
return true;
|
|
495
|
+
};
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region getters & methods / clone to
|
|
498
|
+
BaseGit.prototype.cloneTo = function (cwd, newProjectName) {
|
|
499
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
500
|
+
var dest, res;
|
|
501
|
+
return tslib_1.__generator(this, function (_a) {
|
|
502
|
+
switch (_a.label) {
|
|
503
|
+
case 0:
|
|
504
|
+
//#region @backendFunc
|
|
505
|
+
if (!newProjectName) {
|
|
506
|
+
newProjectName = tnp_core_2.path.basename(this.project.location);
|
|
507
|
+
}
|
|
508
|
+
dest = (0, tnp_core_2.crossPlatformPath)([newProjectName, newProjectName]);
|
|
509
|
+
if (!tnp_core_1.fse.existsSync(dest)) return [3 /*break*/, 2];
|
|
510
|
+
return [4 /*yield*/, index_1.Helpers.questionYesNo("Folder ".concat(newProjectName, " alredy exist, delete it ?"))];
|
|
511
|
+
case 1:
|
|
512
|
+
res = _a.sent();
|
|
513
|
+
if (res) {
|
|
514
|
+
index_1.Helpers.tryRemoveDir(dest);
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
index_1.Helpers.pressKeyAndContinue('Operation not completed... press any key');
|
|
518
|
+
return [2 /*return*/, false];
|
|
519
|
+
}
|
|
520
|
+
_a.label = 2;
|
|
521
|
+
case 2:
|
|
522
|
+
index_1.Helpers.info("Cloning ".concat(this.project.name, "..."));
|
|
523
|
+
// @LAST copy instead cloning
|
|
524
|
+
index_1.Helpers.git.clone({
|
|
525
|
+
cwd: cwd,
|
|
526
|
+
url: this.project.git.remoteOriginUrl,
|
|
527
|
+
destinationFolderName: newProjectName,
|
|
528
|
+
});
|
|
529
|
+
index_1.Helpers.info("Clone success");
|
|
530
|
+
return [2 /*return*/, true];
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
};
|
|
535
|
+
//#endregion
|
|
536
|
+
//#region methods & getters / push process
|
|
537
|
+
BaseGit.prototype.pullProcess = function (cloneChildren) {
|
|
538
|
+
if (cloneChildren === void 0) { cloneChildren = false; }
|
|
539
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
540
|
+
var uncommitedChanges, location, childrenRepos, childrenRepos_1, childrenRepos_1_1, child, e_1_1;
|
|
541
|
+
var e_1, _a;
|
|
542
|
+
return tslib_1.__generator(this, function (_b) {
|
|
543
|
+
switch (_b.label) {
|
|
544
|
+
case 0:
|
|
545
|
+
//#region @backendFunc
|
|
546
|
+
return [4 /*yield*/, this._beforePullProcessAction(cloneChildren)];
|
|
547
|
+
case 1:
|
|
548
|
+
//#region @backendFunc
|
|
549
|
+
_b.sent();
|
|
550
|
+
uncommitedChanges = this.project.git.thereAreSomeUncommitedChange;
|
|
551
|
+
if (uncommitedChanges) {
|
|
552
|
+
index_1.Helpers.warn("Stashing uncommit changes... in ".concat(this.project.genericName));
|
|
553
|
+
try {
|
|
554
|
+
this.project.git.stageAllFiles();
|
|
555
|
+
}
|
|
556
|
+
catch (error) { }
|
|
557
|
+
try {
|
|
558
|
+
this.project.git.stash();
|
|
559
|
+
}
|
|
560
|
+
catch (error) { }
|
|
561
|
+
}
|
|
562
|
+
return [4 /*yield*/, this.project.git.pullCurrentBranch({ askToRetry: true })];
|
|
563
|
+
case 2:
|
|
564
|
+
_b.sent();
|
|
565
|
+
location = this.project.location;
|
|
566
|
+
this.project.ins.unload(this);
|
|
567
|
+
this.project.ins.add(this.project.ins.From(location));
|
|
568
|
+
return [4 /*yield*/, this.project.linkedProjects.saveLocationToDB()];
|
|
569
|
+
case 3:
|
|
570
|
+
_b.sent();
|
|
571
|
+
if (!(this.automaticallyAddAllChnagesWhenPushingToGit() || cloneChildren)) return [3 /*break*/, 11];
|
|
572
|
+
childrenRepos = this.project.children.filter(function (f) { return f.git.isInsideGitRepo && f.git.isGitRoot; });
|
|
573
|
+
_b.label = 4;
|
|
574
|
+
case 4:
|
|
575
|
+
_b.trys.push([4, 9, 10, 11]);
|
|
576
|
+
childrenRepos_1 = tslib_1.__values(childrenRepos), childrenRepos_1_1 = childrenRepos_1.next();
|
|
577
|
+
_b.label = 5;
|
|
578
|
+
case 5:
|
|
579
|
+
if (!!childrenRepos_1_1.done) return [3 /*break*/, 8];
|
|
580
|
+
child = childrenRepos_1_1.value;
|
|
581
|
+
return [4 /*yield*/, child.git.pullProcess()];
|
|
582
|
+
case 6:
|
|
583
|
+
_b.sent();
|
|
584
|
+
_b.label = 7;
|
|
585
|
+
case 7:
|
|
586
|
+
childrenRepos_1_1 = childrenRepos_1.next();
|
|
587
|
+
return [3 /*break*/, 5];
|
|
588
|
+
case 8: return [3 /*break*/, 11];
|
|
589
|
+
case 9:
|
|
590
|
+
e_1_1 = _b.sent();
|
|
591
|
+
e_1 = { error: e_1_1 };
|
|
592
|
+
return [3 /*break*/, 11];
|
|
593
|
+
case 10:
|
|
594
|
+
try {
|
|
595
|
+
if (childrenRepos_1_1 && !childrenRepos_1_1.done && (_a = childrenRepos_1.return)) _a.call(childrenRepos_1);
|
|
596
|
+
}
|
|
597
|
+
finally { if (e_1) throw e_1.error; }
|
|
598
|
+
return [7 /*endfinally*/];
|
|
599
|
+
case 11: return [4 /*yield*/, this.project.linkedProjects.saveAllLinkedProjectsToDB()];
|
|
600
|
+
case 12:
|
|
601
|
+
_b.sent();
|
|
602
|
+
return [2 /*return*/];
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
};
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region methods & getters / push process
|
|
609
|
+
BaseGit.prototype.pushProcess = function (options) {
|
|
610
|
+
var _a, _b;
|
|
611
|
+
if (options === void 0) { options = {}; }
|
|
612
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
613
|
+
var _c, force, typeofCommit, forcePushNoQuestion, _d, origin, exitCallBack, _e, args, commitMessageRequired, skipChildren, setOrigin, commitData, error_2, childrenRepos, childrenRepos_2, childrenRepos_2_1, child, e_2_1;
|
|
614
|
+
var e_2, _f;
|
|
615
|
+
var _this = this;
|
|
616
|
+
return tslib_1.__generator(this, function (_g) {
|
|
617
|
+
switch (_g.label) {
|
|
618
|
+
case 0:
|
|
619
|
+
_c = options.force, force = _c === void 0 ? false : _c, typeofCommit = options.typeofCommit, forcePushNoQuestion = options.forcePushNoQuestion, _d = options.origin, origin = _d === void 0 ? 'origin' : _d, exitCallBack = options.exitCallBack, _e = options.args, args = _e === void 0 ? [] : _e, commitMessageRequired = options.commitMessageRequired, skipChildren = options.skipChildren, setOrigin = options.setOrigin;
|
|
620
|
+
return [4 /*yield*/, this._beforePushProcessAction()];
|
|
621
|
+
case 1:
|
|
622
|
+
_g.sent();
|
|
623
|
+
if (setOrigin === 'ssh') {
|
|
624
|
+
index_1.Helpers.git.changeRemoteFromHttpsToSSh(this.project.location);
|
|
625
|
+
}
|
|
626
|
+
else if (setOrigin === 'http') {
|
|
627
|
+
index_1.Helpers.git.changeRemoveFromSshToHttps(this.project.location);
|
|
628
|
+
}
|
|
629
|
+
return [4 /*yield*/, this.project.linkedProjects.saveLocationToDB()];
|
|
630
|
+
case 2:
|
|
631
|
+
_g.sent();
|
|
632
|
+
return [4 /*yield*/, this._getCommitMessage(typeofCommit, args, commitMessageRequired)];
|
|
633
|
+
case 3:
|
|
634
|
+
commitData = _g.sent();
|
|
635
|
+
if (!this.automaticallyAddAllChnagesWhenPushingToGit()) {
|
|
636
|
+
if ((_a = commitData.commitMessage) === null || _a === void 0 ? void 0 : _a.split(':').map(function (p) { return p.trim(); }).every(function (p) { return p === _this.project.git.currentBranchName; })) {
|
|
637
|
+
// QUICK_FIX
|
|
638
|
+
index_1.Helpers.error("\n\n Please provide more specific commit message than branch name\n\n\n ", false, true);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
_g.label = 4;
|
|
642
|
+
case 4:
|
|
643
|
+
if (!true) return [3 /*break*/, 10];
|
|
644
|
+
_g.label = 5;
|
|
645
|
+
case 5:
|
|
646
|
+
_g.trys.push([5, 7, , 9]);
|
|
647
|
+
return [4 /*yield*/, this.project.lint()];
|
|
648
|
+
case 6:
|
|
649
|
+
_g.sent();
|
|
650
|
+
return [3 /*break*/, 10];
|
|
651
|
+
case 7:
|
|
652
|
+
error_2 = _g.sent();
|
|
653
|
+
index_1.Helpers.warn('Fix your code...');
|
|
654
|
+
return [4 /*yield*/, index_1.Helpers.consoleGui.question.yesNo('Try again lint before commit ?')];
|
|
655
|
+
case 8:
|
|
656
|
+
if (!(_g.sent())) {
|
|
657
|
+
return [3 /*break*/, 10];
|
|
658
|
+
}
|
|
659
|
+
return [3 /*break*/, 9];
|
|
660
|
+
case 9: return [3 /*break*/, 4];
|
|
661
|
+
case 10:
|
|
662
|
+
if (!!commitData.isActionCommit) return [3 /*break*/, 14];
|
|
663
|
+
index_1.Helpers.info("\n\n PROJECT: ".concat(this.project.genericName, "\n\n Current commit:\n - message to include {").concat(commitData.commitMessage, "}\n ").concat(this.useGitBranchesAsMetadataForCommits()
|
|
664
|
+
? "- branch to checkout ".concat(commitData.branchName)
|
|
665
|
+
: '- using current branch', "\n "));
|
|
666
|
+
if (!(this.project.git.lastCommitMessage() === commitData.commitMessage)) return [3 /*break*/, 12];
|
|
667
|
+
return [4 /*yield*/, index_1.Helpers.questionYesNo('Soft reset last commit with same message ?')];
|
|
668
|
+
case 11:
|
|
669
|
+
if (_g.sent()) {
|
|
670
|
+
this.project.git.resetSoftHEAD(1);
|
|
671
|
+
}
|
|
672
|
+
_g.label = 12;
|
|
673
|
+
case 12: return [4 /*yield*/, index_1.Helpers.questionYesNo('Commit and push this ?')];
|
|
674
|
+
case 13:
|
|
675
|
+
if (!(_g.sent())) {
|
|
676
|
+
exitCallBack();
|
|
677
|
+
}
|
|
678
|
+
_g.label = 14;
|
|
679
|
+
case 14:
|
|
680
|
+
if (this.automaticallyAddAllChnagesWhenPushingToGit()) {
|
|
681
|
+
// my project
|
|
682
|
+
this.project.git.stageAllFiles();
|
|
683
|
+
}
|
|
684
|
+
if (this.useGitBranchesAsMetadataForCommits()) {
|
|
685
|
+
index_1.Helpers.info('Checkingout branches (if needed)...');
|
|
686
|
+
if (((_b = this.project.git.currentBranchName) === null || _b === void 0 ? void 0 : _b.trim()) !== commitData.branchName) {
|
|
687
|
+
try {
|
|
688
|
+
this.project.git.checkout(commitData.branchName, {
|
|
689
|
+
createBranchIfNotExists: true,
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
catch (error) {
|
|
693
|
+
index_1.Helpers.error('Please modyfiy you commit message or delete branch,');
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
try {
|
|
698
|
+
this.project.git.commit(commitData.commitMessage);
|
|
699
|
+
}
|
|
700
|
+
catch (error) {
|
|
701
|
+
index_1.Helpers.warn("Not commiting anything... ");
|
|
702
|
+
}
|
|
703
|
+
return [4 /*yield*/, this.project.git.pushCurrentBranch({
|
|
704
|
+
force: force,
|
|
705
|
+
origin: origin,
|
|
706
|
+
forcePushNoQuestion: forcePushNoQuestion,
|
|
707
|
+
askToRetry: true,
|
|
708
|
+
})];
|
|
709
|
+
case 15:
|
|
710
|
+
_g.sent();
|
|
711
|
+
if (!(this.automaticallyAddAllChnagesWhenPushingToGit() && !skipChildren)) return [3 /*break*/, 23];
|
|
712
|
+
if (this.project.linkedProjects.getLinkedProjectsConfig().skipRecrusivePush) {
|
|
713
|
+
index_1.Helpers.warn("Skipping recrusive (children) push for ".concat(this.project.genericName));
|
|
714
|
+
return [2 /*return*/];
|
|
715
|
+
}
|
|
716
|
+
childrenRepos = this.project.children.filter(function (f) { return f.git.isInsideGitRepo && f.git.isGitRoot; });
|
|
717
|
+
_g.label = 16;
|
|
718
|
+
case 16:
|
|
719
|
+
_g.trys.push([16, 21, 22, 23]);
|
|
720
|
+
childrenRepos_2 = tslib_1.__values(childrenRepos), childrenRepos_2_1 = childrenRepos_2.next();
|
|
721
|
+
_g.label = 17;
|
|
722
|
+
case 17:
|
|
723
|
+
if (!!childrenRepos_2_1.done) return [3 /*break*/, 20];
|
|
724
|
+
child = childrenRepos_2_1.value;
|
|
725
|
+
return [4 /*yield*/, child.git.pushProcess(options)];
|
|
726
|
+
case 18:
|
|
727
|
+
_g.sent();
|
|
728
|
+
_g.label = 19;
|
|
729
|
+
case 19:
|
|
730
|
+
childrenRepos_2_1 = childrenRepos_2.next();
|
|
731
|
+
return [3 /*break*/, 17];
|
|
732
|
+
case 20: return [3 /*break*/, 23];
|
|
733
|
+
case 21:
|
|
734
|
+
e_2_1 = _g.sent();
|
|
735
|
+
e_2 = { error: e_2_1 };
|
|
736
|
+
return [3 /*break*/, 23];
|
|
737
|
+
case 22:
|
|
738
|
+
try {
|
|
739
|
+
if (childrenRepos_2_1 && !childrenRepos_2_1.done && (_f = childrenRepos_2.return)) _f.call(childrenRepos_2);
|
|
740
|
+
}
|
|
741
|
+
finally { if (e_2) throw e_2.error; }
|
|
742
|
+
return [7 /*endfinally*/];
|
|
743
|
+
case 23: return [4 /*yield*/, this.project.linkedProjects.saveAllLinkedProjectsToDB()];
|
|
744
|
+
case 24:
|
|
745
|
+
_g.sent();
|
|
746
|
+
return [2 /*return*/];
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
};
|
|
751
|
+
//#endregion
|
|
752
|
+
//#region methods & getters / before any action on git root
|
|
753
|
+
BaseGit.prototype._beforeAnyActionOnGitRoot = function () {
|
|
754
|
+
//#region @backendFunc
|
|
755
|
+
if (!this.project.git.isInsideGitRepo) {
|
|
756
|
+
index_1.Helpers.error("Project ".concat(tnp_core_1.chalk.bold(this.project.name), " is not a git repository\n locaiton: ").concat(this.project.location), false, true);
|
|
757
|
+
}
|
|
758
|
+
if (!this.project.git.isGitRoot) {
|
|
759
|
+
index_1.Helpers.error("Project ".concat(tnp_core_1.chalk.bold(this.project.name), " is not a git root\n locaiton: ").concat(this.project.location), false, true);
|
|
760
|
+
}
|
|
761
|
+
//#endregion
|
|
762
|
+
};
|
|
763
|
+
//#endregion
|
|
764
|
+
//#region methods & getters / before push action
|
|
765
|
+
BaseGit.prototype._beforePushProcessAction = function () {
|
|
766
|
+
var _a;
|
|
767
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
768
|
+
return tslib_1.__generator(this, function (_b) {
|
|
769
|
+
switch (_b.label) {
|
|
770
|
+
case 0:
|
|
771
|
+
//#region @backendFunc
|
|
772
|
+
this._beforeAnyActionOnGitRoot();
|
|
773
|
+
if (!(this.project.git.isInsideGitRepo &&
|
|
774
|
+
this.project.git.isGitRoot &&
|
|
775
|
+
!((_a = this.project.git.currentBranchName) === null || _a === void 0 ? void 0 : _a.trim()))) return [3 /*break*/, 2];
|
|
776
|
+
return [4 /*yield*/, index_1.Helpers.consoleGui.question.yesNo('Repository is empty...Commit "master" branch and commit all as "first commit" ?')];
|
|
777
|
+
case 1:
|
|
778
|
+
if (_b.sent()) {
|
|
779
|
+
this.project.git.checkout('master');
|
|
780
|
+
this.project.git.stageAllFiles();
|
|
781
|
+
this.project.git.commit('first commit ');
|
|
782
|
+
}
|
|
783
|
+
_b.label = 2;
|
|
784
|
+
case 2: return [4 /*yield*/, this.project.linkedProjects.cloneUnexistedLinkedProjects('push')];
|
|
785
|
+
case 3:
|
|
786
|
+
_b.sent();
|
|
787
|
+
return [2 /*return*/];
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
});
|
|
791
|
+
};
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region methods & getters / before push action
|
|
794
|
+
BaseGit.prototype._beforePullProcessAction = function (cloneChildren) {
|
|
795
|
+
if (cloneChildren === void 0) { cloneChildren = false; }
|
|
796
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
797
|
+
return tslib_1.__generator(this, function (_a) {
|
|
798
|
+
switch (_a.label) {
|
|
799
|
+
case 0:
|
|
800
|
+
//#region @backendFunc
|
|
801
|
+
this._beforeAnyActionOnGitRoot();
|
|
802
|
+
return [4 /*yield*/, this.project.linkedProjects.cloneUnexistedLinkedProjects('pull', cloneChildren)];
|
|
803
|
+
case 1:
|
|
804
|
+
_a.sent();
|
|
805
|
+
return [2 /*return*/];
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
//#endregion
|
|
811
|
+
//#region methods & getters / resovle commit message
|
|
812
|
+
BaseGit.prototype._getCommitMessage = function (typeofCommit, args, commitMessageRequired) {
|
|
813
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
814
|
+
var commitData, argsCommitData, commitDataBranch, argsCommitData, _a, from, to, _b, _c, _d;
|
|
815
|
+
return tslib_1.__generator(this, function (_e) {
|
|
816
|
+
switch (_e.label) {
|
|
817
|
+
case 0:
|
|
818
|
+
if (!this.useGitBranchesWhenCommitingAndPushing()) return [3 /*break*/, 5];
|
|
819
|
+
return [4 /*yield*/, index_1.CommitData.getFromArgs(args, typeofCommit)];
|
|
820
|
+
case 1:
|
|
821
|
+
argsCommitData = _e.sent();
|
|
822
|
+
if (!argsCommitData.message) return [3 /*break*/, 2];
|
|
823
|
+
commitData = argsCommitData;
|
|
824
|
+
return [3 /*break*/, 4];
|
|
825
|
+
case 2: return [4 /*yield*/, index_1.CommitData.getFromBranch(this.project.git.currentBranchName)];
|
|
826
|
+
case 3:
|
|
827
|
+
commitDataBranch = _e.sent();
|
|
828
|
+
commitData = commitDataBranch;
|
|
829
|
+
_e.label = 4;
|
|
830
|
+
case 4: return [3 /*break*/, 7];
|
|
831
|
+
case 5: return [4 /*yield*/, index_1.CommitData.getFromArgs(args, typeofCommit)];
|
|
832
|
+
case 6:
|
|
833
|
+
argsCommitData = _e.sent();
|
|
834
|
+
// console.log({ argsCommitData })
|
|
835
|
+
// console.log(argsCommitData)
|
|
836
|
+
if (!argsCommitData.message && commitMessageRequired) {
|
|
837
|
+
index_1.Helpers.error('Please provide message in argument', false, true);
|
|
838
|
+
}
|
|
839
|
+
if (!argsCommitData.message) {
|
|
840
|
+
argsCommitData.message = index_1.Helpers.git.ACTION_MSG_RESET_GIT_HARD_COMMIT;
|
|
841
|
+
}
|
|
842
|
+
commitData = argsCommitData;
|
|
843
|
+
_e.label = 7;
|
|
844
|
+
case 7:
|
|
845
|
+
if (!(commitData.message !== index_1.Helpers.git.ACTION_MSG_RESET_GIT_HARD_COMMIT)) return [3 /*break*/, 9];
|
|
846
|
+
_a = this.transalteGitCommitFromArgs(), from = _a.from, to = _a.to;
|
|
847
|
+
if (!(from && to)) return [3 /*break*/, 9];
|
|
848
|
+
_b = commitData;
|
|
849
|
+
_d = (_c = tnp_core_2._).kebabCase;
|
|
850
|
+
return [4 /*yield*/, (0, translate_1.translate)(commitData.message, { from: from, to: to })];
|
|
851
|
+
case 8:
|
|
852
|
+
_b.message = _d.apply(_c, [_e.sent()]);
|
|
853
|
+
_e.label = 9;
|
|
854
|
+
case 9: return [2 /*return*/, commitData];
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
});
|
|
858
|
+
};
|
|
859
|
+
return BaseGit;
|
|
860
|
+
}(base_feature_for_project_1.BaseFeatureForProject));
|
|
861
|
+
exports.BaseGit = BaseGit;
|
|
862
|
+
//# sourceMappingURL=base-git.js.map
|