tnp-helpers 19.0.5 → 19.0.7
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/fesm2022/tnp-helpers.mjs +2399 -234
- package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base/linked-project.d.ts +4 -1
- package/browser/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +6 -6
- package/browser/lib/build-info._auto-generated_.d.ts +2 -1
- package/browser/lib/helpers/helpers.d.ts +1 -0
- package/browser/lib/index.d.ts +3 -1
- package/browser/lib/old/execute-command.d.ts +12 -0
- package/browser/lib/old/helpers.d.ts +62 -0
- package/browser/lib/old/models.d.ts +81 -0
- package/browser/lib/utils.d.ts +42 -21
- package/browser/package.json +1 -1
- package/client/fesm2022/tnp-helpers.mjs +2399 -234
- package/client/fesm2022/tnp-helpers.mjs.map +1 -1
- package/client/lib/base/linked-project.d.ts +4 -1
- package/client/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +6 -6
- package/client/lib/build-info._auto-generated_.d.ts +2 -1
- package/client/lib/helpers/helpers.d.ts +1 -0
- package/client/lib/index.d.ts +3 -1
- package/client/lib/old/execute-command.d.ts +12 -0
- package/client/lib/old/helpers.d.ts +62 -0
- package/client/lib/old/models.d.ts +81 -0
- package/client/lib/utils.d.ts +42 -21
- package/client/package.json +1 -1
- package/lib/base/classes/base-bower-json.js +2 -2
- package/lib/base/classes/base-bower-json.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-config.js +2 -2
- package/lib/base/classes/base-cli-worker/base-cli-worker-config.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-controller.d.ts +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-controller.js +14 -14
- package/lib/base/classes/base-cli-worker/base-cli-worker-controller.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.js +10 -10
- package/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker.d.ts +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker.js +18 -18
- package/lib/base/classes/base-cli-worker/base-cli-worker.js.map +1 -1
- package/lib/base/classes/base-command-line-feature.backend.js +10 -10
- package/lib/base/classes/base-command-line-feature.backend.js.map +1 -1
- package/lib/base/classes/base-compiler-for-project.d.ts +1 -1
- package/lib/base/classes/base-compiler-for-project.js +13 -13
- package/lib/base/classes/base-compiler-for-project.js.map +1 -1
- package/lib/base/classes/base-db.js +7 -7
- package/lib/base/classes/base-db.js.map +1 -1
- package/lib/base/classes/base-debounce-compiler-for-project.d.ts +1 -1
- package/lib/base/classes/base-debounce-compiler-for-project.js +5 -5
- package/lib/base/classes/base-debounce-compiler-for-project.js.map +1 -1
- package/lib/base/classes/base-git.js +26 -25
- package/lib/base/classes/base-git.js.map +1 -1
- package/lib/base/classes/base-global-command-line.backend.d.ts +3 -1
- package/lib/base/classes/base-global-command-line.backend.js +60 -49
- package/lib/base/classes/base-global-command-line.backend.js.map +1 -1
- package/lib/base/classes/base-ignore-hide.js +2 -2
- package/lib/base/classes/base-ignore-hide.js.map +1 -1
- package/lib/base/classes/base-json-file-reader.js +24 -24
- package/lib/base/classes/base-json-file-reader.js.map +1 -1
- package/lib/base/classes/base-library-build.js +52 -52
- package/lib/base/classes/base-library-build.js.map +1 -1
- package/lib/base/classes/base-linked-projects.js +23 -23
- package/lib/base/classes/base-linked-projects.js.map +1 -1
- package/lib/base/classes/base-node-modules.js +37 -37
- package/lib/base/classes/base-node-modules.js.map +1 -1
- package/lib/base/classes/base-npm-helpers.d.ts +1 -1
- package/lib/base/classes/base-npm-helpers.js +14 -14
- package/lib/base/classes/base-npm-helpers.js.map +1 -1
- package/lib/base/classes/base-package-json.d.ts +1 -1
- package/lib/base/classes/base-package-json.js +27 -27
- package/lib/base/classes/base-package-json.js.map +1 -1
- package/lib/base/classes/base-powershell.js +7 -2
- package/lib/base/classes/base-powershell.js.map +1 -1
- package/lib/base/classes/base-process-manager.js +8 -8
- package/lib/base/classes/base-process-manager.js.map +1 -1
- package/lib/base/classes/base-project-resolver.js +34 -33
- package/lib/base/classes/base-project-resolver.js.map +1 -1
- package/lib/base/classes/base-project.d.ts +1 -1
- package/lib/base/classes/base-project.js +62 -62
- package/lib/base/classes/base-project.js.map +1 -1
- package/lib/base/classes/base-quick-fixes.js +9 -9
- package/lib/base/classes/base-quick-fixes.js.map +1 -1
- package/lib/base/classes/base-release-process.d.ts +1 -1
- package/lib/base/classes/base-release-process.js +19 -19
- package/lib/base/classes/base-release-process.js.map +1 -1
- package/lib/base/classes/base-start-config.backend.js +13 -13
- package/lib/base/classes/base-start-config.backend.js.map +1 -1
- package/lib/base/classes/base-static-pages.js +6 -6
- package/lib/base/classes/base-static-pages.js.map +1 -1
- package/lib/base/classes/base-vscode.js +31 -24
- package/lib/base/classes/base-vscode.js.map +1 -1
- package/lib/base/commit-data.js +25 -25
- package/lib/base/commit-data.js.map +1 -1
- package/lib/base/core-project.d.ts +1 -1
- package/lib/base/core-project.js +9 -9
- package/lib/base/core-project.js.map +1 -1
- package/lib/base/gh-temp-code.js +6 -6
- package/lib/base/gh-temp-code.js.map +1 -1
- package/lib/base/index-rebuilder.backend.js +1 -1
- package/lib/base/index-rebuilder.backend.js.map +1 -1
- package/lib/base/linked-project.d.ts +4 -1
- package/lib/base/linked-project.js +18 -9
- package/lib/base/linked-project.js.map +1 -1
- package/lib/base/tcp-udp-ports/not-assignable-port.entity.js +2 -2
- package/lib/base/tcp-udp-ports/ports.controller.d.ts +1 -1
- package/lib/base/tcp-udp-ports/ports.controller.js +21 -21
- package/lib/base/tcp-udp-ports/ports.controller.js.map +1 -1
- package/lib/base/tcp-udp-ports/ports.entity.d.ts +1 -1
- package/lib/base/tcp-udp-ports/ports.entity.js +10 -10
- package/lib/base/tcp-udp-ports/ports.entity.js.map +1 -1
- package/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +9 -9
- package/lib/base/tcp-udp-ports/tcp-udp-ports.context.js +9 -9
- package/lib/base/tcp-udp-ports/tcp-udp-ports.context.js.map +1 -1
- package/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.js +18 -18
- package/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +2 -1
- package/lib/build-info._auto-generated_.js +3 -2
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/helpers/for-backend/helpers-cli-tool.backend.js +40 -40
- package/lib/helpers/for-backend/helpers-cli-tool.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-console-gui.js +2 -2
- package/lib/helpers/for-backend/helpers-console-gui.js.map +1 -1
- package/lib/helpers/for-backend/helpers-dependencies.backend.js +2 -2
- package/lib/helpers/for-backend/helpers-dependencies.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-file-folders.js +131 -131
- package/lib/helpers/for-backend/helpers-file-folders.js.map +1 -1
- package/lib/helpers/for-backend/helpers-git.backend.js +120 -106
- package/lib/helpers/for-backend/helpers-git.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-network.backend.js +2 -3
- package/lib/helpers/for-backend/helpers-network.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-npm.backend.js +2 -2
- package/lib/helpers/for-backend/helpers-npm.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-path.backend.js +6 -6
- package/lib/helpers/for-backend/helpers-path.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-process.d.ts +1 -1
- package/lib/helpers/for-backend/helpers-process.js +41 -41
- package/lib/helpers/for-backend/helpers-process.js.map +1 -1
- package/lib/helpers/for-backend/helpers-system-terminal.backend.js +2 -2
- package/lib/helpers/for-backend/helpers-system-terminal.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-vscode.backend.d.ts +1 -1
- package/lib/helpers/for-backend/helpers-vscode.backend.js +2 -2
- package/lib/helpers/for-backend/helpers-vscode.backend.js.map +1 -1
- package/lib/helpers/for-browser/angular.helper.js +2 -2
- package/lib/helpers/helpers-array-obj.js +10 -10
- package/lib/helpers/helpers-array-obj.js.map +1 -1
- package/lib/helpers/helpers-json5.backend.js +6 -6
- package/lib/helpers/helpers-json5.backend.js.map +1 -1
- package/lib/helpers/helpers-numbers.js.map +1 -1
- package/lib/helpers/helpers-strings-regexes.js +5 -5
- package/lib/helpers/helpers-strings-regexes.js.map +1 -1
- package/lib/helpers/helpers-strings.js +3 -3
- package/lib/helpers/helpers-strings.js.map +1 -1
- package/lib/helpers/helpers.d.ts +1 -0
- package/lib/helpers/helpers.js +42 -30
- package/lib/helpers/helpers.js.map +1 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +1 -1
- package/lib/lowdb/adapters/node/TextFile.js +2 -2
- package/lib/lowdb/adapters/node/TextFile.js.map +1 -1
- package/lib/models.d.ts +1 -1
- package/lib/models.js +8 -8
- package/lib/models.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/old/execute-command.js +20 -8
- package/lib/old/execute-command.js.map +1 -1
- package/lib/old/helpers.js +2 -2
- package/lib/old/helpers.js.map +1 -1
- package/lib/old/models.d.ts +1 -1
- package/lib/utils.d.ts +42 -21
- package/lib/utils.js +340 -54
- package/lib/utils.js.map +1 -1
- package/lib/validators/validators-firedev.js +6 -6
- package/lib/validators/validators-firedev.js.map +1 -1
- package/lib/validators/validators-git.js.map +1 -1
- package/lib/validators/validators-network.js +2 -2
- package/lib/validators/validators-network.js.map +1 -1
- package/migrations/1736198527297_init.d.ts +1 -1
- package/migrations/1736198527297_init.js +5 -5
- package/migrations/1736198527297_init.js.map +1 -1
- package/migrations/1736199486472_addingNotAssignablePorts.d.ts +1 -1
- package/migrations/1736199486472_addingNotAssignablePorts.js +8 -8
- package/migrations/1736199486472_addingNotAssignablePorts.js.map +1 -1
- package/migrations/1736454437350_addFreePorts.d.ts +1 -1
- package/migrations/1736454437350_addFreePorts.js +11 -11
- package/migrations/1736454437350_addFreePorts.js.map +1 -1
- package/package.json +1 -1
- package/tmp-environment.json +4 -4
- package/websql/fesm2022/tnp-helpers.mjs +2436 -238
- package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base/linked-project.d.ts +4 -1
- package/websql/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +6 -6
- package/websql/lib/build-info._auto-generated_.d.ts +2 -1
- package/websql/lib/helpers/helpers.d.ts +1 -0
- package/websql/lib/index.d.ts +3 -1
- package/websql/lib/old/execute-command.d.ts +12 -0
- package/websql/lib/old/helpers.d.ts +62 -0
- package/websql/lib/old/models.d.ts +81 -0
- package/websql/lib/utils.d.ts +42 -21
- package/websql/package.json +1 -1
|
@@ -4,9 +4,9 @@ exports.HelpersGit = void 0;
|
|
|
4
4
|
//#region imports
|
|
5
5
|
const ini = require("ini");
|
|
6
6
|
const simple_git_1 = require("simple-git");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
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
10
|
const index_1 = require("../../index");
|
|
11
11
|
//#endregion
|
|
12
12
|
class HelpersGit {
|
|
@@ -28,7 +28,7 @@ class HelpersGit {
|
|
|
28
28
|
// const lastCommitHash = this.project.git.lastCommitHash();
|
|
29
29
|
// this.project.packageJson.setBuildHash(lastCommitHash);
|
|
30
30
|
if (autoReleaseUsingConfig ||
|
|
31
|
-
(await
|
|
31
|
+
(await lib_3.UtilsTerminal.confirm({
|
|
32
32
|
message: `Push changes to git repo ?`,
|
|
33
33
|
defaultValue: true,
|
|
34
34
|
}))) {
|
|
@@ -62,11 +62,11 @@ class HelpersGit {
|
|
|
62
62
|
removeTag(cwd, tagName) {
|
|
63
63
|
//#region @backendFunc
|
|
64
64
|
try {
|
|
65
|
-
|
|
65
|
+
lib_2.child_process.execSync(`git tag -d ${tagName}`, { cwd });
|
|
66
66
|
index_1.Helpers.info(`Tag "${tagName}" removed successfully.`);
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
|
-
index_1.Helpers.warn(`[${
|
|
69
|
+
index_1.Helpers.warn(`[${lib_1.config.frameworkName}-helpers] not able to remove tag ${tagName} in ${cwd}`, true);
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
72
|
}
|
|
@@ -81,7 +81,7 @@ class HelpersGit {
|
|
|
81
81
|
index_1.Helpers.log('[taon-helpers][lastcommithash] ' + cwd, 1);
|
|
82
82
|
try {
|
|
83
83
|
let hash = this.isInsideGitRepo(cwd) &&
|
|
84
|
-
|
|
84
|
+
lib_2.child_process
|
|
85
85
|
.execSync(`git log -1 --format="%H"`, { cwd })
|
|
86
86
|
.toString()
|
|
87
87
|
.trim();
|
|
@@ -99,7 +99,7 @@ class HelpersGit {
|
|
|
99
99
|
index_1.Helpers.log('[penultimateCommitHash] ' + cwd, 1);
|
|
100
100
|
try {
|
|
101
101
|
let hash = this.isInsideGitRepo(cwd) &&
|
|
102
|
-
|
|
102
|
+
lib_2.child_process
|
|
103
103
|
.execSync(`git log -2 --format="%H"`, { cwd })
|
|
104
104
|
.toString()
|
|
105
105
|
.trim();
|
|
@@ -130,7 +130,7 @@ class HelpersGit {
|
|
|
130
130
|
return void 0;
|
|
131
131
|
}
|
|
132
132
|
try {
|
|
133
|
-
if (process.platform === 'win32' &&
|
|
133
|
+
if (process.platform === 'win32' && lib_3.UtilsOs.isRunningInWindowsCmd()) {
|
|
134
134
|
let tagOnCMd = index_1.Helpers.commnadOutputAsString(`for /f %i in ('git rev-list --tags --max-count=1') do @git describe --tags %i`);
|
|
135
135
|
console.log({ tagOnCMd });
|
|
136
136
|
tagOnCMd = tagOnCMd.toString().trim();
|
|
@@ -187,10 +187,10 @@ class HelpersGit {
|
|
|
187
187
|
// })
|
|
188
188
|
try {
|
|
189
189
|
if (process.platform === 'win32') {
|
|
190
|
-
tagName =
|
|
190
|
+
tagName = lib_2.child_process.execSync(cm1, { cwd }).toString().trim();
|
|
191
191
|
}
|
|
192
192
|
else {
|
|
193
|
-
tagName =
|
|
193
|
+
tagName = lib_2.child_process.execSync(cm2, { cwd }).toString().trim();
|
|
194
194
|
}
|
|
195
195
|
if (tagName) {
|
|
196
196
|
return tagName;
|
|
@@ -199,10 +199,10 @@ class HelpersGit {
|
|
|
199
199
|
catch (e) { }
|
|
200
200
|
try {
|
|
201
201
|
if (process.platform === 'win32') {
|
|
202
|
-
tagName =
|
|
202
|
+
tagName = lib_2.child_process.execSync(cm3, { cwd }).toString().trim();
|
|
203
203
|
}
|
|
204
204
|
else {
|
|
205
|
-
tagName =
|
|
205
|
+
tagName = lib_2.child_process.execSync(cm4, { cwd }).toString().trim();
|
|
206
206
|
}
|
|
207
207
|
if (tagName) {
|
|
208
208
|
return tagName;
|
|
@@ -250,7 +250,7 @@ class HelpersGit {
|
|
|
250
250
|
const fixFolders = (files) => {
|
|
251
251
|
files = files.reduce((acc, curr) => {
|
|
252
252
|
const newFiles = [curr];
|
|
253
|
-
const fullPath = (0,
|
|
253
|
+
const fullPath = (0, lib_2.crossPlatformPath)([cwd, curr]);
|
|
254
254
|
if (index_1.Helpers.isFolder(fullPath)) {
|
|
255
255
|
newFiles.push(...index_1.Helpers.filesFrom(fullPath, true).map(f => f.replace(cwd + '/', '')));
|
|
256
256
|
}
|
|
@@ -280,7 +280,7 @@ class HelpersGit {
|
|
|
280
280
|
if (!tag) {
|
|
281
281
|
return null;
|
|
282
282
|
}
|
|
283
|
-
let hash =
|
|
283
|
+
let hash = lib_2.child_process
|
|
284
284
|
.execSync(`git log -1 --format=format:"%H" ${tag}`, { cwd })
|
|
285
285
|
.toString()
|
|
286
286
|
.trim();
|
|
@@ -298,7 +298,7 @@ class HelpersGit {
|
|
|
298
298
|
index_1.Helpers.log('[taon-helpers][lastCommitDate] ' + cwd, 1);
|
|
299
299
|
try {
|
|
300
300
|
let unixTimestamp = this.isInsideGitRepo(cwd) &&
|
|
301
|
-
|
|
301
|
+
lib_2.child_process
|
|
302
302
|
.execSync(`git log -1 --pretty=format:%ct`, { cwd })
|
|
303
303
|
.toString()
|
|
304
304
|
.trim();
|
|
@@ -393,7 +393,7 @@ class HelpersGit {
|
|
|
393
393
|
lastCommitMessage(cwd) {
|
|
394
394
|
index_1.Helpers.log('[taon-helpers][lastCommitMessage] ' + cwd, 1);
|
|
395
395
|
try {
|
|
396
|
-
let unixTimestamp =
|
|
396
|
+
let unixTimestamp = lib_2.child_process
|
|
397
397
|
.execSync(`git log -1 --pretty=%B`, { cwd })
|
|
398
398
|
.toString()
|
|
399
399
|
.trim();
|
|
@@ -445,7 +445,7 @@ class HelpersGit {
|
|
|
445
445
|
// child_process.execSync('git rev-parse HEAD', { cwd, stdio: ['pipe',] }).toString().trim()
|
|
446
446
|
}
|
|
447
447
|
else {
|
|
448
|
-
|
|
448
|
+
lib_2.child_process
|
|
449
449
|
.execSync('git rev-parse HEAD &> /dev/null', { cwd })
|
|
450
450
|
.toString()
|
|
451
451
|
.trim();
|
|
@@ -461,7 +461,7 @@ class HelpersGit {
|
|
|
461
461
|
isInMergeProcess(cwd) {
|
|
462
462
|
index_1.Helpers.log('[taon-helpers][hasAnyCommits] ' + cwd, 1);
|
|
463
463
|
try {
|
|
464
|
-
const message = (
|
|
464
|
+
const message = (lib_2.child_process.execSync(`git status`, { cwd }) || '')
|
|
465
465
|
.toString()
|
|
466
466
|
.trim();
|
|
467
467
|
return message.search('Unmerged paths:') !== -1;
|
|
@@ -476,7 +476,7 @@ class HelpersGit {
|
|
|
476
476
|
index_1.Helpers.log('[taon-helpers][getBranchesNames] ' + cwd, 1);
|
|
477
477
|
try {
|
|
478
478
|
let branchPattern = pattern;
|
|
479
|
-
if (
|
|
479
|
+
if (lib_2._.isString(pattern)) {
|
|
480
480
|
branchPattern = new RegExp(pattern.replace(/[^a-zA-Z0-9]+/g, '.*'));
|
|
481
481
|
}
|
|
482
482
|
const command = `git branch -a`;
|
|
@@ -495,7 +495,7 @@ class HelpersGit {
|
|
|
495
495
|
return false;
|
|
496
496
|
}
|
|
497
497
|
// console.log('testing: ' + l)
|
|
498
|
-
if (
|
|
498
|
+
if (lib_2._.isRegExp(branchPattern)) {
|
|
499
499
|
const match = branchPattern.test(l);
|
|
500
500
|
return match;
|
|
501
501
|
}
|
|
@@ -517,10 +517,10 @@ class HelpersGit {
|
|
|
517
517
|
//#region get all origins
|
|
518
518
|
allOrigins(cwd) {
|
|
519
519
|
// Determine the path to the .git/config file
|
|
520
|
-
const gitConfigPath = (0,
|
|
520
|
+
const gitConfigPath = (0, lib_2.crossPlatformPath)([cwd, '.git', 'config']);
|
|
521
521
|
// Read the contents of the .git/config file synchronously
|
|
522
522
|
try {
|
|
523
|
-
const configFile =
|
|
523
|
+
const configFile = lib_2.fse.readFileSync(gitConfigPath, 'utf-8');
|
|
524
524
|
const config = ini.parse(configFile);
|
|
525
525
|
// Extract remotes from the config object
|
|
526
526
|
const remotes = Object.keys(config)
|
|
@@ -541,7 +541,7 @@ class HelpersGit {
|
|
|
541
541
|
currentBranchName(cwd) {
|
|
542
542
|
index_1.Helpers.log('[taon-helpers][currentBranchName] ' + cwd, 1);
|
|
543
543
|
try {
|
|
544
|
-
const branchName =
|
|
544
|
+
const branchName = lib_2.child_process
|
|
545
545
|
.execSync(`git rev-parse --abbrev-ref HEAD`, { cwd })
|
|
546
546
|
.toString()
|
|
547
547
|
.trim();
|
|
@@ -561,10 +561,10 @@ class HelpersGit {
|
|
|
561
561
|
//#region commit
|
|
562
562
|
commit(cwd, commitMessage) {
|
|
563
563
|
index_1.Helpers.log('[taon-helpers][commit] ' + cwd, 1);
|
|
564
|
-
if (!
|
|
564
|
+
if (!lib_2._.isString(commitMessage)) {
|
|
565
565
|
commitMessage = 'update';
|
|
566
566
|
}
|
|
567
|
-
const tempCommitnameFile = (0,
|
|
567
|
+
const tempCommitnameFile = (0, lib_2.crossPlatformPath)([
|
|
568
568
|
cwd,
|
|
569
569
|
'tmp-git-commit-name.txt',
|
|
570
570
|
]);
|
|
@@ -620,30 +620,30 @@ class HelpersGit {
|
|
|
620
620
|
if (this.isGitRoot(cwd)) {
|
|
621
621
|
return cwd;
|
|
622
622
|
}
|
|
623
|
-
let absoluteLocation = (0,
|
|
623
|
+
let absoluteLocation = (0, lib_2.crossPlatformPath)(cwd);
|
|
624
624
|
let previousLocation;
|
|
625
|
-
if (
|
|
626
|
-
absoluteLocation =
|
|
625
|
+
if (lib_2.fse.existsSync(absoluteLocation)) {
|
|
626
|
+
absoluteLocation = lib_2.fse.realpathSync(absoluteLocation);
|
|
627
627
|
}
|
|
628
|
-
if (
|
|
629
|
-
!
|
|
630
|
-
absoluteLocation =
|
|
628
|
+
if (lib_2.fse.existsSync(absoluteLocation) &&
|
|
629
|
+
!lib_2.fse.lstatSync(absoluteLocation).isDirectory()) {
|
|
630
|
+
absoluteLocation = lib_2.path.dirname(absoluteLocation);
|
|
631
631
|
}
|
|
632
632
|
while (true) {
|
|
633
|
-
if (
|
|
634
|
-
|
|
635
|
-
absoluteLocation =
|
|
633
|
+
if (lib_2.path.basename(lib_2.path.dirname(absoluteLocation)) ===
|
|
634
|
+
lib_1.config.folder.node_modules) {
|
|
635
|
+
absoluteLocation = lib_2.path.dirname(lib_2.path.dirname(absoluteLocation));
|
|
636
636
|
}
|
|
637
637
|
if (this.isGitRoot(absoluteLocation)) {
|
|
638
638
|
break;
|
|
639
639
|
}
|
|
640
640
|
previousLocation = absoluteLocation;
|
|
641
|
-
const newAbsLocation =
|
|
642
|
-
if (!
|
|
641
|
+
const newAbsLocation = lib_2.path.join(absoluteLocation, '..');
|
|
642
|
+
if (!lib_2.path.isAbsolute(newAbsLocation)) {
|
|
643
643
|
return;
|
|
644
644
|
}
|
|
645
|
-
absoluteLocation = (0,
|
|
646
|
-
if (!
|
|
645
|
+
absoluteLocation = (0, lib_2.crossPlatformPath)(lib_2.path.resolve(newAbsLocation));
|
|
646
|
+
if (!lib_2.fse.existsSync(absoluteLocation) &&
|
|
647
647
|
absoluteLocation.split('/').length < 2) {
|
|
648
648
|
return;
|
|
649
649
|
}
|
|
@@ -657,7 +657,7 @@ class HelpersGit {
|
|
|
657
657
|
//#region is git root
|
|
658
658
|
isGitRoot(cwd) {
|
|
659
659
|
index_1.Helpers.log('[taon-helpers][isGitRoot] ' + cwd, 1);
|
|
660
|
-
if (!
|
|
660
|
+
if (!lib_2.fse.existsSync((0, lib_2.crossPlatformPath)([cwd, '.git']))) {
|
|
661
661
|
return false;
|
|
662
662
|
}
|
|
663
663
|
index_1.Helpers.log('[taon-helpers][isGitRepo] ' + cwd, 1);
|
|
@@ -674,7 +674,7 @@ class HelpersGit {
|
|
|
674
674
|
// rootGitCwd,
|
|
675
675
|
// cwd
|
|
676
676
|
// })
|
|
677
|
-
return (rootGitCwd && (0,
|
|
677
|
+
return (rootGitCwd && (0, lib_2.crossPlatformPath)(rootGitCwd) === (0, lib_2.crossPlatformPath)(cwd));
|
|
678
678
|
}
|
|
679
679
|
catch (e) {
|
|
680
680
|
return false;
|
|
@@ -703,10 +703,10 @@ class HelpersGit {
|
|
|
703
703
|
//#region reset soft HEAD
|
|
704
704
|
resetSoftHEAD(cwd, HEAD = 1) {
|
|
705
705
|
try {
|
|
706
|
-
|
|
706
|
+
lib_2.child_process.execSync(`git reset --soft HEAD~${HEAD}`, { cwd });
|
|
707
707
|
}
|
|
708
708
|
catch (error) {
|
|
709
|
-
index_1.Helpers.error(`[${
|
|
709
|
+
index_1.Helpers.error(`[${lib_1.config.frameworkName}] not able to soft repository in ${self.location}`);
|
|
710
710
|
}
|
|
711
711
|
}
|
|
712
712
|
//#endregion
|
|
@@ -715,12 +715,12 @@ class HelpersGit {
|
|
|
715
715
|
//#region @backendFunc
|
|
716
716
|
const { HEAD } = options || {};
|
|
717
717
|
index_1.Helpers.info(`[taon-helpers] [resetHard] ` +
|
|
718
|
-
`${
|
|
718
|
+
`${lib_2._.isNumber(HEAD) ? `HEAD~${HEAD}` : ''} ${cwd}`);
|
|
719
719
|
try {
|
|
720
|
-
|
|
720
|
+
lib_2.child_process.execSync(`git reset --hard ${lib_2._.isNumber(HEAD) ? `HEAD~${HEAD}` : ''}`, { cwd });
|
|
721
721
|
}
|
|
722
722
|
catch (error) {
|
|
723
|
-
index_1.Helpers.error(`[${
|
|
723
|
+
index_1.Helpers.error(`[${lib_1.config.frameworkName}] not able to reset repository in ${self.location}`);
|
|
724
724
|
}
|
|
725
725
|
//#endregion
|
|
726
726
|
}
|
|
@@ -728,20 +728,20 @@ class HelpersGit {
|
|
|
728
728
|
//#region pull
|
|
729
729
|
_pull(cwd, options) {
|
|
730
730
|
let { branchName, defaultHardResetCommits } = options || {};
|
|
731
|
-
if (
|
|
731
|
+
if (lib_2._.isNumber(defaultHardResetCommits)) {
|
|
732
732
|
this.resetHard(cwd, { HEAD: defaultHardResetCommits });
|
|
733
733
|
}
|
|
734
734
|
else {
|
|
735
735
|
this.resetHard(cwd);
|
|
736
736
|
}
|
|
737
|
-
|
|
737
|
+
lib_2.child_process.execSync(`git pull --tags --rebase origin ${branchName}`, {
|
|
738
738
|
cwd,
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
async pullCurrentBranch(cwd, options) {
|
|
742
742
|
options = options || {};
|
|
743
743
|
let { askToRetry, exitOnError } = options || {};
|
|
744
|
-
if (
|
|
744
|
+
if (lib_2._.isUndefined(exitOnError)) {
|
|
745
745
|
options.exitOnError = true;
|
|
746
746
|
exitOnError = true;
|
|
747
747
|
}
|
|
@@ -752,10 +752,10 @@ class HelpersGit {
|
|
|
752
752
|
index_1.Helpers.log(`askToRetry: ${askToRetry}`);
|
|
753
753
|
if (this.getOriginURL(cwd) === '') {
|
|
754
754
|
index_1.Helpers.warn(`Not pulling branch without ` +
|
|
755
|
-
`remote origin url.... in folder ${
|
|
755
|
+
`remote origin url.... in folder ${lib_2.path.basename(cwd)}`);
|
|
756
756
|
return;
|
|
757
757
|
}
|
|
758
|
-
index_1.Helpers.info(`[taon-helpers][${(0,
|
|
758
|
+
index_1.Helpers.info(`[taon-helpers][${(0, lib_2.dateformat)(new Date(), 'dd-mm-yyyy HH:MM:ss')}] Pulling git changes in "${cwd}", origin=${index_1.Helpers.git.getOriginURL(cwd)} `);
|
|
759
759
|
let acknowledgeBeforePull = false;
|
|
760
760
|
while (true) {
|
|
761
761
|
try {
|
|
@@ -767,7 +767,7 @@ class HelpersGit {
|
|
|
767
767
|
...options,
|
|
768
768
|
branchName: currentLocalBranch,
|
|
769
769
|
});
|
|
770
|
-
index_1.Helpers.info(`[taon-helpers] Branch "${currentLocalBranch}" updated successfully in ${
|
|
770
|
+
index_1.Helpers.info(`[taon-helpers] Branch "${currentLocalBranch}" updated successfully in ${lib_2.path.basename(cwd)}`);
|
|
771
771
|
break;
|
|
772
772
|
}
|
|
773
773
|
catch (e) {
|
|
@@ -797,7 +797,7 @@ class HelpersGit {
|
|
|
797
797
|
name: 'Exit process',
|
|
798
798
|
},
|
|
799
799
|
};
|
|
800
|
-
const whatToDo = await
|
|
800
|
+
const whatToDo = await lib_3.UtilsTerminal.select({
|
|
801
801
|
question: 'What to do ?',
|
|
802
802
|
choices: pullOptions,
|
|
803
803
|
});
|
|
@@ -826,7 +826,7 @@ class HelpersGit {
|
|
|
826
826
|
}
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
|
-
index_1.Helpers.info(`[${(0,
|
|
829
|
+
index_1.Helpers.info(`[${(0, lib_2.dateformat)(new Date(), 'dd-mm-yyyy HH:MM:ss')}] DONE PULLING`);
|
|
830
830
|
}
|
|
831
831
|
//#endregion
|
|
832
832
|
//#region melts action commits
|
|
@@ -873,12 +873,12 @@ ${cwd}
|
|
|
873
873
|
while (true) {
|
|
874
874
|
try {
|
|
875
875
|
const taskName = `
|
|
876
|
-
[${(0,
|
|
876
|
+
[${(0, lib_2.dateformat)(new Date(), 'dd-mm-yyyy HH:MM:ss')}]
|
|
877
877
|
Pushing ${force ? 'FORCE' : 'NORMALLY'} current branch (remote=${origin}): ${currentBranchName}
|
|
878
878
|
`;
|
|
879
879
|
index_1.Helpers.info(taskName);
|
|
880
880
|
const command = `git push ${force ? '-f' : ''} ${origin} ${currentBranchName} --tags`;
|
|
881
|
-
index_1.Helpers.info(`[git][push] [${(0,
|
|
881
|
+
index_1.Helpers.info(`[git][push] [${(0, lib_2.dateformat)(new Date(), 'dd-mm-yyyy HH:MM:ss')}] ${force ? 'force' : 'normal'} pushing current branch ${currentBranchName} ,` +
|
|
882
882
|
` origin=${index_1.Helpers.git.getOriginURL(cwd, origin)}`);
|
|
883
883
|
index_1.Helpers.run(command, { cwd }).sync();
|
|
884
884
|
index_1.Helpers.info(taskName);
|
|
@@ -907,7 +907,7 @@ ${cwd}
|
|
|
907
907
|
name: 'Exit process',
|
|
908
908
|
},
|
|
909
909
|
};
|
|
910
|
-
const whatToDo = await
|
|
910
|
+
const whatToDo = await lib_3.UtilsTerminal.select({
|
|
911
911
|
question: 'What to do ?',
|
|
912
912
|
choices: pushOptions,
|
|
913
913
|
});
|
|
@@ -936,7 +936,7 @@ ${cwd}
|
|
|
936
936
|
//#region @backendFunc
|
|
937
937
|
index_1.Helpers.log('[defaultRepoBranch] ' + cwd, 1);
|
|
938
938
|
try {
|
|
939
|
-
const raw =
|
|
939
|
+
const raw = lib_2.child_process
|
|
940
940
|
.execSync(`git symbolic-ref refs/remotes/origin/HEAD`, { cwd })
|
|
941
941
|
.toString()
|
|
942
942
|
.trim();
|
|
@@ -957,11 +957,11 @@ ${cwd}
|
|
|
957
957
|
//#region checkout default branch
|
|
958
958
|
checkoutDefaultBranch(cwd) {
|
|
959
959
|
index_1.Helpers.log('[checkoutDefaultBranch] ' + cwd, 1);
|
|
960
|
-
const defaultBranch =
|
|
960
|
+
const defaultBranch = lib_2.child_process
|
|
961
961
|
.execSync(`git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'`, { cwd })
|
|
962
962
|
.toString()
|
|
963
963
|
.trim();
|
|
964
|
-
|
|
964
|
+
lib_2.child_process.execSync(`git checkout ${defaultBranch}`, { cwd });
|
|
965
965
|
}
|
|
966
966
|
//#endregion
|
|
967
967
|
//#region add
|
|
@@ -972,7 +972,7 @@ ${cwd}
|
|
|
972
972
|
*/
|
|
973
973
|
stageAllFiles(cwd) {
|
|
974
974
|
try {
|
|
975
|
-
|
|
975
|
+
lib_2.child_process.execSync(`git add --all .`, { cwd });
|
|
976
976
|
}
|
|
977
977
|
catch (error) { }
|
|
978
978
|
}
|
|
@@ -985,7 +985,7 @@ ${cwd}
|
|
|
985
985
|
*/
|
|
986
986
|
stageFile(cwd, fileRelativePath) {
|
|
987
987
|
try {
|
|
988
|
-
|
|
988
|
+
lib_2.child_process.execSync(`git add ${fileRelativePath}`, { cwd });
|
|
989
989
|
}
|
|
990
990
|
catch (error) { }
|
|
991
991
|
}
|
|
@@ -1001,10 +1001,10 @@ ${cwd}
|
|
|
1001
1001
|
// console.log({ onlyStaged, cwd });
|
|
1002
1002
|
try {
|
|
1003
1003
|
if (onlyStaged) {
|
|
1004
|
-
|
|
1004
|
+
lib_2.child_process.execSync(`git stash push --staged`, { cwd });
|
|
1005
1005
|
}
|
|
1006
1006
|
else {
|
|
1007
|
-
|
|
1007
|
+
lib_2.child_process.execSync(`git stash -u`, { cwd });
|
|
1008
1008
|
}
|
|
1009
1009
|
}
|
|
1010
1010
|
catch (error) {
|
|
@@ -1022,7 +1022,7 @@ ${cwd}
|
|
|
1022
1022
|
rebase(cwd, toBranch) {
|
|
1023
1023
|
// console.log({ onlyStaged, cwd });
|
|
1024
1024
|
try {
|
|
1025
|
-
|
|
1025
|
+
lib_2.child_process.execSync(`git rebase ${toBranch}`, { cwd });
|
|
1026
1026
|
}
|
|
1027
1027
|
catch (error) {
|
|
1028
1028
|
index_1.Helpers.info('Not able to rebase');
|
|
@@ -1033,7 +1033,7 @@ ${cwd}
|
|
|
1033
1033
|
//#region stash apply
|
|
1034
1034
|
stashApply(cwd) {
|
|
1035
1035
|
try {
|
|
1036
|
-
|
|
1036
|
+
lib_2.child_process.execSync(`git stash apply`, { cwd });
|
|
1037
1037
|
}
|
|
1038
1038
|
catch (error) { }
|
|
1039
1039
|
}
|
|
@@ -1042,7 +1042,7 @@ ${cwd}
|
|
|
1042
1042
|
fetch(cwd, all = false) {
|
|
1043
1043
|
index_1.Helpers.taskStarted('Fetching git changes');
|
|
1044
1044
|
try {
|
|
1045
|
-
|
|
1045
|
+
lib_2.child_process.execSync(`git fetch ${all ? '--all' : ''}`, { cwd });
|
|
1046
1046
|
}
|
|
1047
1047
|
catch (error) {
|
|
1048
1048
|
index_1.Helpers.error('Not able to git fetch.', false, true);
|
|
@@ -1052,18 +1052,18 @@ ${cwd}
|
|
|
1052
1052
|
//#endregion
|
|
1053
1053
|
cleanRepoFromAnyFilesExceptDotGitFolder(cwd) {
|
|
1054
1054
|
//#region @backendFunc
|
|
1055
|
-
const entries =
|
|
1055
|
+
const entries = lib_2.fse.readdirSync(cwd);
|
|
1056
1056
|
for (const entry of entries) {
|
|
1057
1057
|
// Skip the .git directory
|
|
1058
1058
|
if (entry === '.git') {
|
|
1059
1059
|
continue;
|
|
1060
1060
|
}
|
|
1061
|
-
const fullPath = (0,
|
|
1062
|
-
const stats =
|
|
1061
|
+
const fullPath = (0, lib_2.crossPlatformPath)([cwd, entry]);
|
|
1062
|
+
const stats = lib_2.fse.statSync(fullPath);
|
|
1063
1063
|
if (stats.isDirectory()) {
|
|
1064
1064
|
try {
|
|
1065
1065
|
// when link
|
|
1066
|
-
|
|
1066
|
+
lib_2.fse.unlinkSync(fullPath);
|
|
1067
1067
|
}
|
|
1068
1068
|
catch (error) { }
|
|
1069
1069
|
// Recursively remove directories
|
|
@@ -1072,7 +1072,7 @@ ${cwd}
|
|
|
1072
1072
|
else {
|
|
1073
1073
|
// Remove files
|
|
1074
1074
|
try {
|
|
1075
|
-
|
|
1075
|
+
lib_2.fse.unlinkSync(fullPath);
|
|
1076
1076
|
}
|
|
1077
1077
|
catch (error) { }
|
|
1078
1078
|
}
|
|
@@ -1090,7 +1090,7 @@ ${cwd}
|
|
|
1090
1090
|
createBranchIfNotExists = false;
|
|
1091
1091
|
}
|
|
1092
1092
|
try {
|
|
1093
|
-
|
|
1093
|
+
lib_2.child_process.execSync(`git checkout ${createBranchIfNotExists ? '-b' : ''} ${branchName}`, { cwd });
|
|
1094
1094
|
}
|
|
1095
1095
|
catch (error) {
|
|
1096
1096
|
index_1.Helpers.error(`Not able to checkout branch: ${branchName}`, false, true);
|
|
@@ -1100,30 +1100,30 @@ ${cwd}
|
|
|
1100
1100
|
//#region checkout from to
|
|
1101
1101
|
checkoutFromTo(checkoutFromBranch, targetBranch, origin = 'origin', cwd) {
|
|
1102
1102
|
index_1.Helpers.log('[checkout] ' + cwd, 1);
|
|
1103
|
-
|
|
1103
|
+
lib_2.child_process.execSync(`git fetch`, { cwd });
|
|
1104
1104
|
const currentBranchName = this.currentBranchName(cwd);
|
|
1105
1105
|
if (currentBranchName === targetBranch) {
|
|
1106
1106
|
index_1.Helpers.info('Already on proper branch.. just pulling');
|
|
1107
|
-
|
|
1108
|
-
|
|
1107
|
+
lib_2.child_process.execSync(`git reset --hard`, { cwd });
|
|
1108
|
+
lib_2.child_process.execSync(`git pull ${origin} ${checkoutFromBranch}`, {
|
|
1109
1109
|
cwd,
|
|
1110
1110
|
});
|
|
1111
1111
|
}
|
|
1112
1112
|
else {
|
|
1113
1113
|
const targetBranchExists = this.getBranchesNames(cwd).filter(f => targetBranch === f).length > 0;
|
|
1114
|
-
|
|
1114
|
+
lib_2.child_process.execSync(`git reset --hard`, { cwd });
|
|
1115
1115
|
if (currentBranchName !== checkoutFromBranch) {
|
|
1116
|
-
|
|
1116
|
+
lib_2.child_process.execSync(`git checkout ${checkoutFromBranch}`, { cwd });
|
|
1117
1117
|
}
|
|
1118
|
-
|
|
1118
|
+
lib_2.child_process.execSync(`git pull ${origin} ${checkoutFromBranch}`, {
|
|
1119
1119
|
cwd,
|
|
1120
1120
|
});
|
|
1121
1121
|
if (targetBranchExists) {
|
|
1122
|
-
|
|
1123
|
-
|
|
1122
|
+
lib_2.child_process.execSync(`git checkout ${targetBranch}`, { cwd });
|
|
1123
|
+
lib_2.child_process.execSync(`git rebase ${checkoutFromBranch}`, { cwd });
|
|
1124
1124
|
}
|
|
1125
1125
|
else {
|
|
1126
|
-
|
|
1126
|
+
lib_2.child_process.execSync(`git checkout -b ${targetBranch}`, { cwd });
|
|
1127
1127
|
}
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
@@ -1179,7 +1179,7 @@ ${cwd}
|
|
|
1179
1179
|
* @returns absolute path to cloned folder
|
|
1180
1180
|
*/
|
|
1181
1181
|
async clone({ cwd, url, destinationFolderName = '', throwErrors, override, }) {
|
|
1182
|
-
cwd = (0,
|
|
1182
|
+
cwd = (0, lib_2.crossPlatformPath)(cwd);
|
|
1183
1183
|
if (!index_1.Helpers.exists(cwd)) {
|
|
1184
1184
|
try {
|
|
1185
1185
|
index_1.Helpers.mkdirp(cwd);
|
|
@@ -1216,10 +1216,10 @@ ${cwd}
|
|
|
1216
1216
|
if (!url.endsWith('.git')) {
|
|
1217
1217
|
url = url + '.git';
|
|
1218
1218
|
}
|
|
1219
|
-
const cloneFolderPath = (0,
|
|
1219
|
+
const cloneFolderPath = (0, lib_2.crossPlatformPath)(lib_2.path
|
|
1220
1220
|
.join(cwd, !!destinationFolderName && destinationFolderName.trim() !== ''
|
|
1221
1221
|
? destinationFolderName
|
|
1222
|
-
:
|
|
1222
|
+
: lib_2.path.basename(url))
|
|
1223
1223
|
.trim()
|
|
1224
1224
|
.replace('.git', ''));
|
|
1225
1225
|
// console.log({ cloneFolderPath })
|
|
@@ -1227,13 +1227,14 @@ ${cwd}
|
|
|
1227
1227
|
index_1.Helpers.tryRemoveDir(cloneFolderPath);
|
|
1228
1228
|
}
|
|
1229
1229
|
else if (index_1.Helpers.exists(cloneFolderPath) &&
|
|
1230
|
-
index_1.Helpers.exists(
|
|
1231
|
-
index_1.Helpers.warn(`[taon-helpers] Already cloned ${
|
|
1230
|
+
index_1.Helpers.exists(lib_2.path.join(cloneFolderPath, '.git'))) {
|
|
1231
|
+
index_1.Helpers.warn(`[taon-helpers] Already cloned ${lib_2.path.basename(cloneFolderPath)}...`);
|
|
1232
1232
|
return cloneFolderPath;
|
|
1233
1233
|
}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1234
|
+
let isHttpCommand = url.startsWith('http://') || url.startsWith('https://');
|
|
1235
|
+
let commnad = isHttpCommand
|
|
1236
|
+
? `git -c http.sslVerify=false clone ${url} ${lib_2.path.basename(cloneFolderPath)}`
|
|
1237
|
+
: `git clone ${url} ${lib_2.path.basename(cloneFolderPath)}`;
|
|
1237
1238
|
index_1.Helpers.info(`
|
|
1238
1239
|
|
|
1239
1240
|
Cloning:
|
|
@@ -1245,7 +1246,11 @@ ${cwd}
|
|
|
1245
1246
|
}
|
|
1246
1247
|
else {
|
|
1247
1248
|
while (true) {
|
|
1248
|
-
|
|
1249
|
+
isHttpCommand = url.startsWith('http://') || url.startsWith('https://');
|
|
1250
|
+
commnad = isHttpCommand
|
|
1251
|
+
? `git -c http.sslVerify=false clone ${url} ${lib_2.path.basename(cloneFolderPath)}`
|
|
1252
|
+
: `git clone ${url} ${lib_2.path.basename(cloneFolderPath)}`;
|
|
1253
|
+
index_1.Helpers.info(`Cloning from url: ${lib_3.CLI.chalk.bold(url)}..`);
|
|
1249
1254
|
try {
|
|
1250
1255
|
index_1.Helpers.run(commnad, { cwd, output: false }).sync();
|
|
1251
1256
|
break;
|
|
@@ -1255,12 +1260,15 @@ ${cwd}
|
|
|
1255
1260
|
index_1.Helpers.error(`[taon-helpers][git] Project not found :${url}`, true, true);
|
|
1256
1261
|
}
|
|
1257
1262
|
else {
|
|
1258
|
-
index_1.Helpers.error(`[taon-helpers] Can't clone from url: ${
|
|
1263
|
+
index_1.Helpers.error(`[taon-helpers] Can't clone from url: ${lib_3.CLI.chalk.bold(url)}..`, true, true);
|
|
1259
1264
|
}
|
|
1260
1265
|
const cloneLinkOpt = {
|
|
1261
1266
|
again: {
|
|
1262
1267
|
name: 'Try again',
|
|
1263
1268
|
},
|
|
1269
|
+
againDif: {
|
|
1270
|
+
name: `Try again with ${isHttpCommand ? 'ssh' : 'http'} url`,
|
|
1271
|
+
},
|
|
1264
1272
|
skip: {
|
|
1265
1273
|
name: 'Skip cloning this repository',
|
|
1266
1274
|
},
|
|
@@ -1272,6 +1280,12 @@ ${cwd}
|
|
|
1272
1280
|
if (res === 'again') {
|
|
1273
1281
|
continue;
|
|
1274
1282
|
}
|
|
1283
|
+
if (res === 'againDif') {
|
|
1284
|
+
url = isHttpCommand
|
|
1285
|
+
? index_1.Helpers.git.originHttpToSsh(url)
|
|
1286
|
+
: index_1.Helpers.git.originSshToHttp(url);
|
|
1287
|
+
continue;
|
|
1288
|
+
}
|
|
1275
1289
|
if (res === 'exit') {
|
|
1276
1290
|
process.exit(0);
|
|
1277
1291
|
}
|
|
@@ -1301,7 +1315,7 @@ ${cwd}
|
|
|
1301
1315
|
//#region check if there are some uncommited changes except
|
|
1302
1316
|
thereAreSomeUncommitedChangeExcept(filesList = [], cwd) {
|
|
1303
1317
|
index_1.Helpers.log('[taon-helpers][thereAreSomeUncommitedChangeExcept] ' + cwd, 1);
|
|
1304
|
-
filesList = filesList.map(f => (0,
|
|
1318
|
+
filesList = filesList.map(f => (0, lib_2.crossPlatformPath)(f));
|
|
1305
1319
|
try {
|
|
1306
1320
|
const res = index_1.Helpers.run(`git ls-files --deleted --modified --others --exclude-standard`, { output: false, cwd })
|
|
1307
1321
|
.sync()
|
|
@@ -1311,7 +1325,7 @@ ${cwd}
|
|
|
1311
1325
|
? []
|
|
1312
1326
|
: res.split(/\r\n|\n|\r/).filter(f => {
|
|
1313
1327
|
f = f?.trim();
|
|
1314
|
-
return !!f && !filesList.includes((0,
|
|
1328
|
+
return !!f && !filesList.includes((0, lib_2.crossPlatformPath)(f));
|
|
1315
1329
|
});
|
|
1316
1330
|
return list.length > 0;
|
|
1317
1331
|
}
|
|
@@ -1353,7 +1367,7 @@ ${cwd}
|
|
|
1353
1367
|
return;
|
|
1354
1368
|
}
|
|
1355
1369
|
try {
|
|
1356
|
-
index_1.Helpers.log(`[taon-helpers][git] restoring last verion of file ${
|
|
1370
|
+
index_1.Helpers.log(`[taon-helpers][git] restoring last verion of file ${lib_2.path.basename(cwd)}/${relativeFilePath}`);
|
|
1357
1371
|
index_1.Helpers.run(`git checkout -- ${relativeFilePath}`, { cwd }).sync();
|
|
1358
1372
|
}
|
|
1359
1373
|
catch (error) {
|
|
@@ -1369,7 +1383,7 @@ ${cwd}
|
|
|
1369
1383
|
index_1.Helpers.run(`git checkout HEAD -- ${p}`, { cwd }).sync();
|
|
1370
1384
|
}
|
|
1371
1385
|
catch (err) {
|
|
1372
|
-
index_1.Helpers.error(`[taon-helpers][git] Not able to reset files: ${p} inside project ${
|
|
1386
|
+
index_1.Helpers.error(`[taon-helpers][git] Not able to reset files: ${p} inside project ${lib_2.path.basename(cwd)}.`, true, true);
|
|
1373
1387
|
}
|
|
1374
1388
|
});
|
|
1375
1389
|
}
|
|
@@ -1382,14 +1396,14 @@ ${cwd}
|
|
|
1382
1396
|
* @returns (absolute pathes to stages files
|
|
1383
1397
|
*/
|
|
1384
1398
|
stagedFiles(cwd, outputRelatieve = false) {
|
|
1385
|
-
cwd = (0,
|
|
1399
|
+
cwd = (0, lib_2.crossPlatformPath)(cwd).replace(/\/$/, '');
|
|
1386
1400
|
const command = `git diff --name-only --cached`.trim();
|
|
1387
1401
|
const result = index_1.Helpers.commnadOutputAsString(command, cwd, {}) || '';
|
|
1388
1402
|
return (result ? result.split('\n') : []).map(relative => {
|
|
1389
1403
|
if (outputRelatieve) {
|
|
1390
|
-
return (0,
|
|
1404
|
+
return (0, lib_2.crossPlatformPath)(relative);
|
|
1391
1405
|
}
|
|
1392
|
-
return (0,
|
|
1406
|
+
return (0, lib_2.crossPlatformPath)([cwd, relative]);
|
|
1393
1407
|
});
|
|
1394
1408
|
}
|
|
1395
1409
|
//#endregion
|
|
@@ -1404,7 +1418,7 @@ ${cwd}
|
|
|
1404
1418
|
originHttpToSsh(originHttp, verbose = false) {
|
|
1405
1419
|
const httpsPattern = /^https:\/\/(.+?)\/(.+?\/.+?)(\.git)?$/;
|
|
1406
1420
|
const match = originHttp.match(httpsPattern);
|
|
1407
|
-
if (originHttp === 'undefined' ||
|
|
1421
|
+
if (originHttp === 'undefined' || lib_2._.isNil(originHttp)) {
|
|
1408
1422
|
index_1.Helpers.error('[taon-helpers][originHttpToSsh] Origin URL is not defined');
|
|
1409
1423
|
return originHttp;
|
|
1410
1424
|
}
|
|
@@ -1438,7 +1452,7 @@ ${cwd}
|
|
|
1438
1452
|
originSshToHttp(originSsh, verbose = false) {
|
|
1439
1453
|
const sshPattern = /^git@(.+?):(.+?\/.+?)(\.git)?$/;
|
|
1440
1454
|
const match = originSsh.match(sshPattern);
|
|
1441
|
-
if (originSsh === 'undefined' ||
|
|
1455
|
+
if (originSsh === 'undefined' || lib_2._.isNil(originSsh)) {
|
|
1442
1456
|
index_1.Helpers.error('[taon-helpers][originSshToHttp] Origin URL is not defined');
|
|
1443
1457
|
return originSsh;
|
|
1444
1458
|
}
|
|
@@ -1542,13 +1556,13 @@ ${cwd}
|
|
|
1542
1556
|
//#region get user info
|
|
1543
1557
|
async getUserInfo(cwd, global = false) {
|
|
1544
1558
|
try {
|
|
1545
|
-
const name =
|
|
1559
|
+
const name = lib_2.child_process
|
|
1546
1560
|
.execSync(`git config ${global ? '--global' : ''} user.name`, {
|
|
1547
1561
|
encoding: 'utf-8',
|
|
1548
1562
|
cwd: cwd || process.cwd(),
|
|
1549
1563
|
})
|
|
1550
1564
|
.trim();
|
|
1551
|
-
const email =
|
|
1565
|
+
const email = lib_2.child_process
|
|
1552
1566
|
.execSync(`git config ${global ? '--global' : ''} user.email`, {
|
|
1553
1567
|
encoding: 'utf-8',
|
|
1554
1568
|
cwd: cwd || process.cwd(),
|
|
@@ -1568,12 +1582,12 @@ ${cwd}
|
|
|
1568
1582
|
return;
|
|
1569
1583
|
}
|
|
1570
1584
|
try {
|
|
1571
|
-
|
|
1572
|
-
|
|
1585
|
+
lib_2.child_process.execSync(`git config ${global ? '--global' : ''} user.name "${name}"`, { cwd });
|
|
1586
|
+
lib_2.child_process.execSync(`git config ${global ? '--global' : ''} user.email "${email}"`, { cwd });
|
|
1573
1587
|
}
|
|
1574
1588
|
catch (error) {
|
|
1575
1589
|
console.error('Error setting Git user info:', error.message);
|
|
1576
|
-
await
|
|
1590
|
+
await lib_3.UtilsTerminal.pressAnyKeyToContinueAsync();
|
|
1577
1591
|
}
|
|
1578
1592
|
}
|
|
1579
1593
|
}
|