tnp-helpers 13.0.38 → 13.1.1
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/app.d.ts +1 -1
- package/app.js +6 -6
- package/app.js.map +1 -1
- package/browser/README.md +24 -24
- package/browser/esm2020/lib/base-component.mjs +48 -48
- package/browser/esm2020/lib/base-formly-component.mjs +126 -126
- package/browser/esm2020/lib/condition-wait.mjs +53 -53
- package/browser/esm2020/lib/constants.mjs +6 -6
- package/browser/esm2020/lib/dual-component-ctrl.mjs +120 -120
- package/browser/esm2020/lib/helpers-array-obj.mjs +80 -80
- package/browser/esm2020/lib/helpers-environment.mjs +30 -30
- package/browser/esm2020/lib/helpers-numbers.mjs +5 -5
- package/browser/esm2020/lib/helpers-strings-regexes.mjs +48 -48
- package/browser/esm2020/lib/helpers-strings.mjs +258 -256
- package/browser/esm2020/lib/helpers.mjs +276 -276
- package/browser/esm2020/lib/index.mjs +14 -14
- package/browser/esm2020/lib/long-press.directive.mjs +112 -112
- package/browser/esm2020/lib/project.mjs +413 -413
- package/browser/esm2020/lib/resize-service.mjs +20 -20
- package/browser/esm2020/public-api.mjs +1 -1
- package/browser/esm2020/tnp-helpers.mjs +4 -4
- package/browser/fesm2015/tnp-helpers.mjs +1535 -1534
- package/browser/fesm2015/tnp-helpers.mjs.map +1 -1
- package/browser/fesm2020/tnp-helpers.mjs +1527 -1526
- package/browser/fesm2020/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base-component.d.ts +17 -17
- package/browser/lib/base-formly-component.d.ts +31 -31
- package/browser/lib/condition-wait.d.ts +8 -8
- package/browser/lib/constants.d.ts +6 -6
- package/browser/lib/dual-component-ctrl.d.ts +25 -25
- package/browser/lib/helpers-array-obj.d.ts +15 -15
- package/browser/lib/helpers-environment.d.ts +5 -5
- package/browser/lib/helpers-numbers.d.ts +3 -3
- package/browser/lib/helpers-strings-regexes.d.ts +28 -28
- package/browser/lib/helpers-strings.d.ts +50 -50
- package/browser/lib/helpers.d.ts +28 -28
- package/browser/lib/index.d.ts +9 -9
- package/browser/lib/long-press.directive.d.ts +25 -25
- package/browser/lib/project.d.ts +91 -91
- package/browser/lib/resize-service.d.ts +9 -9
- package/browser/public-api.d.ts +1 -1
- package/browser/tnp-helpers.d.ts +5 -5
- package/client/README.md +24 -24
- package/client/esm2020/lib/base-component.mjs +48 -48
- package/client/esm2020/lib/base-formly-component.mjs +126 -126
- package/client/esm2020/lib/condition-wait.mjs +53 -53
- package/client/esm2020/lib/constants.mjs +6 -6
- package/client/esm2020/lib/dual-component-ctrl.mjs +120 -120
- package/client/esm2020/lib/helpers-array-obj.mjs +80 -80
- package/client/esm2020/lib/helpers-environment.mjs +30 -30
- package/client/esm2020/lib/helpers-numbers.mjs +5 -5
- package/client/esm2020/lib/helpers-strings-regexes.mjs +48 -48
- package/client/esm2020/lib/helpers-strings.mjs +258 -256
- package/client/esm2020/lib/helpers.mjs +276 -276
- package/client/esm2020/lib/index.mjs +14 -14
- package/client/esm2020/lib/long-press.directive.mjs +112 -112
- package/client/esm2020/lib/project.mjs +413 -413
- package/client/esm2020/lib/resize-service.mjs +20 -20
- package/client/esm2020/public-api.mjs +1 -1
- package/client/esm2020/tnp-helpers.mjs +4 -4
- package/client/fesm2015/tnp-helpers.mjs +1535 -1534
- package/client/fesm2015/tnp-helpers.mjs.map +1 -1
- package/client/fesm2020/tnp-helpers.mjs +1527 -1526
- package/client/fesm2020/tnp-helpers.mjs.map +1 -1
- package/client/lib/base-component.d.ts +17 -17
- package/client/lib/base-formly-component.d.ts +31 -31
- package/client/lib/condition-wait.d.ts +8 -8
- package/client/lib/constants.d.ts +6 -6
- package/client/lib/dual-component-ctrl.d.ts +25 -25
- package/client/lib/helpers-array-obj.d.ts +15 -15
- package/client/lib/helpers-environment.d.ts +5 -5
- package/client/lib/helpers-numbers.d.ts +3 -3
- package/client/lib/helpers-strings-regexes.d.ts +28 -28
- package/client/lib/helpers-strings.d.ts +50 -50
- package/client/lib/helpers.d.ts +28 -28
- package/client/lib/index.d.ts +9 -9
- package/client/lib/long-press.directive.d.ts +25 -25
- package/client/lib/project.d.ts +91 -91
- package/client/lib/resize-service.d.ts +9 -9
- package/client/public-api.d.ts +1 -1
- package/client/tnp-helpers.d.ts +5 -5
- package/index.d.ts +1 -1
- package/index.js +5 -5
- package/index.js.map +1 -1
- package/lib/angular.helper.d.ts +22 -22
- package/lib/angular.helper.js +50 -50
- package/lib/angular.helper.js.map +1 -1
- package/lib/base-component.d.ts +1 -1
- package/lib/base-component.js +6 -6
- package/lib/base-component.js.map +1 -1
- package/lib/base-formly-component.d.ts +1 -1
- package/lib/base-formly-component.js +6 -6
- package/lib/base-formly-component.js.map +1 -1
- package/lib/condition-wait.d.ts +8 -8
- package/lib/condition-wait.js +94 -94
- package/lib/condition-wait.js.map +1 -1
- package/lib/constants.d.ts +6 -6
- package/lib/constants.js +10 -10
- package/lib/constants.js.map +1 -1
- package/lib/dual-component-ctrl.d.ts +1 -1
- package/lib/dual-component-ctrl.js +6 -6
- package/lib/dual-component-ctrl.js.map +1 -1
- package/lib/git-project.d.ts +44 -44
- package/lib/git-project.js +195 -191
- package/lib/git-project.js.map +1 -1
- package/lib/helpers-array-obj.d.ts +15 -15
- package/lib/helpers-array-obj.js +88 -88
- package/lib/helpers-array-obj.js.map +1 -1
- package/lib/helpers-cli-tool.backend.d.ts +45 -45
- package/lib/helpers-cli-tool.backend.js +293 -293
- package/lib/helpers-cli-tool.backend.js.map +1 -1
- package/lib/helpers-dependencies.backend.d.ts +11 -11
- package/lib/helpers-dependencies.backend.js +105 -105
- package/lib/helpers-dependencies.backend.js.map +1 -1
- package/lib/helpers-environment.d.ts +5 -5
- package/lib/helpers-environment.js +35 -35
- package/lib/helpers-environment.js.map +1 -1
- package/lib/helpers-file-folders.backend.d.ts +84 -73
- package/lib/helpers-file-folders.backend.js +736 -714
- package/lib/helpers-file-folders.backend.js.map +1 -1
- package/lib/helpers-git.backend.d.ts +35 -35
- package/lib/helpers-git.backend.js +545 -534
- package/lib/helpers-git.backend.js.map +1 -1
- package/lib/helpers-json5.backend.d.ts +16 -16
- package/lib/helpers-json5.backend.js +70 -70
- package/lib/helpers-json5.backend.js.map +1 -1
- package/lib/helpers-morphi-framework.backend.d.ts +4 -4
- package/lib/helpers-morphi-framework.backend.js +49 -49
- package/lib/helpers-morphi-framework.backend.js.map +1 -1
- package/lib/helpers-network.backend.d.ts +8 -8
- package/lib/helpers-network.backend.js +48 -48
- package/lib/helpers-network.backend.js.map +1 -1
- package/lib/helpers-npm.backend.d.ts +3 -3
- package/lib/helpers-npm.backend.js +17 -17
- package/lib/helpers-npm.backend.js.map +1 -1
- package/lib/helpers-numbers.d.ts +3 -3
- package/lib/helpers-numbers.js +11 -11
- package/lib/helpers-numbers.js.map +1 -1
- package/lib/helpers-path.backend.d.ts +7 -7
- package/lib/helpers-path.backend.js +36 -36
- package/lib/helpers-path.backend.js.map +1 -1
- package/lib/helpers-process.backend.d.ts +57 -51
- package/lib/helpers-process.backend.js +529 -523
- package/lib/helpers-process.backend.js.map +1 -1
- package/lib/helpers-strings-regexes.d.ts +28 -28
- package/lib/helpers-strings-regexes.js +60 -60
- package/lib/helpers-strings-regexes.js.map +1 -1
- package/lib/helpers-strings.d.ts +50 -50
- package/lib/helpers-strings.js +265 -263
- package/lib/helpers-strings.js.map +1 -1
- package/lib/helpers-system-terminal.backend.d.ts +5 -5
- package/lib/helpers-system-terminal.backend.js +53 -53
- package/lib/helpers-system-terminal.backend.js.map +1 -1
- package/lib/helpers.d.ts +67 -67
- package/lib/helpers.js +391 -391
- package/lib/helpers.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +19 -19
- package/lib/index.js.map +1 -1
- package/lib/long-press.directive.d.ts +22 -22
- package/lib/long-press.directive.js +141 -141
- package/lib/long-press.directive.js.map +1 -1
- package/lib/merge-helpers.backend.d.ts +23 -23
- package/lib/merge-helpers.backend.js +108 -108
- package/lib/merge-helpers.backend.js.map +1 -1
- package/lib/project.d.ts +94 -94
- package/lib/project.js +422 -422
- package/lib/project.js.map +1 -1
- package/lib/resize-service.d.ts +6 -6
- package/lib/resize-service.js +24 -24
- package/lib/resize-service.js.map +1 -1
- package/lib/ts-code/index.d.ts +1 -1
- package/lib/ts-code/index.js +7 -7
- package/lib/ts-code/index.js.map +1 -1
- package/lib/ts-code/ts-code-extractor.d.ts +14 -14
- package/lib/ts-code/ts-code-extractor.js +46 -46
- package/lib/ts-code/ts-code-extractor.js.map +1 -1
- package/lib/ts-code/ts-code-modifier.backend.d.ts +12 -12
- package/lib/ts-code/ts-code-modifier.backend.js +70 -70
- package/lib/ts-code/ts-code-modifier.backend.js.map +1 -1
- package/package.json +3 -3
- package/package.json_devDependencies.json +222 -222
- package/package.json_tnp.json5 +41 -41
- package/tmp-environment.json +13 -13
- package/websql/README.md +24 -24
- package/websql/esm2020/lib/base-component.mjs +48 -48
- package/websql/esm2020/lib/base-formly-component.mjs +126 -126
- package/websql/esm2020/lib/condition-wait.mjs +53 -53
- package/websql/esm2020/lib/constants.mjs +6 -6
- package/websql/esm2020/lib/dual-component-ctrl.mjs +120 -120
- package/websql/esm2020/lib/helpers-array-obj.mjs +80 -80
- package/websql/esm2020/lib/helpers-environment.mjs +30 -30
- package/websql/esm2020/lib/helpers-numbers.mjs +5 -5
- package/websql/esm2020/lib/helpers-strings-regexes.mjs +48 -48
- package/websql/esm2020/lib/helpers-strings.mjs +258 -256
- package/websql/esm2020/lib/helpers.mjs +276 -276
- package/websql/esm2020/lib/index.mjs +14 -14
- package/websql/esm2020/lib/long-press.directive.mjs +112 -112
- package/websql/esm2020/lib/project.mjs +413 -413
- package/websql/esm2020/lib/resize-service.mjs +20 -20
- package/websql/esm2020/public-api.mjs +1 -1
- package/websql/esm2020/tnp-helpers.mjs +4 -4
- package/websql/fesm2015/tnp-helpers.mjs +1535 -1534
- package/websql/fesm2015/tnp-helpers.mjs.map +1 -1
- package/websql/fesm2020/tnp-helpers.mjs +1527 -1526
- package/websql/fesm2020/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base-component.d.ts +17 -17
- package/websql/lib/base-formly-component.d.ts +31 -31
- package/websql/lib/condition-wait.d.ts +8 -8
- package/websql/lib/constants.d.ts +6 -6
- package/websql/lib/dual-component-ctrl.d.ts +25 -25
- package/websql/lib/helpers-array-obj.d.ts +15 -15
- package/websql/lib/helpers-environment.d.ts +5 -5
- package/websql/lib/helpers-numbers.d.ts +3 -3
- package/websql/lib/helpers-strings-regexes.d.ts +28 -28
- package/websql/lib/helpers-strings.d.ts +50 -50
- package/websql/lib/helpers.d.ts +28 -28
- package/websql/lib/index.d.ts +9 -9
- package/websql/lib/long-press.directive.d.ts +25 -25
- package/websql/lib/project.d.ts +91 -91
- package/websql/lib/resize-service.d.ts +9 -9
- package/websql/public-api.d.ts +1 -1
- package/websql/tnp-helpers.d.ts +5 -5
|
@@ -1,534 +1,545 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HelpersGit = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
//#region imports
|
|
6
|
-
var tnp_core_1 = require("tnp-core");
|
|
7
|
-
var tnp_cli_1 = require("tnp-cli");
|
|
8
|
-
var index_1 = require("./index");
|
|
9
|
-
var tnp_config_1 = require("tnp-config");
|
|
10
|
-
//#endregion
|
|
11
|
-
var HelpersGit = /** @class */ (function () {
|
|
12
|
-
function HelpersGit() {
|
|
13
|
-
}
|
|
14
|
-
//#region get last commit hash
|
|
15
|
-
HelpersGit.prototype.lastCommitHash = function (directoryPath) {
|
|
16
|
-
try {
|
|
17
|
-
var cwd = directoryPath;
|
|
18
|
-
var hash = tnp_core_1.child_process.execSync("git
|
|
19
|
-
return hash;
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
index_1.Helpers.log(e, 1);
|
|
23
|
-
index_1.Helpers.log("[lastCommitHash] Not able to get last commit hash for repository in ".concat(directoryPath), 1);
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region get penultimate commit hash
|
|
29
|
-
HelpersGit.prototype.penultimageCommitHash = function (directoryPath) {
|
|
30
|
-
try {
|
|
31
|
-
var cwd = directoryPath;
|
|
32
|
-
var hash = tnp_core_1.child_process.execSync("git
|
|
33
|
-
return hash;
|
|
34
|
-
}
|
|
35
|
-
catch (e) {
|
|
36
|
-
index_1.Helpers.log(e, 1);
|
|
37
|
-
index_1.Helpers.log("[lastCommitHash] Not able to get last commit hash for repository in ".concat(directoryPath), 1);
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region check tag exists
|
|
43
|
-
HelpersGit.prototype.checkTagExists = function (tag, cwd) {
|
|
44
|
-
if (cwd === void 0) { cwd = process.cwd(); }
|
|
45
|
-
var command = "git show-ref --tags ".concat(tag).trim();
|
|
46
|
-
var result = (index_1.Helpers.commnadOutputAsString(command, cwd) || '') !== '';
|
|
47
|
-
return result;
|
|
48
|
-
};
|
|
49
|
-
//#endregion
|
|
50
|
-
HelpersGit.prototype.lastTagVersionName = function (directoryPath) {
|
|
51
|
-
try {
|
|
52
|
-
var cwd = directoryPath;
|
|
53
|
-
var command = "git describe --tags $(git rev-list --tags --max-count=1)";
|
|
54
|
-
if (process.platform === 'win32') {
|
|
55
|
-
command = 'git describe --tags --abbrev=0';
|
|
56
|
-
}
|
|
57
|
-
var tag = index_1.Helpers.commnadOutputAsString(command, cwd);
|
|
58
|
-
if (!tag) {
|
|
59
|
-
return void 0;
|
|
60
|
-
}
|
|
61
|
-
return tag;
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
index_1.Helpers.warn("[lastCommitHash] Not able to get last commit version name for repository in ".concat(directoryPath), false);
|
|
65
|
-
return void 0;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
//#region get last tag hash
|
|
69
|
-
HelpersGit.prototype.lastTagHash = function (directoryPath) {
|
|
70
|
-
try {
|
|
71
|
-
var cwd = directoryPath;
|
|
72
|
-
var command = "git describe --tags $(git rev-list --tags --max-count=1)";
|
|
73
|
-
if (process.platform === 'win32') {
|
|
74
|
-
command = 'git describe --tags --abbrev=0';
|
|
75
|
-
}
|
|
76
|
-
var tag = index_1.Helpers.commnadOutputAsString(command, cwd);
|
|
77
|
-
if (!tag) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
var hash = tnp_core_1.child_process.execSync("git log -1 --format=format:\"%H\" ".concat(tag), { cwd: cwd }).toString().trim();
|
|
81
|
-
return hash;
|
|
82
|
-
}
|
|
83
|
-
catch (e) {
|
|
84
|
-
index_1.Helpers.log(e, 1);
|
|
85
|
-
index_1.Helpers.log("[lastCommitHash] Not able to get last commit hash for repository in ".concat(directoryPath), 1);
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region get last commit date
|
|
91
|
-
HelpersGit.prototype.lastCommitDate = function (
|
|
92
|
-
try {
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
try {
|
|
189
|
-
index_1.Helpers.run("git
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
index_1.Helpers.warn("Failed to git
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
index_1.Helpers.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
//#
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
var cwd =
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
452
|
-
var
|
|
453
|
-
?
|
|
454
|
-
:
|
|
455
|
-
|
|
456
|
-
if (
|
|
457
|
-
index_1.Helpers.
|
|
458
|
-
}
|
|
459
|
-
else {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
//#region
|
|
517
|
-
HelpersGit.prototype.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HelpersGit = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
//#region imports
|
|
6
|
+
var tnp_core_1 = require("tnp-core");
|
|
7
|
+
var tnp_cli_1 = require("tnp-cli");
|
|
8
|
+
var index_1 = require("./index");
|
|
9
|
+
var tnp_config_1 = require("tnp-config");
|
|
10
|
+
//#endregion
|
|
11
|
+
var HelpersGit = /** @class */ (function () {
|
|
12
|
+
function HelpersGit() {
|
|
13
|
+
}
|
|
14
|
+
//#region get last commit hash
|
|
15
|
+
HelpersGit.prototype.lastCommitHash = function (directoryPath) {
|
|
16
|
+
try {
|
|
17
|
+
var cwd = directoryPath;
|
|
18
|
+
var hash = this.isGitRepo(cwd) && tnp_core_1.child_process.execSync("git log -1 --format=\"%H\"", { cwd: cwd }).toString().trim();
|
|
19
|
+
return hash;
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
index_1.Helpers.log(e, 1);
|
|
23
|
+
index_1.Helpers.log("[lastCommitHash] Not able to get last commit hash for repository in ".concat(directoryPath), 1);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region get penultimate commit hash
|
|
29
|
+
HelpersGit.prototype.penultimageCommitHash = function (directoryPath) {
|
|
30
|
+
try {
|
|
31
|
+
var cwd = directoryPath;
|
|
32
|
+
var hash = this.isGitRepo(cwd) && tnp_core_1.child_process.execSync("git log -2 --format=\"%H\"", { cwd: cwd }).toString().trim();
|
|
33
|
+
return hash;
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
index_1.Helpers.log(e, 1);
|
|
37
|
+
index_1.Helpers.log("[lastCommitHash] Not able to get last commit hash for repository in ".concat(directoryPath), 1);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region check tag exists
|
|
43
|
+
HelpersGit.prototype.checkTagExists = function (tag, cwd) {
|
|
44
|
+
if (cwd === void 0) { cwd = process.cwd(); }
|
|
45
|
+
var command = "git show-ref --tags ".concat(tag).trim();
|
|
46
|
+
var result = (index_1.Helpers.commnadOutputAsString(command, cwd) || '') !== '';
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
HelpersGit.prototype.lastTagVersionName = function (directoryPath) {
|
|
51
|
+
try {
|
|
52
|
+
var cwd = directoryPath;
|
|
53
|
+
var command = "git describe --tags $(git rev-list --tags --max-count=1)";
|
|
54
|
+
if (process.platform === 'win32') {
|
|
55
|
+
command = 'git describe --tags --abbrev=0';
|
|
56
|
+
}
|
|
57
|
+
var tag = index_1.Helpers.commnadOutputAsString(command, cwd);
|
|
58
|
+
if (!tag) {
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
return tag;
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
index_1.Helpers.warn("[lastCommitHash] Not able to get last commit version name for repository in ".concat(directoryPath), false);
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
//#region get last tag hash
|
|
69
|
+
HelpersGit.prototype.lastTagHash = function (directoryPath) {
|
|
70
|
+
try {
|
|
71
|
+
var cwd = directoryPath;
|
|
72
|
+
var command = "git describe --tags $(git rev-list --tags --max-count=1)";
|
|
73
|
+
if (process.platform === 'win32') {
|
|
74
|
+
command = 'git describe --tags --abbrev=0';
|
|
75
|
+
}
|
|
76
|
+
var tag = index_1.Helpers.commnadOutputAsString(command, cwd);
|
|
77
|
+
if (!tag) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
var hash = tnp_core_1.child_process.execSync("git log -1 --format=format:\"%H\" ".concat(tag), { cwd: cwd }).toString().trim();
|
|
81
|
+
return hash;
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
index_1.Helpers.log(e, 1);
|
|
85
|
+
index_1.Helpers.log("[lastCommitHash] Not able to get last commit hash for repository in ".concat(directoryPath), 1);
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region get last commit date
|
|
91
|
+
HelpersGit.prototype.lastCommitDate = function (cwd) {
|
|
92
|
+
try {
|
|
93
|
+
var unixTimestamp = this.isGitRepo(cwd)
|
|
94
|
+
&& tnp_core_1.child_process
|
|
95
|
+
.execSync("git log -1 --pretty=format:%ct", { cwd: cwd })
|
|
96
|
+
.toString()
|
|
97
|
+
.trim();
|
|
98
|
+
return new Date(Number(unixTimestamp) * 1000);
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
index_1.Helpers.log(e, 1);
|
|
102
|
+
index_1.Helpers.log("[lastCommitDate] Cannot counts commits in branch in: ".concat(cwd), 1);
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region get last commit date
|
|
108
|
+
HelpersGit.prototype.lastCommitMessage = function (directoryPath) {
|
|
109
|
+
try {
|
|
110
|
+
var cwd = directoryPath;
|
|
111
|
+
var unixTimestamp = tnp_core_1.child_process.execSync("git log -1 --pretty=%B", { cwd: cwd }).toString().trim();
|
|
112
|
+
return unixTimestamp;
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
index_1.Helpers.log(e, 1);
|
|
116
|
+
index_1.Helpers.log("[lastCommitMessage] Cannot display last commit message in branch in: ".concat(directoryPath), 1);
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region get number of commit in repository
|
|
122
|
+
HelpersGit.prototype.countCommits = function (cwd) {
|
|
123
|
+
try {
|
|
124
|
+
// git rev-parse HEAD &> /dev/null check if any commits
|
|
125
|
+
var currentLocalBranch = this.currentBranchName(cwd);
|
|
126
|
+
var value = this.isGitRepo(cwd) && tnp_core_1.child_process
|
|
127
|
+
.execSync("git rev-list --count ".concat(currentLocalBranch), { cwd: cwd })
|
|
128
|
+
.toString()
|
|
129
|
+
.trim();
|
|
130
|
+
return Number(value);
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
index_1.Helpers.log(e, 1);
|
|
134
|
+
index_1.Helpers.log("[countCommits] Cannot counts commits in branch in: ".concat(cwd), 1);
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region get branches names
|
|
140
|
+
HelpersGit.prototype.getBranchesNames = function (cwd, pattern) {
|
|
141
|
+
try {
|
|
142
|
+
var branchPattern_1 = pattern;
|
|
143
|
+
if (tnp_core_1._.isString(pattern)) {
|
|
144
|
+
branchPattern_1 = new RegExp(pattern.replace(/[^a-zA-Z0-9]+/g, '.*'));
|
|
145
|
+
}
|
|
146
|
+
var command = "git branch -a";
|
|
147
|
+
// console.log({ command, cwd })
|
|
148
|
+
var branchNames = index_1.Helpers.commnadOutputAsString(command, cwd, true, true);
|
|
149
|
+
// console.log({ branchNames })
|
|
150
|
+
var _branchNames = branchNames
|
|
151
|
+
.toString()
|
|
152
|
+
.trim()
|
|
153
|
+
.split('\n')
|
|
154
|
+
.map(function (l) { return l.replace('*', '').trim(); })
|
|
155
|
+
.filter(function (l) {
|
|
156
|
+
// console.log('testing: ' + l)
|
|
157
|
+
if (tnp_core_1._.isRegExp(branchPattern_1)) {
|
|
158
|
+
var match = branchPattern_1.test(l);
|
|
159
|
+
return match;
|
|
160
|
+
}
|
|
161
|
+
// if (_.isString(pattern)) {
|
|
162
|
+
// return l.search(pattern)
|
|
163
|
+
// }
|
|
164
|
+
return true;
|
|
165
|
+
});
|
|
166
|
+
return _branchNames;
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
index_1.Helpers.log(e);
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region get current branch name
|
|
175
|
+
HelpersGit.prototype.currentBranchName = function (cwd) {
|
|
176
|
+
try {
|
|
177
|
+
var branchName = tnp_core_1.child_process.execSync("git branch | sed -n '/* /s///p'", { cwd: cwd }).toString().trim();
|
|
178
|
+
return branchName;
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
index_1.Helpers.error(e);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region commit "what is"
|
|
186
|
+
HelpersGit.prototype.commitWhatIs = function (customMessage) {
|
|
187
|
+
if (customMessage === void 0) { customMessage = 'changes'; }
|
|
188
|
+
try {
|
|
189
|
+
index_1.Helpers.run("git add --all . ").sync();
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
index_1.Helpers.warn("Failed to git add --all .");
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
index_1.Helpers.run("git commit -m \"".concat(customMessage, "\"")).sync();
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
index_1.Helpers.warn("Failed to git commit -m \"".concat(customMessage, "\""));
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region commit
|
|
203
|
+
HelpersGit.prototype.commit = function (cwd, ProjectClass, args) {
|
|
204
|
+
if (!tnp_core_1._.isString(args)) {
|
|
205
|
+
args = 'update';
|
|
206
|
+
}
|
|
207
|
+
var gitRootProject = ProjectClass.nearestTo(cwd, { findGitRoot: true });
|
|
208
|
+
try {
|
|
209
|
+
index_1.Helpers.info("[git][commit] Adding current git changes in git root:\n ".concat(gitRootProject.location, "\n "));
|
|
210
|
+
gitRootProject.run("git add --all . ").sync();
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
index_1.Helpers.log(error);
|
|
214
|
+
index_1.Helpers.warn("Failed to 'git add --all .' in:\n ".concat(gitRootProject.location));
|
|
215
|
+
}
|
|
216
|
+
if (args.search('-m') === -1 && args.search('-msg') === -1) {
|
|
217
|
+
var addBrackets = !((args.startsWith('\'') ||
|
|
218
|
+
args.startsWith('"')) &&
|
|
219
|
+
(args.endsWith('\'') ||
|
|
220
|
+
args.endsWith('"')));
|
|
221
|
+
args = "-m ".concat(addBrackets ? "\"".concat(args, "\"") : args);
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
index_1.Helpers.info("[git][commit] trying to commit what it with argument:\n \"".concat(args, "\"\n location: ").concat(cwd, "\n "));
|
|
225
|
+
var cmdddd = "git commit --no-verify ".concat(args);
|
|
226
|
+
index_1.Helpers.run(cmdddd, { cwd: cwd }).sync();
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
index_1.Helpers.log(error);
|
|
230
|
+
index_1.Helpers.warn("[git][commit] not able to commit what is with command: ".concat(cmdddd));
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region get remote origin
|
|
235
|
+
HelpersGit.prototype.getOriginURL = function (cwd, differentOriginName) {
|
|
236
|
+
if (differentOriginName === void 0) { differentOriginName = ''; }
|
|
237
|
+
var url = '';
|
|
238
|
+
try {
|
|
239
|
+
// git config --get remote.origin.url
|
|
240
|
+
url = index_1.Helpers.run("git config --get remote.".concat(differentOriginName ? differentOriginName : 'origin', ".url"), { output: false, cwd: cwd }).sync().toString().trim();
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
return '< not able to get origin >';
|
|
244
|
+
}
|
|
245
|
+
return url;
|
|
246
|
+
};
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region is git root
|
|
249
|
+
HelpersGit.prototype.isGitRoot = function (cwd) {
|
|
250
|
+
return this.isGitRepo(cwd) && tnp_core_1.fse.existsSync(tnp_core_1.path.join(cwd, '.git'));
|
|
251
|
+
};
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region is git repo
|
|
254
|
+
HelpersGit.prototype.isGitRepo = function (cwd) {
|
|
255
|
+
// if(this.isGitRoot(cwd)) {
|
|
256
|
+
// return true;
|
|
257
|
+
// }
|
|
258
|
+
try {
|
|
259
|
+
var test = index_1.Helpers.run('git rev-parse --is-inside-work-tree', {
|
|
260
|
+
biggerBuffer: false,
|
|
261
|
+
cwd: cwd,
|
|
262
|
+
output: false
|
|
263
|
+
}).sync();
|
|
264
|
+
}
|
|
265
|
+
catch (e) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
return !!test;
|
|
269
|
+
};
|
|
270
|
+
//#endregion
|
|
271
|
+
HelpersGit.prototype.pull = function (branchName, cwd) {
|
|
272
|
+
if (branchName === void 0) { branchName = 'master'; }
|
|
273
|
+
if (cwd === void 0) { cwd = (0, tnp_core_1.crossPlatformPath)(process.cwd()); }
|
|
274
|
+
tnp_core_1.child_process.execSync("git pull --tags --rebase origin ".concat(branchName), { cwd: cwd });
|
|
275
|
+
};
|
|
276
|
+
//#region pull current branch
|
|
277
|
+
HelpersGit.prototype.pullBranch = function (branchName, directoryPath, askToRetry) {
|
|
278
|
+
if (askToRetry === void 0) { askToRetry = false; }
|
|
279
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
280
|
+
var cwd, e_1;
|
|
281
|
+
var _this = this;
|
|
282
|
+
return tslib_1.__generator(this, function (_a) {
|
|
283
|
+
switch (_a.label) {
|
|
284
|
+
case 0:
|
|
285
|
+
if (this.getOriginURL(directoryPath) === '') {
|
|
286
|
+
index_1.Helpers.warn("Not pulling branch without "
|
|
287
|
+
+ "remote origin url.... in folder ".concat(tnp_core_1.path.basename(directoryPath)));
|
|
288
|
+
return [2 /*return*/];
|
|
289
|
+
}
|
|
290
|
+
index_1.Helpers.info("Pulling git changes in \"".concat(directoryPath, "\" , origin=").concat(index_1.Helpers.git.getOriginURL(directoryPath), " "));
|
|
291
|
+
_a.label = 1;
|
|
292
|
+
case 1:
|
|
293
|
+
_a.trys.push([1, 2, , 5]);
|
|
294
|
+
cwd = directoryPath;
|
|
295
|
+
index_1.Helpers.git.pull(branchName, cwd);
|
|
296
|
+
index_1.Helpers.info("Branch \"".concat(branchName, "\" updated successfully in ").concat(tnp_core_1.path.basename(directoryPath)));
|
|
297
|
+
return [3 /*break*/, 5];
|
|
298
|
+
case 2:
|
|
299
|
+
e_1 = _a.sent();
|
|
300
|
+
// console.log(e)
|
|
301
|
+
index_1.Helpers.error("Cannot update current branch in: ".concat(directoryPath), askToRetry, true);
|
|
302
|
+
if (!askToRetry) return [3 /*break*/, 4];
|
|
303
|
+
return [4 /*yield*/, index_1.Helpers.questionYesNo("Do you wanna try again ?", function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
304
|
+
return tslib_1.__generator(this, function (_a) {
|
|
305
|
+
switch (_a.label) {
|
|
306
|
+
case 0: return [4 /*yield*/, index_1.Helpers.git.pullCurrentBranch(directoryPath, askToRetry)];
|
|
307
|
+
case 1:
|
|
308
|
+
_a.sent();
|
|
309
|
+
return [2 /*return*/];
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}); }, function () {
|
|
313
|
+
process.exit(0);
|
|
314
|
+
})];
|
|
315
|
+
case 3:
|
|
316
|
+
_a.sent();
|
|
317
|
+
_a.label = 4;
|
|
318
|
+
case 4: return [3 /*break*/, 5];
|
|
319
|
+
case 5: return [2 /*return*/];
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region pull current branch
|
|
326
|
+
HelpersGit.prototype.pullCurrentBranch = function (directoryPath, askToRetry) {
|
|
327
|
+
if (askToRetry === void 0) { askToRetry = true; }
|
|
328
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
329
|
+
var cwd, currentLocalBranch, e_2;
|
|
330
|
+
var _this = this;
|
|
331
|
+
return tslib_1.__generator(this, function (_a) {
|
|
332
|
+
switch (_a.label) {
|
|
333
|
+
case 0:
|
|
334
|
+
if (global['tnpNonInteractive']) {
|
|
335
|
+
askToRetry = false;
|
|
336
|
+
}
|
|
337
|
+
index_1.Helpers.log("askToRetry: ".concat(askToRetry));
|
|
338
|
+
if (this.getOriginURL(directoryPath) === '') {
|
|
339
|
+
index_1.Helpers.warn("Not pulling branch without "
|
|
340
|
+
+ "remote origin url.... in folder ".concat(tnp_core_1.path.basename(directoryPath)));
|
|
341
|
+
return [2 /*return*/];
|
|
342
|
+
}
|
|
343
|
+
index_1.Helpers.info("Pulling git changes in \"".concat(directoryPath, "\", origin=").concat(index_1.Helpers.git.getOriginURL(directoryPath), " "));
|
|
344
|
+
_a.label = 1;
|
|
345
|
+
case 1:
|
|
346
|
+
_a.trys.push([1, 2, , 5]);
|
|
347
|
+
cwd = directoryPath;
|
|
348
|
+
currentLocalBranch = tnp_core_1.child_process.execSync("git branch | sed -n '/* /s///p'", { cwd: cwd }).toString().trim();
|
|
349
|
+
index_1.Helpers.git.pull(currentLocalBranch, cwd);
|
|
350
|
+
index_1.Helpers.info("Branch \"".concat(currentLocalBranch, "\" updated successfully in ").concat(tnp_core_1.path.basename(directoryPath)));
|
|
351
|
+
return [3 /*break*/, 5];
|
|
352
|
+
case 2:
|
|
353
|
+
e_2 = _a.sent();
|
|
354
|
+
console.log(e_2);
|
|
355
|
+
index_1.Helpers.error("Cannot update current branch in: ".concat(directoryPath), askToRetry, true);
|
|
356
|
+
if (!askToRetry) return [3 /*break*/, 4];
|
|
357
|
+
return [4 /*yield*/, index_1.Helpers.questionYesNo("Do you wanna try again ?", function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
358
|
+
return tslib_1.__generator(this, function (_a) {
|
|
359
|
+
switch (_a.label) {
|
|
360
|
+
case 0: return [4 /*yield*/, index_1.Helpers.git.pullCurrentBranch(directoryPath, askToRetry)];
|
|
361
|
+
case 1:
|
|
362
|
+
_a.sent();
|
|
363
|
+
return [2 /*return*/];
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}); }, function () {
|
|
367
|
+
process.exit(1);
|
|
368
|
+
})];
|
|
369
|
+
case 3:
|
|
370
|
+
_a.sent();
|
|
371
|
+
_a.label = 4;
|
|
372
|
+
case 4: return [3 /*break*/, 5];
|
|
373
|
+
case 5:
|
|
374
|
+
index_1.Helpers.info("DONE PULLING");
|
|
375
|
+
return [2 /*return*/];
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
};
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region push current branch
|
|
382
|
+
HelpersGit.prototype.pushCurrentBranch = function (cwd, force, origin) {
|
|
383
|
+
if (force === void 0) { force = false; }
|
|
384
|
+
if (origin === void 0) { origin = 'origin'; }
|
|
385
|
+
var currentBranchName = index_1.Helpers.git.currentBranchName(cwd);
|
|
386
|
+
var taskName = "\n Pushing current branch (remote=".concat(origin, "): ").concat(currentBranchName, "\n ");
|
|
387
|
+
index_1.Helpers.info(taskName);
|
|
388
|
+
while (true) {
|
|
389
|
+
try {
|
|
390
|
+
var command = "git push ".concat(force ? '-f' : '', " ").concat(origin, " ").concat(currentBranchName, " --tags");
|
|
391
|
+
index_1.Helpers.info("[git][push] ".concat(force ? 'force' : '', " pushing current branch ").concat(currentBranchName, " ,")
|
|
392
|
+
+ " origin=".concat(index_1.Helpers.git.getOriginURL(cwd, origin)));
|
|
393
|
+
index_1.Helpers.run(command, { cwd: cwd }).sync();
|
|
394
|
+
index_1.Helpers.info(taskName);
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
catch (err) {
|
|
398
|
+
index_1.Helpers.error("[tnp-helpers] Not able to push branch ".concat(currentBranchName, " in (origin=").concat(origin, "):\n ").concat(cwd), true, true);
|
|
399
|
+
index_1.Helpers.pressKeyAndContinue("Press any key to try again: ");
|
|
400
|
+
// TODO issue 1: issue with press any key
|
|
401
|
+
// TODO issue 2: Updates were rejected because the tag already exists in the remote
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region get default branch for repo
|
|
408
|
+
HelpersGit.prototype.defaultRepoBranch = function (cwd) {
|
|
409
|
+
try {
|
|
410
|
+
var defaultBranch = tnp_core_1.child_process
|
|
411
|
+
.execSync("git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'", { cwd: cwd })
|
|
412
|
+
.toString().trim();
|
|
413
|
+
return defaultBranch;
|
|
414
|
+
}
|
|
415
|
+
catch (e) {
|
|
416
|
+
index_1.Helpers.log(e);
|
|
417
|
+
index_1.Helpers.error("Cannot find default branch for repo in : ".concat(cwd));
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region checkout default branch
|
|
422
|
+
HelpersGit.prototype.checkoutDefaultBranch = function (directoryPath) {
|
|
423
|
+
var cwd = directoryPath;
|
|
424
|
+
var defaultBranch = tnp_core_1.child_process
|
|
425
|
+
.execSync("git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'", { cwd: cwd })
|
|
426
|
+
.toString().trim();
|
|
427
|
+
tnp_core_1.child_process.execSync("git checkout ".concat(defaultBranch), { cwd: cwd });
|
|
428
|
+
};
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region clone
|
|
431
|
+
HelpersGit.prototype.clone = function (_a) {
|
|
432
|
+
// const ALWAYS_HTTPS = true;
|
|
433
|
+
var _b, _c;
|
|
434
|
+
var cwd = _a.cwd, url = _a.url, _d = _a.destinationFolderName, destinationFolderName = _d === void 0 ? '' : _d, throwErrors = _a.throwErrors, override = _a.override;
|
|
435
|
+
if (url.split(' ').length > 2) {
|
|
436
|
+
// const [rUrl, rDest] = url.split(' ');
|
|
437
|
+
index_1.Helpers.error("[tnp-helpers]incorrect clone url \"".concat(url, "\""));
|
|
438
|
+
}
|
|
439
|
+
if (url.split(' ').length === 2) {
|
|
440
|
+
var _e = tslib_1.__read(url.split(' '), 2), rUrl = _e[0], rDest = _e[1];
|
|
441
|
+
if (destinationFolderName) {
|
|
442
|
+
index_1.Helpers.error("[tnp-helpers] wrong cloning argument\n\n url = \"".concat(url, "\"\n destinationFolderName = \"").concat(destinationFolderName, "\"\n\n cant use both at the same time\n "));
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
destinationFolderName = rDest;
|
|
446
|
+
url = rUrl;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (!url.endsWith('.git')) {
|
|
450
|
+
url = (url + '.git');
|
|
451
|
+
}
|
|
452
|
+
var cloneFolderPath = tnp_core_1.path.join(cwd, (!!destinationFolderName && destinationFolderName.trim() !== '')
|
|
453
|
+
? destinationFolderName
|
|
454
|
+
: tnp_core_1.path.basename(url)).trim().replace('.git', '');
|
|
455
|
+
// console.log({ cloneFolderPath })
|
|
456
|
+
if (override) {
|
|
457
|
+
index_1.Helpers.remove(cloneFolderPath);
|
|
458
|
+
}
|
|
459
|
+
else if (index_1.Helpers.exists(cloneFolderPath) && index_1.Helpers.exists(tnp_core_1.path.join(cloneFolderPath, '.git'))) {
|
|
460
|
+
index_1.Helpers.warn("Alread cloned ".concat(tnp_core_1.path.basename(cloneFolderPath), "..."));
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
var commnad = url.startsWith("https://")
|
|
464
|
+
? "git -c http.sslVerify=false clone ".concat(url, " ").concat(tnp_core_1.path.basename(cloneFolderPath))
|
|
465
|
+
: "git clone ".concat(url, " ").concat(tnp_core_1.path.basename(cloneFolderPath));
|
|
466
|
+
index_1.Helpers.info("\n\n Cloning:\n ".concat(commnad, "\n\n "));
|
|
467
|
+
if (throwErrors) {
|
|
468
|
+
index_1.Helpers.run(commnad, { cwd: cwd }).sync();
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
try {
|
|
472
|
+
index_1.Helpers.run(commnad, { cwd: cwd, output: false }).sync();
|
|
473
|
+
}
|
|
474
|
+
catch (error) {
|
|
475
|
+
if (((_c = (_b = error === null || error === void 0 ? void 0 : error.stderr) === null || _b === void 0 ? void 0 : _b.toString()) === null || _c === void 0 ? void 0 : _c.search('remote: Not Found')) !== -1) {
|
|
476
|
+
index_1.Helpers.warn("[tnp-helpers][git] Project not found :".concat(url));
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
index_1.Helpers.error("Can't clone from url: ".concat(tnp_cli_1.CLI.chalk.bold(url), ".."), false, true);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
var packageJson = tnp_core_1.path.join(cloneFolderPath, tnp_config_1.config.file.package_json);
|
|
484
|
+
// Helpers.info(packageJson)
|
|
485
|
+
if (!index_1.Helpers.exists(packageJson)) {
|
|
486
|
+
index_1.Helpers.info("Recreating unexited package.json for project ".concat(tnp_core_1.path.basename(cloneFolderPath), ".."));
|
|
487
|
+
try {
|
|
488
|
+
index_1.Helpers.run("npm init -y", { cwd: cloneFolderPath, output: false }).sync();
|
|
489
|
+
}
|
|
490
|
+
catch (error) { }
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region check if there are some uncommited changes
|
|
495
|
+
HelpersGit.prototype.checkIfthereAreSomeUncommitedChange = function (cwd) {
|
|
496
|
+
return index_1.Helpers.git.thereAreSomeUncommitedChangeExcept([], cwd);
|
|
497
|
+
};
|
|
498
|
+
//#endregion
|
|
499
|
+
HelpersGit.prototype.thereAreSomeUncommitedChangeExcept = function (filesList, cwd) {
|
|
500
|
+
if (filesList === void 0) { filesList = []; }
|
|
501
|
+
filesList = filesList.map(function (f) { return (0, tnp_core_1.crossPlatformPath)(f); });
|
|
502
|
+
try {
|
|
503
|
+
var res = index_1.Helpers.run("git ls-files --deleted --modified --others --exclude-standard", { output: false, cwd: cwd }).sync().toString().trim();
|
|
504
|
+
var list = !res ? [] : res
|
|
505
|
+
.split(/\r\n|\n|\r/)
|
|
506
|
+
.filter(function (f) {
|
|
507
|
+
f = f === null || f === void 0 ? void 0 : f.trim();
|
|
508
|
+
return !!f && !filesList.includes((0, tnp_core_1.crossPlatformPath)(f));
|
|
509
|
+
});
|
|
510
|
+
return list.length > 0;
|
|
511
|
+
}
|
|
512
|
+
catch (error) {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
//#region restore last version
|
|
517
|
+
HelpersGit.prototype.restoreLastVersion = function (cwd, localFilePath) {
|
|
518
|
+
try {
|
|
519
|
+
index_1.Helpers.info("[git] restoring last verion of file ".concat(tnp_core_1.path.basename(cwd), "/").concat(localFilePath));
|
|
520
|
+
index_1.Helpers.run("git checkout -- ".concat(localFilePath), { cwd: cwd }).sync();
|
|
521
|
+
}
|
|
522
|
+
catch (error) {
|
|
523
|
+
index_1.Helpers.warn("[tnp-git] Not able to resotre last version of file ".concat(localFilePath));
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region reset files
|
|
528
|
+
HelpersGit.prototype.resetFiles = function (cwd) {
|
|
529
|
+
var relativePathes = [];
|
|
530
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
531
|
+
relativePathes[_i - 1] = arguments[_i];
|
|
532
|
+
}
|
|
533
|
+
relativePathes.forEach(function (p) {
|
|
534
|
+
try {
|
|
535
|
+
index_1.Helpers.run("git checkout HEAD -- ".concat(p), { cwd: cwd }).sync();
|
|
536
|
+
}
|
|
537
|
+
catch (err) {
|
|
538
|
+
index_1.Helpers.error("[project.git] Not able to reset files: ".concat(p, " inside project ").concat(tnp_core_1.path.basename(cwd), "."), true, true);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
return HelpersGit;
|
|
543
|
+
}());
|
|
544
|
+
exports.HelpersGit = HelpersGit;
|
|
545
|
+
//# sourceMappingURL=C:/Users/darek/projects/npm/tnp-helpers/tmp-bundle-release/bundle/project/tnp-helpers/bundle-nocutsrc/lib/helpers-git.backend.js.map
|