tnp-helpers 19.0.2 → 19.0.4
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/assets/shared/shared_folder_info.txt +1 -1
- package/browser/fesm2022/tnp-helpers.mjs +79 -10
- package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base/classes/base-git.d.ts +12 -1
- package/browser/lib/base/classes/base-package-json.d.ts +1 -0
- package/browser/lib/base/classes/base-release-process.d.ts +1 -0
- package/browser/lib/build-info._auto-generated_.d.ts +1 -1
- package/browser/lib/helpers/for-backend/helpers-file-folders.d.ts +2 -2
- package/browser/package.json +13 -0
- package/client/fesm2022/tnp-helpers.mjs +79 -10
- package/client/fesm2022/tnp-helpers.mjs.map +1 -1
- package/client/lib/base/classes/base-git.d.ts +12 -1
- package/client/lib/base/classes/base-package-json.d.ts +1 -0
- package/client/lib/base/classes/base-release-process.d.ts +1 -0
- package/client/lib/build-info._auto-generated_.d.ts +1 -1
- package/client/lib/helpers/for-backend/helpers-file-folders.d.ts +2 -2
- package/client/package.json +13 -0
- package/lib/base/classes/base-cli-worker-config.d.ts +27 -0
- package/lib/base/classes/base-cli-worker-config.js +64 -0
- package/lib/base/classes/base-cli-worker-config.js.map +1 -0
- package/lib/base/classes/base-cli-worker-controller.d.ts +15 -0
- package/lib/base/classes/base-cli-worker-controller.js +124 -0
- package/lib/base/classes/base-cli-worker-controller.js.map +1 -0
- package/lib/base/classes/base-cli-worker.d.ts +111 -0
- package/lib/base/classes/base-cli-worker.js +535 -0
- package/lib/base/classes/base-cli-worker.js.map +1 -0
- package/lib/base/classes/base-detached-service.d.ts +6 -0
- package/lib/base/classes/base-detached-service.js +16 -0
- package/lib/base/classes/base-detached-service.js.map +1 -0
- package/lib/base/classes/base-git.d.ts +11 -0
- package/lib/base/classes/base-git.js +31 -0
- package/lib/base/classes/base-git.js.map +1 -1
- package/lib/base/classes/base-github-pages.d.ts +14 -0
- package/lib/base/classes/base-github-pages.js +173 -0
- package/lib/base/classes/base-github-pages.js.map +1 -0
- package/lib/base/classes/base-global-command-line.backend.d.ts +1 -0
- package/lib/base/classes/base-global-command-line.backend.js +9 -1
- package/lib/base/classes/base-global-command-line.backend.js.map +1 -1
- package/lib/base/classes/base-node-modules.js +16 -14
- package/lib/base/classes/base-node-modules.js.map +1 -1
- package/lib/base/classes/base-package-json.d.ts +1 -0
- package/lib/base/classes/base-package-json.js +5 -0
- package/lib/base/classes/base-package-json.js.map +1 -1
- package/lib/base/classes/base-powershell.js +4 -0
- package/lib/base/classes/base-powershell.js.map +1 -1
- package/lib/base/classes/base-release-process.d.ts +1 -0
- package/lib/base/classes/base-release-process.js +40 -13
- package/lib/base/classes/base-release-process.js.map +1 -1
- package/lib/base/tcp-udp-ports/not-assignable-port.entity.js +2 -2
- package/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +9 -9
- 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-file-folders.backend.d.ts +104 -0
- package/lib/helpers/for-backend/helpers-file-folders.backend.js +896 -0
- package/lib/helpers/for-backend/helpers-file-folders.backend.js.map +1 -0
- package/lib/helpers/for-backend/helpers-file-folders.d.ts +2 -2
- package/lib/helpers/for-backend/helpers-file-folders.js +9 -8
- package/lib/helpers/for-backend/helpers-file-folders.js.map +1 -1
- package/lib/helpers/for-backend/helpers-git.backend.d.ts +10 -0
- package/lib/helpers/for-backend/helpers-git.backend.js +76 -2
- package/lib/helpers/for-backend/helpers-git.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-process.backend.d.ts +87 -0
- package/lib/helpers/for-backend/helpers-process.backend.js +456 -0
- package/lib/helpers/for-backend/helpers-process.backend.js.map +1 -0
- package/lib/helpers/for-backend/ts-code/index.d.ts +1 -0
- package/lib/helpers/for-backend/ts-code/index.js +5 -0
- package/lib/helpers/for-backend/ts-code/index.js.map +1 -0
- package/lib/helpers/for-backend/ts-code/ts-import-export-extractor.d.ts +29 -0
- package/lib/helpers/for-backend/ts-code/ts-import-export-extractor.js +81 -0
- package/lib/helpers/for-backend/ts-code/ts-import-export-extractor.js.map +1 -0
- package/lib/helpers/for-browser/angular.helper.js +2 -2
- package/lib/helpers/helpers.js +5 -1
- package/lib/helpers/helpers.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.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.d.ts +1 -1
- package/lib/old/execute-command.js +2 -2
- package/lib/old/execute-command.js.map +1 -1
- package/package.json +1 -1
- package/tmp-environment.json +4 -3
- package/websql/fesm2022/tnp-helpers.mjs +79 -10
- package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base/classes/base-git.d.ts +12 -1
- package/websql/lib/base/classes/base-package-json.d.ts +1 -0
- package/websql/lib/base/classes/base-release-process.d.ts +1 -0
- package/websql/lib/build-info._auto-generated_.d.ts +1 -1
- package/websql/lib/helpers/for-backend/helpers-file-folders.d.ts +2 -2
- package/websql/package.json +13 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Level } from 'ng2-logger';
|
|
2
|
+
import type { ChildProcess } from 'child_process';
|
|
3
|
+
export declare class HelpersProcess {
|
|
4
|
+
restartApplicationItself(nameOfApp: string): Promise<unknown>;
|
|
5
|
+
osIsMacOs(versino: 'big-sur' | 'catalina'): boolean;
|
|
6
|
+
generatedFileWrap(content: string): string;
|
|
7
|
+
changeCwdWrapper(dir: string, functionToExecure: Function, logLevel?: Level): Promise<void>;
|
|
8
|
+
changeCwd(dir?: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* // TODO refactor this
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
13
|
+
goToDir(dir?: string): boolean;
|
|
14
|
+
pressKeyOrWait(message?: string, printWaitMessages?: number): Promise<unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated use UtilsTerminal.pressAnyKey
|
|
17
|
+
*/
|
|
18
|
+
pressKeyAndContinue(message?: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated use UtilsTerminal.multiselect
|
|
21
|
+
*/
|
|
22
|
+
list<T = string>(question: string, choices: {
|
|
23
|
+
name: string;
|
|
24
|
+
value: T;
|
|
25
|
+
}[] | {
|
|
26
|
+
[choice: string]: {
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
29
|
+
}): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated use UtilsTerminal.multiselect
|
|
32
|
+
*/
|
|
33
|
+
multipleChoicesAsk(question: string, choices: {
|
|
34
|
+
name: string;
|
|
35
|
+
value: string;
|
|
36
|
+
}[], autocomplete?: boolean, selected?: {
|
|
37
|
+
name: string;
|
|
38
|
+
value: string;
|
|
39
|
+
}[]): Promise<string[]>;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated use UtilsTerminal.input
|
|
42
|
+
*/
|
|
43
|
+
input(options: {
|
|
44
|
+
defaultValue?: string;
|
|
45
|
+
question: string;
|
|
46
|
+
validate?: (value: string) => boolean;
|
|
47
|
+
}): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated use UtilsTerminal.multiselect
|
|
50
|
+
* TODO wierd problem when pressing key like "i"
|
|
51
|
+
*/
|
|
52
|
+
selectChoicesAsk<T = string>(question: string, choices: {
|
|
53
|
+
name: string;
|
|
54
|
+
value: T;
|
|
55
|
+
}[] | {
|
|
56
|
+
[choice: string]: {
|
|
57
|
+
name: string;
|
|
58
|
+
};
|
|
59
|
+
}): Promise<T>;
|
|
60
|
+
autocompleteAsk<T = string>(question: string, choices: {
|
|
61
|
+
name: string;
|
|
62
|
+
value: T;
|
|
63
|
+
}[], pageSize?: number): Promise<T>;
|
|
64
|
+
getWorkingDirOfProcess(PID: number): string;
|
|
65
|
+
outputToVScode(data: {
|
|
66
|
+
label: string;
|
|
67
|
+
option: string;
|
|
68
|
+
}[] | string, disableEncode?: boolean): void;
|
|
69
|
+
actionWrapper(fn: () => void, taskName?: string): Promise<void>;
|
|
70
|
+
terminalLine(): string;
|
|
71
|
+
/**
|
|
72
|
+
* THIS DEOS NOT WORK !
|
|
73
|
+
* ! TOOD FIX THIS
|
|
74
|
+
*/
|
|
75
|
+
killAllNodeExceptCurrentProcess(): Promise<void>;
|
|
76
|
+
killAllNode(): void;
|
|
77
|
+
formatPath(pathToFileOrFolder: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated
|
|
80
|
+
*/
|
|
81
|
+
prepareWatchCommand(cmd: any): string;
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated
|
|
84
|
+
*/
|
|
85
|
+
getStringFrom(command: string, descriptionOfCommand?: string): string;
|
|
86
|
+
waitForMessegeInStdout(proc: ChildProcess, message: string): Promise<unknown>;
|
|
87
|
+
}
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HelpersProcess = void 0;
|
|
4
|
+
//#region imports
|
|
5
|
+
const tnp_core_1 = require("tnp-core");
|
|
6
|
+
const tnp_core_2 = require("tnp-core");
|
|
7
|
+
const dateformat = require("dateformat");
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const index_1 = require("../../index");
|
|
10
|
+
const typescript_class_helpers_1 = require("typescript-class-helpers");
|
|
11
|
+
const tnp_config_1 = require("tnp-config");
|
|
12
|
+
const ng2_logger_1 = require("ng2-logger");
|
|
13
|
+
const fuzzy = require("fuzzy");
|
|
14
|
+
const spawn = require("cross-spawn");
|
|
15
|
+
//#endregion
|
|
16
|
+
class HelpersProcess {
|
|
17
|
+
//#region restart application itself
|
|
18
|
+
async restartApplicationItself(nameOfApp) {
|
|
19
|
+
index_1.Helpers.log(`Restarting ${nameOfApp}`);
|
|
20
|
+
return new Promise(() => {
|
|
21
|
+
setTimeout(function () {
|
|
22
|
+
process.on('exit', function () {
|
|
23
|
+
spawn(process.argv.shift(), [...process.argv, '--restarting'], {
|
|
24
|
+
cwd: (0, tnp_core_1.crossPlatformPath)(process.cwd()),
|
|
25
|
+
detached: true,
|
|
26
|
+
stdio: 'inherit',
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
process.exit();
|
|
30
|
+
}, 5000);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region os is macos
|
|
35
|
+
osIsMacOs(versino) {
|
|
36
|
+
if (versino == 'big-sur') {
|
|
37
|
+
return tnp_core_1.os.release().startsWith('20.');
|
|
38
|
+
}
|
|
39
|
+
if (versino == 'catalina') {
|
|
40
|
+
return tnp_core_1.os.release().startsWith('19.');
|
|
41
|
+
}
|
|
42
|
+
// TODO other oses
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region generate file wrap
|
|
46
|
+
generatedFileWrap(content) {
|
|
47
|
+
return `${content}
|
|
48
|
+
// [${tnp_config_1.config.frameworkName}] GENERATED CONTENT FOR BACKEND VERSION
|
|
49
|
+
// [${tnp_config_1.config.frameworkName}] GENERATED CONTENT FOR BACKEND VERSION
|
|
50
|
+
`.trim();
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region change cwd wrapper
|
|
54
|
+
async changeCwdWrapper(dir, functionToExecure, logLevel = ng2_logger_1.Level.__NOTHING) {
|
|
55
|
+
const currentCwd = (0, tnp_core_1.crossPlatformPath)(process.cwd());
|
|
56
|
+
index_1.Helpers.changeCwd(dir);
|
|
57
|
+
ng2_logger_1.Log.disableLogs(logLevel);
|
|
58
|
+
await index_1.Helpers.runSyncOrAsync({ functionFn: functionToExecure });
|
|
59
|
+
ng2_logger_1.Log.enableLogs();
|
|
60
|
+
index_1.Helpers.changeCwd(currentCwd);
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region change cwd
|
|
64
|
+
changeCwd(dir) {
|
|
65
|
+
if (!dir) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
index_1.Helpers.goToDir(dir);
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region go to dir
|
|
72
|
+
/**
|
|
73
|
+
* // TODO refactor this
|
|
74
|
+
* @deprecated
|
|
75
|
+
*/
|
|
76
|
+
goToDir(dir = '..') {
|
|
77
|
+
const previous = (0, tnp_core_1.crossPlatformPath)(process.cwd());
|
|
78
|
+
try {
|
|
79
|
+
dir = tnp_core_1.path.isAbsolute(dir)
|
|
80
|
+
? dir
|
|
81
|
+
: (0, tnp_core_1.crossPlatformPath)(tnp_core_1.path.resolve(tnp_core_1.path.join((0, tnp_core_1.crossPlatformPath)(process.cwd()), dir)));
|
|
82
|
+
if (tnp_core_1.path.basename(dir) === tnp_config_1.config.folder.external) {
|
|
83
|
+
const belowExternal = tnp_core_1.path.resolve(tnp_core_1.path.join(dir, '..'));
|
|
84
|
+
const classProject = typescript_class_helpers_1.CLASS.getBy('Project');
|
|
85
|
+
if (tnp_core_1.fse.existsSync(belowExternal) &&
|
|
86
|
+
!!classProject.ins.From(belowExternal)) {
|
|
87
|
+
dir = belowExternal;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
process.chdir(dir);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
this.goToDir(previous);
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region press key or wait
|
|
100
|
+
async pressKeyOrWait(message = 'Press enter try again', printWaitMessages = 0) {
|
|
101
|
+
if (tnp_core_1._.isNumber(printWaitMessages) && printWaitMessages > 0) {
|
|
102
|
+
index_1.Helpers.log(`Please wait (${printWaitMessages}) seconds`);
|
|
103
|
+
await index_1.Helpers.pressKeyOrWait(message, printWaitMessages - 1);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
return new Promise(resovle => {
|
|
107
|
+
index_1.Helpers.log(message);
|
|
108
|
+
process.stdin.once('data', function () {
|
|
109
|
+
resovle(void 0);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region press key and continue
|
|
115
|
+
/**
|
|
116
|
+
* @deprecated use UtilsTerminal.pressAnyKey
|
|
117
|
+
*/
|
|
118
|
+
pressKeyAndContinue(message = 'Press enter to continue..') {
|
|
119
|
+
return tnp_core_2.UtilsTerminal.pressAnyKey({ message });
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region list
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated use UtilsTerminal.multiselect
|
|
125
|
+
*/
|
|
126
|
+
async list(question, choices) {
|
|
127
|
+
//#region @backendFunc
|
|
128
|
+
if (!tnp_core_1._.isArray(choices) && tnp_core_1._.isObject(choices)) {
|
|
129
|
+
choices = Object.keys(choices)
|
|
130
|
+
.map(key => {
|
|
131
|
+
return {
|
|
132
|
+
name: choices[key].name,
|
|
133
|
+
value: key,
|
|
134
|
+
};
|
|
135
|
+
})
|
|
136
|
+
.reduce((a, b) => a.concat(b), []);
|
|
137
|
+
}
|
|
138
|
+
const inquirer = await Promise.resolve().then(() => require('inquirer'));
|
|
139
|
+
const res = (await inquirer.prompt({
|
|
140
|
+
type: 'list',
|
|
141
|
+
name: 'value',
|
|
142
|
+
message: question,
|
|
143
|
+
choices,
|
|
144
|
+
pageSize: 10,
|
|
145
|
+
loop: true,
|
|
146
|
+
}));
|
|
147
|
+
return res.value;
|
|
148
|
+
//#endregion
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region multiple choices ask
|
|
152
|
+
/**
|
|
153
|
+
* @deprecated use UtilsTerminal.multiselect
|
|
154
|
+
*/
|
|
155
|
+
async multipleChoicesAsk(question, choices, autocomplete = false, selected) {
|
|
156
|
+
return tnp_core_2.UtilsTerminal.multiselect({
|
|
157
|
+
question,
|
|
158
|
+
choices,
|
|
159
|
+
autocomplete,
|
|
160
|
+
defaultSelected: (selected || []).map(s => s.value),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region input
|
|
165
|
+
/**
|
|
166
|
+
* @deprecated use UtilsTerminal.input
|
|
167
|
+
*/
|
|
168
|
+
async input(options) {
|
|
169
|
+
return await tnp_core_2.UtilsTerminal.input(options);
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region select
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated use UtilsTerminal.multiselect
|
|
175
|
+
* TODO wierd problem when pressing key like "i"
|
|
176
|
+
*/
|
|
177
|
+
async selectChoicesAsk(question, choices) {
|
|
178
|
+
//#region @backendFunc
|
|
179
|
+
// console.log({ choices })
|
|
180
|
+
// Helpers.pressKeyAndContinue()
|
|
181
|
+
if (!tnp_core_1._.isArray(choices) && tnp_core_1._.isObject(choices)) {
|
|
182
|
+
choices = Object.keys(choices)
|
|
183
|
+
.map(key => {
|
|
184
|
+
return {
|
|
185
|
+
name: choices[key].name,
|
|
186
|
+
value: key,
|
|
187
|
+
};
|
|
188
|
+
})
|
|
189
|
+
.reduce((a, b) => a.concat(b), []);
|
|
190
|
+
}
|
|
191
|
+
const { AutoComplete } = require('enquirer');
|
|
192
|
+
const prompt = new AutoComplete({
|
|
193
|
+
name: 'value',
|
|
194
|
+
message: question,
|
|
195
|
+
limit: 10,
|
|
196
|
+
multiple: false,
|
|
197
|
+
autocomplete: false,
|
|
198
|
+
choices,
|
|
199
|
+
hint: '- Space to select. Return to submit',
|
|
200
|
+
footer() {
|
|
201
|
+
return tnp_core_2.CLI.chalk.green('(Scroll up and down to reveal more choices)');
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
const res = await prompt.run();
|
|
205
|
+
return res;
|
|
206
|
+
//#endregion
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region autocomplete ask
|
|
210
|
+
async autocompleteAsk(question, choices, pageSize = 10) {
|
|
211
|
+
//#region @backendFunc
|
|
212
|
+
const source = (__, input) => {
|
|
213
|
+
input = input || '';
|
|
214
|
+
return new Promise(resolve => {
|
|
215
|
+
const fuzzyResult = fuzzy.filter(input, choices.map(f => f.name));
|
|
216
|
+
resolve(fuzzyResult.map(el => {
|
|
217
|
+
return {
|
|
218
|
+
name: el.original,
|
|
219
|
+
value: choices.find(c => c.name === el.original).value,
|
|
220
|
+
};
|
|
221
|
+
}));
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
const inquirer = await Promise.resolve().then(() => require('inquirer'));
|
|
225
|
+
const inquirerAutocomplete = await Promise.resolve().then(() => require('inquirer-autocomplete-prompt'));
|
|
226
|
+
inquirer.registerPrompt('autocomplete', inquirerAutocomplete);
|
|
227
|
+
const res = (await inquirer.prompt({
|
|
228
|
+
type: 'autocomplete',
|
|
229
|
+
name: 'command',
|
|
230
|
+
pageSize,
|
|
231
|
+
source,
|
|
232
|
+
message: question,
|
|
233
|
+
choices,
|
|
234
|
+
}));
|
|
235
|
+
return res.command;
|
|
236
|
+
//#endregion
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region get working dir of process
|
|
240
|
+
getWorkingDirOfProcess(PID) {
|
|
241
|
+
try {
|
|
242
|
+
const cwd = tnp_core_1.child_process
|
|
243
|
+
.execSync(`lsof -p ${PID} | awk '$4=="cwd" {print $9}'`)
|
|
244
|
+
.toString()
|
|
245
|
+
.trim();
|
|
246
|
+
return cwd;
|
|
247
|
+
}
|
|
248
|
+
catch (e) {
|
|
249
|
+
index_1.Helpers.error(e);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region output to vscode
|
|
254
|
+
outputToVScode(data, disableEncode = false) {
|
|
255
|
+
if (tnp_core_1._.isObject(data)) {
|
|
256
|
+
data = JSON.stringify(data);
|
|
257
|
+
}
|
|
258
|
+
if (disableEncode) {
|
|
259
|
+
console.log(data);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
console.log(encodeURIComponent(data));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region action wrapper
|
|
267
|
+
async actionWrapper(fn, taskName = 'Task') {
|
|
268
|
+
function currentDate() {
|
|
269
|
+
return `[${dateformat(new Date(), 'dd-mm-yyyy HH:MM:ss')}]`;
|
|
270
|
+
}
|
|
271
|
+
// global.spinner && global.spinner.start()
|
|
272
|
+
index_1.Helpers.taskStarted(`${currentDate()} "${taskName}" Started..`);
|
|
273
|
+
await index_1.Helpers.runSyncOrAsync({ functionFn: fn });
|
|
274
|
+
index_1.Helpers.taskDone(`${currentDate()} "${taskName}" Done`);
|
|
275
|
+
// global.spinner && global.spinner.stop()
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region terminal line
|
|
279
|
+
terminalLine() {
|
|
280
|
+
return tnp_core_1._.times(process.stdout.columns, () => '-').join('');
|
|
281
|
+
}
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region kill all node except current process
|
|
284
|
+
/**
|
|
285
|
+
* THIS DEOS NOT WORK !
|
|
286
|
+
* ! TOOD FIX THIS
|
|
287
|
+
*/
|
|
288
|
+
async killAllNodeExceptCurrentProcess() {
|
|
289
|
+
return new Promise((resolve, reject) => {
|
|
290
|
+
// Get the current process ID
|
|
291
|
+
const currentProcessId = process.pid;
|
|
292
|
+
// Command to list all Node.js processes
|
|
293
|
+
const listProcessesCommand = process.platform === 'win32'
|
|
294
|
+
? 'tasklist /fi "imagename eq node.exe" /fo csv'
|
|
295
|
+
: 'ps -A -o pid,command | grep node';
|
|
296
|
+
// Execute the command to list processes
|
|
297
|
+
(0, child_process_1.exec)(listProcessesCommand, { shell: process.platform === 'win32' ? 'cmd.exe' : void 0 }, (error, stdout, stderr) => {
|
|
298
|
+
if (error) {
|
|
299
|
+
reject(new Error(`Error occurred while listing processes: ${error.message}`));
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (stderr) {
|
|
303
|
+
reject(new Error(`Error occurred while listing processes: ${stderr}`));
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
// Split the output into lines and filter out non-node processes
|
|
307
|
+
const processes = stdout
|
|
308
|
+
.split('\n')
|
|
309
|
+
.map(line => line.trim())
|
|
310
|
+
.filter(line => line.includes('node') &&
|
|
311
|
+
!line.includes('grep') &&
|
|
312
|
+
!line.includes('tasklist'));
|
|
313
|
+
// Extract the process IDs
|
|
314
|
+
const processIds = processes.map(line => parseInt(line.split(',')[1]));
|
|
315
|
+
// Filter out the current process ID
|
|
316
|
+
const processesToKill = processIds
|
|
317
|
+
.filter(id => id !== currentProcessId)
|
|
318
|
+
.filter(f => !!f);
|
|
319
|
+
// If there are no processes to kill, resolve immediately
|
|
320
|
+
if (processesToKill.length === 0) {
|
|
321
|
+
resolve();
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
// Kill the processes
|
|
325
|
+
let numProcessesKilled = 0;
|
|
326
|
+
processesToKill.forEach(id => {
|
|
327
|
+
const killCommand = process.platform === 'win32'
|
|
328
|
+
? `taskkill /pid ${id} /f`
|
|
329
|
+
: `kill ${id}`;
|
|
330
|
+
(0, child_process_1.exec)(killCommand, error => {
|
|
331
|
+
if (error) {
|
|
332
|
+
console.error(`Error occurred while killing process ${id}:`, error);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
console.log(`Successfully killed process ${id}`);
|
|
336
|
+
}
|
|
337
|
+
numProcessesKilled++;
|
|
338
|
+
if (numProcessesKilled === processesToKill.length) {
|
|
339
|
+
resolve();
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region kill all node
|
|
348
|
+
killAllNode() {
|
|
349
|
+
index_1.Helpers.info('Killing all node processes...');
|
|
350
|
+
try {
|
|
351
|
+
if (process.platform === 'win32') {
|
|
352
|
+
index_1.Helpers.run(`taskkill /f /im node.exe`, {
|
|
353
|
+
output: false,
|
|
354
|
+
silence: true,
|
|
355
|
+
}).sync();
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
index_1.Helpers.run(`fkill -f node`, { output: false, silence: true }).sync();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
index_1.Helpers.error(`[${tnp_config_1.config.frameworkName}] not able to kill all node processes`, false, true);
|
|
363
|
+
}
|
|
364
|
+
index_1.Helpers.info('DONE KILL ALL NODE PROCESSES');
|
|
365
|
+
}
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region format path
|
|
368
|
+
formatPath(pathToFileOrFolder) {
|
|
369
|
+
if (!tnp_core_1._.isString(pathToFileOrFolder)) {
|
|
370
|
+
return `\n< provided path is not string: ${pathToFileOrFolder} >\n`;
|
|
371
|
+
}
|
|
372
|
+
if (!tnp_core_1.path.isAbsolute(pathToFileOrFolder)) {
|
|
373
|
+
return `\n
|
|
374
|
+
${index_1.Helpers.terminalLine()}
|
|
375
|
+
relativePath: ${pathToFileOrFolder}
|
|
376
|
+
${index_1.Helpers.terminalLine()}\n`;
|
|
377
|
+
}
|
|
378
|
+
if (!tnp_core_1.fse.existsSync(pathToFileOrFolder)) {
|
|
379
|
+
return `\n
|
|
380
|
+
${index_1.Helpers.terminalLine()}
|
|
381
|
+
< provided path does not exist: ${pathToFileOrFolder} >
|
|
382
|
+
${index_1.Helpers.terminalLine()}\n`;
|
|
383
|
+
}
|
|
384
|
+
const isDirectory = tnp_core_1.fse.lstatSync(pathToFileOrFolder).isDirectory();
|
|
385
|
+
return `
|
|
386
|
+
${index_1.Helpers.terminalLine()}
|
|
387
|
+
<-- ${isDirectory ? 'Path to directory' : 'Path to file'}: -->
|
|
388
|
+
${isDirectory
|
|
389
|
+
? pathToFileOrFolder
|
|
390
|
+
.split('/')
|
|
391
|
+
.map(c => `/${c}`)
|
|
392
|
+
.join('')
|
|
393
|
+
.replace(/^\//, '')
|
|
394
|
+
: tnp_core_1.path.dirname(pathToFileOrFolder
|
|
395
|
+
.split('/')
|
|
396
|
+
.map(c => `/${c}`)
|
|
397
|
+
.join('')
|
|
398
|
+
.replace(/^\//, '')) +
|
|
399
|
+
'\n/' +
|
|
400
|
+
tnp_core_2.CLI.chalk.bold(tnp_core_1.path.basename(pathToFileOrFolder))}
|
|
401
|
+
${index_1.Helpers.terminalLine()}\n`;
|
|
402
|
+
}
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region prepare wathc command
|
|
405
|
+
/**
|
|
406
|
+
* @deprecated
|
|
407
|
+
*/
|
|
408
|
+
prepareWatchCommand(cmd) {
|
|
409
|
+
return tnp_core_1.os.platform() === 'win32' ? `"${cmd}"` : `'${cmd}'`;
|
|
410
|
+
}
|
|
411
|
+
//#endregion
|
|
412
|
+
//#region get string from
|
|
413
|
+
/**
|
|
414
|
+
* @deprecated
|
|
415
|
+
*/
|
|
416
|
+
getStringFrom(command, descriptionOfCommand) {
|
|
417
|
+
try {
|
|
418
|
+
const res = index_1.Helpers.run(command, { output: false }).sync().toString();
|
|
419
|
+
return res;
|
|
420
|
+
}
|
|
421
|
+
catch (error) {
|
|
422
|
+
index_1.Helpers.warn(`Not able to get string from "${descriptionOfCommand ? descriptionOfCommand : command}"`);
|
|
423
|
+
return void 0;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region wait for message in stdout
|
|
428
|
+
async waitForMessegeInStdout(proc, message) {
|
|
429
|
+
return new Promise((resolve, reject) => {
|
|
430
|
+
let resolved = false;
|
|
431
|
+
proc.stdout.on('data', data => {
|
|
432
|
+
// console.log(`
|
|
433
|
+
// [waitForMessegeInStdout] data: ${data}
|
|
434
|
+
// [waitForMessegeInStdout] data typeof: ${typeof data}
|
|
435
|
+
// `);
|
|
436
|
+
if (tnp_core_1._.isObject(data) && tnp_core_1._.isFunction(data.toString)) {
|
|
437
|
+
data = data.toString();
|
|
438
|
+
}
|
|
439
|
+
if (tnp_core_1._.isString(data) && data.search(message) !== -1) {
|
|
440
|
+
resolved = true;
|
|
441
|
+
resolve(void 0);
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
proc.once('exit', () => {
|
|
445
|
+
// console.log(`
|
|
446
|
+
// [waitForMessegeInStdout] exit: ${code}
|
|
447
|
+
// `);
|
|
448
|
+
if (!resolved) {
|
|
449
|
+
reject();
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
exports.HelpersProcess = HelpersProcess;
|
|
456
|
+
//# sourceMappingURL=helpers-process.backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-process.backend.js","sourceRoot":"","sources":["c:/Users/darek/projects/npm/taon-dev/tnp-helpers/src/lib/helpers/for-backend/helpers-process.backend.ts"],"names":[],"mappings":";;;AAAA,iBAAiB;AACjB,uCASkB;AAClB,uCAA4D;AAC5D,yCAAyC;AACzC,iDAAqC;AAErC,uCAAsC;AACtC,uEAAiD;AACjD,2CAAoC;AACpC,2CAAwC;AAExC,+BAA+B;AAE/B,qCAAqC;AACrC,YAAY;AAEZ,MAAa,cAAc;IACzB,oCAAoC;IACpC,KAAK,CAAC,wBAAwB,CAAC,SAAiB;QAC9C,eAAO,CAAC,GAAG,CAAC,cAAc,SAAS,EAAE,CAAC,CAAC;QACvC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE;YACtB,UAAU,CAAC;gBACT,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE;oBACjB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE;wBAC7D,GAAG,EAAE,IAAA,4BAAiB,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC;wBACrC,QAAQ,EAAE,IAAI;wBAC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,MAAM;gBACN,IAAI,YAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,YAAC,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACpD,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACzB,CAAC;gBAED,IAAI,YAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;oBACpD,QAAQ,GAAG,IAAI,CAAC;oBAChB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;gBACrB,gBAAgB;gBAEhB,yCAAyC;gBAEzC,MAAM;gBACN,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACd,MAAM,EAAE,CAAC;gBACX,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CAEF;AAtiBD,wCAsiBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ts-import-export-extractor';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["c:/Users/darek/projects/npm/taon-dev/tnp-helpers/src/lib/helpers/for-backend/ts-code/index.ts"],"names":[],"mappings":";;;AAAA,uEAA6C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LineAndCharacter } from 'typescript';
|
|
2
|
+
export declare class TsImportExport {
|
|
3
|
+
type: 'export' | 'import' | 'async-import' | 'require';
|
|
4
|
+
/**
|
|
5
|
+
* ORIGNAL
|
|
6
|
+
* Name of the file that is being imported/exported
|
|
7
|
+
* with parenthesis included
|
|
8
|
+
*/
|
|
9
|
+
embeddedPathToFile: string;
|
|
10
|
+
/**
|
|
11
|
+
* same as cleanEmbeddedPathToFile but without quotes (parenthesis)
|
|
12
|
+
*/
|
|
13
|
+
cleanEmbeddedPathToFile: string;
|
|
14
|
+
removeStartEndQuotes(str: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* RESULT OF PROCESSING
|
|
17
|
+
*/
|
|
18
|
+
embeddedPathToFileResult: string;
|
|
19
|
+
packageName: string;
|
|
20
|
+
isIsomorphic?: boolean;
|
|
21
|
+
startRow: number;
|
|
22
|
+
startCol: number;
|
|
23
|
+
endRow: number;
|
|
24
|
+
endCol: number;
|
|
25
|
+
parenthesisType: 'single' | 'double' | 'tics';
|
|
26
|
+
wrapInParenthesis(str: string): string;
|
|
27
|
+
constructor(type: 'export' | 'import' | 'async-import' | 'require', embeddedPathToFile: string, start: LineAndCharacter, end: LineAndCharacter, parenthesisType: 'single' | 'double' | 'tics');
|
|
28
|
+
}
|
|
29
|
+
export declare const recognizeImportsFromFile: (fileContent: string) => TsImportExport[];
|