tnp-helpers 19.0.71 → 19.0.73
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/browser/README.md +24 -24
- package/browser/fesm2022/tnp-helpers.mjs +400 -69
- package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base/classes/base-compiler-for-project.d.ts +4 -4
- package/browser/lib/base/classes/base-global-command-line.d.ts +14 -1
- package/browser/lib/build-info._auto-generated_.d.ts +1 -1
- package/browser/lib/utils.d.ts +25 -1
- package/browser/package.json +1 -1
- package/lib/base/classes/base-command-line-feature.backend.d.ts +47 -0
- package/lib/base/classes/base-command-line-feature.backend.js +147 -0
- package/lib/base/classes/base-command-line-feature.backend.js.map +1 -0
- package/lib/base/classes/base-compiler-for-project.d.ts +4 -4
- package/lib/base/classes/base-compiler-for-project.js +9 -11
- package/lib/base/classes/base-compiler-for-project.js.map +1 -1
- package/lib/base/classes/base-debounce-compiler-for-project.js +8 -5
- package/lib/base/classes/base-debounce-compiler-for-project.js.map +1 -1
- package/lib/base/classes/base-global-command-line.backend.d.ts +231 -0
- package/lib/base/classes/base-global-command-line.backend.js +1807 -0
- package/lib/base/classes/base-global-command-line.backend.js.map +1 -0
- package/lib/base/classes/base-global-command-line.d.ts +13 -0
- package/lib/base/classes/base-global-command-line.js +89 -4
- package/lib/base/classes/base-global-command-line.js.map +1 -1
- package/lib/base/classes/base-powershell.d.ts +1 -0
- package/lib/base/classes/base-powershell.js +13 -0
- package/lib/base/classes/base-powershell.js.map +1 -1
- package/lib/base/classes/base-project.js +10 -1
- package/lib/base/classes/base-project.js.map +1 -1
- package/lib/base/classes/base-vscode.js +14 -6
- package/lib/base/classes/base-vscode.js.map +1 -1
- package/lib/base/tcp-udp-ports/not-assignable-port.entity.js +2 -2
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/helpers/for-backend/helpers-dependencies.backend.d.ts +3 -0
- package/lib/helpers/for-backend/helpers-dependencies.backend.js +34 -0
- package/lib/helpers/for-backend/helpers-dependencies.backend.js.map +1 -0
- package/lib/helpers/for-backend/helpers-network.backend.d.ts +9 -0
- package/lib/helpers/for-backend/helpers-network.backend.js +44 -0
- package/lib/helpers/for-backend/helpers-network.backend.js.map +1 -0
- package/lib/helpers/for-browser/angular.helper.js +2 -2
- package/lib/helpers/helpers-numbers.js.map +1 -1
- package/lib/old/base-component.js +2 -2
- package/lib/old/base-formly-component.js +2 -2
- package/lib/old/dual-component-ctrl.js +2 -2
- package/lib/utils.d.ts +25 -1
- package/lib/utils.js +195 -13
- package/lib/utils.js.map +1 -1
- package/lib/validators/validators-firedev.d.ts +3 -0
- package/lib/validators/validators-firedev.js +34 -0
- package/lib/validators/validators-firedev.js.map +1 -0
- package/lib/validators/validators-git.d.ts +3 -0
- package/lib/validators/validators-git.js +13 -0
- package/lib/validators/validators-git.js.map +1 -0
- package/lib/validators/validators-network.d.ts +3 -0
- package/lib/validators/validators-network.js +19 -0
- package/lib/validators/validators-network.js.map +1 -0
- package/lib/validators/validators.d.ts +6 -0
- package/lib/validators/validators.js +11 -0
- package/lib/validators/validators.js.map +1 -0
- package/package.json +1 -1
- package/tmp-environment.json +37 -0
- package/websql/README.md +24 -24
- package/websql/fesm2022/tnp-helpers.mjs +359 -12
- package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base/classes/base-compiler-for-project.d.ts +4 -4
- package/websql/lib/base/classes/base-global-command-line.d.ts +14 -1
- package/websql/lib/build-info._auto-generated_.d.ts +1 -1
- package/websql/lib/utils.d.ts +25 -1
- package/websql/package.json +1 -1
|
@@ -0,0 +1,1807 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseGlobalCommandLine = void 0;
|
|
4
|
+
//#region imports
|
|
5
|
+
const readline = require("readline"); // @backend
|
|
6
|
+
const rxjs_1 = require("rxjs");
|
|
7
|
+
const lib_1 = require("tnp-config/lib");
|
|
8
|
+
const lib_2 = require("tnp-core/lib");
|
|
9
|
+
const lib_3 = require("tnp-core/lib");
|
|
10
|
+
const lib_4 = require("tnp-core/lib");
|
|
11
|
+
const lib_5 = require("tnp-core/lib");
|
|
12
|
+
const lib_6 = require("tnp-core/lib"); //@backend
|
|
13
|
+
const index_1 = require("../../index");
|
|
14
|
+
const commit_data_1 = require("../commit-data");
|
|
15
|
+
const gh_temp_code_1 = require("../gh-temp-code");
|
|
16
|
+
const base_command_line_feature_1 = require("./base-command-line-feature");
|
|
17
|
+
//#endregion
|
|
18
|
+
class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineFeature {
|
|
19
|
+
_() {
|
|
20
|
+
index_1.Helpers.error('Please select git command');
|
|
21
|
+
}
|
|
22
|
+
//#region commands / prevent cwd is not project
|
|
23
|
+
/**
|
|
24
|
+
* TODO return argument not need for now
|
|
25
|
+
*/
|
|
26
|
+
async cwdIsProject(options) {
|
|
27
|
+
const { requireProjectWithGitRoot } = options || {};
|
|
28
|
+
if (!!this.project && !requireProjectWithGitRoot) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (requireProjectWithGitRoot &&
|
|
32
|
+
(!this.project || !this.project.git.isGitRoot)) {
|
|
33
|
+
const proj = this.ins.nearestTo(this.cwd, { findGitRoot: true });
|
|
34
|
+
if (proj) {
|
|
35
|
+
index_1.Helpers.info(`
|
|
36
|
+
Current folder (${this.cwd})
|
|
37
|
+
is not a git root folder, but nearest project with
|
|
38
|
+
git root has been found in: ${lib_2.chalk.bold(proj.genericName)}
|
|
39
|
+
|
|
40
|
+
`);
|
|
41
|
+
const useRoot = await index_1.Helpers.questionYesNo('Would you like to use this project ?');
|
|
42
|
+
if (useRoot) {
|
|
43
|
+
this.project = proj;
|
|
44
|
+
this.cwd = proj.location;
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
index_1.Helpers.error(`[${lib_1.config.frameworkName}] This is not git root project folder`, true, true);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
index_1.Helpers.error(`[${lib_1.config.frameworkName}] This folder is not project folder`, false, true);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region commands / hosts
|
|
59
|
+
hosts() {
|
|
60
|
+
index_1.Helpers.run(`code ${(0, lib_3.crossPlatformPath)(lib_5.UtilsNetwork.getEtcHostsPath())}`).sync();
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region commands / count commits
|
|
65
|
+
countCommits() {
|
|
66
|
+
console.log(index_1.Helpers.git.countCommits(this.cwd));
|
|
67
|
+
this._exit();
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region commands / remove submodules
|
|
71
|
+
removeSubmodules() {
|
|
72
|
+
index_1.Helpers.taskStarted('Removing submodules...');
|
|
73
|
+
for (const folderAbsPath of index_1.Helpers.foldersFrom(this.cwd, {
|
|
74
|
+
recursive: false,
|
|
75
|
+
})) {
|
|
76
|
+
if (index_1.Helpers.exists((0, lib_3.crossPlatformPath)([folderAbsPath, '.git']))) {
|
|
77
|
+
try {
|
|
78
|
+
index_1.Helpers.run(`git rm --cached ${lib_2.path.basename(folderAbsPath)}`).sync();
|
|
79
|
+
}
|
|
80
|
+
catch (error) { }
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
index_1.Helpers.taskDone('Done');
|
|
84
|
+
this._exit();
|
|
85
|
+
}
|
|
86
|
+
removeSubmodule() {
|
|
87
|
+
index_1.Helpers.taskStarted(`Removing submodules.. ${this.firstArg}`);
|
|
88
|
+
if (index_1.Helpers.exists((0, lib_3.crossPlatformPath)([this.cwd, this.firstArg || '', '.git']))) {
|
|
89
|
+
try {
|
|
90
|
+
index_1.Helpers.run(`git rm --cached ${this.firstArg}`).sync();
|
|
91
|
+
}
|
|
92
|
+
catch (error) { }
|
|
93
|
+
}
|
|
94
|
+
index_1.Helpers.taskDone('Done');
|
|
95
|
+
this._exit();
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region commands / set editor
|
|
99
|
+
async setEditor() {
|
|
100
|
+
await this.ins.configDb.selectCodeEditor();
|
|
101
|
+
this._exit();
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region commands / api update
|
|
105
|
+
async upapi() {
|
|
106
|
+
await this.apiUpdate();
|
|
107
|
+
}
|
|
108
|
+
async apiup() {
|
|
109
|
+
await this.apiUpdate();
|
|
110
|
+
}
|
|
111
|
+
async apiUpdate() {
|
|
112
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
index_1.Helpers.info('Updating & push project...');
|
|
116
|
+
try {
|
|
117
|
+
this.project.git.addAndCommit(`chore: api ${!!this.firstArg ? this.firstArg : 'update'}`);
|
|
118
|
+
}
|
|
119
|
+
catch (error) { }
|
|
120
|
+
await this.project.git.pushCurrentBranch({
|
|
121
|
+
askToRetry: true,
|
|
122
|
+
forcePushNoQuestion: true,
|
|
123
|
+
});
|
|
124
|
+
index_1.Helpers.info('Done');
|
|
125
|
+
this._exit();
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region commands / chore update
|
|
129
|
+
async cu() {
|
|
130
|
+
await this.update();
|
|
131
|
+
}
|
|
132
|
+
async choreUpdate() {
|
|
133
|
+
await this.update();
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region commands / color vscode
|
|
137
|
+
colorvscode() {
|
|
138
|
+
this.settingsVscode();
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region commands / settings vscode
|
|
142
|
+
/**
|
|
143
|
+
* Generate or update .vscode/settings.json file color settings
|
|
144
|
+
*/
|
|
145
|
+
settingsVscode() {
|
|
146
|
+
this.refreshVscodeColors();
|
|
147
|
+
}
|
|
148
|
+
refreshVscodeColors() {
|
|
149
|
+
this._regenerateVscodeSettingsColors();
|
|
150
|
+
this._exit();
|
|
151
|
+
}
|
|
152
|
+
_regenerateVscodeSettingsColors(overideBottomColor) {
|
|
153
|
+
index_1.UtilsVSCode.regenerateVsCodeSettingsColors(this.cwd, overideBottomColor);
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region commands / quick git update
|
|
157
|
+
/**
|
|
158
|
+
* quick git update push
|
|
159
|
+
*/
|
|
160
|
+
async update() {
|
|
161
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
index_1.Helpers.info('Updating & push project...');
|
|
165
|
+
try {
|
|
166
|
+
this.project.git.addAndCommit(`chore: ${!!this.firstArg ? this.firstArg : 'update'}`);
|
|
167
|
+
}
|
|
168
|
+
catch (error) { }
|
|
169
|
+
await this.project.git.pushCurrentBranch({
|
|
170
|
+
askToRetry: true,
|
|
171
|
+
forcePushNoQuestion: true,
|
|
172
|
+
});
|
|
173
|
+
index_1.Helpers.info('Done');
|
|
174
|
+
this._exit();
|
|
175
|
+
}
|
|
176
|
+
async updateProject(project, force = false) {
|
|
177
|
+
try {
|
|
178
|
+
await project.packageJson.bumpPatchVersion();
|
|
179
|
+
}
|
|
180
|
+
catch (error) { }
|
|
181
|
+
try {
|
|
182
|
+
project.git.addAndCommit(`chore: ${!!this.firstArg ? this.args.join(' ') : 'update'}`);
|
|
183
|
+
}
|
|
184
|
+
catch (error) { }
|
|
185
|
+
await project.git.pushCurrentBranch({
|
|
186
|
+
askToRetry: true,
|
|
187
|
+
forcePushNoQuestion: true,
|
|
188
|
+
force,
|
|
189
|
+
});
|
|
190
|
+
if (!project.isMonorepo) {
|
|
191
|
+
for (const child of project.children) {
|
|
192
|
+
if (child.git.isGitRoot) {
|
|
193
|
+
await this.updateProject(child, force);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
async deepUp(noExit = false) {
|
|
199
|
+
await this.deepUpdate(noExit);
|
|
200
|
+
}
|
|
201
|
+
async deepUpForce(noExit = false) {
|
|
202
|
+
await this.deepUpdateForce(noExit);
|
|
203
|
+
}
|
|
204
|
+
async deepUpdateForce(noExit = false) {
|
|
205
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
index_1.Helpers.info('(force) Deep updating & force pushing project with children...');
|
|
209
|
+
await this.updateProject(this.project, true);
|
|
210
|
+
index_1.Helpers.info('Done');
|
|
211
|
+
this._exit();
|
|
212
|
+
}
|
|
213
|
+
async deepUpdate(noExit = false) {
|
|
214
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
index_1.Helpers.info('Deep updating & pushing project with children...');
|
|
218
|
+
await this.updateProject(this.project);
|
|
219
|
+
index_1.Helpers.info('Done');
|
|
220
|
+
this._exit();
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Push update
|
|
224
|
+
*/
|
|
225
|
+
async up() {
|
|
226
|
+
await this.update();
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Push update
|
|
230
|
+
*/
|
|
231
|
+
async pu() {
|
|
232
|
+
await this.update();
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region commands / develop
|
|
236
|
+
async develop() {
|
|
237
|
+
// Helpers.clearConsole();
|
|
238
|
+
index_1.Helpers.taskStarted(`getting all projects...`);
|
|
239
|
+
const founded = ((await this.ins.projectsDb.getAllProjectsFromDB()) || [])
|
|
240
|
+
.filter(p => index_1.Helpers.exists(p.location))
|
|
241
|
+
.map(p => {
|
|
242
|
+
const proj = this.ins.From(p.location);
|
|
243
|
+
// console.log(`Proj for ${p.location} `, !!proj)
|
|
244
|
+
if (proj) {
|
|
245
|
+
return proj;
|
|
246
|
+
// return proj.embeddedProject ? proj.embeddedProject : proj;
|
|
247
|
+
}
|
|
248
|
+
// const nereset = this.ins.nearestTo(p.location);
|
|
249
|
+
// if (nereset) {
|
|
250
|
+
// const embeded = nereset.linkedProjects.find(l => crossPlatformPath([nereset.location, l.relativeClonePath]) === p.location);
|
|
251
|
+
// if (embeded) {
|
|
252
|
+
// return this.ins.From([nereset.location, embeded.relativeClonePath]);
|
|
253
|
+
// }
|
|
254
|
+
// }
|
|
255
|
+
})
|
|
256
|
+
.filter(p => !!p);
|
|
257
|
+
index_1.Helpers.taskDone(`found ${founded.length} projects...`);
|
|
258
|
+
index_1.Helpers.taskStarted(`searching for project...`);
|
|
259
|
+
// @ts-ignore
|
|
260
|
+
const results = index_1.Helpers.uniqArray([
|
|
261
|
+
...index_1.Helpers.arrays.fuzzy(this.args.join(' '), founded, p => p.name)
|
|
262
|
+
.results,
|
|
263
|
+
...index_1.Helpers.arrays.fuzzy(this.args.join(' '), founded, p => p.basename)
|
|
264
|
+
.results,
|
|
265
|
+
...index_1.Helpers.arrays.fuzzy(this.args.join(' '), founded, p => p.location)
|
|
266
|
+
.results,
|
|
267
|
+
], 'location');
|
|
268
|
+
index_1.Helpers.taskDone(`found ${results.length} projects...`);
|
|
269
|
+
const openInEditor = async (proj) => {
|
|
270
|
+
index_1.Helpers.taskStarted(`Getting code editor info...`);
|
|
271
|
+
const editor = await this.ins.configDb.getCodeEditor();
|
|
272
|
+
index_1.Helpers.taskDone(`Got code editor info...`);
|
|
273
|
+
const embededProject = proj.linkedProjects.embeddedProject;
|
|
274
|
+
const porjToOpen = embededProject || proj;
|
|
275
|
+
const locaitonFolderToOpen = porjToOpen.location;
|
|
276
|
+
index_1.Helpers.info('Initing and opening project...');
|
|
277
|
+
try {
|
|
278
|
+
await porjToOpen?.struct();
|
|
279
|
+
}
|
|
280
|
+
catch (error) { }
|
|
281
|
+
index_1.Helpers.run(`${editor} ${locaitonFolderToOpen}`).sync();
|
|
282
|
+
};
|
|
283
|
+
if (results.length === 1) {
|
|
284
|
+
await openInEditor(lib_2._.first(results));
|
|
285
|
+
}
|
|
286
|
+
else if (results.length === 0) {
|
|
287
|
+
index_1.Helpers.error(`No project found by name: "${this.args.join(' ')}"`, false, true);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
index_1.Helpers.info(`Opening console gui to select project...`);
|
|
291
|
+
const res = await index_1.Helpers.consoleGui.select('Select project to open', results.map(p => {
|
|
292
|
+
return {
|
|
293
|
+
name: p.genericName,
|
|
294
|
+
value: p.location,
|
|
295
|
+
};
|
|
296
|
+
}), true);
|
|
297
|
+
await openInEditor(this.ins.From(res));
|
|
298
|
+
}
|
|
299
|
+
this._exit();
|
|
300
|
+
}
|
|
301
|
+
async dev() {
|
|
302
|
+
return await this.develop();
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region commands / repulll
|
|
306
|
+
async repul() {
|
|
307
|
+
await this.repull();
|
|
308
|
+
}
|
|
309
|
+
async repull() {
|
|
310
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
await this.project.git.resetHard({ HEAD: 10 });
|
|
314
|
+
await this.pull();
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region commands / pull
|
|
318
|
+
async pul() {
|
|
319
|
+
await this.pull();
|
|
320
|
+
}
|
|
321
|
+
async pull() {
|
|
322
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
await this.project.git.pullProcess({
|
|
326
|
+
setOrigin: this.params['setOrigin'],
|
|
327
|
+
});
|
|
328
|
+
this._exit();
|
|
329
|
+
}
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region commands / pull all
|
|
332
|
+
async pullAll() {
|
|
333
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
await this.project.git.pullProcess({
|
|
337
|
+
setOrigin: this.params['setOrigin'],
|
|
338
|
+
});
|
|
339
|
+
this._exit();
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region commands / push and pull
|
|
343
|
+
async pp() {
|
|
344
|
+
const currentBranch = this.project.git.currentBranchName;
|
|
345
|
+
this.project
|
|
346
|
+
.run(`git push origin ${currentBranch} && git pull origin ${currentBranch}`)
|
|
347
|
+
.sync();
|
|
348
|
+
console.log('Done push and pull');
|
|
349
|
+
this._exit();
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region commands / reset
|
|
353
|
+
__resetInfo(branchToReset, withChildren) {
|
|
354
|
+
index_1.Helpers.info(`
|
|
355
|
+
|
|
356
|
+
YOU ARE RESETING ${withChildren ? 'EVERYTHING' : 'PROJECT'} ` +
|
|
357
|
+
`TO BRANCH: ${lib_2.chalk.bold(branchToReset)}
|
|
358
|
+
|
|
359
|
+
- curret project (${this.project.name})
|
|
360
|
+
${withChildren &&
|
|
361
|
+
lib_2._.isArray(this.project.children) &&
|
|
362
|
+
this.project.children.length > 0
|
|
363
|
+
? `- modules:\n${this.project.children
|
|
364
|
+
.map(c => `\t${c.basename} (${lib_2.chalk.yellow(c.name)})`)
|
|
365
|
+
.join('\n')}`
|
|
366
|
+
: ''}
|
|
367
|
+
`);
|
|
368
|
+
}
|
|
369
|
+
async fetch() {
|
|
370
|
+
try {
|
|
371
|
+
this.project?.git?.fetch();
|
|
372
|
+
}
|
|
373
|
+
catch (error) { }
|
|
374
|
+
this._exit();
|
|
375
|
+
}
|
|
376
|
+
async reset() {
|
|
377
|
+
// Helpers.clearConsole();
|
|
378
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
const parent = this.project.parent;
|
|
382
|
+
const branchFromLinkedProjectConfig = parent?.linkedProjects?.linkedProjects.find(l => {
|
|
383
|
+
return ((0, lib_3.crossPlatformPath)([parent.location, l.relativeClonePath]) ===
|
|
384
|
+
this.project.location);
|
|
385
|
+
})?.defaultBranch;
|
|
386
|
+
let overrideBranchToReset = this.firstArg ||
|
|
387
|
+
branchFromLinkedProjectConfig ||
|
|
388
|
+
this.project.core?.branch ||
|
|
389
|
+
this.project.git.getDefaultDevelopmentBranch() ||
|
|
390
|
+
this.project.git.currentBranchName;
|
|
391
|
+
if (this.project.core?.branch) {
|
|
392
|
+
index_1.Helpers.info(`
|
|
393
|
+
|
|
394
|
+
Core branch for project: ${this.project.core?.branch}
|
|
395
|
+
|
|
396
|
+
`);
|
|
397
|
+
}
|
|
398
|
+
const resetOnlyChildren = !!this.project.linkedProjects.getLinkedProjectsConfig().resetOnlyChildren;
|
|
399
|
+
const branches = index_1.Helpers.uniqArray([
|
|
400
|
+
...this.__filterBranchesByPattern(overrideBranchToReset),
|
|
401
|
+
...this.__filterBranchesByPattern(''),
|
|
402
|
+
]);
|
|
403
|
+
const resetChildren = this.project.git.resetIsRestingAlsoChildren();
|
|
404
|
+
if (resetChildren && resetOnlyChildren) {
|
|
405
|
+
index_1.Helpers.info(`Reseting only children...for defualt branches.`);
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
if (branches.length > 0) {
|
|
409
|
+
overrideBranchToReset = await this.__selectBrach(branches, 'reset');
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
index_1.Helpers.error(`No branch found by name "${overrideBranchToReset || this.firstArg}"`, false, true);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
overrideBranchToReset = overrideBranchToReset || '';
|
|
416
|
+
this.__resetInfo(overrideBranchToReset
|
|
417
|
+
? overrideBranchToReset
|
|
418
|
+
: this.project.git.getDefaultDevelopmentBranch(), resetChildren);
|
|
419
|
+
let resetProject = this.project;
|
|
420
|
+
if (this.project.git.isInsideGitRepo && !this.project.git.isGitRoot) {
|
|
421
|
+
index_1.Helpers.warn(`You are not in root of git repo...`, false);
|
|
422
|
+
resetProject = this.ins.nearestTo((0, lib_3.crossPlatformPath)([this.project.location, '..']), {
|
|
423
|
+
findGitRoot: true,
|
|
424
|
+
});
|
|
425
|
+
if (!(await index_1.Helpers.questionYesNo(`Would you like to reset root repo instead (project=${lib_2.chalk.bold.red(resetProject.genericName)}) ?`))) {
|
|
426
|
+
index_1.Helpers.error(`Aborted`, false, true);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const res = await index_1.Helpers.questionYesNo(`Reset hard and pull current project ` +
|
|
430
|
+
`${resetChildren && resetProject.linkedProjects.linkedProjects.length > 0 ? '(and children)' : ''} ?`);
|
|
431
|
+
if (res) {
|
|
432
|
+
await resetProject.resetProcess(overrideBranchToReset);
|
|
433
|
+
}
|
|
434
|
+
this._exit();
|
|
435
|
+
}
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region commands / soft
|
|
438
|
+
async soft() {
|
|
439
|
+
// TODO when aciton commit
|
|
440
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
const howManyCommits = Number(this.firstArg) || 1;
|
|
444
|
+
lib_2._.times(howManyCommits, n => {
|
|
445
|
+
console.log(`Resetting soft ${n + 1} commit "${this.project.git.lastCommitMessage()}"`);
|
|
446
|
+
this.project.git.resetSoftHEAD(1);
|
|
447
|
+
});
|
|
448
|
+
this._exit();
|
|
449
|
+
}
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region commands / rebase
|
|
452
|
+
async rebase() {
|
|
453
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
const currentBranch = this.project.git.currentBranchName;
|
|
457
|
+
let safeReset = 10;
|
|
458
|
+
let rebaseBranch = this.firstArg || this.project.git.getDefaultDevelopmentBranch();
|
|
459
|
+
const branches = this.__filterBranchesByPattern(rebaseBranch);
|
|
460
|
+
if (branches.length > 1) {
|
|
461
|
+
rebaseBranch = await this.__selectBrach(branches, 'rebase');
|
|
462
|
+
}
|
|
463
|
+
else if (branches.length === 1) {
|
|
464
|
+
rebaseBranch = lib_2._.first(branches);
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
index_1.Helpers.error(`No rebase branch found by name "${rebaseBranch}"`, false, true);
|
|
468
|
+
}
|
|
469
|
+
index_1.Helpers.info(`
|
|
470
|
+
You are rebasing current branch (${currentBranch}) to ${rebaseBranch}
|
|
471
|
+
|
|
472
|
+
Files from last commit:
|
|
473
|
+
|
|
474
|
+
"${lib_2.chalk.gray(await this.project.git.getCommitMessageByHash(this.project.git.lastCommitHash()))}"
|
|
475
|
+
(hash: ${lib_2.chalk.gray(this.project.git.lastCommitHash())})
|
|
476
|
+
|
|
477
|
+
are going to be applied after rebase.
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
`);
|
|
481
|
+
if (!(await lib_4.UtilsTerminal.confirm({
|
|
482
|
+
message: `Do you want to continue ?`,
|
|
483
|
+
defaultValue: true,
|
|
484
|
+
}))) {
|
|
485
|
+
this._exit();
|
|
486
|
+
}
|
|
487
|
+
try {
|
|
488
|
+
this.project.git.resetHard();
|
|
489
|
+
this.project.git.checkout(rebaseBranch);
|
|
490
|
+
this.project.git.resetHard({ HEAD: safeReset });
|
|
491
|
+
await this.project.git.pullCurrentBranch();
|
|
492
|
+
this.project.git.checkout(currentBranch);
|
|
493
|
+
this.project.git.resetSoftHEAD(1);
|
|
494
|
+
this.project.git.stageAllFiles();
|
|
495
|
+
this.project.git.stash();
|
|
496
|
+
this.project.git.resetHard({ HEAD: safeReset });
|
|
497
|
+
this.project.git.rebase(rebaseBranch);
|
|
498
|
+
this.project.git.stashApply();
|
|
499
|
+
await this.project.struct();
|
|
500
|
+
index_1.Helpers.info('REBASE DONE');
|
|
501
|
+
}
|
|
502
|
+
catch (error) {
|
|
503
|
+
index_1.Helpers.renderError(error);
|
|
504
|
+
try {
|
|
505
|
+
// dummy init to get back to previous vscode settings
|
|
506
|
+
await this.project.init();
|
|
507
|
+
}
|
|
508
|
+
catch (error) { }
|
|
509
|
+
index_1.Helpers.error('Not able to rebase', true, true);
|
|
510
|
+
}
|
|
511
|
+
this._exit();
|
|
512
|
+
}
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region commands / stash
|
|
515
|
+
/**
|
|
516
|
+
* stash only staged files
|
|
517
|
+
*/
|
|
518
|
+
async stash() {
|
|
519
|
+
index_1.Helpers.info(`Stashing only staged files...`);
|
|
520
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
this.project.git.stash({ onlyStaged: true });
|
|
524
|
+
this._exit();
|
|
525
|
+
}
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region commands / stash all
|
|
528
|
+
/**
|
|
529
|
+
* stash all files
|
|
530
|
+
*/
|
|
531
|
+
async stashAll() {
|
|
532
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
this.project.git.stageAllFiles();
|
|
536
|
+
this.project.git.stash();
|
|
537
|
+
this._exit();
|
|
538
|
+
}
|
|
539
|
+
//#endregion
|
|
540
|
+
//#region commands / push all origins
|
|
541
|
+
/**
|
|
542
|
+
* push force to all orgins
|
|
543
|
+
*/
|
|
544
|
+
async pushAllForce() {
|
|
545
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
await this.pushAll(true);
|
|
549
|
+
}
|
|
550
|
+
async pAllForce() {
|
|
551
|
+
await this.pushAllForce();
|
|
552
|
+
}
|
|
553
|
+
async pAllf() {
|
|
554
|
+
await this.pushAllForce();
|
|
555
|
+
}
|
|
556
|
+
async pAll() {
|
|
557
|
+
await this.pushAll();
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* push to all origins
|
|
561
|
+
*/
|
|
562
|
+
async pushAll(force = false) {
|
|
563
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
const remotes = this.project.git.allOrigins;
|
|
567
|
+
index_1.Helpers.info(`
|
|
568
|
+
|
|
569
|
+
Remotes for repo:
|
|
570
|
+
|
|
571
|
+
${remotes.map((r, i) => `${i + 1}. ${r.origin} ${r.url}`).join('\n')}
|
|
572
|
+
|
|
573
|
+
`);
|
|
574
|
+
for (let index = 0; index < remotes.length; index++) {
|
|
575
|
+
const { origin, url } = remotes[index];
|
|
576
|
+
index_1.Helpers.taskStarted(`Pushing to ${lib_2.chalk.bold(origin)} (${url})...`);
|
|
577
|
+
await this.push({ force, origin, noExit: true });
|
|
578
|
+
index_1.Helpers.taskDone(`Pushed to ${origin}`);
|
|
579
|
+
}
|
|
580
|
+
this._exit();
|
|
581
|
+
}
|
|
582
|
+
//#endregion
|
|
583
|
+
//#region commands / push force
|
|
584
|
+
async forcePush() {
|
|
585
|
+
await this.push({ force: true, typeofCommit: 'feature' });
|
|
586
|
+
}
|
|
587
|
+
async pushForce() {
|
|
588
|
+
await this.push({ force: true, typeofCommit: 'feature' });
|
|
589
|
+
}
|
|
590
|
+
//#endregion
|
|
591
|
+
//#region commands / commit
|
|
592
|
+
/**
|
|
593
|
+
* Commit and push this for single repo
|
|
594
|
+
*/
|
|
595
|
+
async commit(options = {}) {
|
|
596
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
await this.project.git.meltActionCommits();
|
|
600
|
+
await this.project.git.pushProcess({
|
|
601
|
+
...options,
|
|
602
|
+
forcePushNoQuestion: options.force,
|
|
603
|
+
args: this.args,
|
|
604
|
+
exitCallBack: () => {
|
|
605
|
+
this._exit();
|
|
606
|
+
},
|
|
607
|
+
skipChildren: true,
|
|
608
|
+
overrideCommitMessage: this.args.join(' '),
|
|
609
|
+
setOrigin: this.params['setOrigin'],
|
|
610
|
+
currentOrigin: this.project.git.originURL,
|
|
611
|
+
});
|
|
612
|
+
if (options.noExit) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
this._exit();
|
|
616
|
+
}
|
|
617
|
+
//#endregion
|
|
618
|
+
//#region commands / push
|
|
619
|
+
async _preventPushPullFromNotCorrectBranch() {
|
|
620
|
+
while (true) {
|
|
621
|
+
const devBranch = this.project.git.duringPushWarnIfProjectNotOnSpecyficDevBranch();
|
|
622
|
+
if (!!devBranch && devBranch !== this.project.git.currentBranchName) {
|
|
623
|
+
index_1.Helpers.warn(`
|
|
624
|
+
|
|
625
|
+
${this.project.genericName}
|
|
626
|
+
|
|
627
|
+
You are not on ${devBranch} branch. Please switch to this branch and try again
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
`, false);
|
|
632
|
+
const options = {
|
|
633
|
+
open: { name: 'Open in vscode' },
|
|
634
|
+
continue: { name: 'Continue (check again)' },
|
|
635
|
+
continueForce: { name: 'Continue (without checking)' },
|
|
636
|
+
exit: { name: 'Exit process' },
|
|
637
|
+
};
|
|
638
|
+
const res = await index_1.Helpers.selectChoicesAsk('What you want to do ?', Object.keys(options).map(k => {
|
|
639
|
+
return { name: options[k].name, value: k };
|
|
640
|
+
}));
|
|
641
|
+
if (res === 'continue') {
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
if (res === 'exit') {
|
|
645
|
+
this._exit();
|
|
646
|
+
}
|
|
647
|
+
if (res === 'open') {
|
|
648
|
+
this.project.run('code . ').sync();
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
if (res === 'continueForce') {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
async qPush() {
|
|
659
|
+
await this.quickPush();
|
|
660
|
+
}
|
|
661
|
+
async quickPush() {
|
|
662
|
+
await this.push({ skipLint: true });
|
|
663
|
+
}
|
|
664
|
+
async repushauto() {
|
|
665
|
+
await this.rePush(true);
|
|
666
|
+
}
|
|
667
|
+
async rePush(skipQuesion = false) {
|
|
668
|
+
const lastCommitMessage = this.project.git.lastCommitMessage();
|
|
669
|
+
this.project.git.resetSoftHEAD();
|
|
670
|
+
this.project.git.stageAllFiles();
|
|
671
|
+
this.project.git.commit(lastCommitMessage);
|
|
672
|
+
if (!skipQuesion) {
|
|
673
|
+
index_1.Helpers.info(`Last fixed commit:
|
|
674
|
+
${lastCommitMessage}
|
|
675
|
+
|
|
676
|
+
...`);
|
|
677
|
+
await lib_4.UtilsTerminal.pressAnyKeyToContinueAsync({
|
|
678
|
+
message: `Press any key to force push`,
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
await this.project.git.pushCurrentBranch({
|
|
682
|
+
forcePushNoQuestion: true,
|
|
683
|
+
force: true,
|
|
684
|
+
});
|
|
685
|
+
this._exit();
|
|
686
|
+
}
|
|
687
|
+
async push(options = {}) {
|
|
688
|
+
// console.log('args', this.args);
|
|
689
|
+
// console.log(`argsWithParams "${this.argsWithParams}"` );
|
|
690
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
await this._preventPushPullFromNotCorrectBranch();
|
|
694
|
+
if (!options.overrideCommitMessage &&
|
|
695
|
+
this.project.git.useBranchNameDirectlyAsCommitMessage()) {
|
|
696
|
+
options.overrideCommitMessage = (this.project.git.currentBranchName || '')
|
|
697
|
+
.split('-')
|
|
698
|
+
.join(' ');
|
|
699
|
+
const jiraNumbers = commit_data_1.CommitData.extractAndOrderJiraNumbers(this.project.git.currentBranchName) || [];
|
|
700
|
+
for (const jiraNum of jiraNumbers) {
|
|
701
|
+
options.overrideCommitMessage = options.overrideCommitMessage.replace(jiraNum.replace('-', ' '), jiraNum);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
await this.project.git.pushProcess({
|
|
705
|
+
...options,
|
|
706
|
+
forcePushNoQuestion: options.force,
|
|
707
|
+
args: options?.overrideCommitMessage
|
|
708
|
+
? (options?.overrideCommitMessage || '').split(' ')
|
|
709
|
+
: this.args,
|
|
710
|
+
exitCallBack: () => {
|
|
711
|
+
this._exit();
|
|
712
|
+
},
|
|
713
|
+
setOrigin: this.params['setOrigin'],
|
|
714
|
+
currentOrigin: this.project.git.originURL,
|
|
715
|
+
});
|
|
716
|
+
if (options.noExit) {
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
this._exit();
|
|
720
|
+
}
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region commands / melt
|
|
723
|
+
async melt() {
|
|
724
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
await this.meltUpdateCommits({ hideInfo: true });
|
|
728
|
+
this._exit();
|
|
729
|
+
}
|
|
730
|
+
//#endregion
|
|
731
|
+
//#region commands / melt
|
|
732
|
+
async meltUp() {
|
|
733
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
const alreadyProcessedOrigins = [];
|
|
737
|
+
const processProject = async (proj) => {
|
|
738
|
+
if (alreadyProcessedOrigins.includes(proj.git.originURL)) {
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
alreadyProcessedOrigins.push(proj.git.originURL);
|
|
742
|
+
index_1.Helpers.clearConsole();
|
|
743
|
+
await proj.git.resolveLastChanges({
|
|
744
|
+
tryAutomaticActionFirst: false,
|
|
745
|
+
projectNameAsOutputPrefix: this.project.location !== proj.location ? proj.name : void 0,
|
|
746
|
+
});
|
|
747
|
+
for (const child of proj.children) {
|
|
748
|
+
await processProject(child);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
await processProject(this.project);
|
|
752
|
+
index_1.Helpers.info('All projects are up to date with remote');
|
|
753
|
+
this._exit();
|
|
754
|
+
}
|
|
755
|
+
//#endregion
|
|
756
|
+
//#region commands / melt
|
|
757
|
+
async meltAll() {
|
|
758
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
await this.meltUpdateCommits({ hideInfo: true });
|
|
762
|
+
for (const child of this.project.children) {
|
|
763
|
+
await this.__meltCommitsFunc(child, { hideInfo: true });
|
|
764
|
+
}
|
|
765
|
+
this._exit();
|
|
766
|
+
}
|
|
767
|
+
//#endregion
|
|
768
|
+
//#region commands / melt updat ecommits
|
|
769
|
+
async __meltCommitsFunc(project, options) {
|
|
770
|
+
options = options || {};
|
|
771
|
+
const meltedCommits = project.git.meltActionCommits();
|
|
772
|
+
if (meltedCommits > 0) {
|
|
773
|
+
index_1.Helpers.logInfo(`${meltedCommits} has been soft reset (melted) in ${project.genericName}`);
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
index_1.Helpers.logInfo(`No commits to melt for project ${project.genericName}`);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
async meltUpdateCommits(options) {
|
|
780
|
+
await this.__meltCommitsFunc(this.project, options);
|
|
781
|
+
}
|
|
782
|
+
//#endregion
|
|
783
|
+
//#region commands / push feature
|
|
784
|
+
async pf() {
|
|
785
|
+
await this.pushFeature();
|
|
786
|
+
}
|
|
787
|
+
async pRel() {
|
|
788
|
+
await this.pushRelease();
|
|
789
|
+
}
|
|
790
|
+
async pRelease() {
|
|
791
|
+
await this.pushRelease();
|
|
792
|
+
}
|
|
793
|
+
async pushRelease() {
|
|
794
|
+
await this.meltUpdateCommits();
|
|
795
|
+
await this.push({
|
|
796
|
+
typeofCommit: 'release',
|
|
797
|
+
commitMessageRequired: true,
|
|
798
|
+
overrideCommitMessage: `${lib_2._.first(this.project.releaseProcess.getReleaseWords())} ` +
|
|
799
|
+
`version ${this.project.packageJson.version}`,
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
async mPush() {
|
|
803
|
+
await this.meltPush();
|
|
804
|
+
}
|
|
805
|
+
async fmPush() {
|
|
806
|
+
await this.forceMeltPush();
|
|
807
|
+
}
|
|
808
|
+
async mfPush() {
|
|
809
|
+
await this.forceMeltPush();
|
|
810
|
+
}
|
|
811
|
+
async mforcePush() {
|
|
812
|
+
await this.forceMeltPush();
|
|
813
|
+
}
|
|
814
|
+
async meltforcePush() {
|
|
815
|
+
await this.forceMeltPush();
|
|
816
|
+
}
|
|
817
|
+
async forceMeltPush() {
|
|
818
|
+
await this.meltPush(true);
|
|
819
|
+
}
|
|
820
|
+
async meltPush(force = false) {
|
|
821
|
+
await this.meltUpdateCommits();
|
|
822
|
+
await this.push({
|
|
823
|
+
mergeUpdateCommits: true,
|
|
824
|
+
force,
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
async pushFeature() {
|
|
828
|
+
await this.meltUpdateCommits();
|
|
829
|
+
await this.push({ typeofCommit: 'feature', commitMessageRequired: true });
|
|
830
|
+
}
|
|
831
|
+
//#endregion
|
|
832
|
+
//#region commands / push fix
|
|
833
|
+
async pushFix() {
|
|
834
|
+
await this.meltUpdateCommits();
|
|
835
|
+
await this.push({ typeofCommit: 'bugfix', commitMessageRequired: true });
|
|
836
|
+
}
|
|
837
|
+
pfix() {
|
|
838
|
+
this.pushFix();
|
|
839
|
+
}
|
|
840
|
+
//#endregion
|
|
841
|
+
//#region commands / push chore
|
|
842
|
+
async pushChore() {
|
|
843
|
+
await this.meltUpdateCommits();
|
|
844
|
+
await this.push({ typeofCommit: 'chore', commitMessageRequired: true });
|
|
845
|
+
}
|
|
846
|
+
async pc() {
|
|
847
|
+
await this.pushChore();
|
|
848
|
+
}
|
|
849
|
+
//#endregion
|
|
850
|
+
//#region commands / push refactor
|
|
851
|
+
async pushRefactor() {
|
|
852
|
+
await this.meltUpdateCommits();
|
|
853
|
+
await this.push({ typeofCommit: 'refactor', commitMessageRequired: true });
|
|
854
|
+
}
|
|
855
|
+
async pushref() {
|
|
856
|
+
await this.pushRefactor();
|
|
857
|
+
}
|
|
858
|
+
async pref() {
|
|
859
|
+
await this.pushRefactor();
|
|
860
|
+
}
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region commands / push style
|
|
863
|
+
async pushStyle() {
|
|
864
|
+
await this.meltUpdateCommits();
|
|
865
|
+
await this.push({ typeofCommit: 'style', commitMessageRequired: true });
|
|
866
|
+
}
|
|
867
|
+
async pstyl() {
|
|
868
|
+
await this.pushStyle();
|
|
869
|
+
}
|
|
870
|
+
async pstyle() {
|
|
871
|
+
await this.pushStyle();
|
|
872
|
+
}
|
|
873
|
+
//#endregion
|
|
874
|
+
//#region commands / push docs
|
|
875
|
+
async pushDocs() {
|
|
876
|
+
await this.meltUpdateCommits();
|
|
877
|
+
await this.push({ typeofCommit: 'docs', commitMessageRequired: true });
|
|
878
|
+
}
|
|
879
|
+
async pd() {
|
|
880
|
+
await this.pushDocs();
|
|
881
|
+
}
|
|
882
|
+
async pdocs() {
|
|
883
|
+
await this.pushDocs();
|
|
884
|
+
}
|
|
885
|
+
//#endregion
|
|
886
|
+
//#region commands / push test
|
|
887
|
+
async pushTest() {
|
|
888
|
+
await this.meltUpdateCommits();
|
|
889
|
+
await this.push({ typeofCommit: 'test', commitMessageRequired: true });
|
|
890
|
+
}
|
|
891
|
+
async pTest() {
|
|
892
|
+
await this.pushTest();
|
|
893
|
+
}
|
|
894
|
+
async pTests() {
|
|
895
|
+
await this.pushTest();
|
|
896
|
+
}
|
|
897
|
+
//#endregion
|
|
898
|
+
//#region commands / push perf
|
|
899
|
+
async pushPerf() {
|
|
900
|
+
await this.meltUpdateCommits();
|
|
901
|
+
await this.push({
|
|
902
|
+
typeofCommit: 'performance',
|
|
903
|
+
commitMessageRequired: true,
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
//#endregion
|
|
907
|
+
//#region commands / push ci
|
|
908
|
+
async pushCi() {
|
|
909
|
+
await this.meltUpdateCommits();
|
|
910
|
+
await this.push({ typeofCommit: 'ci', commitMessageRequired: true });
|
|
911
|
+
}
|
|
912
|
+
//#endregion
|
|
913
|
+
//#region commands / select branch
|
|
914
|
+
async branch() {
|
|
915
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
await this.project.struct();
|
|
919
|
+
try {
|
|
920
|
+
this.project.git.fetch();
|
|
921
|
+
}
|
|
922
|
+
catch (error) { }
|
|
923
|
+
let branchName = this.firstArg;
|
|
924
|
+
const branches = this.__filterBranchesByPattern(branchName);
|
|
925
|
+
if (branches.length > 0) {
|
|
926
|
+
branchName = await this.__selectBrach(branches, 'checkout');
|
|
927
|
+
}
|
|
928
|
+
else {
|
|
929
|
+
index_1.Helpers.error(`No branch found by name "${branchName}"`, false, true);
|
|
930
|
+
}
|
|
931
|
+
try {
|
|
932
|
+
this.project.git.stageAllFiles();
|
|
933
|
+
this.project.git.stash();
|
|
934
|
+
}
|
|
935
|
+
catch (error) { }
|
|
936
|
+
this.project.git.checkout(branchName);
|
|
937
|
+
this._exit();
|
|
938
|
+
}
|
|
939
|
+
//#endregion
|
|
940
|
+
//#region commands / push build
|
|
941
|
+
async pushBuild() {
|
|
942
|
+
await this.meltUpdateCommits();
|
|
943
|
+
await this.push({ typeofCommit: 'build', commitMessageRequired: true });
|
|
944
|
+
}
|
|
945
|
+
//#endregion
|
|
946
|
+
//#region commands / set origin
|
|
947
|
+
async SET_ORIGIN() {
|
|
948
|
+
let newOriginNameOrUrl = this.firstArg;
|
|
949
|
+
if (newOriginNameOrUrl === 'ssh') {
|
|
950
|
+
newOriginNameOrUrl = index_1.Helpers.git.originHttpToSsh(index_1.Helpers.git.getOriginURL(this.cwd));
|
|
951
|
+
}
|
|
952
|
+
if (newOriginNameOrUrl === 'http') {
|
|
953
|
+
newOriginNameOrUrl = index_1.Helpers.git.originSshToHttp(index_1.Helpers.git.getOriginURL(this.cwd));
|
|
954
|
+
}
|
|
955
|
+
if (index_1.Helpers.git.isInsideGitRepo(this.cwd)) {
|
|
956
|
+
index_1.Helpers.run(`git remote rm origin`, { cwd: this.cwd }).sync();
|
|
957
|
+
index_1.Helpers.run(`git remote add origin ${newOriginNameOrUrl} `, {
|
|
958
|
+
cwd: this.cwd,
|
|
959
|
+
}).sync();
|
|
960
|
+
index_1.Helpers.info(`Done`);
|
|
961
|
+
}
|
|
962
|
+
else {
|
|
963
|
+
index_1.Helpers.error(`This folder is not a git repo... `, false, true);
|
|
964
|
+
}
|
|
965
|
+
this._exit();
|
|
966
|
+
}
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region commands / rename origin
|
|
969
|
+
async RENAME_ORIGIN() {
|
|
970
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
const newOriginNameOrUrl = this.firstArg;
|
|
974
|
+
const proj = this.project;
|
|
975
|
+
if (proj && proj.git.isInsideGitRepo) {
|
|
976
|
+
proj.git.renameOrigin(newOriginNameOrUrl);
|
|
977
|
+
}
|
|
978
|
+
else {
|
|
979
|
+
index_1.Helpers.error(`This folder is not a git repo... `, false, true);
|
|
980
|
+
}
|
|
981
|
+
this._exit();
|
|
982
|
+
}
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region commands / last hash tag
|
|
985
|
+
async LAST_TAG_HASH() {
|
|
986
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
index_1.Helpers.info(this.project.git.lastTagHash());
|
|
990
|
+
this._exit();
|
|
991
|
+
}
|
|
992
|
+
//#endregion
|
|
993
|
+
//#region commands / last tag
|
|
994
|
+
async LAST_TAG() {
|
|
995
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
const proj = this.project;
|
|
999
|
+
index_1.Helpers.info(`
|
|
1000
|
+
|
|
1001
|
+
last tag: ${proj.git.lastTagVersionName}
|
|
1002
|
+
last tag hash: ${proj.git.lastTagHash()}
|
|
1003
|
+
|
|
1004
|
+
`);
|
|
1005
|
+
this._exit();
|
|
1006
|
+
}
|
|
1007
|
+
//#endregion
|
|
1008
|
+
//#region commands / check tag exists
|
|
1009
|
+
CHECK_TAG_EXISTS() {
|
|
1010
|
+
index_1.Helpers.info(`tag "${this.firstArg}" exits = ${index_1.Helpers.git.checkTagExists(this.firstArg)} `);
|
|
1011
|
+
this._exit();
|
|
1012
|
+
}
|
|
1013
|
+
//#endregion
|
|
1014
|
+
//#region commands / lint
|
|
1015
|
+
/**
|
|
1016
|
+
* TODO move somewhere
|
|
1017
|
+
*/
|
|
1018
|
+
async lint() {
|
|
1019
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
await this.project.lint();
|
|
1023
|
+
}
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region commands / version
|
|
1026
|
+
/**
|
|
1027
|
+
* TODO move somewhere
|
|
1028
|
+
*/
|
|
1029
|
+
async version() {
|
|
1030
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
console.log('Current project verison: ' + this.project.packageJson.version);
|
|
1034
|
+
this._exit();
|
|
1035
|
+
}
|
|
1036
|
+
//#endregion
|
|
1037
|
+
//#region commands / init
|
|
1038
|
+
/**
|
|
1039
|
+
* TODO move somewhere
|
|
1040
|
+
*/
|
|
1041
|
+
async init() {
|
|
1042
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
await this.project.init();
|
|
1046
|
+
this._exit();
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* init parent and first level children
|
|
1050
|
+
*/
|
|
1051
|
+
async initAll() {
|
|
1052
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
await this.project.init();
|
|
1056
|
+
for (const child of this.project.children) {
|
|
1057
|
+
await child.init();
|
|
1058
|
+
}
|
|
1059
|
+
this._exit();
|
|
1060
|
+
}
|
|
1061
|
+
//#endregion
|
|
1062
|
+
//#region commands / struct
|
|
1063
|
+
/**
|
|
1064
|
+
* TODO move somewhere
|
|
1065
|
+
*/
|
|
1066
|
+
async struct() {
|
|
1067
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
await this.project.struct();
|
|
1071
|
+
this._exit();
|
|
1072
|
+
}
|
|
1073
|
+
//#endregion
|
|
1074
|
+
//#region commands / info
|
|
1075
|
+
/**
|
|
1076
|
+
* TODO move somewhere
|
|
1077
|
+
*/
|
|
1078
|
+
async info() {
|
|
1079
|
+
if (!(await this.cwdIsProject({
|
|
1080
|
+
requireProjectWithGitRoot: false,
|
|
1081
|
+
}))) {
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
index_1.Helpers.clearConsole();
|
|
1085
|
+
index_1.Helpers.info(await this.project.info());
|
|
1086
|
+
await this.project.linkedProjects.saveAllLinkedProjectsToDB();
|
|
1087
|
+
this._exit();
|
|
1088
|
+
}
|
|
1089
|
+
//#endregion
|
|
1090
|
+
//#region commands / info
|
|
1091
|
+
async modified() {
|
|
1092
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
const proj = this.project;
|
|
1096
|
+
const libs = proj.children.filter(child => {
|
|
1097
|
+
process.stdout.write('.');
|
|
1098
|
+
return child.git.thereAreSomeUncommitedChangeExcept([
|
|
1099
|
+
lib_1.config.file.package_json,
|
|
1100
|
+
]);
|
|
1101
|
+
});
|
|
1102
|
+
console.log('\n' + index_1.Helpers.terminalLine());
|
|
1103
|
+
index_1.Helpers.info(libs.length
|
|
1104
|
+
? libs
|
|
1105
|
+
.map(c => `${lib_2.chalk.bold(c.name)} (${c.git.uncommitedFiles.map(p => lib_2.chalk.black(lib_2.path.basename(p))).join(', ')})`)
|
|
1106
|
+
.join('\n')
|
|
1107
|
+
: 'Nothing modifed');
|
|
1108
|
+
this._exit();
|
|
1109
|
+
}
|
|
1110
|
+
//#endregion
|
|
1111
|
+
//#region commands / update
|
|
1112
|
+
async refresh() {
|
|
1113
|
+
await this.project.refreshChildrenProjects({
|
|
1114
|
+
askUserAboutUpdate: true,
|
|
1115
|
+
});
|
|
1116
|
+
this._exit(0);
|
|
1117
|
+
}
|
|
1118
|
+
//#endregion
|
|
1119
|
+
//#region commands / changes
|
|
1120
|
+
async changes() {
|
|
1121
|
+
index_1.Helpers.info(await this.project.git.changesSummary());
|
|
1122
|
+
index_1.Helpers.terminalLine();
|
|
1123
|
+
for (const chil of this.project.children) {
|
|
1124
|
+
index_1.Helpers.info(await chil.git.changesSummary());
|
|
1125
|
+
}
|
|
1126
|
+
this._exit();
|
|
1127
|
+
}
|
|
1128
|
+
//#endregion
|
|
1129
|
+
//#region commands / all tags
|
|
1130
|
+
async allTags() {
|
|
1131
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
const allTags = await index_1.Helpers.git.getAllTags(this.cwd);
|
|
1135
|
+
console.log(allTags);
|
|
1136
|
+
this._exit();
|
|
1137
|
+
}
|
|
1138
|
+
//#endregion
|
|
1139
|
+
//#region commands / remove tag
|
|
1140
|
+
async removeTag() {
|
|
1141
|
+
let tagToRemove = this.firstArg;
|
|
1142
|
+
if (!tagToRemove) {
|
|
1143
|
+
const allTags = await index_1.Helpers.git.getAllTags(this.cwd);
|
|
1144
|
+
tagToRemove = await lib_4.UtilsTerminal.select({
|
|
1145
|
+
question: `Select tag to remove`,
|
|
1146
|
+
autocomplete: true,
|
|
1147
|
+
choices: allTags.map(t => {
|
|
1148
|
+
return { name: t, value: t };
|
|
1149
|
+
}),
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
index_1.Helpers.git.removeTag(this.cwd, tagToRemove);
|
|
1153
|
+
this._exit();
|
|
1154
|
+
}
|
|
1155
|
+
//#endregion
|
|
1156
|
+
//#region commands / branch name
|
|
1157
|
+
BRANCH_NAME() {
|
|
1158
|
+
console.log(`current branch name: "${index_1.Helpers.git.currentBranchName(process.cwd())}"`);
|
|
1159
|
+
this._exit();
|
|
1160
|
+
}
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region commands / remotes
|
|
1163
|
+
REMOTES() {
|
|
1164
|
+
console.log(index_1.Helpers.git.allOrigins(this.cwd));
|
|
1165
|
+
this._exit();
|
|
1166
|
+
}
|
|
1167
|
+
async SET_REMOTE_SSH() {
|
|
1168
|
+
await index_1.Helpers.git.changeRemoteFromHttpsToSSh(this.cwd);
|
|
1169
|
+
this._exit();
|
|
1170
|
+
}
|
|
1171
|
+
async SET_REMOTE_http() {
|
|
1172
|
+
await index_1.Helpers.git.changeRemoveFromSshToHttps(this.cwd);
|
|
1173
|
+
this._exit();
|
|
1174
|
+
}
|
|
1175
|
+
async SET_REMOTE_https() {
|
|
1176
|
+
await this.SET_REMOTE_http();
|
|
1177
|
+
}
|
|
1178
|
+
_resolveChildFromArg() {
|
|
1179
|
+
const { resolved: projFromArg, clearedCommand } = index_1.Helpers.cliTool.resolveItemFromArgsBegin(this.args, arg => this.ins.From([this.cwd, arg]));
|
|
1180
|
+
if (!!projFromArg) {
|
|
1181
|
+
this.args = clearedCommand.split(' ');
|
|
1182
|
+
this.cwd = projFromArg.location;
|
|
1183
|
+
this.project = projFromArg;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
origin() {
|
|
1187
|
+
this._resolveChildFromArg();
|
|
1188
|
+
console.log(index_1.Helpers.git.getOriginURL(this.cwd));
|
|
1189
|
+
this._exit();
|
|
1190
|
+
}
|
|
1191
|
+
remote() {
|
|
1192
|
+
console.log(index_1.Helpers.git.getOriginURL(this.cwd));
|
|
1193
|
+
this._exit();
|
|
1194
|
+
}
|
|
1195
|
+
originHttp() {
|
|
1196
|
+
console.log(index_1.Helpers.git.originSshToHttp(index_1.Helpers.git.getOriginURL(this.cwd)));
|
|
1197
|
+
this._exit();
|
|
1198
|
+
}
|
|
1199
|
+
originHttps() {
|
|
1200
|
+
console.log(index_1.Helpers.git.originSshToHttp(index_1.Helpers.git.getOriginURL(this.cwd)));
|
|
1201
|
+
this._exit();
|
|
1202
|
+
}
|
|
1203
|
+
originssh() {
|
|
1204
|
+
console.log(index_1.Helpers.git.originHttpToSsh(index_1.Helpers.git.getOriginURL(this.cwd)));
|
|
1205
|
+
this._exit();
|
|
1206
|
+
}
|
|
1207
|
+
origins() {
|
|
1208
|
+
this.REMOTES();
|
|
1209
|
+
}
|
|
1210
|
+
//#endregion
|
|
1211
|
+
//#region commands / git config
|
|
1212
|
+
gitConfig() {
|
|
1213
|
+
const root = index_1.Helpers.git.findGitRoot(this.cwd);
|
|
1214
|
+
index_1.Helpers.run(`code ${(0, lib_3.crossPlatformPath)([root, '.git', 'config'])}`).sync();
|
|
1215
|
+
this._exit();
|
|
1216
|
+
}
|
|
1217
|
+
//#endregion
|
|
1218
|
+
//#region commands / lastCommitHash
|
|
1219
|
+
LAST_COMMIT_HASH() {
|
|
1220
|
+
console.log(index_1.Helpers.git.lastCommitHash(this.cwd));
|
|
1221
|
+
this._exit();
|
|
1222
|
+
}
|
|
1223
|
+
//#endregion
|
|
1224
|
+
//#region commands / commit message by hash
|
|
1225
|
+
async COMMIT_MESSAGE_BY_HASH() {
|
|
1226
|
+
const hash = this.firstArg;
|
|
1227
|
+
console.log(await this.project.git.getCommitMessageByHash(hash));
|
|
1228
|
+
this._exit();
|
|
1229
|
+
}
|
|
1230
|
+
//#endregion
|
|
1231
|
+
//#region commands / last 5 commit hashes
|
|
1232
|
+
async LAST_5_COMMITS() {
|
|
1233
|
+
for (let index = 0; index < 5; index++) {
|
|
1234
|
+
const hash = await this.project.git.getCommitHashByIndex(index);
|
|
1235
|
+
console.log(hash);
|
|
1236
|
+
}
|
|
1237
|
+
this._exit();
|
|
1238
|
+
}
|
|
1239
|
+
//#endregion
|
|
1240
|
+
//#region commands / update deps from
|
|
1241
|
+
async updateDepsFrom() {
|
|
1242
|
+
let locations = this.args.join(' ').trim() === '' ? [] : this.args;
|
|
1243
|
+
if (lib_2._.isArray(locations)) {
|
|
1244
|
+
locations = locations.map(l => {
|
|
1245
|
+
if (lib_2.path.isAbsolute(l)) {
|
|
1246
|
+
return lib_2.path.resolve(l);
|
|
1247
|
+
}
|
|
1248
|
+
return lib_2.path.resolve(lib_2.path.join(this.cwd, l));
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
this.project.packageJson.updateDepsFrom(locations);
|
|
1252
|
+
this._exit();
|
|
1253
|
+
}
|
|
1254
|
+
//#endregion
|
|
1255
|
+
//#region is terminal supported
|
|
1256
|
+
isSupportedTaonTerminal() {
|
|
1257
|
+
console.log(`Terminal is supported: ${index_1.Helpers.isSupportedTaonTerminal}`);
|
|
1258
|
+
this._exit();
|
|
1259
|
+
}
|
|
1260
|
+
//#endregion
|
|
1261
|
+
//#region is terminal running inside cmd
|
|
1262
|
+
isRunningInWindowsCmd() {
|
|
1263
|
+
console.log(`Is terminal running insdie cmd.exe: ${lib_2.UtilsOs.isRunningInWindowsCmd()}`);
|
|
1264
|
+
this._exit();
|
|
1265
|
+
}
|
|
1266
|
+
//#endregion
|
|
1267
|
+
//#region is running inside powershell
|
|
1268
|
+
isRunningInWindowsPowerShell() {
|
|
1269
|
+
console.log(`Is terminal running insdie powershell: ${lib_2.UtilsOs.isRunningInWindowsPowerShell()}`);
|
|
1270
|
+
this._exit();
|
|
1271
|
+
}
|
|
1272
|
+
//#endregion
|
|
1273
|
+
//#region prox ext
|
|
1274
|
+
async INSTALL_PROJECT_EXTENSIONS() {
|
|
1275
|
+
await this.INSTALL_PROJ_EXT();
|
|
1276
|
+
}
|
|
1277
|
+
async INSTALL_PROJECT_EXT() {
|
|
1278
|
+
await this.INSTALL_PROJ_EXT();
|
|
1279
|
+
}
|
|
1280
|
+
async INS_PROJ_EXT() {
|
|
1281
|
+
await this.INSTALL_PROJ_EXT();
|
|
1282
|
+
}
|
|
1283
|
+
async INSTALL_PROJ_EXT() {
|
|
1284
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
this.project.vsCodeHelpers.recreateExtensions();
|
|
1288
|
+
const p = this.project.pathFor('.vscode/extensions.json');
|
|
1289
|
+
const extensions = index_1.Helpers.readJson(p, { recommendations: [] }, true);
|
|
1290
|
+
index_1.Helpers.clearConsole();
|
|
1291
|
+
await this.project.vsCodeHelpers.installExtensions(extensions.recommendations, true);
|
|
1292
|
+
this._exit();
|
|
1293
|
+
}
|
|
1294
|
+
//#endregion
|
|
1295
|
+
//#region proj db
|
|
1296
|
+
async projdb() {
|
|
1297
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: false }))) {
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
index_1.Helpers.info(`Projects db location:
|
|
1301
|
+
${this.project.linkedProjects.projectsDbLocation}
|
|
1302
|
+
|
|
1303
|
+
opening in vscode...
|
|
1304
|
+
|
|
1305
|
+
`);
|
|
1306
|
+
index_1.Helpers.run(`code ${this.project.linkedProjects.projectsDbLocation}`).sync();
|
|
1307
|
+
this._exit();
|
|
1308
|
+
}
|
|
1309
|
+
//#endregion
|
|
1310
|
+
//#region filter all project branches by pattern
|
|
1311
|
+
__filterBranchesByPattern(branchPatternOrBranchName) {
|
|
1312
|
+
const branches = index_1.Helpers.arrays.uniqArray(this.project.git.getBranchesNamesBy(branchPatternOrBranchName) ||
|
|
1313
|
+
this.project.getMainBranches());
|
|
1314
|
+
// console.log('branches', branches);
|
|
1315
|
+
return branches;
|
|
1316
|
+
}
|
|
1317
|
+
//#endregion
|
|
1318
|
+
//#region select branch from list of branches
|
|
1319
|
+
async __selectBrach(branches, task) {
|
|
1320
|
+
const actionWithoutChildren = task === 'reset' && !this.project.git.resetIsRestingAlsoChildren();
|
|
1321
|
+
const childrenMsg = actionWithoutChildren
|
|
1322
|
+
? '(without children)'
|
|
1323
|
+
: this.project.children.length == 0
|
|
1324
|
+
? '(no children in project)'
|
|
1325
|
+
: '(with children)';
|
|
1326
|
+
return await index_1.Helpers.autocompleteAsk(`Choose branch to ${task} in this project ${childrenMsg}: `, branches.map(b => {
|
|
1327
|
+
return { name: b, value: b };
|
|
1328
|
+
}));
|
|
1329
|
+
}
|
|
1330
|
+
//#endregion
|
|
1331
|
+
//#region commands / clone
|
|
1332
|
+
async clone() {
|
|
1333
|
+
let url = this.firstArg;
|
|
1334
|
+
const originType = this.params['setOrigin'];
|
|
1335
|
+
if (originType) {
|
|
1336
|
+
if (originType === 'ssh') {
|
|
1337
|
+
url = index_1.Helpers.git.originHttpToSsh(url);
|
|
1338
|
+
}
|
|
1339
|
+
if (originType === 'http') {
|
|
1340
|
+
url = index_1.Helpers.git.originSshToHttp(url);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
await index_1.Helpers.git.clone({
|
|
1344
|
+
url,
|
|
1345
|
+
cwd: this.cwd,
|
|
1346
|
+
});
|
|
1347
|
+
this._exit();
|
|
1348
|
+
}
|
|
1349
|
+
//#endregion
|
|
1350
|
+
//#region commands / gh temp
|
|
1351
|
+
async ghSave() {
|
|
1352
|
+
await new gh_temp_code_1.GhTempCode(this.cwd, this.project).init().save();
|
|
1353
|
+
this._exit();
|
|
1354
|
+
}
|
|
1355
|
+
async ghRestore() {
|
|
1356
|
+
await new gh_temp_code_1.GhTempCode(this.cwd, this.project).init().restore();
|
|
1357
|
+
this._exit();
|
|
1358
|
+
}
|
|
1359
|
+
//#endregion
|
|
1360
|
+
//#region commands / start cli service ports worker
|
|
1361
|
+
async ports() {
|
|
1362
|
+
await this.ins.portsWorker.terminalUI.infoScreen();
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* tnp startCliServicePortsWorker --restart
|
|
1366
|
+
*/
|
|
1367
|
+
async startCliServicePortsWorker() {
|
|
1368
|
+
await this.ins.portsWorker.cliStartProcedure(this.params);
|
|
1369
|
+
}
|
|
1370
|
+
//#endregion
|
|
1371
|
+
//#region commands / pause terminal
|
|
1372
|
+
pauseTerminal() {
|
|
1373
|
+
index_1.Helpers.pressKeyAndContinue();
|
|
1374
|
+
this._exit();
|
|
1375
|
+
}
|
|
1376
|
+
//#endregion
|
|
1377
|
+
//#region commands / pause terminal
|
|
1378
|
+
sleepTerminal() {
|
|
1379
|
+
index_1.Helpers.info(`Sleeping terminal for 1 second... before exit`);
|
|
1380
|
+
index_1.Helpers.sleep(1);
|
|
1381
|
+
this._exit();
|
|
1382
|
+
}
|
|
1383
|
+
//#endregion
|
|
1384
|
+
//#region commands / gh pages init
|
|
1385
|
+
async ghPagesInit() {
|
|
1386
|
+
await this.project.init();
|
|
1387
|
+
await this.project.staticPages.init(this.params['provider'] || 'github', !!this.params['full']);
|
|
1388
|
+
index_1.Helpers.run('code .', {
|
|
1389
|
+
cwd: this.project.staticPages.mainFolderAbsPath,
|
|
1390
|
+
}).sync();
|
|
1391
|
+
this._exit();
|
|
1392
|
+
}
|
|
1393
|
+
//#endregion
|
|
1394
|
+
//#region commands / is port in use
|
|
1395
|
+
async isPortInUse() {
|
|
1396
|
+
const port = parseInt(this.firstArg);
|
|
1397
|
+
console.log(`Port ${port} is in use: ${await lib_2.UtilsOs.isPortInUse(port)}`);
|
|
1398
|
+
this._exit();
|
|
1399
|
+
}
|
|
1400
|
+
//#endregion
|
|
1401
|
+
//#region commands / proc menu
|
|
1402
|
+
//#region @notForNpm
|
|
1403
|
+
async procMenu() {
|
|
1404
|
+
//#region @backendFunc
|
|
1405
|
+
const { BaseProcessManger, CommandConfig } = await Promise.resolve().then(() => require('./base-process-manager'));
|
|
1406
|
+
const ngBuildLibCommand = CommandConfig.from({
|
|
1407
|
+
name: 'TSC',
|
|
1408
|
+
cmd: 'node -e "let i = 0; setInterval(() => console.log(\'TSC lib Compiled success \' + (++i)), 1000)"',
|
|
1409
|
+
goToNextCommandWhenOutput: {
|
|
1410
|
+
stdoutContains: 'TSC lib Compiled success 5',
|
|
1411
|
+
},
|
|
1412
|
+
});
|
|
1413
|
+
const angularNormalNgServe = CommandConfig.from({
|
|
1414
|
+
shouldBeActiveOrAlreadyBuild: [ngBuildLibCommand],
|
|
1415
|
+
name: 'NG Normal',
|
|
1416
|
+
cmd: 'node -e "let i = 0; setInterval(() => console.log(\'NG NORMAL: Hello from ng --watch \' + (++i)), 1200)"',
|
|
1417
|
+
goToNextCommandWhenOutput: {
|
|
1418
|
+
stdoutContains: 'NG NORMAL: Hello from ng --watch 5',
|
|
1419
|
+
},
|
|
1420
|
+
});
|
|
1421
|
+
const angularWebsqlNgServe = CommandConfig.from({
|
|
1422
|
+
shouldBeActiveOrAlreadyBuild: [ngBuildLibCommand],
|
|
1423
|
+
name: 'NG websql',
|
|
1424
|
+
cmd: 'node -e "let i = 0; setInterval(() => console.log(\'NG WEBSQL: Hello from ng --watch \' + (++i)), 1200)"',
|
|
1425
|
+
goToNextCommandWhenOutput: {
|
|
1426
|
+
stdoutContains: 'NG WEBSQL: Hello from ng --watch 5',
|
|
1427
|
+
},
|
|
1428
|
+
});
|
|
1429
|
+
const electronNormalNgServe = CommandConfig.from({
|
|
1430
|
+
shouldBeActiveOrAlreadyBuild: [angularNormalNgServe],
|
|
1431
|
+
name: 'ELECTRON Normal',
|
|
1432
|
+
cmd: 'node -e "let i = 0; setInterval(() => console.log(\'ELECTRON Normal: Hello from electron \' + (++i)), 1500)"',
|
|
1433
|
+
});
|
|
1434
|
+
const updateAssets = CommandConfig.from({
|
|
1435
|
+
name: 'Update assets',
|
|
1436
|
+
cmd: 'node -e "let i = 0; setInterval(() => console.log(\'Updated assets \' + (++i)), 1000)"',
|
|
1437
|
+
});
|
|
1438
|
+
await new BaseProcessManger(this.project).init({
|
|
1439
|
+
title: 'What do you want to build?',
|
|
1440
|
+
header: 'Starting process selection...',
|
|
1441
|
+
watch: true,
|
|
1442
|
+
commands: [
|
|
1443
|
+
ngBuildLibCommand,
|
|
1444
|
+
angularNormalNgServe,
|
|
1445
|
+
angularWebsqlNgServe,
|
|
1446
|
+
electronNormalNgServe,
|
|
1447
|
+
updateAssets,
|
|
1448
|
+
],
|
|
1449
|
+
});
|
|
1450
|
+
//#endregion
|
|
1451
|
+
}
|
|
1452
|
+
//#endregion
|
|
1453
|
+
//#endregion
|
|
1454
|
+
//#region commands / proc info
|
|
1455
|
+
procInfo() {
|
|
1456
|
+
this.processInfo();
|
|
1457
|
+
}
|
|
1458
|
+
processInfo() {
|
|
1459
|
+
index_1.Helpers.info(`
|
|
1460
|
+
|
|
1461
|
+
Is running in CLI mode: ${lib_2.UtilsOs.isRunningInCliMode()}
|
|
1462
|
+
Is running in Mocha test: ${lib_2.UtilsOs.isRunningInMochaTest()}
|
|
1463
|
+
Is running in VSCode extension: ${lib_2.UtilsOs.isRunningInVscodeExtension()}
|
|
1464
|
+
Is running in Electron: ${lib_2.UtilsOs.isRunningInElectron()}
|
|
1465
|
+
Is running in Docker: ${lib_2.UtilsOs.isRunningInDocker()}
|
|
1466
|
+
Is running in WebSQL: ${lib_2.UtilsOs.isRunningInWebSQL()}
|
|
1467
|
+
Is running in WSL: ${lib_2.UtilsOs.isRunningInWsl()}
|
|
1468
|
+
Is running in Linux graphics capable environment: ${lib_2.UtilsOs.isRunningInLinuxGraphicsCapableEnvironment()}
|
|
1469
|
+
Is running in Node: ${lib_2.UtilsOs.isRunningInNode()}
|
|
1470
|
+
Is running in Browser: ${lib_2.UtilsOs.isRunningInBrowser()}
|
|
1471
|
+
|
|
1472
|
+
`);
|
|
1473
|
+
this._exit();
|
|
1474
|
+
}
|
|
1475
|
+
//#endregion
|
|
1476
|
+
//#region commands / last git tag
|
|
1477
|
+
lastGitTag() {
|
|
1478
|
+
console.log('Latest tag');
|
|
1479
|
+
console.log(this.project?.git.lastTagVersionName);
|
|
1480
|
+
this._exit();
|
|
1481
|
+
}
|
|
1482
|
+
//#endregion
|
|
1483
|
+
//#region commands / check ports
|
|
1484
|
+
async checkPort() {
|
|
1485
|
+
await this.checkPorts();
|
|
1486
|
+
}
|
|
1487
|
+
async checkPorts() {
|
|
1488
|
+
const ports = this.args
|
|
1489
|
+
.join(' ')
|
|
1490
|
+
.replace(/\,/, '')
|
|
1491
|
+
.split(' ')
|
|
1492
|
+
.map(p => {
|
|
1493
|
+
return parseInt(p);
|
|
1494
|
+
});
|
|
1495
|
+
console.log(`Checking ports: ${ports.join(', ')}`);
|
|
1496
|
+
if (ports.length === 0) {
|
|
1497
|
+
index_1.Helpers.error(`No ports provided`, false, true);
|
|
1498
|
+
}
|
|
1499
|
+
for (const port of ports) {
|
|
1500
|
+
const isPortInUse = await lib_2.UtilsOs.isPortInUse(port);
|
|
1501
|
+
console.log(`Port ${port} is in use: ${isPortInUse ? lib_2.chalk.red('YES') : lib_2.chalk.green('NO')}`);
|
|
1502
|
+
}
|
|
1503
|
+
this._exit();
|
|
1504
|
+
}
|
|
1505
|
+
//#endregion
|
|
1506
|
+
//#region commands / remove symlinks
|
|
1507
|
+
removeSymlinksDryRun() {
|
|
1508
|
+
index_1.Helpers.removeSymlinks(this.project.nodeModules.path, {
|
|
1509
|
+
dryRun: true,
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
//#endregion
|
|
1513
|
+
//#region commands / select java
|
|
1514
|
+
async selectJava() {
|
|
1515
|
+
const selectedJava = await index_1.UtilsJava.selectJdkVersion();
|
|
1516
|
+
index_1.UtilsJava.updateJavaHomePath(selectedJava);
|
|
1517
|
+
}
|
|
1518
|
+
//#endregion
|
|
1519
|
+
//#region commands / select tomcat
|
|
1520
|
+
async selectTomcat() {
|
|
1521
|
+
const selectedTomcat = await index_1.UtilsJava.selectTomcatVersion();
|
|
1522
|
+
index_1.UtilsJava.updateTomcatHomePath(selectedTomcat);
|
|
1523
|
+
this._exit();
|
|
1524
|
+
}
|
|
1525
|
+
//#endregion
|
|
1526
|
+
//#region commands / ln
|
|
1527
|
+
LN() {
|
|
1528
|
+
const [source, dest] = this.args;
|
|
1529
|
+
index_1.Helpers.createSymLink(source, dest);
|
|
1530
|
+
this._exit();
|
|
1531
|
+
}
|
|
1532
|
+
//#endregion
|
|
1533
|
+
//#region commands / copy
|
|
1534
|
+
copy() {
|
|
1535
|
+
let [from, to] = this.args;
|
|
1536
|
+
from = lib_2.path.isAbsolute(from)
|
|
1537
|
+
? (0, lib_3.crossPlatformPath)(from)
|
|
1538
|
+
: (0, lib_3.crossPlatformPath)([this.cwd, from]);
|
|
1539
|
+
to = lib_2.path.isAbsolute(to)
|
|
1540
|
+
? (0, lib_3.crossPlatformPath)(to)
|
|
1541
|
+
: (0, lib_3.crossPlatformPath)([this.cwd, to]);
|
|
1542
|
+
if (lib_2.path.basename(to) !== lib_2.path.basename(from)) {
|
|
1543
|
+
to = (0, lib_3.crossPlatformPath)([to, lib_2.path.basename(from)]);
|
|
1544
|
+
}
|
|
1545
|
+
index_1.Helpers.taskStarted(`Copying from ${from} to ${to}`);
|
|
1546
|
+
if (!index_1.Helpers.exists(from)) {
|
|
1547
|
+
index_1.Helpers.error(`Source file or folder "${from}" does not exist`, false, true);
|
|
1548
|
+
}
|
|
1549
|
+
if (index_1.Helpers.isFolder(from)) {
|
|
1550
|
+
index_1.Helpers.copy(from, to);
|
|
1551
|
+
}
|
|
1552
|
+
else {
|
|
1553
|
+
index_1.Helpers.copyFile(from, to);
|
|
1554
|
+
}
|
|
1555
|
+
index_1.Helpers.taskDone(`Copied`);
|
|
1556
|
+
this._exit();
|
|
1557
|
+
}
|
|
1558
|
+
//#endregion
|
|
1559
|
+
//#region commands / simulate domain
|
|
1560
|
+
async simulateDomain() {
|
|
1561
|
+
//#region @backendFunc
|
|
1562
|
+
// UtilsTerminal.clearConsole();
|
|
1563
|
+
await lib_5.UtilsNetwork.simulateDomain(this.args);
|
|
1564
|
+
this._exit();
|
|
1565
|
+
//#endregion
|
|
1566
|
+
}
|
|
1567
|
+
//#endregion
|
|
1568
|
+
//#region commands / preview
|
|
1569
|
+
async preview() {
|
|
1570
|
+
//#region handle preview of docker compose
|
|
1571
|
+
if ([lib_1.fileName.docker_compose_yml, lib_1.fileName.compose_yml].includes(lib_2.path.basename(this.firstArg))) {
|
|
1572
|
+
const simulateDomain = this.params['domain'] || this.params['domains'];
|
|
1573
|
+
const firstArg = lib_2.path.isAbsolute(this.firstArg)
|
|
1574
|
+
? this.firstArg
|
|
1575
|
+
: (0, lib_3.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
1576
|
+
const cwd = (0, lib_3.crossPlatformPath)(lib_2.path.dirname(firstArg));
|
|
1577
|
+
const composeFileName = lib_2.path.basename(firstArg);
|
|
1578
|
+
// import { spawn } from 'child_process';
|
|
1579
|
+
// import { readFileSync } from 'fs';
|
|
1580
|
+
// import { resolve } from 'path';
|
|
1581
|
+
const envPath = (0, lib_3.crossPlatformPath)([cwd, '.env']);
|
|
1582
|
+
const COMPOSE_PROJECT_NAME = index_1.UtilsDotFile.getValueFromDotFile(envPath, 'COMPOSE_PROJECT_NAME');
|
|
1583
|
+
const envContent = index_1.UtilsDotFile.getValuesKeysAsJsonObject(envPath) || {};
|
|
1584
|
+
const allDomains = lib_2.Utils.uniqArray(Object.keys(envContent)
|
|
1585
|
+
.filter(key => {
|
|
1586
|
+
return key.startsWith('FRONTEND_HOST_URL_');
|
|
1587
|
+
})
|
|
1588
|
+
.map(domainKey => envContent[domainKey]));
|
|
1589
|
+
if (simulateDomain && allDomains.length === 0) {
|
|
1590
|
+
index_1.Helpers.error(`No domains to simulate found in .env file.
|
|
1591
|
+
|
|
1592
|
+
Before release build update your
|
|
1593
|
+
|
|
1594
|
+
env.ts or env.angular-node-app.ENVIRONTMENT_NAME.ts with
|
|
1595
|
+
|
|
1596
|
+
${lib_2.chalk.bold(`website.useDomain = true;`)}
|
|
1597
|
+
|
|
1598
|
+
`, false, true);
|
|
1599
|
+
}
|
|
1600
|
+
const project = this.ins.From(cwd);
|
|
1601
|
+
await project.docker.updateDockerComposePorts();
|
|
1602
|
+
let closing = false;
|
|
1603
|
+
const triggerRevertChangesToEtcHosts = new rxjs_1.Subject();
|
|
1604
|
+
if (simulateDomain) {
|
|
1605
|
+
await lib_5.UtilsNetwork.simulateDomain(allDomains, {
|
|
1606
|
+
triggerRevertChangesToEtcHosts,
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
const child = this.project.docker.getDockerComposeUpExecChildProcess('up');
|
|
1610
|
+
console.log(`
|
|
1611
|
+
|
|
1612
|
+
|
|
1613
|
+
${lib_2.chalk.bold('PRESS ANY KEY TO STOP')} RUNNING CONTAINER(S) ` +
|
|
1614
|
+
`FOR ${lib_2.chalk.bold.underline(COMPOSE_PROJECT_NAME)}
|
|
1615
|
+
${simulateDomain ? `AND SIMULATING DOMAINS: ${allDomains.join(', ')} IN ETC/HOST` : ''}
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
`);
|
|
1619
|
+
process.stdin.setRawMode(true);
|
|
1620
|
+
process.stdin.resume();
|
|
1621
|
+
process.stdin.on('data', () => {
|
|
1622
|
+
if (closing) {
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1625
|
+
// If we are already closing, ignore further input
|
|
1626
|
+
closing = true;
|
|
1627
|
+
triggerRevertChangesToEtcHosts.next();
|
|
1628
|
+
console.log('Stopping container...');
|
|
1629
|
+
child.kill('SIGINT');
|
|
1630
|
+
console.log('Exiting...');
|
|
1631
|
+
const downProcess = this.project.docker.getDockerComposeUpExecChildProcess('down');
|
|
1632
|
+
downProcess.on('close', code => {
|
|
1633
|
+
console.log(`docker compose down exited with code ${code}`);
|
|
1634
|
+
process.exit(0);
|
|
1635
|
+
});
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
else {
|
|
1639
|
+
index_1.Helpers.error(`You can preview only docker-compose.yml or compose.yml files`, false, true);
|
|
1640
|
+
}
|
|
1641
|
+
//#endregion
|
|
1642
|
+
}
|
|
1643
|
+
//#endregion
|
|
1644
|
+
//#region commands / shorten
|
|
1645
|
+
/**
|
|
1646
|
+
* read huge file and display only lines with specyfic words
|
|
1647
|
+
*/
|
|
1648
|
+
async shorten() {
|
|
1649
|
+
//#region @backendFunc
|
|
1650
|
+
const rl = readline.createInterface({
|
|
1651
|
+
input: lib_2.fse.createReadStream(lib_2.path.isAbsolute(this.firstArg)
|
|
1652
|
+
? (0, lib_3.crossPlatformPath)(this.firstArg)
|
|
1653
|
+
: (0, lib_3.crossPlatformPath)([this.cwd, this.firstArg]), { encoding: 'utf8' }),
|
|
1654
|
+
crlfDelay: Infinity,
|
|
1655
|
+
});
|
|
1656
|
+
const keywords = this.args.splice(1);
|
|
1657
|
+
console.log(`Searching for keywords: ${keywords.join(', ')}`);
|
|
1658
|
+
for await (const line of rl) {
|
|
1659
|
+
if (keywords.some(word => line.includes(word))) {
|
|
1660
|
+
console.log(line);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
index_1.Helpers.info(`File processed`);
|
|
1664
|
+
this._exit();
|
|
1665
|
+
//#endregion
|
|
1666
|
+
}
|
|
1667
|
+
//#endregion
|
|
1668
|
+
//#region commands / dump packages versions
|
|
1669
|
+
dumpPackagesVersions() {
|
|
1670
|
+
const getData = (location) => {
|
|
1671
|
+
const version = index_1.Helpers.readValueFromJson((0, lib_3.crossPlatformPath)([location, lib_1.fileName.package_json]), 'version');
|
|
1672
|
+
const name = index_1.Helpers.readValueFromJson((0, lib_3.crossPlatformPath)([location, lib_1.fileName.package_json]), 'name');
|
|
1673
|
+
return { version, name };
|
|
1674
|
+
};
|
|
1675
|
+
const pkgs = index_1.Helpers.foldersFrom([this.cwd, lib_1.folderName.node_modules], {
|
|
1676
|
+
recursive: false,
|
|
1677
|
+
})
|
|
1678
|
+
.reduce((arr, c) => {
|
|
1679
|
+
if (lib_2.path.basename(c).startsWith('@')) {
|
|
1680
|
+
const newData = index_1.Helpers.foldersFrom([
|
|
1681
|
+
this.cwd,
|
|
1682
|
+
lib_1.folderName.node_modules,
|
|
1683
|
+
lib_2.path.basename(c),
|
|
1684
|
+
]).map(c2 => getData(c2));
|
|
1685
|
+
return arr.concat(newData);
|
|
1686
|
+
}
|
|
1687
|
+
return arr.concat(getData(c));
|
|
1688
|
+
}, [])
|
|
1689
|
+
.reduce((arr, c) => {
|
|
1690
|
+
return lib_2._.merge(arr, { [c.name]: c.version });
|
|
1691
|
+
}, {});
|
|
1692
|
+
index_1.Helpers.writeJson([this.cwd, 'packages-versions.json'], pkgs);
|
|
1693
|
+
index_1.Helpers.info(`packages-versions.json created with ${pkgs.length} packages`);
|
|
1694
|
+
this._exit();
|
|
1695
|
+
}
|
|
1696
|
+
//#endregion
|
|
1697
|
+
//#region commands / zip
|
|
1698
|
+
async zip() {
|
|
1699
|
+
let folderPath = (0, lib_3.crossPlatformPath)(this.firstArg);
|
|
1700
|
+
if (!lib_2.path.isAbsolute(folderPath)) {
|
|
1701
|
+
folderPath = (0, lib_3.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
1702
|
+
}
|
|
1703
|
+
if (!index_1.Helpers.exists(folderPath)) {
|
|
1704
|
+
index_1.Helpers.error(`File or folder to zip does not exist: ${folderPath}`, false, true);
|
|
1705
|
+
}
|
|
1706
|
+
if (!index_1.Helpers.isFolder(folderPath)) {
|
|
1707
|
+
index_1.Helpers.error(`You can zip only folders. Provided path is not a folder: ${folderPath}`, false, true);
|
|
1708
|
+
}
|
|
1709
|
+
const zipFilePath = await index_1.UtilsZip.zipDir(folderPath, {
|
|
1710
|
+
overrideIfZipFileExists: true,
|
|
1711
|
+
});
|
|
1712
|
+
index_1.Helpers.info(`Created zip file: ${zipFilePath}`);
|
|
1713
|
+
this._exit();
|
|
1714
|
+
}
|
|
1715
|
+
//#endregion
|
|
1716
|
+
//#region commands / unzip
|
|
1717
|
+
async unzip() {
|
|
1718
|
+
let folderPath = (0, lib_3.crossPlatformPath)(this.firstArg);
|
|
1719
|
+
if (!lib_2.path.isAbsolute(folderPath)) {
|
|
1720
|
+
folderPath = (0, lib_3.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
1721
|
+
}
|
|
1722
|
+
if (!index_1.Helpers.exists(folderPath)) {
|
|
1723
|
+
index_1.Helpers.error(`File or folder to zip does not exist: ${folderPath}`, false, true);
|
|
1724
|
+
}
|
|
1725
|
+
await index_1.UtilsZip.unzipArchive(folderPath);
|
|
1726
|
+
index_1.Helpers.info(`Created zip file: ${folderPath.replace('.zip', '')}`);
|
|
1727
|
+
this._exit();
|
|
1728
|
+
}
|
|
1729
|
+
//#endregion
|
|
1730
|
+
//#region commands / start transmission
|
|
1731
|
+
async startTransmission() {
|
|
1732
|
+
await this._removeTransmission();
|
|
1733
|
+
const userProfile = process.env.USERPROFILE || lib_2.os.homedir();
|
|
1734
|
+
const downloadsDir = lib_2.path.join(userProfile, 'Downloads');
|
|
1735
|
+
const configDir = lib_2.path.join(userProfile, 'transmission-config');
|
|
1736
|
+
await lib_2.UtilsProcess.killProcessOnPort(9091);
|
|
1737
|
+
const ctrl = await this.ins.portsWorker.getControllerForRemoteConnection();
|
|
1738
|
+
const data = await ctrl
|
|
1739
|
+
.registerAndAssignPort('transmission service for whole system')
|
|
1740
|
+
.request();
|
|
1741
|
+
const mainPort = data.body.json.port;
|
|
1742
|
+
index_1.Helpers.info(`Transmission will use port: ${mainPort}`);
|
|
1743
|
+
const args = [
|
|
1744
|
+
'run',
|
|
1745
|
+
'-d',
|
|
1746
|
+
'--name',
|
|
1747
|
+
'transmission',
|
|
1748
|
+
'-p',
|
|
1749
|
+
'9091:9091',
|
|
1750
|
+
'-p',
|
|
1751
|
+
`${mainPort}:${mainPort}`,
|
|
1752
|
+
'-p',
|
|
1753
|
+
`${mainPort}:${mainPort}/udp`,
|
|
1754
|
+
'-e',
|
|
1755
|
+
'TZ=Europe/Warsaw',
|
|
1756
|
+
'-e',
|
|
1757
|
+
`TRANSMISSION_PEER_PORT=${mainPort}`,
|
|
1758
|
+
'-v',
|
|
1759
|
+
`${downloadsDir}:/downloads`,
|
|
1760
|
+
'-v',
|
|
1761
|
+
`${configDir}:/config`,
|
|
1762
|
+
'--restart',
|
|
1763
|
+
'unless-stopped',
|
|
1764
|
+
'linuxserver/transmission:latest',
|
|
1765
|
+
];
|
|
1766
|
+
console.log('Running:', 'docker', args.join(' '));
|
|
1767
|
+
const child = lib_6.child_process.spawn('docker', args, { stdio: 'inherit' });
|
|
1768
|
+
child.on('exit', code => {
|
|
1769
|
+
if (code === 0) {
|
|
1770
|
+
console.log('✅ Transmission container started');
|
|
1771
|
+
console.log('➡ Open http://localhost:9091 in your browser');
|
|
1772
|
+
}
|
|
1773
|
+
else {
|
|
1774
|
+
console.error('❌ Docker exited with code', code);
|
|
1775
|
+
}
|
|
1776
|
+
this._exit();
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
async _removeTransmission() {
|
|
1780
|
+
return new Promise(resolve => {
|
|
1781
|
+
const args = ['rm', '-f', 'transmission'];
|
|
1782
|
+
console.log('Running:', 'docker', args.join(' '));
|
|
1783
|
+
const child = lib_6.child_process.spawn('docker', args, { stdio: 'inherit' });
|
|
1784
|
+
child.on('exit', code => {
|
|
1785
|
+
if (code === 0) {
|
|
1786
|
+
console.log('🗑️ Transmission container removed');
|
|
1787
|
+
}
|
|
1788
|
+
else {
|
|
1789
|
+
// In bash `2>$null` would silence errors; here we just log a note
|
|
1790
|
+
console.warn('⚠️ Could not remove container (maybe it doesn’t exist)');
|
|
1791
|
+
}
|
|
1792
|
+
resolve();
|
|
1793
|
+
});
|
|
1794
|
+
});
|
|
1795
|
+
}
|
|
1796
|
+
//#endregion
|
|
1797
|
+
// projectName|-|www-domgrubegozwierzaka-pl||--||releaseType|-|manual||--||version|-|0.0.8||--||
|
|
1798
|
+
// envName|-|__||--||envNumber|-|||--||targetArtifact|-|angular-node-app|||||-1759151320202-fa12e3a5cfdd
|
|
1799
|
+
extractStringMetadata() {
|
|
1800
|
+
const str = this.firstArg || '';
|
|
1801
|
+
console.log(str);
|
|
1802
|
+
console.log(index_1.FilePathMetaData.extractData(str));
|
|
1803
|
+
this._exit();
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
exports.BaseGlobalCommandLine = BaseGlobalCommandLine;
|
|
1807
|
+
//# sourceMappingURL=base-global-command-line.backend.js.map
|