tnp-helpers 16.5.15 → 16.5.18

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.
Files changed (130) hide show
  1. package/assets/shared/shared_folder_info.txt +1 -1
  2. package/browser/esm2022/lib/base/base-feature-for-project.mjs +8 -0
  3. package/browser/esm2022/lib/base/base-project-resolver.mjs +204 -0
  4. package/browser/esm2022/lib/base/base-project.mjs +1007 -0
  5. package/browser/esm2022/lib/base/commit-data.mjs +145 -0
  6. package/browser/esm2022/lib/base/index.mjs +11 -0
  7. package/browser/esm2022/lib/base/translate.mjs +42 -0
  8. package/browser/esm2022/lib/helpers.mjs +6 -3
  9. package/browser/esm2022/lib/index.mjs +2 -3
  10. package/browser/esm2022/lib/models.mjs +1 -1
  11. package/browser/fesm2022/tnp-helpers.mjs +860 -84
  12. package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
  13. package/browser/lib/base/base-feature-for-project.d.ts +6 -0
  14. package/{client/lib → browser/lib/base}/base-project-resolver.d.ts +4 -7
  15. package/browser/lib/base/base-project.d.ts +287 -0
  16. package/browser/lib/base/commit-data.d.ts +31 -0
  17. package/browser/lib/base/index.d.ts +5 -0
  18. package/browser/lib/base/translate.d.ts +2 -0
  19. package/browser/lib/index.d.ts +2 -3
  20. package/browser/lib/models.d.ts +1 -1
  21. package/client/esm2022/lib/base/base-feature-for-project.mjs +8 -0
  22. package/client/esm2022/lib/base/base-project-resolver.mjs +204 -0
  23. package/client/esm2022/lib/base/base-project.mjs +1007 -0
  24. package/client/esm2022/lib/base/commit-data.mjs +145 -0
  25. package/client/esm2022/lib/base/index.mjs +11 -0
  26. package/client/esm2022/lib/base/translate.mjs +42 -0
  27. package/client/esm2022/lib/helpers.mjs +6 -3
  28. package/client/esm2022/lib/index.mjs +2 -3
  29. package/client/esm2022/lib/models.mjs +1 -1
  30. package/client/fesm2022/tnp-helpers.mjs +860 -84
  31. package/client/fesm2022/tnp-helpers.mjs.map +1 -1
  32. package/client/lib/base/base-feature-for-project.d.ts +6 -0
  33. package/{browser/lib → client/lib/base}/base-project-resolver.d.ts +4 -7
  34. package/client/lib/base/base-project.d.ts +287 -0
  35. package/client/lib/base/commit-data.d.ts +31 -0
  36. package/client/lib/base/index.d.ts +5 -0
  37. package/client/lib/base/translate.d.ts +2 -0
  38. package/client/lib/index.d.ts +2 -3
  39. package/client/lib/models.d.ts +1 -1
  40. package/client/package.json +37 -34
  41. package/lib/base/base-command-line.backend.d.ts +79 -0
  42. package/lib/base/base-command-line.backend.js +674 -0
  43. package/lib/base/base-command-line.backend.js.map +1 -0
  44. package/lib/base/base-feature-for-project.d.ts +5 -0
  45. package/lib/base/base-feature-for-project.js +11 -0
  46. package/lib/base/base-feature-for-project.js.map +1 -0
  47. package/lib/{base-project-resolver.d.ts → base/base-project-resolver.d.ts} +4 -7
  48. package/lib/{base-project-resolver.js → base/base-project-resolver.js} +33 -28
  49. package/lib/base/base-project-resolver.js.map +1 -0
  50. package/lib/base/base-project.d.ts +297 -0
  51. package/lib/base/base-project.js +1451 -0
  52. package/lib/base/base-project.js.map +1 -0
  53. package/lib/base/base-start-config.backend.d.ts +35 -0
  54. package/lib/base/base-start-config.backend.js +126 -0
  55. package/lib/base/base-start-config.backend.js.map +1 -0
  56. package/lib/base/command-line-feature.backend.d.ts +32 -0
  57. package/lib/base/command-line-feature.backend.js +89 -0
  58. package/lib/base/command-line-feature.backend.js.map +1 -0
  59. package/lib/base/commit-data.d.ts +30 -0
  60. package/lib/base/commit-data.js +200 -0
  61. package/lib/base/commit-data.js.map +1 -0
  62. package/lib/base/index.d.ts +7 -0
  63. package/lib/base/index.js +13 -0
  64. package/lib/base/index.js.map +1 -0
  65. package/lib/base/translate.d.ts +1 -0
  66. package/lib/base/translate.js +80 -0
  67. package/lib/base/translate.js.map +1 -0
  68. package/lib/for-backend/helpers-cli-tool.backend.d.ts +42 -22
  69. package/lib/for-backend/helpers-cli-tool.backend.js +129 -180
  70. package/lib/for-backend/helpers-cli-tool.backend.js.map +1 -1
  71. package/lib/for-backend/helpers-file-folders.backend.d.ts +2 -8
  72. package/lib/for-backend/helpers-file-folders.backend.js +4 -14
  73. package/lib/for-backend/helpers-file-folders.backend.js.map +1 -1
  74. package/lib/for-backend/helpers-git.backend.d.ts +48 -12
  75. package/lib/for-backend/helpers-git.backend.js +227 -142
  76. package/lib/for-backend/helpers-git.backend.js.map +1 -1
  77. package/lib/for-backend/helpers-process.backend.d.ts +5 -11
  78. package/lib/for-backend/helpers-process.backend.js +77 -39
  79. package/lib/for-backend/helpers-process.backend.js.map +1 -1
  80. package/lib/for-backend/helpers-vscode.backend.d.ts +3 -3
  81. package/lib/for-backend/helpers-vscode.backend.js.map +1 -1
  82. package/lib/for-browser/angular.helper.js +3 -3
  83. package/lib/helpers.d.ts +2 -3
  84. package/lib/helpers.js +5 -2
  85. package/lib/helpers.js.map +1 -1
  86. package/lib/index.d.ts +2 -3
  87. package/lib/index.js +1 -2
  88. package/lib/index.js.map +1 -1
  89. package/lib/models.d.ts +1 -1
  90. package/lib/old/base-component.js +3 -3
  91. package/lib/old/base-formly-component.js +3 -3
  92. package/lib/old/dual-component-ctrl.js +3 -3
  93. package/package.json +8 -5
  94. package/package.json_tnp.json5 +4 -1
  95. package/tmp-environment.json +41 -45
  96. package/websql/esm2022/lib/base/base-feature-for-project.mjs +8 -0
  97. package/websql/esm2022/lib/base/base-project-resolver.mjs +203 -0
  98. package/websql/esm2022/lib/base/base-project.mjs +994 -0
  99. package/websql/esm2022/lib/base/commit-data.mjs +145 -0
  100. package/websql/esm2022/lib/base/index.mjs +11 -0
  101. package/websql/esm2022/lib/base/translate.mjs +42 -0
  102. package/websql/esm2022/lib/helpers.mjs +6 -3
  103. package/websql/esm2022/lib/index.mjs +2 -3
  104. package/websql/esm2022/lib/models.mjs +1 -1
  105. package/websql/fesm2022/tnp-helpers.mjs +861 -85
  106. package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
  107. package/websql/lib/base/base-feature-for-project.d.ts +6 -0
  108. package/websql/lib/{base-project-resolver.d.ts → base/base-project-resolver.d.ts} +4 -7
  109. package/websql/lib/base/base-project.d.ts +287 -0
  110. package/websql/lib/base/commit-data.d.ts +31 -0
  111. package/websql/lib/base/index.d.ts +5 -0
  112. package/websql/lib/base/translate.d.ts +2 -0
  113. package/websql/lib/index.d.ts +2 -3
  114. package/websql/lib/models.d.ts +1 -1
  115. package/browser/esm2022/lib/base-project-resolver.mjs +0 -223
  116. package/browser/esm2022/lib/base-project.mjs +0 -374
  117. package/browser/lib/base-project.d.ts +0 -94
  118. package/client/esm2022/lib/base-project-resolver.mjs +0 -223
  119. package/client/esm2022/lib/base-project.mjs +0 -374
  120. package/client/lib/base-project.d.ts +0 -94
  121. package/lib/base-project-resolver.js.map +0 -1
  122. package/lib/base-project.d.ts +0 -103
  123. package/lib/base-project.js +0 -482
  124. package/lib/base-project.js.map +0 -1
  125. package/lib/git-project.d.ts +0 -57
  126. package/lib/git-project.js +0 -224
  127. package/lib/git-project.js.map +0 -1
  128. package/websql/esm2022/lib/base-project-resolver.mjs +0 -222
  129. package/websql/esm2022/lib/base-project.mjs +0 -361
  130. package/websql/lib/base-project.d.ts +0 -94
@@ -0,0 +1,1451 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseProject = exports.ChildProcess = void 0;
4
+ var tslib_1 = require("tslib");
5
+ //#region @backend
6
+ var tnp_core_1 = require("tnp-core");
7
+ var child_process_1 = require("child_process");
8
+ Object.defineProperty(exports, "ChildProcess", { enumerable: true, get: function () { return child_process_1.ChildProcess; } });
9
+ //#endregion
10
+ var tnp_cli_1 = require("tnp-cli");
11
+ var tnp_core_2 = require("tnp-core");
12
+ var tnp_config_1 = require("tnp-config");
13
+ var tnp_core_3 = require("tnp-core");
14
+ var index_1 = require("../index");
15
+ var base_project_resolver_1 = require("./base-project-resolver");
16
+ var translate_1 = require("./translate");
17
+ //#endregion
18
+ var takenPorts = [];
19
+ var BaseProject = exports.BaseProject = /** @class */ (function () {
20
+ //#endregion
21
+ //#region constructor
22
+ // @ts-ignore
23
+ function BaseProject(
24
+ /**
25
+ * doesn't need to be real path -> can be link
26
+ */
27
+ location) {
28
+ var _this = this;
29
+ this.location = location;
30
+ //#endregion
31
+ //#endregion
32
+ //#region fields
33
+ this.cache = {};
34
+ this.type = 'unknow';
35
+ //#endregion
36
+ //#region getters & methods / to string
37
+ this.toString = function () {
38
+ return "".concat(_this.name, "=>").concat(_this.location);
39
+ };
40
+ }
41
+ //#endregion
42
+ //#region static / sort group of projects
43
+ BaseProject.sortGroupOfProject = function (projects, resoveDepsArray, projNameToCompare) {
44
+ var visited = {};
45
+ var stack = {};
46
+ var result = [];
47
+ var visit = function (project) {
48
+ if (stack[projNameToCompare(project)]) {
49
+ // Circular dependency detected
50
+ index_1.Helpers.error("Circular dependency detected involving project: ".concat(projNameToCompare(project)));
51
+ }
52
+ if (!visited[projNameToCompare(project)]) {
53
+ visited[projNameToCompare(project)] = true;
54
+ stack[projNameToCompare(project)] = true;
55
+ var depsResolved = resoveDepsArray(project);
56
+ depsResolved.forEach(function (dependency) {
57
+ var dependentProject = projects.find(function (p) {
58
+ // console.log(`comparing :"${projNameToCompare(p)}" and "${dependency}"`)
59
+ return projNameToCompare(p) === dependency;
60
+ });
61
+ if (dependentProject) {
62
+ visit(dependentProject);
63
+ }
64
+ });
65
+ stack[projNameToCompare(project)] = false;
66
+ result.push(project);
67
+ }
68
+ };
69
+ projects.forEach(function (project) { return visit(project); });
70
+ return result;
71
+ // return result.reverse(); // Reverse the result to get the correct order
72
+ };
73
+ //#endregion
74
+ //#region methods & getters
75
+ //#region methods & getters / set type
76
+ BaseProject.prototype.setType = function (type) {
77
+ // @ts-ignore
78
+ this.type = type;
79
+ };
80
+ //#endregion
81
+ //#region methods & getters / type is
82
+ BaseProject.prototype.typeIs = function () {
83
+ var types = [];
84
+ for (var _i = 0; _i < arguments.length; _i++) {
85
+ types[_i] = arguments[_i];
86
+ }
87
+ return this.type && types.includes(this.type);
88
+ };
89
+ //#endregion
90
+ //#region methods & getters / type is not
91
+ BaseProject.prototype.typeIsNot = function () {
92
+ var types = [];
93
+ for (var _i = 0; _i < arguments.length; _i++) {
94
+ types[_i] = arguments[_i];
95
+ }
96
+ return !this.typeIs.apply(this, tslib_1.__spreadArray([], tslib_1.__read(types), false));
97
+ };
98
+ Object.defineProperty(BaseProject.prototype, "basename", {
99
+ //#endregion
100
+ //#region methods & getters / basename
101
+ /**
102
+ * project folder basename
103
+ */
104
+ get: function () {
105
+ //#region @websqlFunc
106
+ return tnp_core_2.path.basename(this.location);
107
+ //#endregion
108
+ },
109
+ enumerable: false,
110
+ configurable: true
111
+ });
112
+ Object.defineProperty(BaseProject.prototype, "name", {
113
+ //#endregion
114
+ //#region methods & getters / name
115
+ /**
116
+ * name from package.json
117
+ */
118
+ get: function () {
119
+ var _a;
120
+ return (_a = this.packageJSON) === null || _a === void 0 ? void 0 : _a.name;
121
+ },
122
+ enumerable: false,
123
+ configurable: true
124
+ });
125
+ Object.defineProperty(BaseProject.prototype, "version", {
126
+ //#endregion
127
+ //#region methods & getters / version
128
+ /**
129
+ * version from package.json -> property version
130
+ */
131
+ get: function () {
132
+ var _a;
133
+ return (_a = this.packageJSON) === null || _a === void 0 ? void 0 : _a.version;
134
+ },
135
+ enumerable: false,
136
+ configurable: true
137
+ });
138
+ Object.defineProperty(BaseProject.prototype, "majorVersion", {
139
+ //#endregion
140
+ //#region methods & getters / major version
141
+ /**
142
+ * Major Version from package.json
143
+ */
144
+ // @ts-ignore
145
+ get: function () {
146
+ //#region @backendFunc
147
+ return Number(tnp_core_3._.first((this.version || '').split('.')));
148
+ //#endregion
149
+ },
150
+ enumerable: false,
151
+ configurable: true
152
+ });
153
+ Object.defineProperty(BaseProject.prototype, "minorVersion", {
154
+ //#endregion
155
+ //#region methods & getters / minor version
156
+ /**
157
+ * Minor Version from package.json
158
+ */
159
+ // @ts-ignore
160
+ get: function () {
161
+ var _a;
162
+ //#region @backendFunc
163
+ var __ = (_a = tslib_1.__read(((this.version || '').split('.') || [void 0, void 0]), 2), _a[0]), minor = _a[1];
164
+ return Number(minor);
165
+ //#endregion
166
+ },
167
+ enumerable: false,
168
+ configurable: true
169
+ });
170
+ Object.defineProperty(BaseProject.prototype, "versionPathAsNumber", {
171
+ //#endregion
172
+ //#region methods & getters / get version path as number
173
+ get: function () {
174
+ //#region @backendFunc
175
+ var ver = this.version.split('.');
176
+ var res = Number(tnp_core_3._.last(ver));
177
+ return isNaN(res) ? 0 : res;
178
+ //#endregion
179
+ },
180
+ enumerable: false,
181
+ configurable: true
182
+ });
183
+ Object.defineProperty(BaseProject.prototype, "dependencies", {
184
+ //#endregion
185
+ //#region methods & getters / dependencies
186
+ /**
187
+ * npm dependencies from package.json
188
+ */
189
+ get: function () {
190
+ return (this.packageJSON ? this.packageJSON.dependencies : {}) || {};
191
+ },
192
+ enumerable: false,
193
+ configurable: true
194
+ });
195
+ Object.defineProperty(BaseProject.prototype, "peerDependencies", {
196
+ //#endregion
197
+ //#region methods & getters / peer dependencies
198
+ /**
199
+ * peerDependencies dependencies
200
+ */
201
+ get: function () {
202
+ return (this.packageJSON ? this.packageJSON.peerDependencies : {}) || {};
203
+ },
204
+ enumerable: false,
205
+ configurable: true
206
+ });
207
+ Object.defineProperty(BaseProject.prototype, "devDependencies", {
208
+ //#endregion
209
+ //#region methods & getters / dev dependencies
210
+ /**
211
+ * devDependencies dependencies
212
+ */
213
+ get: function () {
214
+ return (this.packageJSON ? this.packageJSON.devDependencies : {}) || {};
215
+ },
216
+ enumerable: false,
217
+ configurable: true
218
+ });
219
+ Object.defineProperty(BaseProject.prototype, "resolutions", {
220
+ //#endregion
221
+ //#region methods & getters / resolutions dependencies
222
+ /**
223
+ * resolutions dependencies
224
+ */
225
+ get: function () {
226
+ return (this.packageJSON ? this.packageJSON['resolutions'] : {}) || {};
227
+ },
228
+ enumerable: false,
229
+ configurable: true
230
+ });
231
+ Object.defineProperty(BaseProject.prototype, "allDependencies", {
232
+ //#endregion
233
+ //#region methods & getters / all dependencies
234
+ /**
235
+ * object with all deps from package json
236
+ */
237
+ get: function () {
238
+ return tnp_core_3._.merge(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, this.devDependencies), this.peerDependencies), this.dependencies), this.resolutions));
239
+ },
240
+ enumerable: false,
241
+ configurable: true
242
+ });
243
+ //#endregion
244
+ //#region methods & getters / get folder for possible project chhildrens
245
+ BaseProject.prototype.getFoldersForPossibleProjectChildren = function () {
246
+ //#region @backendFunc
247
+ var isDirectory = function (source) { return tnp_core_1.fse.lstatSync(source).isDirectory(); };
248
+ var getDirectories = function (source) {
249
+ return tnp_core_1.fse.readdirSync(source).map(function (name) { return tnp_core_2.path.join(source, name); }).filter(isDirectory);
250
+ };
251
+ var subdirectories = getDirectories(this.location)
252
+ .filter(function (f) {
253
+ var folderName = tnp_core_2.path.basename(f);
254
+ return index_1.Helpers.checkIfNameAllowedForFiredevProj(folderName);
255
+ });
256
+ // if (this.isTnp' && fse.existsSync(path.join(this.location, '../firedev-projects'))) {
257
+ // subdirectories = subdirectories.concat(getDirectories(path.join(this.location, '../firedev-projects'))
258
+ // .filter(f => {
259
+ // const folderName = path.basename(f);
260
+ // return Helpers.checkIfNameAllowedForFiredevProj(folderName);
261
+ // }))
262
+ // }'
263
+ return subdirectories;
264
+ //#endregion
265
+ };
266
+ //#endregion
267
+ //#region methods * getters / get all childrens
268
+ BaseProject.prototype.getAllChildren = function () {
269
+ var _this = this;
270
+ //#region @backendFunc
271
+ var subdirectories = this.getFoldersForPossibleProjectChildren();
272
+ var res = subdirectories
273
+ .map(function (dir) {
274
+ // console.log('child:', dir)
275
+ return _this.ins.From(dir);
276
+ })
277
+ .filter(function (c) { return !!c; });
278
+ return res;
279
+ //#endregion
280
+ };
281
+ Object.defineProperty(BaseProject.prototype, "children", {
282
+ //#endregion
283
+ //#region methods & getters / children
284
+ /**
285
+ * alias to getAllChildren
286
+ */
287
+ get: function () {
288
+ //#region @websqlFunc
289
+ return this.getAllChildren();
290
+ //#endregion
291
+ },
292
+ enumerable: false,
293
+ configurable: true
294
+ });
295
+ //#endregion
296
+ //#region methods & getters / get child
297
+ BaseProject.prototype.getChildBy = function (nameOrBasename, errors) {
298
+ if (errors === void 0) { errors = true; }
299
+ //#region @websqlFunc
300
+ var c = this.children.find(function (c) { return c.name === nameOrBasename || c.basename === nameOrBasename; });
301
+ if (errors && !c) {
302
+ index_1.Helpers.warn("Project doesnt contain child with name or basename: ".concat(nameOrBasename));
303
+ }
304
+ return c;
305
+ //#endregion
306
+ };
307
+ Object.defineProperty(BaseProject.prototype, "parent", {
308
+ //#endregion
309
+ //#region methods & getters / parent
310
+ get: function () {
311
+ //#region @websqlFunc
312
+ if (!tnp_core_3._.isString(this.location) || this.location.trim() === '') {
313
+ return void 0;
314
+ }
315
+ return this.ins.From(tnp_core_2.path.join(this.location, '..'));
316
+ //#endregion
317
+ },
318
+ enumerable: false,
319
+ configurable: true
320
+ });
321
+ Object.defineProperty(BaseProject.prototype, "grandpa", {
322
+ //#endregion
323
+ //#region methods & getters / grandpa
324
+ get: function () {
325
+ //#region @websqlFunc
326
+ if (!tnp_core_3._.isString(this.location) || this.location.trim() === '') {
327
+ return void 0;
328
+ }
329
+ var grandpa = this.ins.From(tnp_core_2.path.join(this.location, '..', '..'));
330
+ return grandpa;
331
+ //#endregion
332
+ },
333
+ enumerable: false,
334
+ configurable: true
335
+ });
336
+ Object.defineProperty(BaseProject.prototype, "genericName", {
337
+ //#endregion
338
+ //#region methods & getters / generic name
339
+ get: function () {
340
+ //#region @websqlFunc
341
+ var parent = this.parent;
342
+ return [
343
+ parent ? tnp_core_2.path.basename(tnp_core_2.path.dirname(parent.location)) : void 0,
344
+ parent ? parent.basename : tnp_core_2.path.basename(this.location),
345
+ this.basename,
346
+ //#region @backend
347
+ "(".concat(tnp_cli_1.CLI.chalk.bold(this.name), ")"),
348
+ //#endregion
349
+ ]
350
+ .filter(function (f) { return !!f; })
351
+ .join('/');
352
+ //#endregion
353
+ },
354
+ enumerable: false,
355
+ configurable: true
356
+ });
357
+ //#endregion
358
+ //#region methods & getters / path exits
359
+ /**
360
+ * same has project.hasFile();
361
+ */
362
+ BaseProject.prototype.pathExists = function (relativePath) {
363
+ return this.hasFile(relativePath);
364
+ };
365
+ //#endregion
366
+ //#region methods & getters / has file
367
+ /**
368
+ * same as project.pathExists();
369
+ */
370
+ BaseProject.prototype.hasFile = function (relativePath) {
371
+ return index_1.Helpers.exists(this.pathFor(relativePath));
372
+ };
373
+ //#endregion
374
+ //#region methods & getters / contains file
375
+ /**
376
+ * same as project.pathhasFileExists();
377
+ * but with path.resolve
378
+ */
379
+ BaseProject.prototype.containsFile = function (fileRelativeToProjectPath) {
380
+ var fullPath = tnp_core_2.path.resolve(tnp_core_2.path.join(this.location, fileRelativeToProjectPath));
381
+ return index_1.Helpers.exists(fullPath);
382
+ };
383
+ //#endregion
384
+ //#region methods & getters / path for
385
+ /**
386
+ * absolute path:
387
+ * concated project location with relative path
388
+ */
389
+ BaseProject.prototype.pathFor = function (relativePath) {
390
+ //#region @backendFunc
391
+ if (Array.isArray(relativePath)) {
392
+ relativePath = relativePath.join('/');
393
+ }
394
+ if (tnp_core_2.path.isAbsolute(relativePath)) {
395
+ index_1.Helpers.error("Cannot join relative path with absolute: ".concat(relativePath));
396
+ }
397
+ return (0, tnp_core_2.crossPlatformPath)(tnp_core_2.path.join(this.location, relativePath));
398
+ //#endregion
399
+ };
400
+ //#endregion
401
+ //#region methods & getters / write json
402
+ BaseProject.prototype.writeJson = function (relativePath, json) {
403
+ //#region @backendFunc
404
+ if (tnp_core_2.path.isAbsolute(relativePath)) {
405
+ index_1.Helpers.error("Cannot join relative path with absolute: ".concat(relativePath));
406
+ }
407
+ index_1.Helpers.writeJson((0, tnp_core_2.crossPlatformPath)([this.location, relativePath]), json);
408
+ //#endregion
409
+ };
410
+ //#endregion
411
+ //#region methods & getters / run
412
+ /**
413
+ * @deprecated us execute instead
414
+ * use output from or more preciese crafted api
415
+ */
416
+ BaseProject.prototype.run = function (command, options) {
417
+ //#region @backendFunc
418
+ options = tnp_core_3._.cloneDeep(options) || {};
419
+ index_1.Helpers.log("command: ".concat(command));
420
+ if (tnp_core_3._.isUndefined(options.showCommand)) {
421
+ options.showCommand = false;
422
+ }
423
+ var opt = options;
424
+ if (!opt.cwd) {
425
+ opt.cwd = this.location;
426
+ }
427
+ if (opt.showCommand) {
428
+ index_1.Helpers.info("[".concat(tnp_cli_1.CLI.chalk.underline('Executing shell command'), "] \"").concat(command, "\" in [").concat(opt.cwd, "]"));
429
+ }
430
+ else {
431
+ index_1.Helpers.log("[".concat(tnp_cli_1.CLI.chalk.underline('Executing shell command'), "] \"").concat(command, "\" in [").concat(opt.cwd, "]"));
432
+ }
433
+ return index_1.Helpers.run(command, opt);
434
+ //#endregion
435
+ };
436
+ //#endregion
437
+ //#region methods & getters / execute
438
+ /**
439
+ * same as run but async
440
+ */
441
+ BaseProject.prototype.execute = function (command, options) {
442
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
443
+ var cwd;
444
+ return tslib_1.__generator(this, function (_a) {
445
+ switch (_a.label) {
446
+ case 0:
447
+ //#region @backendFunc
448
+ if (tnp_core_3._.isUndefined(options.showCommand)) {
449
+ options.showCommand = false;
450
+ }
451
+ if (!options) {
452
+ options = {};
453
+ }
454
+ cwd = this.location;
455
+ if (options.showCommand) {
456
+ index_1.Helpers.logInfo("[".concat(tnp_cli_1.CLI.chalk.underline('Executing shell command'), "] \"").concat(command, "\" in [").concat(cwd, "]"));
457
+ }
458
+ else {
459
+ index_1.Helpers.log("[".concat(tnp_cli_1.CLI.chalk.underline('Executing shell command'), "] \"").concat(command, "\" in [").concat(cwd, "]"));
460
+ }
461
+ return [4 /*yield*/, index_1.Helpers.execute(command, cwd, options)];
462
+ case 1: return [2 /*return*/, _a.sent()];
463
+ }
464
+ });
465
+ });
466
+ };
467
+ //#endregion
468
+ //#region methods & getters / try run sync command
469
+ /**
470
+ * try run but continue when it fails
471
+ * @param command
472
+ * @param options
473
+ * @returns
474
+ */
475
+ BaseProject.prototype.tryRunSync = function (command
476
+ //#region @backend
477
+ , options
478
+ //#endregion
479
+ ) {
480
+ //#region @backendFunc
481
+ try {
482
+ this.run(command, options).sync();
483
+ }
484
+ catch (error) {
485
+ index_1.Helpers.warn("Not able to execute: ".concat(command));
486
+ }
487
+ //#endregion
488
+ };
489
+ //#endregion
490
+ //#region methods & getters / output from command
491
+ BaseProject.prototype.outputFrom = function (command
492
+ //#region @backend
493
+ , options
494
+ //#endregion
495
+ ) {
496
+ //#region @backendFunc
497
+ return index_1.Helpers.commnadOutputAsString(command, this.location, options);
498
+ //#endregion
499
+ };
500
+ //#endregion
501
+ //#region methods & getters / remove file
502
+ BaseProject.prototype.removeFile = function (fileRelativeToProjectPath) {
503
+ //#region @backendFunc
504
+ var fullPath = tnp_core_2.path.resolve(tnp_core_2.path.join(this.location, fileRelativeToProjectPath));
505
+ return index_1.Helpers.removeFileIfExists(fullPath);
506
+ //#endregion
507
+ };
508
+ //#endregion
509
+ //#region methods & getters / remove (fiel or folder)
510
+ BaseProject.prototype.remove = function (relativePath, exactPath) {
511
+ if (exactPath === void 0) { exactPath = true; }
512
+ //#region @backend
513
+ relativePath = relativePath.replace(/^\//, '');
514
+ index_1.Helpers.remove([this.location, relativePath], exactPath);
515
+ //#endregion
516
+ };
517
+ //#endregion
518
+ //#region methods & getters / remove folder by relative path
519
+ BaseProject.prototype.removeFolderByRelativePath = function (relativePathToFolder) {
520
+ //#region @backend
521
+ relativePathToFolder = relativePathToFolder.replace(/^\//, '');
522
+ var location = this.location;
523
+ var p = tnp_core_2.path.join(location, relativePathToFolder);
524
+ index_1.Helpers.remove(p, true);
525
+ //#endregion
526
+ };
527
+ //#endregion
528
+ //#region methods & getters / link node_modules to other project
529
+ BaseProject.prototype.linkNodeModulesTo = function (proj) {
530
+ //#region @backendFunc
531
+ var source = this.pathFor(tnp_config_1.config.folder.node_modules);
532
+ var dest = proj.pathFor(tnp_config_1.config.folder.node_modules);
533
+ index_1.Helpers.remove(dest, true);
534
+ index_1.Helpers.createSymLink(source, dest);
535
+ //#endregion
536
+ };
537
+ //#endregion
538
+ //#region methods & getters / reinstall node_modules
539
+ BaseProject.prototype.reinstallNodeModules = function (forcerRemoveNodeModules) {
540
+ if (forcerRemoveNodeModules === void 0) { forcerRemoveNodeModules = false; }
541
+ //#region @backendFunc
542
+ index_1.Helpers.taskStarted("Reinstalling node_modules in ".concat(this.genericName));
543
+ var source = this.pathFor(tnp_config_1.config.folder.node_modules);
544
+ if (forcerRemoveNodeModules) {
545
+ index_1.Helpers.remove(source, true);
546
+ }
547
+ this.run('yarn install').sync();
548
+ index_1.Helpers.taskDone("Reinstalling done for ".concat(this.genericName));
549
+ //#endregion
550
+ };
551
+ //#endregion
552
+ //#region methods & getters / assign free port to project instance
553
+ BaseProject.prototype.assignFreePort = function (startFrom, howManyFreePortsAfterThatPort) {
554
+ if (startFrom === void 0) { startFrom = 4200; }
555
+ if (howManyFreePortsAfterThatPort === void 0) { howManyFreePortsAfterThatPort = 0; }
556
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
557
+ var max, i, port, err_1;
558
+ return tslib_1.__generator(this, function (_a) {
559
+ switch (_a.label) {
560
+ case 0:
561
+ //#region @backendFunc
562
+ if (tnp_core_3._.isNumber(this.port) && this.port >= startFrom) {
563
+ return [2 /*return*/, startFrom];
564
+ }
565
+ max = 2000;
566
+ i = 0;
567
+ while (takenPorts.includes(startFrom)) {
568
+ startFrom += (1 + howManyFreePortsAfterThatPort);
569
+ }
570
+ _a.label = 1;
571
+ case 1:
572
+ if (!true) return [3 /*break*/, 6];
573
+ _a.label = 2;
574
+ case 2:
575
+ _a.trys.push([2, 4, , 5]);
576
+ return [4 /*yield*/, tnp_core_1.portfinder.getPortPromise({ port: startFrom })];
577
+ case 3:
578
+ port = _a.sent();
579
+ takenPorts.push(port);
580
+ // @ts-ignore
581
+ this.port = port;
582
+ return [2 /*return*/, port];
583
+ case 4:
584
+ err_1 = _a.sent();
585
+ console.log(err_1);
586
+ index_1.Helpers.warn("Trying to assign port :".concat(startFrom, " but already in use."), false);
587
+ return [3 /*break*/, 5];
588
+ case 5:
589
+ startFrom += 1;
590
+ if (i++ === max) {
591
+ index_1.Helpers.error("[firedev-helpers]] failed to assign free port after ".concat(max, " trys..."));
592
+ }
593
+ return [3 /*break*/, 1];
594
+ case 6: return [2 /*return*/];
595
+ }
596
+ });
597
+ });
598
+ };
599
+ //#endregion
600
+ //#region methods & getters / remove project from disk/memory
601
+ BaseProject.prototype.removeItself = function () {
602
+ //#region @backend
603
+ this.ins.remove(this);
604
+ //#endregion
605
+ };
606
+ //#endregion
607
+ //#region methods & getters / define property
608
+ /**
609
+ * Purpose: not initializing all classes at the beginning
610
+ * Only for BaseFeatureForProject class
611
+ */
612
+ BaseProject.prototype.defineProperty = function (variableName, classFn, options) {
613
+ //#region @backendFunc
614
+ var customInstanceReturn = (options || {}).customInstanceReturn;
615
+ var that = this;
616
+ // @ts-ignore
617
+ var prefixedName = "__".concat(variableName);
618
+ Object.defineProperty(this, variableName, {
619
+ get: function () {
620
+ if (!that[prefixedName]) {
621
+ if (typeof classFn === 'function') {
622
+ if (!!customInstanceReturn) {
623
+ that[prefixedName] = customInstanceReturn();
624
+ }
625
+ else {
626
+ that[prefixedName] = new classFn(that);
627
+ }
628
+ }
629
+ else {
630
+ index_1.Helpers.warn("[firedev-helpers] Cannot create dynamic instance of class \"".concat(tnp_core_3._.kebabCase(prefixedName.replace('__', '')), "\"."));
631
+ }
632
+ // }
633
+ }
634
+ return that[prefixedName];
635
+ },
636
+ set: function (v) {
637
+ that[prefixedName] = v;
638
+ },
639
+ });
640
+ //#endregion
641
+ };
642
+ //#endregion
643
+ //#region methods & getters / filter only copy
644
+ /**
645
+ * fs.copy option filter function for copying only selected folders from project
646
+ */
647
+ BaseProject.prototype.filterOnlyCopy = function (basePathFoldersOnlyToInclude) {
648
+ //#region @backendFunc
649
+ return index_1.Helpers.filterOnlyCopy(basePathFoldersOnlyToInclude, this.location);
650
+ //#endregion
651
+ };
652
+ //#endregion
653
+ //#region methods & getters / filter don't copy
654
+ /**
655
+ * fs.copy option filter function for copying only not selected folders from project
656
+ */
657
+ BaseProject.prototype.filterDontCopy = function (basePathFoldersTosSkip) {
658
+ //#region @backendFunc
659
+ return index_1.Helpers.filterDontCopy(basePathFoldersTosSkip, this.location);
660
+ //#endregion
661
+ };
662
+ //#endregion
663
+ //#region methods & getters / get default develop Branch
664
+ BaseProject.prototype.getDefaultDevelopmentBranch = function () {
665
+ return 'develop';
666
+ };
667
+ //#endregion
668
+ //#region methods & getters / get main branches
669
+ /**
670
+ * main/default hardcoded branches
671
+ */
672
+ BaseProject.prototype.getMainBranches = function () {
673
+ return ['master', 'develop', 'stage', 'prod', 'test'];
674
+ };
675
+ //#endregion
676
+ //#region methods & getters / is using aciton commit
677
+ BaseProject.prototype.isUnsingActionCommit = function () {
678
+ return false;
679
+ };
680
+ //#endregion
681
+ //#region methods & getters / reset process
682
+ BaseProject.prototype.resetProcess = function (overrideBranch) {
683
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
684
+ var defaultBranch, childrenRepos, childrenRepos_1, childrenRepos_1_1, child, e_1_1;
685
+ var e_1, _a;
686
+ return tslib_1.__generator(this, function (_b) {
687
+ switch (_b.label) {
688
+ case 0:
689
+ //#region @backend
690
+ this._beforeAnyActionOnGitRoot();
691
+ defaultBranch = overrideBranch
692
+ ? overrideBranch : this.getDefaultDevelopmentBranch();
693
+ this.git.fetch();
694
+ this.git.stageAllFiles();
695
+ this.git.stash();
696
+ this.git.resetHard();
697
+ this.git.checkout(defaultBranch);
698
+ if (!this.isUnsingActionCommit()) return [3 /*break*/, 2];
699
+ return [4 /*yield*/, this.git.pullCurrentBranch({ askToRetry: true })];
700
+ case 1:
701
+ _b.sent();
702
+ return [3 /*break*/, 4];
703
+ case 2: return [4 /*yield*/, this.git.pullCurrentBranch({ askToRetry: true, defaultHardResetCommits: 5 })];
704
+ case 3:
705
+ _b.sent();
706
+ _b.label = 4;
707
+ case 4:
708
+ this.git.stashApply();
709
+ return [4 /*yield*/, this.struct()];
710
+ case 5:
711
+ _b.sent();
712
+ index_1.Helpers.info("RESET DONE for branch: ".concat(tnp_core_1.chalk.bold(defaultBranch)));
713
+ childrenRepos = this.children.filter(function (f) { return f.git.isGitRepo && f.git.isGitRoot; });
714
+ _b.label = 6;
715
+ case 6:
716
+ _b.trys.push([6, 11, 12, 13]);
717
+ childrenRepos_1 = tslib_1.__values(childrenRepos), childrenRepos_1_1 = childrenRepos_1.next();
718
+ _b.label = 7;
719
+ case 7:
720
+ if (!!childrenRepos_1_1.done) return [3 /*break*/, 10];
721
+ child = childrenRepos_1_1.value;
722
+ return [4 /*yield*/, child.resetProcess(overrideBranch)];
723
+ case 8:
724
+ _b.sent();
725
+ _b.label = 9;
726
+ case 9:
727
+ childrenRepos_1_1 = childrenRepos_1.next();
728
+ return [3 /*break*/, 7];
729
+ case 10: return [3 /*break*/, 13];
730
+ case 11:
731
+ e_1_1 = _b.sent();
732
+ e_1 = { error: e_1_1 };
733
+ return [3 /*break*/, 13];
734
+ case 12:
735
+ try {
736
+ if (childrenRepos_1_1 && !childrenRepos_1_1.done && (_a = childrenRepos_1.return)) _a.call(childrenRepos_1);
737
+ }
738
+ finally { if (e_1) throw e_1.error; }
739
+ return [7 /*endfinally*/];
740
+ case 13: return [2 /*return*/];
741
+ }
742
+ });
743
+ });
744
+ };
745
+ //#endregion
746
+ //#region methods & getters / push process
747
+ BaseProject.prototype.pullProcess = function () {
748
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
749
+ var uncommitedChanges, location, childrenRepos, childrenRepos_2, childrenRepos_2_1, child, e_2_1;
750
+ var e_2, _a;
751
+ return tslib_1.__generator(this, function (_b) {
752
+ switch (_b.label) {
753
+ case 0:
754
+ //#region @backendFunc
755
+ return [4 /*yield*/, this._beforePullProcessAction()];
756
+ case 1:
757
+ //#region @backendFunc
758
+ _b.sent();
759
+ uncommitedChanges = this.git.thereAreSomeUncommitedChange;
760
+ if (uncommitedChanges) {
761
+ index_1.Helpers.warn("Stashing uncommit changes... in ".concat(this.genericName));
762
+ try {
763
+ this.git.stageAllFiles();
764
+ }
765
+ catch (error) { }
766
+ try {
767
+ this.git.stash();
768
+ }
769
+ catch (error) { }
770
+ ;
771
+ }
772
+ return [4 /*yield*/, this.git.pullCurrentBranch({ askToRetry: true })];
773
+ case 2:
774
+ _b.sent();
775
+ location = this.location;
776
+ this.ins.unload(this);
777
+ this.ins.add(this.ins.From(location));
778
+ if (!this.automaticallyAddAllChnagesWhenPushingToGit()) return [3 /*break*/, 10];
779
+ childrenRepos = this.children.filter(function (f) { return f.git.isGitRepo && f.git.isGitRoot; });
780
+ _b.label = 3;
781
+ case 3:
782
+ _b.trys.push([3, 8, 9, 10]);
783
+ childrenRepos_2 = tslib_1.__values(childrenRepos), childrenRepos_2_1 = childrenRepos_2.next();
784
+ _b.label = 4;
785
+ case 4:
786
+ if (!!childrenRepos_2_1.done) return [3 /*break*/, 7];
787
+ child = childrenRepos_2_1.value;
788
+ return [4 /*yield*/, child.pullProcess()];
789
+ case 5:
790
+ _b.sent();
791
+ _b.label = 6;
792
+ case 6:
793
+ childrenRepos_2_1 = childrenRepos_2.next();
794
+ return [3 /*break*/, 4];
795
+ case 7: return [3 /*break*/, 10];
796
+ case 8:
797
+ e_2_1 = _b.sent();
798
+ e_2 = { error: e_2_1 };
799
+ return [3 /*break*/, 10];
800
+ case 9:
801
+ try {
802
+ if (childrenRepos_2_1 && !childrenRepos_2_1.done && (_a = childrenRepos_2.return)) _a.call(childrenRepos_2);
803
+ }
804
+ finally { if (e_2) throw e_2.error; }
805
+ return [7 /*endfinally*/];
806
+ case 10: return [2 /*return*/];
807
+ }
808
+ });
809
+ });
810
+ };
811
+ //#endregion
812
+ //#region methods & getters / push process
813
+ BaseProject.prototype.pushProcess = function (options) {
814
+ var _a;
815
+ if (options === void 0) { options = {}; }
816
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
817
+ var force, typeofCommit, forcePushNoQuestion, origin, exitCallBack, args, commitMessageRequired, commitData, error_1, childrenRepos, childrenRepos_3, childrenRepos_3_1, child, e_3_1;
818
+ var _b, _c, _d, e_3, _e;
819
+ return tslib_1.__generator(this, function (_f) {
820
+ switch (_f.label) {
821
+ case 0:
822
+ force = (_b = options.force, _b === void 0 ? false : _b), typeofCommit = options.typeofCommit, forcePushNoQuestion = options.forcePushNoQuestion, origin = (_c = options.origin, _c === void 0 ? 'origin' : _c), exitCallBack = options.exitCallBack, args = (_d = options.args, _d === void 0 ? [] : _d), commitMessageRequired = options.commitMessageRequired;
823
+ this._beforePushProcessAction();
824
+ return [4 /*yield*/, this._getCommitMessage(typeofCommit, args, commitMessageRequired)];
825
+ case 1:
826
+ commitData = _f.sent();
827
+ _f.label = 2;
828
+ case 2:
829
+ if (!true) return [3 /*break*/, 8];
830
+ _f.label = 3;
831
+ case 3:
832
+ _f.trys.push([3, 5, , 7]);
833
+ return [4 /*yield*/, this.lint()];
834
+ case 4:
835
+ _f.sent();
836
+ return [3 /*break*/, 8];
837
+ case 5:
838
+ error_1 = _f.sent();
839
+ index_1.Helpers.warn('Fix your code...');
840
+ return [4 /*yield*/, index_1.Helpers.consoleGui.question.yesNo('Try again lint ? .. (or just skip it)')];
841
+ case 6:
842
+ if (!(_f.sent())) {
843
+ return [3 /*break*/, 8];
844
+ }
845
+ return [3 /*break*/, 7];
846
+ case 7: return [3 /*break*/, 2];
847
+ case 8:
848
+ if (!!commitData.isActionCommit) return [3 /*break*/, 10];
849
+ index_1.Helpers.info("Current commit:\n - message to include {".concat(commitData.commitMessage, "}\n - branch to checkout {").concat(commitData.branchName, "}\n "));
850
+ return [4 /*yield*/, index_1.Helpers.questionYesNo('Commit and push this ?')];
851
+ case 9:
852
+ if (!(_f.sent())) {
853
+ exitCallBack();
854
+ }
855
+ _f.label = 10;
856
+ case 10:
857
+ if (this.automaticallyAddAllChnagesWhenPushingToGit()) { // my project
858
+ this.git.stageAllFiles();
859
+ }
860
+ if (this.useGitBranchesAsMetadataForCommits()) {
861
+ if (((_a = this.git.currentBranchName) === null || _a === void 0 ? void 0 : _a.trim()) !== commitData.branchName) {
862
+ try {
863
+ this.git.checkout(commitData.branchName, { createBranchIfNotExists: true });
864
+ }
865
+ catch (error) {
866
+ index_1.Helpers.error('Please modyfiy you commit message or delete branch,');
867
+ }
868
+ }
869
+ }
870
+ try {
871
+ this.git.commit(commitData.commitMessage);
872
+ }
873
+ catch (error) {
874
+ index_1.Helpers.warn("Not commiting anything... ");
875
+ }
876
+ return [4 /*yield*/, this.git.pushCurrentBranch({ force: force, origin: origin, forcePushNoQuestion: forcePushNoQuestion, askToRetry: true })];
877
+ case 11:
878
+ _f.sent();
879
+ if (!this.automaticallyAddAllChnagesWhenPushingToGit()) return [3 /*break*/, 19];
880
+ childrenRepos = this.children.filter(function (f) { return f.git.isGitRepo && f.git.isGitRoot; });
881
+ _f.label = 12;
882
+ case 12:
883
+ _f.trys.push([12, 17, 18, 19]);
884
+ childrenRepos_3 = tslib_1.__values(childrenRepos), childrenRepos_3_1 = childrenRepos_3.next();
885
+ _f.label = 13;
886
+ case 13:
887
+ if (!!childrenRepos_3_1.done) return [3 /*break*/, 16];
888
+ child = childrenRepos_3_1.value;
889
+ return [4 /*yield*/, child.pushProcess(options)];
890
+ case 14:
891
+ _f.sent();
892
+ _f.label = 15;
893
+ case 15:
894
+ childrenRepos_3_1 = childrenRepos_3.next();
895
+ return [3 /*break*/, 13];
896
+ case 16: return [3 /*break*/, 19];
897
+ case 17:
898
+ e_3_1 = _f.sent();
899
+ e_3 = { error: e_3_1 };
900
+ return [3 /*break*/, 19];
901
+ case 18:
902
+ try {
903
+ if (childrenRepos_3_1 && !childrenRepos_3_1.done && (_e = childrenRepos_3.return)) _e.call(childrenRepos_3);
904
+ }
905
+ finally { if (e_3) throw e_3.error; }
906
+ return [7 /*endfinally*/];
907
+ case 19: return [2 /*return*/];
908
+ }
909
+ });
910
+ });
911
+ };
912
+ //#endregion
913
+ //#region methods & getters / before any action on git root
914
+ BaseProject.prototype._beforeAnyActionOnGitRoot = function () {
915
+ //#region @backendFunc
916
+ if (!this.git.isGitRepo) {
917
+ index_1.Helpers.error("Project ".concat(tnp_core_1.chalk.bold(this.name), " is not a git repository\n locaiton: ").concat(this.location), false, true);
918
+ }
919
+ if (!this.git.isGitRoot) {
920
+ index_1.Helpers.error("Project ".concat(tnp_core_1.chalk.bold(this.name), " is not a git root\n locaiton: ").concat(this.location), false, true);
921
+ }
922
+ //#endregion
923
+ };
924
+ //#endregion
925
+ //#region before push action
926
+ BaseProject.prototype._beforePushProcessAction = function () {
927
+ var _a;
928
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
929
+ return tslib_1.__generator(this, function (_b) {
930
+ switch (_b.label) {
931
+ case 0:
932
+ //#region @backendFunc
933
+ this._beforeAnyActionOnGitRoot();
934
+ if (!(this.git.isGitRepo && this.git.isGitRoot && !((_a = this.git.currentBranchName) === null || _a === void 0 ? void 0 : _a.trim()))) return [3 /*break*/, 2];
935
+ return [4 /*yield*/, index_1.Helpers.consoleGui.question.yesNo('Repository is empty...Commit "master" branch and commit all as "first commit" ?')];
936
+ case 1:
937
+ if (_b.sent()) {
938
+ this.git.checkout('master');
939
+ this.git.stageAllFiles();
940
+ this.git.commit('first commit ');
941
+ }
942
+ _b.label = 2;
943
+ case 2: return [2 /*return*/];
944
+ }
945
+ });
946
+ });
947
+ };
948
+ //#endregion
949
+ //#region before push action
950
+ BaseProject.prototype._beforePullProcessAction = function () {
951
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
952
+ return tslib_1.__generator(this, function (_a) {
953
+ //#region @backendFunc
954
+ this._beforeAnyActionOnGitRoot();
955
+ return [2 /*return*/];
956
+ });
957
+ });
958
+ };
959
+ //#endregion
960
+ //#region resovle commit message
961
+ BaseProject.prototype._getCommitMessage = function (typeofCommit, args, commitMessageRequired) {
962
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
963
+ var commitData, argsCommitData, commitDataBranch, argsCommitData, from, to, _a, _b, _c;
964
+ var _d;
965
+ return tslib_1.__generator(this, function (_e) {
966
+ switch (_e.label) {
967
+ case 0:
968
+ if (!this.useGitBranchesWhenCommitingAndPushing()) return [3 /*break*/, 5];
969
+ return [4 /*yield*/, index_1.CommitData.getFromArgs(args, typeofCommit)];
970
+ case 1:
971
+ argsCommitData = _e.sent();
972
+ if (!argsCommitData.message) return [3 /*break*/, 2];
973
+ commitData = argsCommitData;
974
+ return [3 /*break*/, 4];
975
+ case 2: return [4 /*yield*/, index_1.CommitData.getFromBranch(this.git.currentBranchName)];
976
+ case 3:
977
+ commitDataBranch = _e.sent();
978
+ commitData = commitDataBranch;
979
+ _e.label = 4;
980
+ case 4: return [3 /*break*/, 7];
981
+ case 5: return [4 /*yield*/, index_1.CommitData.getFromArgs(args, typeofCommit)];
982
+ case 6:
983
+ argsCommitData = _e.sent();
984
+ // console.log({ argsCommitData })
985
+ // console.log(argsCommitData)
986
+ if (!argsCommitData.message && commitMessageRequired) {
987
+ index_1.Helpers.error('Please provide message in argument', false, true);
988
+ }
989
+ if (!argsCommitData.message) {
990
+ argsCommitData.message = index_1.Helpers.git.ACTION_MSG_RESET_GIT_HARD_COMMIT;
991
+ }
992
+ commitData = argsCommitData;
993
+ _e.label = 7;
994
+ case 7:
995
+ if (!(commitData.message !== index_1.Helpers.git.ACTION_MSG_RESET_GIT_HARD_COMMIT)) return [3 /*break*/, 9];
996
+ from = (_d = this.transalteGitCommitFromArgs(), _d.from), to = _d.to;
997
+ if (!(from && to)) return [3 /*break*/, 9];
998
+ _a = commitData;
999
+ _c = (_b = tnp_core_3._).kebabCase;
1000
+ return [4 /*yield*/, (0, translate_1.translate)(commitData.message, { from: from, to: to })];
1001
+ case 8:
1002
+ _a.message = _c.apply(_b, [_e.sent()]);
1003
+ _e.label = 9;
1004
+ case 9: return [2 /*return*/, commitData];
1005
+ }
1006
+ });
1007
+ });
1008
+ };
1009
+ //#endregion
1010
+ //#region methods & getters / link project to
1011
+ BaseProject.prototype.linkTo = function (destPackageLocation) {
1012
+ //#region @backend
1013
+ index_1.Helpers.createSymLink(this.location, destPackageLocation);
1014
+ //#endregion
1015
+ };
1016
+ //#endregion
1017
+ //#region methods & getters / write file
1018
+ BaseProject.prototype.writeFile = function (relativePath, content) {
1019
+ //#region @backend
1020
+ index_1.Helpers.writeFile([this.location, relativePath], content);
1021
+ //#endregion
1022
+ };
1023
+ //#endregion
1024
+ //#region getters & methods / ru command and get string
1025
+ BaseProject.prototype.runCommandGetString = function (command) {
1026
+ //#region @backendFunc
1027
+ return index_1.Helpers.commnadOutputAsString(command, this.location, { biggerBuffer: false });
1028
+ //#endregion
1029
+ };
1030
+ Object.defineProperty(BaseProject.prototype, "git", {
1031
+ //#endregion
1032
+ //#region getters & methods / git
1033
+ get: function () {
1034
+ var self = this;
1035
+ return {
1036
+ revertFileChanges: function (fileReletivePath) {
1037
+ //#region @backendFunc
1038
+ index_1.Helpers.git.revertFileChanges(self.location, fileReletivePath);
1039
+ //#endregion
1040
+ },
1041
+ clone: function (url, destinationFolderName) {
1042
+ if (destinationFolderName === void 0) { destinationFolderName = ''; }
1043
+ //#region @backendFunc
1044
+ return index_1.Helpers.git.clone({ cwd: self.location, url: url, destinationFolderName: destinationFolderName });
1045
+ //#endregion
1046
+ },
1047
+ restoreLastVersion: function (localFilePath) {
1048
+ //#region @backendFunc
1049
+ return index_1.Helpers.git.restoreLastVersion(self.location, localFilePath);
1050
+ //#endregion
1051
+ },
1052
+ stageAllFiles: function () {
1053
+ //#region @backendFunc
1054
+ index_1.Helpers.git.stageAllFiles(self.location);
1055
+ //#endregion
1056
+ },
1057
+ stash: function (optinos) {
1058
+ //#region @backendFunc
1059
+ index_1.Helpers.git.stash(self.location, optinos);
1060
+ //#endregion
1061
+ },
1062
+ stashApply: function () {
1063
+ //#region @backendFunc
1064
+ index_1.Helpers.git.stashApply(self.location);
1065
+ //#endregion
1066
+ },
1067
+ fetch: function () {
1068
+ //#region @backendFunc
1069
+ index_1.Helpers.git.fetch(self.location);
1070
+ //#endregion
1071
+ },
1072
+ resetFiles: function () {
1073
+ var _a;
1074
+ var relativePathes = [];
1075
+ for (var _i = 0; _i < arguments.length; _i++) {
1076
+ relativePathes[_i] = arguments[_i];
1077
+ }
1078
+ //#region @backendFunc
1079
+ return (_a = index_1.Helpers.git).resetFiles.apply(_a, tslib_1.__spreadArray([self.location], tslib_1.__read(relativePathes), false));
1080
+ //#endregion
1081
+ },
1082
+ get isGitRepo() {
1083
+ //#region @backendFunc
1084
+ return index_1.Helpers.git.isGitRepo(self.location);
1085
+ //#endregion
1086
+ },
1087
+ get isGitRoot() {
1088
+ //#region @backendFunc
1089
+ return index_1.Helpers.git.isGitRoot(self.location);
1090
+ //#endregion
1091
+ },
1092
+ get originURL() {
1093
+ //#region @backendFunc
1094
+ return index_1.Helpers.git.getOriginURL(self.location);
1095
+ //#endregion
1096
+ },
1097
+ commit: function (commitMessage) {
1098
+ //#region @backendFunc
1099
+ return index_1.Helpers.git.commit(self.location, commitMessage);
1100
+ //#endregion
1101
+ },
1102
+ /**
1103
+ * alias to stage all and commit
1104
+ */
1105
+ addAndCommit: function (commitMessage) {
1106
+ //#region @backendFunc
1107
+ return index_1.Helpers.git.stageAllAndCommit(self.location, commitMessage);
1108
+ //#endregion
1109
+ },
1110
+ stageAllAndCommit: function (commitMessage) {
1111
+ //#region @backendFunc
1112
+ return index_1.Helpers.git.stageAllAndCommit(self.location, commitMessage);
1113
+ //#endregion
1114
+ },
1115
+ pushCurrentBranch: function (options) {
1116
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1117
+ return tslib_1.__generator(this, function (_a) {
1118
+ switch (_a.label) {
1119
+ case 0: return [4 /*yield*/, index_1.Helpers.git.pushCurrentBranch(self.location, options)];
1120
+ case 1:
1121
+ //#region @backendFunc
1122
+ return [2 /*return*/, _a.sent()];
1123
+ }
1124
+ });
1125
+ });
1126
+ },
1127
+ get allOrigins() {
1128
+ //#region @backendFunc
1129
+ return index_1.Helpers.git.allOrigins(self.location);
1130
+ //#endregion
1131
+ },
1132
+ get thereAreSomeUncommitedChange() {
1133
+ //#region @backendFunc
1134
+ return index_1.Helpers.git.checkIfthereAreSomeUncommitedChange(self.location);
1135
+ //#endregion
1136
+ },
1137
+ thereAreSomeUncommitedChangeExcept: function (filesList) {
1138
+ if (filesList === void 0) { filesList = []; }
1139
+ //#region @backendFunc
1140
+ return index_1.Helpers.git.thereAreSomeUncommitedChangeExcept(filesList, self.location);
1141
+ //#endregion
1142
+ },
1143
+ meltActionCommits: function (soft) {
1144
+ if (soft === void 0) { soft = false; }
1145
+ //#region @backend
1146
+ return index_1.Helpers.git.meltActionCommits(self.location, soft);
1147
+ //#endregion
1148
+ },
1149
+ pullCurrentBranch: function (options) {
1150
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1151
+ return tslib_1.__generator(this, function (_a) {
1152
+ switch (_a.label) {
1153
+ case 0:
1154
+ //#region @backendFunc
1155
+ return [4 /*yield*/, index_1.Helpers.git.pullCurrentBranch(self.location, tslib_1.__assign({}, options))];
1156
+ case 1:
1157
+ //#region @backendFunc
1158
+ _a.sent();
1159
+ return [2 /*return*/];
1160
+ }
1161
+ });
1162
+ });
1163
+ },
1164
+ get currentBranchName() {
1165
+ //#region @backendFunc
1166
+ return index_1.Helpers.git.currentBranchName(self.location);
1167
+ //#endregion
1168
+ },
1169
+ getBranchesNamesBy: function (pattern) {
1170
+ //#region @backendFunc
1171
+ return index_1.Helpers.git.getBranchesNames(self.location, pattern);
1172
+ //#endregion
1173
+ },
1174
+ resetSoftHEAD: function (HEAD) {
1175
+ if (HEAD === void 0) { HEAD = 1; }
1176
+ //#region @backendFunc
1177
+ index_1.Helpers.git.resetSoftHEAD(self.location, HEAD);
1178
+ //#endregion
1179
+ },
1180
+ resetHard: function (options) {
1181
+ //#region @backendFunc
1182
+ index_1.Helpers.git.resetHard(self.location, options);
1183
+ //#endregion
1184
+ },
1185
+ countComits: function () {
1186
+ //#region @backendFunc
1187
+ return index_1.Helpers.git.countCommits(self.location);
1188
+ //#endregion
1189
+ },
1190
+ hasAnyCommits: function () {
1191
+ //#region @backendFunc
1192
+ return index_1.Helpers.git.hasAnyCommits(self.location);
1193
+ //#endregion
1194
+ },
1195
+ get isInMergeProcess() {
1196
+ //#region @backendFunc
1197
+ return index_1.Helpers.git.isInMergeProcess(self.location);
1198
+ //#endregion
1199
+ },
1200
+ lastCommitDate: function () {
1201
+ //#region @backendFunc
1202
+ return index_1.Helpers.git.lastCommitDate(self.location);
1203
+ //#endregion
1204
+ },
1205
+ lastCommitHash: function () {
1206
+ //#region @backendFunc
1207
+ return index_1.Helpers.git.lastCommitHash(self.location);
1208
+ //#endregion
1209
+ },
1210
+ lastCommitMessage: function () {
1211
+ //#region @backendFunc
1212
+ return index_1.Helpers.git.lastCommitMessage(self.location);
1213
+ //#endregion
1214
+ },
1215
+ penultimageCommitHash: function () {
1216
+ //#region @backendFunc
1217
+ return index_1.Helpers.git.penultimageCommitHash(self.location);
1218
+ //#endregion
1219
+ },
1220
+ checkTagExists: function (tag) {
1221
+ //#region @backendFunc
1222
+ return index_1.Helpers.git.checkTagExists(tag, self.location);
1223
+ //#endregion
1224
+ },
1225
+ checkout: function (branchName, options) {
1226
+ //#region @backendFunc
1227
+ return index_1.Helpers.git.checkout(self.location, branchName, options);
1228
+ //#endregion
1229
+ },
1230
+ checkoutFromTo: function (checkoutFromBranch, branch, origin) {
1231
+ if (origin === void 0) { origin = 'origin'; }
1232
+ //#region @backendFunc
1233
+ return index_1.Helpers.git.checkoutFromTo(checkoutFromBranch, branch, origin, self.location);
1234
+ //#endregion
1235
+ },
1236
+ /**
1237
+ *
1238
+ * @param majorVersion example: v1, v2 etc.
1239
+ * @returns tag name
1240
+ */
1241
+ lastTagNameForMajorVersion: function (majorVersion) {
1242
+ //#region @backendFunc
1243
+ return index_1.Helpers.git.lastTagNameForMajorVersion(self.location, majorVersion);
1244
+ //#endregion
1245
+ },
1246
+ lastTagHash: function () {
1247
+ //#region @backendFunc
1248
+ return index_1.Helpers.git.lastTagHash(self.location);
1249
+ //#endregion
1250
+ },
1251
+ get remoteOriginUrl() {
1252
+ //#region @backendFunc
1253
+ return index_1.Helpers.git.getOriginURL(self.location);
1254
+ //#endregion
1255
+ },
1256
+ get lastTagVersionName() {
1257
+ //#region @backendFunc
1258
+ return (index_1.Helpers.git.lastTagVersionName(self.location) || '');
1259
+ //#endregion
1260
+ },
1261
+ get stagedFiles() {
1262
+ //#region @backendFunc
1263
+ return index_1.Helpers.git.stagedFiles(self.location);
1264
+ //#endregion
1265
+ },
1266
+ /**
1267
+ * TODO does this make any sense
1268
+ */
1269
+ renameOrigin: function (newNameOrUlr) {
1270
+ //#region @backendFunc
1271
+ if (!newNameOrUlr.endsWith('.git')) {
1272
+ newNameOrUlr = (newNameOrUlr + '.git');
1273
+ }
1274
+ var oldOrigin = self.git.originURL;
1275
+ if (!newNameOrUlr.startsWith('git@') && !newNameOrUlr.startsWith('https://')) {
1276
+ newNameOrUlr = oldOrigin.replace(tnp_core_2.path.basename(oldOrigin), newNameOrUlr);
1277
+ }
1278
+ try {
1279
+ self.run("git remote rm origin").sync();
1280
+ }
1281
+ catch (error) { }
1282
+ try {
1283
+ self.run("git remote add origin ".concat(newNameOrUlr)).sync();
1284
+ index_1.Helpers.info("Origin changed:\n from: ".concat(oldOrigin, "\n to: ").concat(newNameOrUlr, "\n"));
1285
+ }
1286
+ catch (e) {
1287
+ index_1.Helpers.error("Not able to change origin.. reverting to old", true, true);
1288
+ self.run("git remote add origin ".concat(oldOrigin)).sync();
1289
+ }
1290
+ //#endregion
1291
+ },
1292
+ };
1293
+ },
1294
+ enumerable: false,
1295
+ configurable: true
1296
+ });
1297
+ //#endregion
1298
+ //#region getters & methods / check if loggin in to npm
1299
+ BaseProject.prototype.checkIfLogginInToNpm = function () {
1300
+ //#region @backendFunc
1301
+ // if (!this.canBePublishToNpmRegistry) {
1302
+ // return;
1303
+ // }
1304
+ try {
1305
+ this.run('npm whoami').sync();
1306
+ }
1307
+ catch (e) {
1308
+ index_1.Helpers.error("Please login in to npm.", false, true);
1309
+ }
1310
+ //#endregion
1311
+ };
1312
+ Object.defineProperty(BaseProject.prototype, "parentsNames", {
1313
+ //#endregion
1314
+ //#region getters & methods / find partners names
1315
+ get: function () {
1316
+ //#region @backendFunc
1317
+ return this.findParentsNames();
1318
+ //#endregion
1319
+ },
1320
+ enumerable: false,
1321
+ configurable: true
1322
+ });
1323
+ BaseProject.prototype.findParentsNames = function (project, parent, result) {
1324
+ if (result === void 0) { result = []; }
1325
+ //#region @backendFunc
1326
+ if (!project && !parent) {
1327
+ project = this;
1328
+ }
1329
+ if (!project && parent) {
1330
+ return result.reverse();
1331
+ }
1332
+ if (project && project.parent) {
1333
+ result.push(project.parent.name);
1334
+ }
1335
+ return this.findParentsNames(project.parent, project, result);
1336
+ //#endregion
1337
+ };
1338
+ //#endregion
1339
+ //#region getters & methods / init
1340
+ /**
1341
+ * init project files structure and depedencies
1342
+ */
1343
+ BaseProject.prototype.init = function (initOptions) {
1344
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1345
+ return tslib_1.__generator(this, function (_a) {
1346
+ throw (new Error('TODO IMPLEMENT'));
1347
+ });
1348
+ });
1349
+ };
1350
+ //#endregion
1351
+ //#region getters & methods / link
1352
+ /**
1353
+ * globally link npm as package
1354
+ */
1355
+ BaseProject.prototype.link = function () {
1356
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1357
+ return tslib_1.__generator(this, function (_a) {
1358
+ throw (new Error('TODO IMPLEMENT'));
1359
+ });
1360
+ });
1361
+ };
1362
+ //#endregion
1363
+ //#region getters & methods / struct
1364
+ /**
1365
+ * init project files structure without depedencies
1366
+ */
1367
+ BaseProject.prototype.struct = function (initOptions) {
1368
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1369
+ return tslib_1.__generator(this, function (_a) {
1370
+ throw (new Error('TODO IMPLEMENT'));
1371
+ });
1372
+ });
1373
+ };
1374
+ //#endregion
1375
+ //#region getters & methods / build
1376
+ /**
1377
+ * init and build() project
1378
+ */
1379
+ BaseProject.prototype.build = function (buildOptions) {
1380
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1381
+ return tslib_1.__generator(this, function (_a) {
1382
+ throw (new Error('TODO IMPLEMENT'));
1383
+ });
1384
+ });
1385
+ };
1386
+ //#endregion
1387
+ //#region getters & methods / lint
1388
+ /**
1389
+ * lint porject
1390
+ */
1391
+ BaseProject.prototype.lint = function (lintOptions) {
1392
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1393
+ return tslib_1.__generator(this, function (_a) {
1394
+ throw (new Error('TODO IMPLEMENT'));
1395
+ });
1396
+ });
1397
+ };
1398
+ //#endregion
1399
+ //#region getters & methods / lint
1400
+ /**
1401
+ * get info about porject
1402
+ */
1403
+ BaseProject.prototype.info = function () {
1404
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1405
+ var proj;
1406
+ return tslib_1.__generator(this, function (_a) {
1407
+ proj = this;
1408
+ index_1.Helpers.info("\n\n name: ".concat(proj === null || proj === void 0 ? void 0 : proj.name, "\n type: ").concat(proj === null || proj === void 0 ? void 0 : proj.type, "\n children (").concat(proj === null || proj === void 0 ? void 0 : proj.children.length, "): ").concat((!proj || !proj.children.length) ? '< none >' : '', "\n").concat(proj === null || proj === void 0 ? void 0 : proj.children.map(function (c) { return '+' + c.genericName; }).join('\n'), "\n\n\n "));
1409
+ return [2 /*return*/];
1410
+ });
1411
+ });
1412
+ };
1413
+ //#endregion
1414
+ //#region getters & methods / translate git commit from args
1415
+ /**
1416
+ * By default no translation of commit
1417
+ */
1418
+ BaseProject.prototype.transalteGitCommitFromArgs = function () {
1419
+ return { from: void 0, to: void 0 };
1420
+ };
1421
+ //#endregion
1422
+ //#region getters & methods / us git branches when commiting and pushing
1423
+ /**
1424
+ * By defult true.. when commit branches will not function.
1425
+ * (false is better for simple projects)
1426
+ */
1427
+ BaseProject.prototype.useGitBranchesWhenCommitingAndPushing = function () {
1428
+ return true;
1429
+ };
1430
+ //#endregion
1431
+ //#region getters & methods / automatically add all changes when pushing to git
1432
+ /**
1433
+ * usefull when pushing in project with childrens as git repos
1434
+ */
1435
+ BaseProject.prototype.automaticallyAddAllChnagesWhenPushingToGit = function () {
1436
+ return false;
1437
+ };
1438
+ //#endregion
1439
+ //#region getters & methods / use git branches as metadata for commits
1440
+ /**
1441
+ * usefull when pushing in project with childrens as git repos
1442
+ */
1443
+ BaseProject.prototype.useGitBranchesAsMetadataForCommits = function () {
1444
+ return true;
1445
+ };
1446
+ //#region static
1447
+ //#region static / instance of resovle
1448
+ BaseProject.ins = new base_project_resolver_1.BaseProjectResolver(BaseProject);
1449
+ return BaseProject;
1450
+ }());
1451
+ //# sourceMappingURL=base-project.js.map