tnp-helpers 19.0.76 → 21.0.2
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 +294 -102
- package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base/classes/base-db.d.ts +1 -1
- package/browser/lib/base/classes/base-global-command-line.d.ts +2 -0
- package/browser/lib/build-info._auto-generated_.d.ts +1 -1
- package/browser/lib/utils.d.ts +28 -4
- package/browser/package.json +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-database-config.js +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-database-config.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker.utils.js +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker.utils.js.map +1 -1
- package/lib/base/classes/base-db.d.ts +2 -2
- package/lib/base/classes/base-db.js +5 -3
- package/lib/base/classes/base-db.js.map +1 -1
- package/lib/base/classes/base-global-command-line.backend.d.ts +13 -1
- package/lib/base/classes/base-global-command-line.backend.js +416 -11
- package/lib/base/classes/base-global-command-line.backend.js.map +1 -1
- package/lib/base/classes/base-global-command-line.d.ts +2 -0
- package/lib/base/classes/base-global-command-line.js +182 -141
- package/lib/base/classes/base-global-command-line.js.map +1 -1
- package/lib/base/classes/base-process/base-process-api.service.d.ts +7 -0
- package/lib/base/classes/base-process/base-process.context.d.ts +19 -0
- package/lib/base/classes/base-process/base-process.context.js +22 -0
- package/lib/base/classes/base-process/base-process.context.js.map +1 -0
- package/lib/base/classes/base-process/base-process.controller.d.ts +17 -0
- package/lib/base/classes/base-process/base-process.controller.js +91 -0
- package/lib/base/classes/base-process/base-process.controller.js.map +1 -0
- package/lib/base/classes/base-process/base-process.d.ts +8 -0
- package/lib/base/classes/base-process/base-process.defaults-values.d.ts +2 -0
- package/lib/base/classes/base-process/base-process.defaults-values.js +9 -0
- package/lib/base/classes/base-process/base-process.defaults-values.js.map +1 -0
- package/lib/base/classes/base-process/base-process.js +62 -0
- package/lib/base/classes/base-process/base-process.js.map +1 -0
- package/lib/base/classes/base-process/base-process.models.d.ts +6 -0
- package/lib/base/classes/base-process/base-process.models.js +3 -0
- package/lib/base/classes/base-process/base-process.models.js.map +1 -0
- package/lib/base/classes/base-process/base-process.provider.d.ts +16 -0
- package/lib/base/classes/base-process/base-process.provider.js +69 -0
- package/lib/base/classes/base-process/base-process.provider.js.map +1 -0
- package/lib/base/classes/base-process/base-process.repository copy.d.ts +8 -0
- package/lib/base/classes/base-process/base-process.repository copy.js +32 -0
- package/lib/base/classes/base-process/base-process.repository copy.js.map +1 -0
- package/lib/base/classes/base-process/base-process.repository.d.ts +8 -0
- package/lib/base/classes/base-process/base-process.repository.js +32 -0
- package/lib/base/classes/base-process/base-process.repository.js.map +1 -0
- package/lib/base/classes/base-process/base-process.terminal-ui.d.ts +11 -0
- package/lib/base/classes/base-process/base-process.terminal-ui.js +54 -0
- package/lib/base/classes/base-process/base-process.terminal-ui.js.map +1 -0
- package/lib/base/classes/base-process/base-process.worker.d.ts +16 -0
- package/lib/base/classes/base-process/base-process.worker.js +29 -0
- package/lib/base/classes/base-process/base-process.worker.js.map +1 -0
- package/lib/base/classes/base-process/index.d.ts +1 -0
- package/lib/base/classes/base-process/index.js +22 -0
- package/lib/base/classes/base-process/index.js.map +1 -0
- package/lib/base/classes/base-process/processes.repository.d.ts +0 -0
- package/lib/base/classes/base-process/processes.repository.js +5 -0
- package/lib/base/classes/base-process/processes.repository.js.map +1 -0
- package/lib/base/classes/base-vscode.js +5 -1
- package/lib/base/classes/base-vscode.js.map +1 -1
- package/lib/base/gh-temp-code.js +6 -5
- package/lib/base/gh-temp-code.js.map +1 -1
- package/lib/base/tcp-udp-ports/not-assignable-port.entity.js +2 -2
- package/lib/base/tcp-udp-ports/ports.entity.d.ts +1 -1
- package/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +1 -19
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/env-backend._auto-generated_.d.ts +34 -0
- package/lib/env-backend._auto-generated_.js +38 -0
- package/lib/env-backend._auto-generated_.js.map +1 -0
- package/lib/env-browser._auto-generated_.d.ts +34 -0
- package/lib/env-browser._auto-generated_.js +38 -0
- package/lib/env-browser._auto-generated_.js.map +1 -0
- package/lib/env.backend.d.ts +34 -0
- package/lib/env.backend.js +40 -0
- package/lib/env.backend.js.map +1 -0
- package/lib/env.browser.d.ts +34 -0
- package/lib/helpers/for-backend/helpers-dependencies.backend.d.ts +0 -1
- package/lib/helpers/for-backend/helpers-dependencies.backend.js +0 -27
- package/lib/helpers/for-backend/helpers-dependencies.backend.js.map +1 -1
- package/lib/helpers/for-browser/angular.helper.js +2 -2
- 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 +28 -4
- package/lib/utils.js +167 -26
- package/lib/utils.js.map +1 -1
- package/lib/validators/validators-git.js.map +1 -1
- package/package.json +5 -5
- package/tmp-environment.json +7 -11
- package/websql/fesm2022/tnp-helpers.mjs +294 -102
- package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base/classes/base-db.d.ts +1 -1
- package/websql/lib/base/classes/base-global-command-line.d.ts +2 -0
- package/websql/lib/build-info._auto-generated_.d.ts +1 -1
- package/websql/lib/utils.d.ts +28 -4
- package/websql/package.json +1 -1
|
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BaseGlobalCommandLine = void 0;
|
|
4
4
|
//#region imports
|
|
5
5
|
const readline = require("readline"); // @backend
|
|
6
|
+
const lib_1 = require("magic-renamer/lib"); // @backend
|
|
6
7
|
const rxjs_1 = require("rxjs");
|
|
7
|
-
const lib_1 = require("tnp-core/lib");
|
|
8
8
|
const lib_2 = require("tnp-core/lib");
|
|
9
9
|
const lib_3 = require("tnp-core/lib");
|
|
10
10
|
const lib_4 = require("tnp-core/lib");
|
|
11
11
|
const lib_5 = require("tnp-core/lib");
|
|
12
|
-
const lib_6 = require("tnp-core/lib");
|
|
13
|
-
const lib_7 = require("tnp-core/lib");
|
|
12
|
+
const lib_6 = require("tnp-core/lib");
|
|
13
|
+
const lib_7 = require("tnp-core/lib"); //@backend
|
|
14
|
+
const lib_8 = require("tnp-core/lib");
|
|
14
15
|
const index_1 = require("../../index");
|
|
15
16
|
const commit_data_1 = require("../commit-data");
|
|
16
17
|
const gh_temp_code_1 = require("../gh-temp-code");
|
|
@@ -25,14 +26,14 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
25
26
|
*/
|
|
26
27
|
async _runAsSudoIfNotElevated({ globalCommandName, }) {
|
|
27
28
|
//#region @backendFunc
|
|
28
|
-
if (!(await (0,
|
|
29
|
+
if (!(await (0, lib_3.isElevated)())) {
|
|
29
30
|
if (process.platform === 'win32') {
|
|
30
|
-
await
|
|
31
|
+
await lib_2.UtilsExecProc.spawnAdminSudo(`${lib_2.config.frameworkName} ${globalCommandName}`);
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
let pathOfExecutableNode = await
|
|
34
|
-
let pathOfExecutable = await
|
|
35
|
-
await
|
|
34
|
+
let pathOfExecutableNode = await lib_3.UtilsProcess.getPathOfExecutable('node');
|
|
35
|
+
let pathOfExecutable = await lib_3.UtilsProcess.getPathOfExecutable(lib_2.config.frameworkName);
|
|
36
|
+
await lib_2.UtilsExecProc.spawnAdminSudo(`${pathOfExecutableNode} ${pathOfExecutable} ${globalCommandName}`);
|
|
36
37
|
}
|
|
37
38
|
return true;
|
|
38
39
|
}
|
|
@@ -56,7 +57,7 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
56
57
|
index_1.Helpers.info(`
|
|
57
58
|
Current folder (${this.cwd})
|
|
58
59
|
is not a git root folder, but nearest project with
|
|
59
|
-
git root has been found in: ${
|
|
60
|
+
git root has been found in: ${lib_3.chalk.bold(proj.genericName)}
|
|
60
61
|
|
|
61
62
|
`);
|
|
62
63
|
const useRoot = await index_1.Helpers.questionYesNo('Would you like to use this project ?');
|
|
@@ -66,11 +67,11 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
66
67
|
return true;
|
|
67
68
|
}
|
|
68
69
|
else {
|
|
69
|
-
index_1.Helpers.error(`[${
|
|
70
|
+
index_1.Helpers.error(`[${lib_2.config.frameworkName}] This is not git root project folder`, true, true);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
else {
|
|
73
|
-
index_1.Helpers.error(`[${
|
|
74
|
+
index_1.Helpers.error(`[${lib_2.config.frameworkName}] This folder is not project folder`, false, true);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
return true;
|
|
@@ -80,7 +81,7 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
80
81
|
//#region commands / hosts
|
|
81
82
|
hosts() {
|
|
82
83
|
//#region @backendFunc
|
|
83
|
-
index_1.Helpers.run(`code ${(0,
|
|
84
|
+
index_1.Helpers.run(`code ${(0, lib_4.crossPlatformPath)(lib_6.UtilsNetwork.getEtcHostsPath())}`).sync();
|
|
84
85
|
process.exit(0);
|
|
85
86
|
//#endregion
|
|
86
87
|
}
|
|
@@ -100,9 +101,9 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
100
101
|
for (const folderAbsPath of index_1.Helpers.foldersFrom(this.cwd, {
|
|
101
102
|
recursive: false,
|
|
102
103
|
})) {
|
|
103
|
-
if (index_1.Helpers.exists((0,
|
|
104
|
+
if (index_1.Helpers.exists((0, lib_4.crossPlatformPath)([folderAbsPath, '.git']))) {
|
|
104
105
|
try {
|
|
105
|
-
index_1.Helpers.run(`git rm --cached ${
|
|
106
|
+
index_1.Helpers.run(`git rm --cached ${lib_3.path.basename(folderAbsPath)}`).sync();
|
|
106
107
|
}
|
|
107
108
|
catch (error) { }
|
|
108
109
|
}
|
|
@@ -114,7 +115,7 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
114
115
|
removeSubmodule() {
|
|
115
116
|
//#region @backendFunc
|
|
116
117
|
index_1.Helpers.taskStarted(`Removing submodules.. ${this.firstArg}`);
|
|
117
|
-
if (index_1.Helpers.exists((0,
|
|
118
|
+
if (index_1.Helpers.exists((0, lib_4.crossPlatformPath)([this.cwd, this.firstArg || '', '.git']))) {
|
|
118
119
|
try {
|
|
119
120
|
index_1.Helpers.run(`git rm --cached ${this.firstArg}`).sync();
|
|
120
121
|
}
|
|
@@ -216,9 +217,9 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
216
217
|
skipUpdate: { name: 'Skip project update' },
|
|
217
218
|
meltNow: { name: 'Melt action commits now' },
|
|
218
219
|
};
|
|
219
|
-
const resp = await
|
|
220
|
+
const resp = await lib_5.UtilsTerminal.select({
|
|
220
221
|
choices,
|
|
221
|
-
question: `Project ${
|
|
222
|
+
question: `Project ${lib_3.chalk.bold(project.genericName)} has action commits to melt. What you want to do ?`,
|
|
222
223
|
});
|
|
223
224
|
if (resp === 'continue') {
|
|
224
225
|
continue;
|
|
@@ -236,7 +237,7 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
236
237
|
console.log(await project.git.changesSummary({
|
|
237
238
|
prefix: `${project.location}/`,
|
|
238
239
|
}));
|
|
239
|
-
await
|
|
240
|
+
await lib_5.UtilsTerminal.pressAnyKeyToContinueAsync({
|
|
240
241
|
message: `Press any key to continue...`,
|
|
241
242
|
});
|
|
242
243
|
}
|
|
@@ -423,7 +424,7 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
423
424
|
index_1.Helpers.run(`${editor} ${locaitonFolderToOpen}`).sync();
|
|
424
425
|
};
|
|
425
426
|
if (results.length === 1) {
|
|
426
|
-
await openInEditor(
|
|
427
|
+
await openInEditor(lib_3._.first(results));
|
|
427
428
|
}
|
|
428
429
|
else if (results.length === 0) {
|
|
429
430
|
index_1.Helpers.error(`No project found by name: "${this.args.join(' ')}"`, false, true);
|
|
@@ -512,14 +513,14 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
512
513
|
index_1.Helpers.info(`
|
|
513
514
|
|
|
514
515
|
YOU ARE RESETING ${withChildren ? 'EVERYTHING' : 'PROJECT'} ` +
|
|
515
|
-
`TO BRANCH: ${
|
|
516
|
+
`TO BRANCH: ${lib_3.chalk.bold(branchToReset)}
|
|
516
517
|
|
|
517
518
|
- curret project (${this.project.name})
|
|
518
519
|
${withChildren &&
|
|
519
|
-
|
|
520
|
+
lib_3._.isArray(this.project.children) &&
|
|
520
521
|
this.project.children.length > 0
|
|
521
522
|
? `- modules:\n${this.project.children
|
|
522
|
-
.map(c => `\t${c.basename} (${
|
|
523
|
+
.map(c => `\t${c.basename} (${lib_3.chalk.yellow(c.name)})`)
|
|
523
524
|
.join('\n')}`
|
|
524
525
|
: ''}
|
|
525
526
|
`);
|
|
@@ -542,7 +543,7 @@ ${withChildren &&
|
|
|
542
543
|
}
|
|
543
544
|
const parent = this.project.parent;
|
|
544
545
|
const branchFromLinkedProjectConfig = parent?.linkedProjects?.linkedProjects.find(l => {
|
|
545
|
-
return ((0,
|
|
546
|
+
return ((0, lib_4.crossPlatformPath)([parent.location, l.relativeClonePath]) ===
|
|
546
547
|
this.project.location);
|
|
547
548
|
})?.defaultBranch;
|
|
548
549
|
let overrideBranchToReset = this.firstArg ||
|
|
@@ -581,10 +582,10 @@ ${withChildren &&
|
|
|
581
582
|
let resetProject = this.project;
|
|
582
583
|
if (this.project.git.isInsideGitRepo && !this.project.git.isGitRoot) {
|
|
583
584
|
index_1.Helpers.warn(`You are not in root of git repo...`, false);
|
|
584
|
-
resetProject = this.ins.nearestTo((0,
|
|
585
|
+
resetProject = this.ins.nearestTo((0, lib_4.crossPlatformPath)([this.project.location, '..']), {
|
|
585
586
|
findGitRoot: true,
|
|
586
587
|
});
|
|
587
|
-
if (!(await index_1.Helpers.questionYesNo(`Would you like to reset root repo instead (project=${
|
|
588
|
+
if (!(await index_1.Helpers.questionYesNo(`Would you like to reset root repo instead (project=${lib_3.chalk.bold.red(resetProject.genericName)}) ?`))) {
|
|
588
589
|
index_1.Helpers.error(`Aborted`, false, true);
|
|
589
590
|
}
|
|
590
591
|
}
|
|
@@ -605,7 +606,7 @@ ${withChildren &&
|
|
|
605
606
|
return;
|
|
606
607
|
}
|
|
607
608
|
const howManyCommits = Number(this.firstArg) || 1;
|
|
608
|
-
|
|
609
|
+
lib_3._.times(howManyCommits, n => {
|
|
609
610
|
console.log(`Resetting soft ${n + 1} commit "${this.project.git.lastCommitMessage()}"`);
|
|
610
611
|
this.project.git.resetSoftHEAD(1);
|
|
611
612
|
});
|
|
@@ -627,7 +628,7 @@ ${withChildren &&
|
|
|
627
628
|
rebaseBranch = await this.__selectBrach(branches, 'rebase');
|
|
628
629
|
}
|
|
629
630
|
else if (branches.length === 1) {
|
|
630
|
-
rebaseBranch =
|
|
631
|
+
rebaseBranch = lib_3._.first(branches);
|
|
631
632
|
}
|
|
632
633
|
else {
|
|
633
634
|
index_1.Helpers.error(`No rebase branch found by name "${rebaseBranch}"`, false, true);
|
|
@@ -637,14 +638,14 @@ ${withChildren &&
|
|
|
637
638
|
|
|
638
639
|
Files from last commit:
|
|
639
640
|
|
|
640
|
-
"${
|
|
641
|
-
(hash: ${
|
|
641
|
+
"${lib_3.chalk.gray(await this.project.git.getCommitMessageByHash(this.project.git.lastCommitHash()))}"
|
|
642
|
+
(hash: ${lib_3.chalk.gray(this.project.git.lastCommitHash())})
|
|
642
643
|
|
|
643
644
|
are going to be applied after rebase.
|
|
644
645
|
|
|
645
646
|
|
|
646
647
|
`);
|
|
647
|
-
if (!(await
|
|
648
|
+
if (!(await lib_5.UtilsTerminal.confirm({
|
|
648
649
|
message: `Do you want to continue ?`,
|
|
649
650
|
defaultValue: true,
|
|
650
651
|
}))) {
|
|
@@ -753,7 +754,7 @@ ${remotes.map((r, i) => `${i + 1}. ${r.origin} ${r.url}`).join('\n')}
|
|
|
753
754
|
`);
|
|
754
755
|
for (let index = 0; index < remotes.length; index++) {
|
|
755
756
|
const { origin, url } = remotes[index];
|
|
756
|
-
index_1.Helpers.taskStarted(`Pushing to ${
|
|
757
|
+
index_1.Helpers.taskStarted(`Pushing to ${lib_3.chalk.bold(origin)} (${url})...`);
|
|
757
758
|
await this.push({ force, origin, noExit: true });
|
|
758
759
|
index_1.Helpers.taskDone(`Pushed to ${origin}`);
|
|
759
760
|
}
|
|
@@ -870,7 +871,7 @@ ${remotes.map((r, i) => `${i + 1}. ${r.origin} ${r.url}`).join('\n')}
|
|
|
870
871
|
${lastCommitMessage}
|
|
871
872
|
|
|
872
873
|
...`);
|
|
873
|
-
await
|
|
874
|
+
await lib_5.UtilsTerminal.pressAnyKeyToContinueAsync({
|
|
874
875
|
message: `Press any key to force push`,
|
|
875
876
|
});
|
|
876
877
|
}
|
|
@@ -1011,7 +1012,7 @@ ${lastCommitMessage}
|
|
|
1011
1012
|
await this.push({
|
|
1012
1013
|
typeofCommit: 'release',
|
|
1013
1014
|
commitMessageRequired: true,
|
|
1014
|
-
overrideCommitMessage: `${
|
|
1015
|
+
overrideCommitMessage: `${lib_3._.first(this.project.releaseProcess.getReleaseWords())} ` +
|
|
1015
1016
|
`version ${this.project.packageJson.version}`,
|
|
1016
1017
|
});
|
|
1017
1018
|
//#endregion
|
|
@@ -1240,6 +1241,16 @@ ${lastCommitMessage}
|
|
|
1240
1241
|
//#endregion
|
|
1241
1242
|
}
|
|
1242
1243
|
//#endregion
|
|
1244
|
+
//#region copy and rename (vscode option)
|
|
1245
|
+
async $COPY_AND_RENAME() {
|
|
1246
|
+
//#region @backendFunc
|
|
1247
|
+
// console.log(`>> ${args} <<`)
|
|
1248
|
+
const ins = lib_1.MagicRenamer.Instance(this.cwd);
|
|
1249
|
+
await ins.start(this.argsWithParams);
|
|
1250
|
+
this._exit();
|
|
1251
|
+
//#endregion
|
|
1252
|
+
}
|
|
1253
|
+
//#endregion
|
|
1243
1254
|
//#region commands / rename origin
|
|
1244
1255
|
async RENAME_ORIGIN() {
|
|
1245
1256
|
//#region @backendFunc
|
|
@@ -1392,13 +1403,13 @@ ${lastCommitMessage}
|
|
|
1392
1403
|
const libs = proj.children.filter(child => {
|
|
1393
1404
|
process.stdout.write('.');
|
|
1394
1405
|
return child.git.thereAreSomeUncommitedChangeExcept([
|
|
1395
|
-
|
|
1406
|
+
lib_2.config.file.package_json,
|
|
1396
1407
|
]);
|
|
1397
1408
|
});
|
|
1398
1409
|
console.log('\n' + index_1.Helpers.terminalLine());
|
|
1399
1410
|
index_1.Helpers.info(libs.length
|
|
1400
1411
|
? libs
|
|
1401
|
-
.map(c => `${
|
|
1412
|
+
.map(c => `${lib_3.chalk.bold(c.name)} (${c.git.uncommitedFiles.map(p => lib_3.chalk.black(lib_3.path.basename(p))).join(', ')})`)
|
|
1402
1413
|
.join('\n')
|
|
1403
1414
|
: 'Nothing modifed');
|
|
1404
1415
|
this._exit();
|
|
@@ -1445,7 +1456,7 @@ ${lastCommitMessage}
|
|
|
1445
1456
|
let tagToRemove = this.firstArg;
|
|
1446
1457
|
if (!tagToRemove) {
|
|
1447
1458
|
const allTags = await index_1.Helpers.git.getAllTags(this.cwd);
|
|
1448
|
-
tagToRemove = await
|
|
1459
|
+
tagToRemove = await lib_5.UtilsTerminal.select({
|
|
1449
1460
|
question: `Select tag to remove`,
|
|
1450
1461
|
autocomplete: true,
|
|
1451
1462
|
choices: allTags.map(t => {
|
|
@@ -1541,7 +1552,7 @@ ${lastCommitMessage}
|
|
|
1541
1552
|
gitConfig() {
|
|
1542
1553
|
//#region @backendFunc
|
|
1543
1554
|
const root = index_1.Helpers.git.findGitRoot(this.cwd);
|
|
1544
|
-
index_1.Helpers.run(`code ${(0,
|
|
1555
|
+
index_1.Helpers.run(`code ${(0, lib_4.crossPlatformPath)([root, '.git', 'config'])}`).sync();
|
|
1545
1556
|
this._exit();
|
|
1546
1557
|
//#endregion
|
|
1547
1558
|
}
|
|
@@ -1578,12 +1589,12 @@ ${lastCommitMessage}
|
|
|
1578
1589
|
async updateDepsFrom() {
|
|
1579
1590
|
//#region @backendFunc
|
|
1580
1591
|
let locations = this.args.join(' ').trim() === '' ? [] : this.args;
|
|
1581
|
-
if (
|
|
1592
|
+
if (lib_3._.isArray(locations)) {
|
|
1582
1593
|
locations = locations.map(l => {
|
|
1583
|
-
if (
|
|
1584
|
-
return
|
|
1594
|
+
if (lib_3.path.isAbsolute(l)) {
|
|
1595
|
+
return lib_3.path.resolve(l);
|
|
1585
1596
|
}
|
|
1586
|
-
return
|
|
1597
|
+
return lib_3.path.resolve(lib_3.path.join(this.cwd, l));
|
|
1587
1598
|
});
|
|
1588
1599
|
}
|
|
1589
1600
|
this.project.packageJson.updateDepsFrom(locations);
|
|
@@ -1602,7 +1613,7 @@ ${lastCommitMessage}
|
|
|
1602
1613
|
//#region is terminal running inside cmd
|
|
1603
1614
|
isRunningInWindowsCmd() {
|
|
1604
1615
|
//#region @backendFunc
|
|
1605
|
-
console.log(`Is terminal running insdie cmd.exe: ${
|
|
1616
|
+
console.log(`Is terminal running insdie cmd.exe: ${lib_3.UtilsOs.isRunningInWindowsCmd()}`);
|
|
1606
1617
|
this._exit();
|
|
1607
1618
|
//#endregion
|
|
1608
1619
|
}
|
|
@@ -1610,7 +1621,7 @@ ${lastCommitMessage}
|
|
|
1610
1621
|
//#region is running inside powershell
|
|
1611
1622
|
isRunningInWindowsPowerShell() {
|
|
1612
1623
|
//#region @backendFunc
|
|
1613
|
-
console.log(`Is terminal running insdie powershell: ${
|
|
1624
|
+
console.log(`Is terminal running insdie powershell: ${lib_3.UtilsOs.isRunningInWindowsPowerShell()}`);
|
|
1614
1625
|
this._exit();
|
|
1615
1626
|
//#endregion
|
|
1616
1627
|
}
|
|
@@ -1749,7 +1760,7 @@ ${lastCommitMessage}
|
|
|
1749
1760
|
async waitForUserAnyKey() {
|
|
1750
1761
|
//#region @backendFunc
|
|
1751
1762
|
console.log('Press any key to exit...');
|
|
1752
|
-
await
|
|
1763
|
+
await lib_5.UtilsTerminal.waitForUserAnyKey(async () => {
|
|
1753
1764
|
console.log('Exiting...');
|
|
1754
1765
|
this._exit();
|
|
1755
1766
|
});
|
|
@@ -1789,7 +1800,7 @@ ${lastCommitMessage}
|
|
|
1789
1800
|
async isPortInUse() {
|
|
1790
1801
|
//#region @backendFunc
|
|
1791
1802
|
const port = parseInt(this.firstArg);
|
|
1792
|
-
console.log(`Port ${port} is in use: ${await
|
|
1803
|
+
console.log(`Port ${port} is in use: ${await lib_3.UtilsOs.isPortInUse(port)}`);
|
|
1793
1804
|
this._exit();
|
|
1794
1805
|
//#endregion
|
|
1795
1806
|
}
|
|
@@ -1864,16 +1875,16 @@ ${lastCommitMessage}
|
|
|
1864
1875
|
//#region @backendFunc
|
|
1865
1876
|
index_1.Helpers.info(`
|
|
1866
1877
|
|
|
1867
|
-
Is running in CLI mode: ${
|
|
1868
|
-
Is running in Mocha test: ${
|
|
1869
|
-
Is running in VSCode extension: ${
|
|
1870
|
-
Is running in Electron: ${
|
|
1871
|
-
Is running in Docker: ${
|
|
1872
|
-
Is running in WebSQL: ${
|
|
1873
|
-
Is running in WSL: ${
|
|
1874
|
-
Is running in Linux graphics capable environment: ${
|
|
1875
|
-
Is running in Node: ${
|
|
1876
|
-
Is running in Browser: ${
|
|
1878
|
+
Is running in CLI mode: ${lib_3.UtilsOs.isRunningInCliMode()}
|
|
1879
|
+
Is running in Mocha test: ${lib_3.UtilsOs.isRunningInMochaTest()}
|
|
1880
|
+
Is running in VSCode extension: ${lib_3.UtilsOs.isRunningInVscodeExtension()}
|
|
1881
|
+
Is running in Electron: ${lib_3.UtilsOs.isRunningInElectron()}
|
|
1882
|
+
Is running in Docker: ${lib_3.UtilsOs.isRunningInDocker()}
|
|
1883
|
+
Is running in WebSQL: ${lib_3.UtilsOs.isRunningInWebSQL()}
|
|
1884
|
+
Is running in WSL: ${lib_3.UtilsOs.isRunningInWsl()}
|
|
1885
|
+
Is running in Linux graphics capable environment: ${lib_3.UtilsOs.isRunningInLinuxGraphicsCapableEnvironment()}
|
|
1886
|
+
Is running in Node: ${lib_3.UtilsOs.isRunningInNode()}
|
|
1887
|
+
Is running in Browser: ${lib_3.UtilsOs.isRunningInBrowser()}
|
|
1877
1888
|
|
|
1878
1889
|
`);
|
|
1879
1890
|
this._exit();
|
|
@@ -1909,13 +1920,43 @@ ${lastCommitMessage}
|
|
|
1909
1920
|
index_1.Helpers.error(`No ports provided`, false, true);
|
|
1910
1921
|
}
|
|
1911
1922
|
for (const port of ports) {
|
|
1912
|
-
const isPortInUse = await
|
|
1913
|
-
console.log(`Port ${port} is in use: ${isPortInUse ?
|
|
1923
|
+
const isPortInUse = await lib_3.UtilsOs.isPortInUse(port);
|
|
1924
|
+
console.log(`Port ${port} is in use: ${isPortInUse ? lib_3.chalk.red('YES') : lib_3.chalk.green('NO')}`);
|
|
1914
1925
|
}
|
|
1915
1926
|
this._exit();
|
|
1916
1927
|
//#endregion
|
|
1917
1928
|
}
|
|
1918
1929
|
//#endregion
|
|
1930
|
+
symlink() {
|
|
1931
|
+
//#region @backendFunc
|
|
1932
|
+
let [fromArg, toArg] = this.args;
|
|
1933
|
+
if (!lib_3.path.isAbsolute(fromArg)) {
|
|
1934
|
+
fromArg = (0, lib_4.crossPlatformPath)([
|
|
1935
|
+
this.cwd,
|
|
1936
|
+
fromArg.replace('./', '').replace('.\\', ''),
|
|
1937
|
+
]);
|
|
1938
|
+
}
|
|
1939
|
+
if (!lib_3.path.isAbsolute(toArg)) {
|
|
1940
|
+
toArg = (0, lib_4.crossPlatformPath)([
|
|
1941
|
+
this.cwd,
|
|
1942
|
+
toArg.replace('./', '').replace('.\\', ''),
|
|
1943
|
+
]);
|
|
1944
|
+
}
|
|
1945
|
+
if (index_1.Helpers.isUnexistedLink(fromArg)) {
|
|
1946
|
+
index_1.Helpers.error(`Source path "${fromArg}" is an unexisted link`, false, true);
|
|
1947
|
+
}
|
|
1948
|
+
if (!index_1.Helpers.exists(fromArg)) {
|
|
1949
|
+
index_1.Helpers.error(`Source path "${fromArg}" does not exist`, false, true);
|
|
1950
|
+
}
|
|
1951
|
+
fromArg = (0, lib_4.crossPlatformPath)(lib_3.fse.realpathSync(fromArg));
|
|
1952
|
+
if (lib_3.path.basename(fromArg) !== lib_3.path.basename(toArg)) {
|
|
1953
|
+
toArg = (0, lib_4.crossPlatformPath)([toArg, lib_3.path.basename(fromArg)]);
|
|
1954
|
+
}
|
|
1955
|
+
index_1.Helpers.createSymLink(fromArg, toArg);
|
|
1956
|
+
index_1.Helpers.info(`Symlink created from "${fromArg}" to "${toArg}"`);
|
|
1957
|
+
this._exit();
|
|
1958
|
+
//#endregion
|
|
1959
|
+
}
|
|
1919
1960
|
//#region commands / remove symlinks
|
|
1920
1961
|
removeSymlinksDryRun() {
|
|
1921
1962
|
//#region @backendFunc
|
|
@@ -1955,14 +1996,14 @@ ${lastCommitMessage}
|
|
|
1955
1996
|
copy() {
|
|
1956
1997
|
//#region @backendFunc
|
|
1957
1998
|
let [from, to] = this.args;
|
|
1958
|
-
from =
|
|
1959
|
-
? (0,
|
|
1960
|
-
: (0,
|
|
1961
|
-
to =
|
|
1962
|
-
? (0,
|
|
1963
|
-
: (0,
|
|
1964
|
-
if (
|
|
1965
|
-
to = (0,
|
|
1999
|
+
from = lib_3.path.isAbsolute(from)
|
|
2000
|
+
? (0, lib_4.crossPlatformPath)(from)
|
|
2001
|
+
: (0, lib_4.crossPlatformPath)([this.cwd, from]);
|
|
2002
|
+
to = lib_3.path.isAbsolute(to)
|
|
2003
|
+
? (0, lib_4.crossPlatformPath)(to)
|
|
2004
|
+
: (0, lib_4.crossPlatformPath)([this.cwd, to]);
|
|
2005
|
+
if (lib_3.path.basename(to) !== lib_3.path.basename(from)) {
|
|
2006
|
+
to = (0, lib_4.crossPlatformPath)([to, lib_3.path.basename(from)]);
|
|
1966
2007
|
}
|
|
1967
2008
|
index_1.Helpers.taskStarted(`Copying from ${from} to ${to}`);
|
|
1968
2009
|
if (!index_1.Helpers.exists(from)) {
|
|
@@ -1987,7 +2028,7 @@ ${lastCommitMessage}
|
|
|
1987
2028
|
globalCommandName: 'simulateDomain',
|
|
1988
2029
|
});
|
|
1989
2030
|
if (!commandEvaluatedAsSudo) {
|
|
1990
|
-
await
|
|
2031
|
+
await lib_2.UtilsEtcHosts.simulateDomain(this.args);
|
|
1991
2032
|
}
|
|
1992
2033
|
this._exit();
|
|
1993
2034
|
//#endregion
|
|
@@ -1997,20 +2038,20 @@ ${lastCommitMessage}
|
|
|
1997
2038
|
async preview() {
|
|
1998
2039
|
//#region @backendFunc
|
|
1999
2040
|
//#region handle preview of docker compose
|
|
2000
|
-
if ([
|
|
2041
|
+
if ([lib_2.fileName.docker_compose_yml, lib_2.fileName.compose_yml].includes(lib_3.path.basename(this.firstArg))) {
|
|
2001
2042
|
const simulateDomain = this.params['domain'] || this.params['domains'];
|
|
2002
|
-
const firstArg =
|
|
2043
|
+
const firstArg = lib_3.path.isAbsolute(this.firstArg)
|
|
2003
2044
|
? this.firstArg
|
|
2004
|
-
: (0,
|
|
2005
|
-
const cwd = (0,
|
|
2006
|
-
const composeFileName =
|
|
2045
|
+
: (0, lib_4.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
2046
|
+
const cwd = (0, lib_4.crossPlatformPath)(lib_3.path.dirname(firstArg));
|
|
2047
|
+
const composeFileName = lib_3.path.basename(firstArg);
|
|
2007
2048
|
// import { spawn } from 'child_process';
|
|
2008
2049
|
// import { readFileSync } from 'fs';
|
|
2009
2050
|
// import { resolve } from 'path';
|
|
2010
|
-
const envPath = (0,
|
|
2011
|
-
const COMPOSE_PROJECT_NAME =
|
|
2012
|
-
const envContent =
|
|
2013
|
-
const allDomains =
|
|
2051
|
+
const envPath = (0, lib_4.crossPlatformPath)([cwd, '.env']);
|
|
2052
|
+
const COMPOSE_PROJECT_NAME = lib_6.UtilsDotFile.getValueFromDotFile(envPath, 'COMPOSE_PROJECT_NAME');
|
|
2053
|
+
const envContent = lib_6.UtilsDotFile.getValuesKeysAsJsonObject(envPath) || {};
|
|
2054
|
+
const allDomains = lib_3.Utils.uniqArray(Object.keys(envContent)
|
|
2014
2055
|
.filter(key => {
|
|
2015
2056
|
return key.startsWith('FRONTEND_HOST_URL_');
|
|
2016
2057
|
})
|
|
@@ -2022,7 +2063,7 @@ ${lastCommitMessage}
|
|
|
2022
2063
|
|
|
2023
2064
|
env.ts or env.angular-node-app.ENVIRONTMENT_NAME.ts with
|
|
2024
2065
|
|
|
2025
|
-
${
|
|
2066
|
+
${lib_3.chalk.bold(`website.useDomain = true;`)}
|
|
2026
2067
|
|
|
2027
2068
|
`, false, true);
|
|
2028
2069
|
}
|
|
@@ -2031,7 +2072,7 @@ ${lastCommitMessage}
|
|
|
2031
2072
|
let closing = false;
|
|
2032
2073
|
const triggerRevertChangesToEtcHosts = new rxjs_1.Subject();
|
|
2033
2074
|
if (simulateDomain) {
|
|
2034
|
-
await
|
|
2075
|
+
await lib_6.UtilsNetwork.simulateDomain(allDomains, {
|
|
2035
2076
|
triggerRevertChangesToEtcHosts,
|
|
2036
2077
|
});
|
|
2037
2078
|
}
|
|
@@ -2039,8 +2080,8 @@ ${lastCommitMessage}
|
|
|
2039
2080
|
console.log(`
|
|
2040
2081
|
|
|
2041
2082
|
|
|
2042
|
-
${
|
|
2043
|
-
`FOR ${
|
|
2083
|
+
${lib_3.chalk.bold('PRESS ANY KEY TO STOP')} RUNNING CONTAINER(S) ` +
|
|
2084
|
+
`FOR ${lib_3.chalk.bold.underline(COMPOSE_PROJECT_NAME)}
|
|
2044
2085
|
${simulateDomain ? `AND SIMULATING DOMAINS: ${allDomains.join(', ')} IN ETC/HOST` : ''}
|
|
2045
2086
|
|
|
2046
2087
|
|
|
@@ -2079,9 +2120,9 @@ ${lastCommitMessage}
|
|
|
2079
2120
|
async shorten() {
|
|
2080
2121
|
//#region @backendFunc
|
|
2081
2122
|
const rl = readline.createInterface({
|
|
2082
|
-
input:
|
|
2083
|
-
? (0,
|
|
2084
|
-
: (0,
|
|
2123
|
+
input: lib_3.fse.createReadStream(lib_3.path.isAbsolute(this.firstArg)
|
|
2124
|
+
? (0, lib_4.crossPlatformPath)(this.firstArg)
|
|
2125
|
+
: (0, lib_4.crossPlatformPath)([this.cwd, this.firstArg]), { encoding: 'utf8' }),
|
|
2085
2126
|
crlfDelay: Infinity,
|
|
2086
2127
|
});
|
|
2087
2128
|
const keywords = this.args.splice(1);
|
|
@@ -2100,26 +2141,26 @@ ${lastCommitMessage}
|
|
|
2100
2141
|
dumpPackagesVersions() {
|
|
2101
2142
|
//#region @backendFunc
|
|
2102
2143
|
const getData = (location) => {
|
|
2103
|
-
const version = index_1.Helpers.readValueFromJson((0,
|
|
2104
|
-
const name = index_1.Helpers.readValueFromJson((0,
|
|
2144
|
+
const version = index_1.Helpers.readValueFromJson((0, lib_4.crossPlatformPath)([location, lib_2.fileName.package_json]), 'version');
|
|
2145
|
+
const name = index_1.Helpers.readValueFromJson((0, lib_4.crossPlatformPath)([location, lib_2.fileName.package_json]), 'name');
|
|
2105
2146
|
return { version, name };
|
|
2106
2147
|
};
|
|
2107
|
-
const pkgs = index_1.Helpers.foldersFrom([this.cwd,
|
|
2148
|
+
const pkgs = index_1.Helpers.foldersFrom([this.cwd, lib_2.folderName.node_modules], {
|
|
2108
2149
|
recursive: false,
|
|
2109
2150
|
})
|
|
2110
2151
|
.reduce((arr, c) => {
|
|
2111
|
-
if (
|
|
2152
|
+
if (lib_3.path.basename(c).startsWith('@')) {
|
|
2112
2153
|
const newData = index_1.Helpers.foldersFrom([
|
|
2113
2154
|
this.cwd,
|
|
2114
|
-
|
|
2115
|
-
|
|
2155
|
+
lib_2.folderName.node_modules,
|
|
2156
|
+
lib_3.path.basename(c),
|
|
2116
2157
|
]).map(c2 => getData(c2));
|
|
2117
2158
|
return arr.concat(newData);
|
|
2118
2159
|
}
|
|
2119
2160
|
return arr.concat(getData(c));
|
|
2120
2161
|
}, [])
|
|
2121
2162
|
.reduce((arr, c) => {
|
|
2122
|
-
return
|
|
2163
|
+
return lib_3._.merge(arr, { [c.name]: c.version });
|
|
2123
2164
|
}, {});
|
|
2124
2165
|
index_1.Helpers.writeJson([this.cwd, 'packages-versions.json'], pkgs);
|
|
2125
2166
|
index_1.Helpers.info(`packages-versions.json created with ${pkgs.length} packages`);
|
|
@@ -2130,9 +2171,9 @@ ${lastCommitMessage}
|
|
|
2130
2171
|
//#region commands / zip
|
|
2131
2172
|
async zip() {
|
|
2132
2173
|
//#region @backendFunc
|
|
2133
|
-
let folderPath = (0,
|
|
2134
|
-
if (!
|
|
2135
|
-
folderPath = (0,
|
|
2174
|
+
let folderPath = (0, lib_4.crossPlatformPath)(this.firstArg);
|
|
2175
|
+
if (!lib_3.path.isAbsolute(folderPath)) {
|
|
2176
|
+
folderPath = (0, lib_4.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
2136
2177
|
}
|
|
2137
2178
|
if (!index_1.Helpers.exists(folderPath)) {
|
|
2138
2179
|
index_1.Helpers.error(`File or folder to zip does not exist: ${folderPath}`, false, true);
|
|
@@ -2151,9 +2192,9 @@ ${lastCommitMessage}
|
|
|
2151
2192
|
//#region commands / unzip
|
|
2152
2193
|
async unzip() {
|
|
2153
2194
|
//#region @backendFunc
|
|
2154
|
-
let folderPath = (0,
|
|
2155
|
-
if (!
|
|
2156
|
-
folderPath = (0,
|
|
2195
|
+
let folderPath = (0, lib_4.crossPlatformPath)(this.firstArg);
|
|
2196
|
+
if (!lib_3.path.isAbsolute(folderPath)) {
|
|
2197
|
+
folderPath = (0, lib_4.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
2157
2198
|
}
|
|
2158
2199
|
if (!index_1.Helpers.exists(folderPath)) {
|
|
2159
2200
|
index_1.Helpers.error(`File or folder to zip does not exist: ${folderPath}`, false, true);
|
|
@@ -2168,13 +2209,13 @@ ${lastCommitMessage}
|
|
|
2168
2209
|
async startTransmission() {
|
|
2169
2210
|
//#region @backendFunc
|
|
2170
2211
|
await this._removeTransmission();
|
|
2171
|
-
const userProfile = process.env.USERPROFILE ||
|
|
2172
|
-
const downloadsDir =
|
|
2173
|
-
const configDir =
|
|
2174
|
-
await
|
|
2212
|
+
const userProfile = process.env.USERPROFILE || lib_3.os.homedir();
|
|
2213
|
+
const downloadsDir = lib_3.path.join(userProfile, 'Downloads');
|
|
2214
|
+
const configDir = lib_3.path.join(userProfile, 'transmission-config');
|
|
2215
|
+
await lib_3.UtilsProcess.killProcessOnPort(9091);
|
|
2175
2216
|
const ctrl = await this.ins.portsWorker.getRemoteControllerFor({
|
|
2176
2217
|
methodOptions: {
|
|
2177
|
-
calledFrom: `${
|
|
2218
|
+
calledFrom: `${lib_2.config.frameworkName} startTransmission`,
|
|
2178
2219
|
},
|
|
2179
2220
|
});
|
|
2180
2221
|
const data = await ctrl
|
|
@@ -2206,7 +2247,7 @@ ${lastCommitMessage}
|
|
|
2206
2247
|
'linuxserver/transmission:latest',
|
|
2207
2248
|
];
|
|
2208
2249
|
console.log('Running:', 'docker', args.join(' '));
|
|
2209
|
-
const child =
|
|
2250
|
+
const child = lib_7.child_process.spawn('docker', args, { stdio: 'inherit' });
|
|
2210
2251
|
child.on('exit', code => {
|
|
2211
2252
|
if (code === 0) {
|
|
2212
2253
|
console.log('✅ Transmission container started');
|
|
@@ -2224,7 +2265,7 @@ ${lastCommitMessage}
|
|
|
2224
2265
|
return new Promise(resolve => {
|
|
2225
2266
|
const args = ['rm', '-f', 'transmission'];
|
|
2226
2267
|
console.log('Running:', 'docker', args.join(' '));
|
|
2227
|
-
const child =
|
|
2268
|
+
const child = lib_7.child_process.spawn('docker', args, { stdio: 'inherit' });
|
|
2228
2269
|
child.on('exit', code => {
|
|
2229
2270
|
if (code === 0) {
|
|
2230
2271
|
console.log('🗑️ Transmission container removed');
|
|
@@ -2286,9 +2327,9 @@ ${lastCommitMessage}
|
|
|
2286
2327
|
'browser',
|
|
2287
2328
|
];
|
|
2288
2329
|
const walk = (folder) => {
|
|
2289
|
-
const entries =
|
|
2330
|
+
const entries = lib_3.fse.readdirSync(folder, { withFileTypes: true });
|
|
2290
2331
|
for (const entry of entries) {
|
|
2291
|
-
const fullPath =
|
|
2332
|
+
const fullPath = lib_3.path.join(folder, entry.name);
|
|
2292
2333
|
if (skip.some(s => entry.name.startsWith(s))) {
|
|
2293
2334
|
continue;
|
|
2294
2335
|
}
|
|
@@ -2296,16 +2337,16 @@ ${lastCommitMessage}
|
|
|
2296
2337
|
// console.log('Processing: ', path.basename(fullPath));
|
|
2297
2338
|
walk(fullPath);
|
|
2298
2339
|
}
|
|
2299
|
-
else if (extensions.includes(
|
|
2300
|
-
const code =
|
|
2301
|
-
const stats = sloc(code,
|
|
2340
|
+
else if (extensions.includes(lib_3.path.extname(entry.name))) {
|
|
2341
|
+
const code = lib_3.fse.readFileSync(fullPath, 'utf8');
|
|
2342
|
+
const stats = sloc(code, lib_3.path.extname(entry.name).slice(1)); // e.g., "ts" or "js"
|
|
2302
2343
|
for (const key in total) {
|
|
2303
2344
|
total[key] += stats[key] ?? 0;
|
|
2304
2345
|
}
|
|
2305
2346
|
}
|
|
2306
2347
|
}
|
|
2307
2348
|
};
|
|
2308
|
-
walk((0,
|
|
2349
|
+
walk((0, lib_4.crossPlatformPath)([
|
|
2309
2350
|
this.cwd,
|
|
2310
2351
|
// 'src'
|
|
2311
2352
|
]));
|
|
@@ -2320,7 +2361,7 @@ ${lastCommitMessage}
|
|
|
2320
2361
|
isNodeVersionOk() {
|
|
2321
2362
|
//#region @backendFunc
|
|
2322
2363
|
try {
|
|
2323
|
-
|
|
2364
|
+
lib_3.UtilsOs.isNodeVersionOk({
|
|
2324
2365
|
throwErrorIfNotOk: true,
|
|
2325
2366
|
});
|
|
2326
2367
|
console.info(`Node.js version is OK: ${process.version}`);
|
|
@@ -2335,19 +2376,19 @@ ${lastCommitMessage}
|
|
|
2335
2376
|
//#endregion
|
|
2336
2377
|
//#region commands / pwd
|
|
2337
2378
|
pwd() {
|
|
2338
|
-
|
|
2339
|
-
console.log((0,
|
|
2379
|
+
lib_2.config.frameworkName = 'taon';
|
|
2380
|
+
console.log((0, lib_4.crossPlatformPath)(this.cwd));
|
|
2340
2381
|
this._exit();
|
|
2341
2382
|
}
|
|
2342
2383
|
//#endregion
|
|
2343
2384
|
//#region commands / less-more big text files preview
|
|
2344
2385
|
async more() {
|
|
2345
2386
|
//#region @backendFunc
|
|
2346
|
-
const pathToFile =
|
|
2347
|
-
? (0,
|
|
2348
|
-
: (0,
|
|
2387
|
+
const pathToFile = lib_3.path.isAbsolute(this.firstArg)
|
|
2388
|
+
? (0, lib_4.crossPlatformPath)(this.firstArg)
|
|
2389
|
+
: (0, lib_4.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
2349
2390
|
console.log(`Displaying file: ${pathToFile}`);
|
|
2350
|
-
await
|
|
2391
|
+
await lib_5.UtilsTerminal.previewLongListGitLogLike(index_1.Helpers.readFile(pathToFile) || '< empty log file >');
|
|
2351
2392
|
this._exit();
|
|
2352
2393
|
//#endregion
|
|
2353
2394
|
}
|
|
@@ -2365,8 +2406,8 @@ ${lastCommitMessage}
|
|
|
2365
2406
|
*/
|
|
2366
2407
|
MP3(args) {
|
|
2367
2408
|
//#region @backendFunc
|
|
2368
|
-
const downloadPath = (0,
|
|
2369
|
-
|
|
2409
|
+
const downloadPath = (0, lib_4.crossPlatformPath)([
|
|
2410
|
+
lib_3.UtilsOs.getRealHomeDir(),
|
|
2370
2411
|
'Downloads',
|
|
2371
2412
|
'mp3-from-websites',
|
|
2372
2413
|
]);
|
|
@@ -2385,8 +2426,8 @@ ${lastCommitMessage}
|
|
|
2385
2426
|
//#region commands / mp4
|
|
2386
2427
|
MP4(args) {
|
|
2387
2428
|
//#region @backendFunc
|
|
2388
|
-
const downloadPath = (0,
|
|
2389
|
-
|
|
2429
|
+
const downloadPath = (0, lib_4.crossPlatformPath)([
|
|
2430
|
+
lib_3.UtilsOs.getRealHomeDir(),
|
|
2390
2431
|
'Downloads',
|
|
2391
2432
|
'mp4-from-websites',
|
|
2392
2433
|
]);
|
|
@@ -2403,17 +2444,17 @@ ${lastCommitMessage}
|
|
|
2403
2444
|
//#region commands / gif from video
|
|
2404
2445
|
gif() {
|
|
2405
2446
|
//#region @backendFunc
|
|
2406
|
-
const cwdToProcess =
|
|
2407
|
-
?
|
|
2447
|
+
const cwdToProcess = lib_3.path.isAbsolute(this.firstArg)
|
|
2448
|
+
? lib_3.path.dirname(this.firstArg)
|
|
2408
2449
|
: this.cwd;
|
|
2409
|
-
const basenameToProcess =
|
|
2410
|
-
const gifDownloadPath = (0,
|
|
2411
|
-
|
|
2450
|
+
const basenameToProcess = lib_3.path.basename(this.firstArg);
|
|
2451
|
+
const gifDownloadPath = (0, lib_4.crossPlatformPath)([
|
|
2452
|
+
lib_3.UtilsOs.getRealHomeDir(),
|
|
2412
2453
|
'Downloads',
|
|
2413
2454
|
'gif-from-videos',
|
|
2414
|
-
basenameToProcess.replace(
|
|
2455
|
+
basenameToProcess.replace(lib_3.path.extname(basenameToProcess), '.gif'),
|
|
2415
2456
|
]);
|
|
2416
|
-
const palleteBasename = `${
|
|
2457
|
+
const palleteBasename = `${lib_3._.kebabCase(lib_3.path.basename(gifDownloadPath))}-palette.png`;
|
|
2417
2458
|
index_1.Helpers.removeFileIfExists([cwdToProcess, palleteBasename]);
|
|
2418
2459
|
const quality = `fps=10,scale=960`;
|
|
2419
2460
|
index_1.Helpers.info(`Preparing gif from video (creating palette)...`);
|
|
@@ -2425,18 +2466,18 @@ ${lastCommitMessage}
|
|
|
2425
2466
|
index_1.Helpers.info(`Preparing gif from video (creating video)...`);
|
|
2426
2467
|
index_1.Helpers.run(`ffmpeg -i ${basenameToProcess} -i ` +
|
|
2427
2468
|
` ${palleteBasename} -filter_complex ` +
|
|
2428
|
-
`"${quality}:-1:flags=lanczos[x];[x][1:v]paletteuse" ${
|
|
2469
|
+
`"${quality}:-1:flags=lanczos[x];[x][1:v]paletteuse" ${lib_3.path.basename(gifDownloadPath)}`, {
|
|
2429
2470
|
output: true,
|
|
2430
2471
|
cwd: cwdToProcess,
|
|
2431
2472
|
}).sync();
|
|
2432
2473
|
index_1.Helpers.removeFileIfExists(gifDownloadPath);
|
|
2433
|
-
index_1.Helpers.move((0,
|
|
2474
|
+
index_1.Helpers.move((0, lib_4.crossPlatformPath)([cwdToProcess, lib_3.path.basename(gifDownloadPath)]), gifDownloadPath);
|
|
2434
2475
|
index_1.Helpers.taskDone(`Done creating gif from video:
|
|
2435
2476
|
|
|
2436
2477
|
${gifDownloadPath}
|
|
2437
2478
|
|
|
2438
2479
|
`);
|
|
2439
|
-
index_1.Helpers.openFolderInFileExplorer(
|
|
2480
|
+
index_1.Helpers.openFolderInFileExplorer(lib_3.path.dirname(gifDownloadPath));
|
|
2440
2481
|
this._exit();
|
|
2441
2482
|
//#endregion
|
|
2442
2483
|
}
|
|
@@ -2509,7 +2550,7 @@ ${lastCommitMessage}
|
|
|
2509
2550
|
if (!this.firstArg) {
|
|
2510
2551
|
index_1.Helpers.error(`You need to provide command name to check`, false, true);
|
|
2511
2552
|
}
|
|
2512
|
-
const hasSudo = await
|
|
2553
|
+
const hasSudo = await lib_3.UtilsOs.commandExistsAsync(this.firstArg);
|
|
2513
2554
|
console.log(`[ASYNC] Your os has "${this.firstArg}" command: ${hasSudo}`);
|
|
2514
2555
|
this._exit();
|
|
2515
2556
|
//#endregion
|
|
@@ -2519,7 +2560,7 @@ ${lastCommitMessage}
|
|
|
2519
2560
|
if (!this.firstArg) {
|
|
2520
2561
|
index_1.Helpers.error(`You need to provide command name to check`, false, true);
|
|
2521
2562
|
}
|
|
2522
|
-
const hasSudo =
|
|
2563
|
+
const hasSudo = lib_3.UtilsOs.commandExistsSync(this.firstArg);
|
|
2523
2564
|
console.log(`[sync version] Your os has "${this.firstArg}" command: ${hasSudo}`);
|
|
2524
2565
|
this._exit();
|
|
2525
2566
|
//#endregion
|
|
@@ -2527,7 +2568,7 @@ ${lastCommitMessage}
|
|
|
2527
2568
|
//#endregion
|
|
2528
2569
|
//#region commands / public ip address
|
|
2529
2570
|
async publicIpAddress() {
|
|
2530
|
-
const ip = await
|
|
2571
|
+
const ip = await lib_6.UtilsNetwork.getCurrentPublicIpAddress();
|
|
2531
2572
|
console.log(`Your public IP address is: ${ip}`);
|
|
2532
2573
|
this._exit();
|
|
2533
2574
|
}
|
|
@@ -2539,9 +2580,9 @@ ${lastCommitMessage}
|
|
|
2539
2580
|
//#endregion
|
|
2540
2581
|
//#region commands / open origins in vscode
|
|
2541
2582
|
async localIps() {
|
|
2542
|
-
const firstActiveLocalIp = await
|
|
2583
|
+
const firstActiveLocalIp = await lib_6.UtilsNetwork.getFirstIpV4LocalActiveIpAddress();
|
|
2543
2584
|
console.log(`Your first active local IP address is: ${firstActiveLocalIp} `);
|
|
2544
|
-
const ips = await
|
|
2585
|
+
const ips = await lib_6.UtilsNetwork.getLocalIpAddresses();
|
|
2545
2586
|
for (let index = 0; index < ips.length; index++) {
|
|
2546
2587
|
const ip = ips[index];
|
|
2547
2588
|
// console.log(ip);
|
|
@@ -2554,8 +2595,8 @@ ${lastCommitMessage}
|
|
|
2554
2595
|
//#region commands / is online
|
|
2555
2596
|
async isOnline() {
|
|
2556
2597
|
//#region @backendFunc
|
|
2557
|
-
const pingIsOK = await
|
|
2558
|
-
const checkIfServerIsOnline = await
|
|
2598
|
+
const pingIsOK = await lib_6.UtilsNetwork.checkIfServerPings(this.firstArg);
|
|
2599
|
+
const checkIfServerIsOnline = await lib_6.UtilsNetwork.checkIfServerOnline(this.firstArg);
|
|
2559
2600
|
console.log(`Server ${this.firstArg}
|
|
2560
2601
|
|
|
2561
2602
|
is ping ok ?: ${pingIsOK}
|
|
@@ -2600,17 +2641,17 @@ ${lastCommitMessage}
|
|
|
2600
2641
|
//#region commands / is elevated
|
|
2601
2642
|
async isElevated() {
|
|
2602
2643
|
//#region @backendFunc
|
|
2603
|
-
console.log(`Is running with elevated privileges (sudo/admin): ${await (0,
|
|
2644
|
+
console.log(`Is running with elevated privileges (sudo/admin): ${await (0, lib_3.isElevated)()}`);
|
|
2604
2645
|
this._exit();
|
|
2605
2646
|
//#endregion
|
|
2606
2647
|
}
|
|
2607
2648
|
//#endregion
|
|
2608
2649
|
//#region commands / sudo check
|
|
2609
2650
|
async sudoCheck() {
|
|
2610
|
-
const sudoStatus = await
|
|
2651
|
+
const sudoStatus = await lib_8.UtilsSudo.getStatus();
|
|
2611
2652
|
console.log('is command available', sudoStatus.isAvailable);
|
|
2612
2653
|
console.log('is inline sudo enable', sudoStatus.isInline);
|
|
2613
|
-
console.log('is this command elevated (sudo or admin)', await (0,
|
|
2654
|
+
console.log('is this command elevated (sudo or admin)', await (0, lib_3.isElevated)());
|
|
2614
2655
|
this._exit();
|
|
2615
2656
|
}
|
|
2616
2657
|
//#endregion
|
|
@@ -2621,10 +2662,10 @@ ${lastCommitMessage}
|
|
|
2621
2662
|
if (!moduleName) {
|
|
2622
2663
|
index_1.Helpers.error(`You need to provide python module name to check`, false, true);
|
|
2623
2664
|
}
|
|
2624
|
-
let exists = await
|
|
2665
|
+
let exists = await lib_3.UtilsOs.pythonModuleExists(moduleName);
|
|
2625
2666
|
if (!exists) {
|
|
2626
2667
|
index_1.Helpers.warn(`Module not found in global python packages, checking pipx packages...`);
|
|
2627
|
-
exists = await
|
|
2668
|
+
exists = await lib_3.UtilsOs.pipxPackageExists(moduleName);
|
|
2628
2669
|
}
|
|
2629
2670
|
console.log(`Python module "${moduleName}" exists: ${exists ? 'YES' : 'NO'}`);
|
|
2630
2671
|
this._exit();
|