tnp-helpers 13.0.38 → 13.1.1
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/app.d.ts +1 -1
- package/app.js +6 -6
- package/app.js.map +1 -1
- package/browser/README.md +24 -24
- package/browser/esm2020/lib/base-component.mjs +48 -48
- package/browser/esm2020/lib/base-formly-component.mjs +126 -126
- package/browser/esm2020/lib/condition-wait.mjs +53 -53
- package/browser/esm2020/lib/constants.mjs +6 -6
- package/browser/esm2020/lib/dual-component-ctrl.mjs +120 -120
- package/browser/esm2020/lib/helpers-array-obj.mjs +80 -80
- package/browser/esm2020/lib/helpers-environment.mjs +30 -30
- package/browser/esm2020/lib/helpers-numbers.mjs +5 -5
- package/browser/esm2020/lib/helpers-strings-regexes.mjs +48 -48
- package/browser/esm2020/lib/helpers-strings.mjs +258 -256
- package/browser/esm2020/lib/helpers.mjs +276 -276
- package/browser/esm2020/lib/index.mjs +14 -14
- package/browser/esm2020/lib/long-press.directive.mjs +112 -112
- package/browser/esm2020/lib/project.mjs +413 -413
- package/browser/esm2020/lib/resize-service.mjs +20 -20
- package/browser/esm2020/public-api.mjs +1 -1
- package/browser/esm2020/tnp-helpers.mjs +4 -4
- package/browser/fesm2015/tnp-helpers.mjs +1535 -1534
- package/browser/fesm2015/tnp-helpers.mjs.map +1 -1
- package/browser/fesm2020/tnp-helpers.mjs +1527 -1526
- package/browser/fesm2020/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base-component.d.ts +17 -17
- package/browser/lib/base-formly-component.d.ts +31 -31
- package/browser/lib/condition-wait.d.ts +8 -8
- package/browser/lib/constants.d.ts +6 -6
- package/browser/lib/dual-component-ctrl.d.ts +25 -25
- package/browser/lib/helpers-array-obj.d.ts +15 -15
- package/browser/lib/helpers-environment.d.ts +5 -5
- package/browser/lib/helpers-numbers.d.ts +3 -3
- package/browser/lib/helpers-strings-regexes.d.ts +28 -28
- package/browser/lib/helpers-strings.d.ts +50 -50
- package/browser/lib/helpers.d.ts +28 -28
- package/browser/lib/index.d.ts +9 -9
- package/browser/lib/long-press.directive.d.ts +25 -25
- package/browser/lib/project.d.ts +91 -91
- package/browser/lib/resize-service.d.ts +9 -9
- package/browser/public-api.d.ts +1 -1
- package/browser/tnp-helpers.d.ts +5 -5
- package/client/README.md +24 -24
- package/client/esm2020/lib/base-component.mjs +48 -48
- package/client/esm2020/lib/base-formly-component.mjs +126 -126
- package/client/esm2020/lib/condition-wait.mjs +53 -53
- package/client/esm2020/lib/constants.mjs +6 -6
- package/client/esm2020/lib/dual-component-ctrl.mjs +120 -120
- package/client/esm2020/lib/helpers-array-obj.mjs +80 -80
- package/client/esm2020/lib/helpers-environment.mjs +30 -30
- package/client/esm2020/lib/helpers-numbers.mjs +5 -5
- package/client/esm2020/lib/helpers-strings-regexes.mjs +48 -48
- package/client/esm2020/lib/helpers-strings.mjs +258 -256
- package/client/esm2020/lib/helpers.mjs +276 -276
- package/client/esm2020/lib/index.mjs +14 -14
- package/client/esm2020/lib/long-press.directive.mjs +112 -112
- package/client/esm2020/lib/project.mjs +413 -413
- package/client/esm2020/lib/resize-service.mjs +20 -20
- package/client/esm2020/public-api.mjs +1 -1
- package/client/esm2020/tnp-helpers.mjs +4 -4
- package/client/fesm2015/tnp-helpers.mjs +1535 -1534
- package/client/fesm2015/tnp-helpers.mjs.map +1 -1
- package/client/fesm2020/tnp-helpers.mjs +1527 -1526
- package/client/fesm2020/tnp-helpers.mjs.map +1 -1
- package/client/lib/base-component.d.ts +17 -17
- package/client/lib/base-formly-component.d.ts +31 -31
- package/client/lib/condition-wait.d.ts +8 -8
- package/client/lib/constants.d.ts +6 -6
- package/client/lib/dual-component-ctrl.d.ts +25 -25
- package/client/lib/helpers-array-obj.d.ts +15 -15
- package/client/lib/helpers-environment.d.ts +5 -5
- package/client/lib/helpers-numbers.d.ts +3 -3
- package/client/lib/helpers-strings-regexes.d.ts +28 -28
- package/client/lib/helpers-strings.d.ts +50 -50
- package/client/lib/helpers.d.ts +28 -28
- package/client/lib/index.d.ts +9 -9
- package/client/lib/long-press.directive.d.ts +25 -25
- package/client/lib/project.d.ts +91 -91
- package/client/lib/resize-service.d.ts +9 -9
- package/client/public-api.d.ts +1 -1
- package/client/tnp-helpers.d.ts +5 -5
- package/index.d.ts +1 -1
- package/index.js +5 -5
- package/index.js.map +1 -1
- package/lib/angular.helper.d.ts +22 -22
- package/lib/angular.helper.js +50 -50
- package/lib/angular.helper.js.map +1 -1
- package/lib/base-component.d.ts +1 -1
- package/lib/base-component.js +6 -6
- package/lib/base-component.js.map +1 -1
- package/lib/base-formly-component.d.ts +1 -1
- package/lib/base-formly-component.js +6 -6
- package/lib/base-formly-component.js.map +1 -1
- package/lib/condition-wait.d.ts +8 -8
- package/lib/condition-wait.js +94 -94
- package/lib/condition-wait.js.map +1 -1
- package/lib/constants.d.ts +6 -6
- package/lib/constants.js +10 -10
- package/lib/constants.js.map +1 -1
- package/lib/dual-component-ctrl.d.ts +1 -1
- package/lib/dual-component-ctrl.js +6 -6
- package/lib/dual-component-ctrl.js.map +1 -1
- package/lib/git-project.d.ts +44 -44
- package/lib/git-project.js +195 -191
- package/lib/git-project.js.map +1 -1
- package/lib/helpers-array-obj.d.ts +15 -15
- package/lib/helpers-array-obj.js +88 -88
- package/lib/helpers-array-obj.js.map +1 -1
- package/lib/helpers-cli-tool.backend.d.ts +45 -45
- package/lib/helpers-cli-tool.backend.js +293 -293
- package/lib/helpers-cli-tool.backend.js.map +1 -1
- package/lib/helpers-dependencies.backend.d.ts +11 -11
- package/lib/helpers-dependencies.backend.js +105 -105
- package/lib/helpers-dependencies.backend.js.map +1 -1
- package/lib/helpers-environment.d.ts +5 -5
- package/lib/helpers-environment.js +35 -35
- package/lib/helpers-environment.js.map +1 -1
- package/lib/helpers-file-folders.backend.d.ts +84 -73
- package/lib/helpers-file-folders.backend.js +736 -714
- package/lib/helpers-file-folders.backend.js.map +1 -1
- package/lib/helpers-git.backend.d.ts +35 -35
- package/lib/helpers-git.backend.js +545 -534
- package/lib/helpers-git.backend.js.map +1 -1
- package/lib/helpers-json5.backend.d.ts +16 -16
- package/lib/helpers-json5.backend.js +70 -70
- package/lib/helpers-json5.backend.js.map +1 -1
- package/lib/helpers-morphi-framework.backend.d.ts +4 -4
- package/lib/helpers-morphi-framework.backend.js +49 -49
- package/lib/helpers-morphi-framework.backend.js.map +1 -1
- package/lib/helpers-network.backend.d.ts +8 -8
- package/lib/helpers-network.backend.js +48 -48
- package/lib/helpers-network.backend.js.map +1 -1
- package/lib/helpers-npm.backend.d.ts +3 -3
- package/lib/helpers-npm.backend.js +17 -17
- package/lib/helpers-npm.backend.js.map +1 -1
- package/lib/helpers-numbers.d.ts +3 -3
- package/lib/helpers-numbers.js +11 -11
- package/lib/helpers-numbers.js.map +1 -1
- package/lib/helpers-path.backend.d.ts +7 -7
- package/lib/helpers-path.backend.js +36 -36
- package/lib/helpers-path.backend.js.map +1 -1
- package/lib/helpers-process.backend.d.ts +57 -51
- package/lib/helpers-process.backend.js +529 -523
- package/lib/helpers-process.backend.js.map +1 -1
- package/lib/helpers-strings-regexes.d.ts +28 -28
- package/lib/helpers-strings-regexes.js +60 -60
- package/lib/helpers-strings-regexes.js.map +1 -1
- package/lib/helpers-strings.d.ts +50 -50
- package/lib/helpers-strings.js +265 -263
- package/lib/helpers-strings.js.map +1 -1
- package/lib/helpers-system-terminal.backend.d.ts +5 -5
- package/lib/helpers-system-terminal.backend.js +53 -53
- package/lib/helpers-system-terminal.backend.js.map +1 -1
- package/lib/helpers.d.ts +67 -67
- package/lib/helpers.js +391 -391
- package/lib/helpers.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +19 -19
- package/lib/index.js.map +1 -1
- package/lib/long-press.directive.d.ts +22 -22
- package/lib/long-press.directive.js +141 -141
- package/lib/long-press.directive.js.map +1 -1
- package/lib/merge-helpers.backend.d.ts +23 -23
- package/lib/merge-helpers.backend.js +108 -108
- package/lib/merge-helpers.backend.js.map +1 -1
- package/lib/project.d.ts +94 -94
- package/lib/project.js +422 -422
- package/lib/project.js.map +1 -1
- package/lib/resize-service.d.ts +6 -6
- package/lib/resize-service.js +24 -24
- package/lib/resize-service.js.map +1 -1
- package/lib/ts-code/index.d.ts +1 -1
- package/lib/ts-code/index.js +7 -7
- package/lib/ts-code/index.js.map +1 -1
- package/lib/ts-code/ts-code-extractor.d.ts +14 -14
- package/lib/ts-code/ts-code-extractor.js +46 -46
- package/lib/ts-code/ts-code-extractor.js.map +1 -1
- package/lib/ts-code/ts-code-modifier.backend.d.ts +12 -12
- package/lib/ts-code/ts-code-modifier.backend.js +70 -70
- package/lib/ts-code/ts-code-modifier.backend.js.map +1 -1
- package/package.json +3 -3
- package/package.json_devDependencies.json +222 -222
- package/package.json_tnp.json5 +41 -41
- package/tmp-environment.json +13 -13
- package/websql/README.md +24 -24
- package/websql/esm2020/lib/base-component.mjs +48 -48
- package/websql/esm2020/lib/base-formly-component.mjs +126 -126
- package/websql/esm2020/lib/condition-wait.mjs +53 -53
- package/websql/esm2020/lib/constants.mjs +6 -6
- package/websql/esm2020/lib/dual-component-ctrl.mjs +120 -120
- package/websql/esm2020/lib/helpers-array-obj.mjs +80 -80
- package/websql/esm2020/lib/helpers-environment.mjs +30 -30
- package/websql/esm2020/lib/helpers-numbers.mjs +5 -5
- package/websql/esm2020/lib/helpers-strings-regexes.mjs +48 -48
- package/websql/esm2020/lib/helpers-strings.mjs +258 -256
- package/websql/esm2020/lib/helpers.mjs +276 -276
- package/websql/esm2020/lib/index.mjs +14 -14
- package/websql/esm2020/lib/long-press.directive.mjs +112 -112
- package/websql/esm2020/lib/project.mjs +413 -413
- package/websql/esm2020/lib/resize-service.mjs +20 -20
- package/websql/esm2020/public-api.mjs +1 -1
- package/websql/esm2020/tnp-helpers.mjs +4 -4
- package/websql/fesm2015/tnp-helpers.mjs +1535 -1534
- package/websql/fesm2015/tnp-helpers.mjs.map +1 -1
- package/websql/fesm2020/tnp-helpers.mjs +1527 -1526
- package/websql/fesm2020/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base-component.d.ts +17 -17
- package/websql/lib/base-formly-component.d.ts +31 -31
- package/websql/lib/condition-wait.d.ts +8 -8
- package/websql/lib/constants.d.ts +6 -6
- package/websql/lib/dual-component-ctrl.d.ts +25 -25
- package/websql/lib/helpers-array-obj.d.ts +15 -15
- package/websql/lib/helpers-environment.d.ts +5 -5
- package/websql/lib/helpers-numbers.d.ts +3 -3
- package/websql/lib/helpers-strings-regexes.d.ts +28 -28
- package/websql/lib/helpers-strings.d.ts +50 -50
- package/websql/lib/helpers.d.ts +28 -28
- package/websql/lib/index.d.ts +9 -9
- package/websql/lib/long-press.directive.d.ts +25 -25
- package/websql/lib/project.d.ts +91 -91
- package/websql/lib/resize-service.d.ts +9 -9
- package/websql/public-api.d.ts +1 -1
- package/websql/tnp-helpers.d.ts +5 -5
|
@@ -1,523 +1,529 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HelpersProcess = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
//#region imports
|
|
6
|
-
var tnp_core_1 = require("tnp-core");
|
|
7
|
-
var tnp_cli_1 = require("tnp-cli");
|
|
8
|
-
var dateformat = require("dateformat");
|
|
9
|
-
var index_1 = require("./index");
|
|
10
|
-
var typescript_class_helpers_1 = require("typescript-class-helpers");
|
|
11
|
-
var tnp_config_1 = require("tnp-config");
|
|
12
|
-
var ng2_logger_1 = require("ng2-logger");
|
|
13
|
-
var prompts = require('prompts');
|
|
14
|
-
var fuzzy = require("fuzzy");
|
|
15
|
-
var inquirer = require("inquirer");
|
|
16
|
-
var inquirerAutocomplete = require("inquirer-autocomplete-prompt");
|
|
17
|
-
inquirer.registerPrompt('autocomplete', inquirerAutocomplete);
|
|
18
|
-
var spawn = require("cross-spawn");
|
|
19
|
-
//#endregion
|
|
20
|
-
// TODO idea of procees someday to change
|
|
21
|
-
/**
|
|
22
|
-
* - long buffer by default
|
|
23
|
-
* - easy catch output of commands
|
|
24
|
-
* - wrap with try catch
|
|
25
|
-
* - handle backgroud proceses
|
|
26
|
-
*/
|
|
27
|
-
// function childExc(command: string) {
|
|
28
|
-
// return {
|
|
29
|
-
// syncExecutedValue({ displayOutput = false }): string {
|
|
30
|
-
// return '';
|
|
31
|
-
// },
|
|
32
|
-
// asycRun({ hideOutput: 'all' | 'stdout' | 'stder' }) {
|
|
33
|
-
// }
|
|
34
|
-
// }
|
|
35
|
-
// }
|
|
36
|
-
var HelpersProcess = /** @class */ (function () {
|
|
37
|
-
function HelpersProcess() {
|
|
38
|
-
}
|
|
39
|
-
HelpersProcess.prototype.restartApplicationItself = function (nameOfApp) {
|
|
40
|
-
return
|
|
41
|
-
return
|
|
42
|
-
index_1.Helpers.log("Restarting ".concat(nameOfApp));
|
|
43
|
-
return [2 /*return*/, new Promise(function () {
|
|
44
|
-
setTimeout(function () {
|
|
45
|
-
process.on('exit', function () {
|
|
46
|
-
spawn(process.argv.shift(),
|
|
47
|
-
cwd: (0, tnp_core_1.crossPlatformPath)(process.cwd()),
|
|
48
|
-
detached: true,
|
|
49
|
-
stdio: 'inherit'
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
process.exit();
|
|
53
|
-
}, 5000);
|
|
54
|
-
})];
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
HelpersProcess.prototype.osIsMacOs = function (versino) {
|
|
59
|
-
if (versino == 'big-sur') {
|
|
60
|
-
return tnp_core_1.os.release().startsWith('20.');
|
|
61
|
-
}
|
|
62
|
-
if (versino == 'catalina') {
|
|
63
|
-
return tnp_core_1.os.release().startsWith('19.');
|
|
64
|
-
}
|
|
65
|
-
// TODO other oses
|
|
66
|
-
};
|
|
67
|
-
HelpersProcess.prototype.generatedFileWrap = function (content) {
|
|
68
|
-
return "".concat(content, "\n // [").concat(tnp_config_1.config.frameworkName, "] GENERATED CONTENT FOR BACKEND VERSION\n // [").concat(tnp_config_1.config.frameworkName, "] GENERATED CONTENT FOR BACKEND VERSION\n ").trim();
|
|
69
|
-
};
|
|
70
|
-
HelpersProcess.prototype.changeCwdWrapper = function (dir, functionToExecure, logLevel) {
|
|
71
|
-
if (logLevel === void 0) { logLevel = ng2_logger_1.Level.__NOTHING; }
|
|
72
|
-
return
|
|
73
|
-
var currentCwd;
|
|
74
|
-
return
|
|
75
|
-
switch (_a.label) {
|
|
76
|
-
case 0:
|
|
77
|
-
currentCwd = (0, tnp_core_1.crossPlatformPath)(process.cwd());
|
|
78
|
-
index_1.Helpers.changeCwd(dir);
|
|
79
|
-
ng2_logger_1.Log.disableLogs(logLevel);
|
|
80
|
-
return [4 /*yield*/, index_1.Helpers.runSyncOrAsync(functionToExecure)];
|
|
81
|
-
case 1:
|
|
82
|
-
_a.sent();
|
|
83
|
-
ng2_logger_1.Log.enableLogs();
|
|
84
|
-
index_1.Helpers.changeCwd(currentCwd);
|
|
85
|
-
return [2 /*return*/];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
HelpersProcess.prototype.changeCwd = function (dir) {
|
|
91
|
-
if (!dir) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
index_1.Helpers.goToDir(dir);
|
|
95
|
-
};
|
|
96
|
-
HelpersProcess.prototype.goToDir = function (dir) {
|
|
97
|
-
if (dir === void 0) { dir = '..'; }
|
|
98
|
-
var previous = (0, tnp_core_1.crossPlatformPath)(process.cwd());
|
|
99
|
-
try {
|
|
100
|
-
dir = tnp_core_1.path.isAbsolute(dir) ? dir :
|
|
101
|
-
(0, tnp_core_1.crossPlatformPath)(tnp_core_1.path.resolve(tnp_core_1.path.join((0, tnp_core_1.crossPlatformPath)(process.cwd()), dir)));
|
|
102
|
-
if (tnp_core_1.path.basename(dir) === tnp_config_1.config.folder.external) {
|
|
103
|
-
var belowExternal = tnp_core_1.path.resolve(tnp_core_1.path.join(dir, '..'));
|
|
104
|
-
var classProject = typescript_class_helpers_1.CLASS.getBy('Project');
|
|
105
|
-
if (tnp_core_1.fse.existsSync(belowExternal) && !!classProject.From(belowExternal)) {
|
|
106
|
-
dir = belowExternal;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
process.chdir(dir);
|
|
110
|
-
}
|
|
111
|
-
catch (err) {
|
|
112
|
-
this.goToDir(previous);
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
return true;
|
|
116
|
-
};
|
|
117
|
-
HelpersProcess.prototype.pressKeyOrWait = function (message, printWaitMessages) {
|
|
118
|
-
if (message === void 0) { message = 'Press enter try again'; }
|
|
119
|
-
if (printWaitMessages === void 0) { printWaitMessages = 0; }
|
|
120
|
-
return
|
|
121
|
-
return
|
|
122
|
-
switch (_a.label) {
|
|
123
|
-
case 0:
|
|
124
|
-
if (!(tnp_core_1._.isNumber(printWaitMessages) && printWaitMessages > 0)) return [3 /*break*/, 2];
|
|
125
|
-
index_1.Helpers.log("Please wait (".concat(printWaitMessages, ") seconds"));
|
|
126
|
-
return [4 /*yield*/, index_1.Helpers.pressKeyOrWait(message, printWaitMessages - 1)];
|
|
127
|
-
case 1:
|
|
128
|
-
_a.sent();
|
|
129
|
-
return [2 /*return*/];
|
|
130
|
-
case 2: return [2 /*return*/, new Promise(function (resovle) {
|
|
131
|
-
index_1.Helpers.log(message);
|
|
132
|
-
process.stdin.once('data', function () {
|
|
133
|
-
resovle(void 0);
|
|
134
|
-
});
|
|
135
|
-
})];
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
HelpersProcess.prototype.pressKeyAndContinue = function (message) {
|
|
141
|
-
if (message === void 0) { message = 'Press enter to continue..'; }
|
|
142
|
-
|
|
143
|
-
if (process.platform === 'win32') {
|
|
144
|
-
spawn.sync('pause', '', { shell: true, stdio: [0, 1, 2] });
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
require('child_process').spawnSync('read _ ', { shell: true, stdio: [0, 1, 2] });
|
|
148
|
-
// return new Promise((resovle) => {
|
|
149
|
-
// Helpers.log(message);
|
|
150
|
-
// process.stdin.once('data', function () {
|
|
151
|
-
// resovle()
|
|
152
|
-
// });
|
|
153
|
-
// })
|
|
154
|
-
};
|
|
155
|
-
HelpersProcess.prototype.list = function (question, choices) {
|
|
156
|
-
return
|
|
157
|
-
var res;
|
|
158
|
-
return
|
|
159
|
-
switch (_a.label) {
|
|
160
|
-
case 0: return [4 /*yield*/, inquirer.prompt({
|
|
161
|
-
type: 'list',
|
|
162
|
-
name: 'value',
|
|
163
|
-
message: question,
|
|
164
|
-
choices: choices,
|
|
165
|
-
pageSize: 10,
|
|
166
|
-
loop: false,
|
|
167
|
-
})];
|
|
168
|
-
case 1:
|
|
169
|
-
res = _a.sent();
|
|
170
|
-
return [2 /*return*/, res.value];
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
HelpersProcess.prototype.autocompleteAsk = function (question, choices, pageSize) {
|
|
176
|
-
if (pageSize === void 0) { pageSize = 10; }
|
|
177
|
-
return
|
|
178
|
-
function source(__, input) {
|
|
179
|
-
input = input || '';
|
|
180
|
-
return new Promise(function (resolve) {
|
|
181
|
-
var fuzzyResult = fuzzy.filter(input, choices.map(function (f) { return f.name; }));
|
|
182
|
-
resolve(fuzzyResult.map(function (el) {
|
|
183
|
-
return { name: el.original, value: choices.find(function (c) { return c.name === el.original; }).value };
|
|
184
|
-
}));
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
var res;
|
|
188
|
-
return
|
|
189
|
-
switch (_a.label) {
|
|
190
|
-
case 0: return [4 /*yield*/, inquirer.prompt({
|
|
191
|
-
type: 'autocomplete',
|
|
192
|
-
name: 'command',
|
|
193
|
-
pageSize: pageSize,
|
|
194
|
-
source: source,
|
|
195
|
-
message: question,
|
|
196
|
-
choices: choices
|
|
197
|
-
})];
|
|
198
|
-
case 1:
|
|
199
|
-
res = _a.sent();
|
|
200
|
-
return [2 /*return*/, res.command];
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
HelpersProcess.prototype.questionYesNo = function (message, callbackTrue, callbackFalse, defaultValue) {
|
|
206
|
-
if (defaultValue === void 0) { defaultValue = true; }
|
|
207
|
-
return
|
|
208
|
-
var response;
|
|
209
|
-
return
|
|
210
|
-
switch (_a.label) {
|
|
211
|
-
case 0:
|
|
212
|
-
response = {
|
|
213
|
-
value: defaultValue
|
|
214
|
-
};
|
|
215
|
-
if (!global.tnpNonInteractive) return [3 /*break*/, 1];
|
|
216
|
-
index_1.Helpers.info("".concat(message, " - AUTORESPONSE: ").concat(defaultValue ? 'YES' : 'NO'));
|
|
217
|
-
return [3 /*break*/, 3];
|
|
218
|
-
case 1: return [4 /*yield*/, prompts({
|
|
219
|
-
type: 'toggle',
|
|
220
|
-
name: 'value',
|
|
221
|
-
message: message,
|
|
222
|
-
initial: defaultValue,
|
|
223
|
-
active: 'yes',
|
|
224
|
-
inactive: 'no'
|
|
225
|
-
})];
|
|
226
|
-
case 2:
|
|
227
|
-
response = _a.sent();
|
|
228
|
-
_a.label = 3;
|
|
229
|
-
case 3:
|
|
230
|
-
if (!response.value) return [3 /*break*/, 6];
|
|
231
|
-
if (!callbackTrue) return [3 /*break*/, 5];
|
|
232
|
-
return [4 /*yield*/, index_1.Helpers.runSyncOrAsync(callbackTrue)];
|
|
233
|
-
case 4:
|
|
234
|
-
_a.sent();
|
|
235
|
-
_a.label = 5;
|
|
236
|
-
case 5: return [3 /*break*/, 8];
|
|
237
|
-
case 6:
|
|
238
|
-
if (!callbackFalse) return [3 /*break*/, 8];
|
|
239
|
-
return [4 /*yield*/, index_1.Helpers.runSyncOrAsync(callbackFalse)];
|
|
240
|
-
case 7:
|
|
241
|
-
_a.sent();
|
|
242
|
-
_a.label = 8;
|
|
243
|
-
case 8: return [2 /*return*/, response.value];
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
};
|
|
248
|
-
Object.defineProperty(HelpersProcess.prototype, "isWsl", {
|
|
249
|
-
get: function () {
|
|
250
|
-
if (process.platform !== 'linux') {
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
if (tnp_core_1.os.release().toLowerCase().includes('microsoft')) {
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
try {
|
|
257
|
-
return tnp_core_1.fse.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft');
|
|
258
|
-
}
|
|
259
|
-
catch (_) {
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
enumerable: false,
|
|
264
|
-
configurable: true
|
|
265
|
-
});
|
|
266
|
-
;
|
|
267
|
-
HelpersProcess.prototype.getWorkingDirOfProcess = function (PID) {
|
|
268
|
-
try {
|
|
269
|
-
var cwd = tnp_core_1.child_process.execSync("lsof -p ".concat(PID, " | awk '$4==\"cwd\" {print $9}'")).toString().trim();
|
|
270
|
-
return cwd;
|
|
271
|
-
}
|
|
272
|
-
catch (e) {
|
|
273
|
-
index_1.Helpers.error(e);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
HelpersProcess.prototype.commnadOutputAsStringAsync = function (command, cwd, biggerBuffer, showWholeCommandNotOnlyLastLine) {
|
|
277
|
-
if (cwd === void 0) { cwd = (0, tnp_core_1.crossPlatformPath)(process.cwd()); }
|
|
278
|
-
if (biggerBuffer === void 0) { biggerBuffer = false; }
|
|
279
|
-
if (showWholeCommandNotOnlyLastLine === void 0) { showWholeCommandNotOnlyLastLine = false; }
|
|
280
|
-
return
|
|
281
|
-
var output, splited, e_1;
|
|
282
|
-
return
|
|
283
|
-
switch (_a.label) {
|
|
284
|
-
case 0:
|
|
285
|
-
output = '';
|
|
286
|
-
_a.label = 1;
|
|
287
|
-
case 1:
|
|
288
|
-
_a.trys.push([1, 3, , 4]);
|
|
289
|
-
return [4 /*yield*/, index_1.Helpers.command(command).getherOutput()];
|
|
290
|
-
case 2:
|
|
291
|
-
output = _a.sent();
|
|
292
|
-
// console.log({
|
|
293
|
-
// output
|
|
294
|
-
// })
|
|
295
|
-
if (showWholeCommandNotOnlyLastLine) {
|
|
296
|
-
// console.log('SHHOW WOLE', output)
|
|
297
|
-
return [2 /*return*/, output.replace(/[^\x00-\xFF]/g, '')];
|
|
298
|
-
}
|
|
299
|
-
splited = (output || '').split('\n');
|
|
300
|
-
output = (splited.pop() || '').replace(/[^\x00-\xFF]/g, '');
|
|
301
|
-
return [3 /*break*/, 4];
|
|
302
|
-
case 3:
|
|
303
|
-
e_1 = _a.sent();
|
|
304
|
-
index_1.Helpers.warn("[tnp-helepr] Not able to get output from command:\n \"".concat(command, "\"\n "));
|
|
305
|
-
return [3 /*break*/, 4];
|
|
306
|
-
case 4: return [2 /*return*/, output];
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
HelpersProcess.prototype.commnadOutputAsString = function (command, cwd, biggerBuffer, showWholeCommandNotOnlyLastLine) {
|
|
312
|
-
if (cwd === void 0) { cwd = (0, tnp_core_1.crossPlatformPath)(process.cwd()); }
|
|
313
|
-
if (biggerBuffer === void 0) { biggerBuffer = false; }
|
|
314
|
-
if (showWholeCommandNotOnlyLastLine === void 0) { showWholeCommandNotOnlyLastLine = false; }
|
|
315
|
-
var output = '';
|
|
316
|
-
try {
|
|
317
|
-
output = index_1.Helpers.run(command, { output: false, cwd: cwd, biggerBuffer: biggerBuffer }).sync().toString().trim();
|
|
318
|
-
// console.log({
|
|
319
|
-
// output
|
|
320
|
-
// })
|
|
321
|
-
if (showWholeCommandNotOnlyLastLine) {
|
|
322
|
-
return output.replace(/[^\x00-\xFF]/g, '');
|
|
323
|
-
}
|
|
324
|
-
var splited = (output || '').split('\n');
|
|
325
|
-
output = (splited.pop() || '').replace(/[^\x00-\xFF]/g, '');
|
|
326
|
-
}
|
|
327
|
-
catch (e) {
|
|
328
|
-
index_1.Helpers.warn("[tnp-helepr] Not able to get output from command:\n \"".concat(command, "\"\n "));
|
|
329
|
-
}
|
|
330
|
-
return output;
|
|
331
|
-
};
|
|
332
|
-
HelpersProcess.prototype.outputToVScode = function (data, disableEncode) {
|
|
333
|
-
if (disableEncode === void 0) { disableEncode = false; }
|
|
334
|
-
if (tnp_core_1._.isObject(data)) {
|
|
335
|
-
data = JSON.stringify(data);
|
|
336
|
-
}
|
|
337
|
-
if (disableEncode) {
|
|
338
|
-
console.log(data);
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
341
|
-
console.log(encodeURIComponent(data));
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
HelpersProcess.prototype.sleep = function (seconds) {
|
|
345
|
-
if (seconds === void 0) { seconds = 1; }
|
|
346
|
-
return index_1.Helpers.run("sleep ".concat(seconds)).sync();
|
|
347
|
-
};
|
|
348
|
-
HelpersProcess.prototype.actionWrapper = function (fn, taskName) {
|
|
349
|
-
if (taskName === void 0) { taskName = 'Task'; }
|
|
350
|
-
return
|
|
351
|
-
function currentDate() {
|
|
352
|
-
return "[".concat(dateformat(new Date(), 'HH:MM:ss'), "]");
|
|
353
|
-
}
|
|
354
|
-
return
|
|
355
|
-
switch (_a.label) {
|
|
356
|
-
case 0:
|
|
357
|
-
// global.spinner && global.spinner.start()
|
|
358
|
-
index_1.Helpers.
|
|
359
|
-
return [4 /*yield*/, index_1.Helpers.runSyncOrAsync(fn)];
|
|
360
|
-
case 1:
|
|
361
|
-
_a.sent();
|
|
362
|
-
index_1.Helpers.
|
|
363
|
-
return [2 /*return*/];
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
};
|
|
368
|
-
HelpersProcess.prototype.terminalLine = function () {
|
|
369
|
-
return tnp_core_1._.times(process.stdout.columns, function () { return '-'; }).join('');
|
|
370
|
-
};
|
|
371
|
-
HelpersProcess.prototype.killProcess = function (byPid) {
|
|
372
|
-
index_1.Helpers.run("kill -9 ".concat(byPid)).sync();
|
|
373
|
-
};
|
|
374
|
-
HelpersProcess.prototype.killProcessByPort = function (portOrPortsToKill) {
|
|
375
|
-
return
|
|
376
|
-
var index, port, org, e_2;
|
|
377
|
-
return
|
|
378
|
-
switch (_a.label) {
|
|
379
|
-
case 0:
|
|
380
|
-
if (!tnp_core_1._.isArray(portOrPortsToKill)) {
|
|
381
|
-
portOrPortsToKill = [portOrPortsToKill];
|
|
382
|
-
}
|
|
383
|
-
index = 0;
|
|
384
|
-
_a.label = 1;
|
|
385
|
-
case 1:
|
|
386
|
-
if (!(index < portOrPortsToKill.length)) return [3 /*break*/, 6];
|
|
387
|
-
port = portOrPortsToKill[index];
|
|
388
|
-
org = port;
|
|
389
|
-
port = Number(port);
|
|
390
|
-
if (!tnp_core_1._.isNumber(port)) {
|
|
391
|
-
index_1.Helpers.warn("[tnp-helpers] Can't kill on port: \"".concat(org, "\""));
|
|
392
|
-
return [2 /*return*/];
|
|
393
|
-
}
|
|
394
|
-
_a.label = 2;
|
|
395
|
-
case 2:
|
|
396
|
-
_a.trys.push([2, 4, , 5]);
|
|
397
|
-
return [4 /*yield*/, (0, tnp_core_1.fkill)(":".concat(port), { force: true })];
|
|
398
|
-
case 3:
|
|
399
|
-
_a.sent();
|
|
400
|
-
// run(`fkill -f :${port} &> /dev/null`, { output: false }).sync()
|
|
401
|
-
index_1.Helpers.info("Processs killed successfully on port: ".concat(port));
|
|
402
|
-
return [3 /*break*/, 5];
|
|
403
|
-
case 4:
|
|
404
|
-
e_2 = _a.sent();
|
|
405
|
-
index_1.Helpers.warn("No process to kill on port: ".concat(port, "... "));
|
|
406
|
-
return [3 /*break*/, 5];
|
|
407
|
-
case 5:
|
|
408
|
-
index++;
|
|
409
|
-
return [3 /*break*/, 1];
|
|
410
|
-
case 6: return [2 /*return*/];
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
});
|
|
414
|
-
};
|
|
415
|
-
HelpersProcess.prototype.clearConsole = function () {
|
|
416
|
-
index_1.Helpers.msgCacheClear();
|
|
417
|
-
console.log('\x1Bc');
|
|
418
|
-
// process.stdout.write('\033c\033[3J');
|
|
419
|
-
// try {
|
|
420
|
-
// run('clear').sync()
|
|
421
|
-
// } catch (error) {
|
|
422
|
-
// console.log('clear console not succedd')
|
|
423
|
-
// }
|
|
424
|
-
};
|
|
425
|
-
// process.on('uncaughtException', cleanExit)
|
|
426
|
-
// process.on('unhandledRejection', cleanExit)
|
|
427
|
-
// process.once('unhandledRejection', (err, aa) => {
|
|
428
|
-
// error(`'Exiting unhandledRejection
|
|
429
|
-
// Reason: ${err}
|
|
430
|
-
// ${JSON.stringify(aa)}
|
|
431
|
-
// `);
|
|
432
|
-
// })
|
|
433
|
-
HelpersProcess.prototype.formatPath = function (pathToFileOrFolder) {
|
|
434
|
-
if (!tnp_core_1._.isString(pathToFileOrFolder)) {
|
|
435
|
-
return "\n< provided path is not string: ".concat(pathToFileOrFolder, " >\n");
|
|
436
|
-
}
|
|
437
|
-
if (!tnp_core_1.path.isAbsolute(pathToFileOrFolder)) {
|
|
438
|
-
return "\n\n".concat(index_1.Helpers.terminalLine(), "\nrelativePath: ").concat(pathToFileOrFolder, "\n").concat(index_1.Helpers.terminalLine(), "\n");
|
|
439
|
-
}
|
|
440
|
-
if (!tnp_core_1.fse.existsSync(pathToFileOrFolder)) {
|
|
441
|
-
return "\n\n".concat(index_1.Helpers.terminalLine(), "\n< provided path does not exist: ").concat(pathToFileOrFolder, " >\n").concat(index_1.Helpers.terminalLine(), "\n");
|
|
442
|
-
}
|
|
443
|
-
var isDirectory = tnp_core_1.fse.lstatSync(pathToFileOrFolder).isDirectory();
|
|
444
|
-
return "\n".concat(index_1.Helpers.terminalLine(), "\n<-- ").concat(isDirectory ? 'Path to directory' : 'Path to file', ": -->\n").concat(isDirectory ? pathToFileOrFolder.split('/').map(function (c) { return "/".concat(c); }).join('').replace(/^\//, '') : (tnp_core_1.path.dirname(pathToFileOrFolder.split('/').map(function (c) { return "/".concat(c); }).join('').replace(/^\//, ''))
|
|
445
|
-
+ '\n/' + tnp_cli_1.CLI.chalk.bold(tnp_core_1.path.basename(pathToFileOrFolder))), "\n").concat(index_1.Helpers.terminalLine(), "\n");
|
|
446
|
-
};
|
|
447
|
-
;
|
|
448
|
-
HelpersProcess.prototype.waitForMessegeInStdout = function (proc, message) {
|
|
449
|
-
return
|
|
450
|
-
return
|
|
451
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
452
|
-
var resolved = false;
|
|
453
|
-
proc.stdout.on('data', function (data) {
|
|
454
|
-
// console.log(`
|
|
455
|
-
// [waitForMessegeInStdout] data: ${data}
|
|
456
|
-
// [waitForMessegeInStdout] data typeof: ${typeof data}
|
|
457
|
-
// `);
|
|
458
|
-
if (tnp_core_1._.isObject(data) && tnp_core_1._.isFunction(data.toString)) {
|
|
459
|
-
data = data.toString();
|
|
460
|
-
}
|
|
461
|
-
if (tnp_core_1._.isString(data) && data.search(message) !== -1) {
|
|
462
|
-
resolved = true;
|
|
463
|
-
resolve(void 0);
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
proc.once('exit', function () {
|
|
467
|
-
// console.log(`
|
|
468
|
-
// [waitForMessegeInStdout] exit: ${code}
|
|
469
|
-
// `);
|
|
470
|
-
if (!resolved) {
|
|
471
|
-
reject();
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
})];
|
|
475
|
-
});
|
|
476
|
-
});
|
|
477
|
-
};
|
|
478
|
-
HelpersProcess.prototype.prepareWatchCommand = function (cmd) {
|
|
479
|
-
return tnp_core_1.os.platform() === 'win32' ? "\"".concat(cmd, "\"") : "'".concat(cmd, "'");
|
|
480
|
-
};
|
|
481
|
-
Object.defineProperty(HelpersProcess.prototype, "watcher", {
|
|
482
|
-
get: function () {
|
|
483
|
-
var that = index_1.Helpers;
|
|
484
|
-
return {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
var
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HelpersProcess = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
//#region imports
|
|
6
|
+
var tnp_core_1 = require("tnp-core");
|
|
7
|
+
var tnp_cli_1 = require("tnp-cli");
|
|
8
|
+
var dateformat = require("dateformat");
|
|
9
|
+
var index_1 = require("./index");
|
|
10
|
+
var typescript_class_helpers_1 = require("typescript-class-helpers");
|
|
11
|
+
var tnp_config_1 = require("tnp-config");
|
|
12
|
+
var ng2_logger_1 = require("ng2-logger");
|
|
13
|
+
var prompts = require('prompts');
|
|
14
|
+
var fuzzy = require("fuzzy");
|
|
15
|
+
var inquirer = require("inquirer");
|
|
16
|
+
var inquirerAutocomplete = require("inquirer-autocomplete-prompt");
|
|
17
|
+
inquirer.registerPrompt('autocomplete', inquirerAutocomplete);
|
|
18
|
+
var spawn = require("cross-spawn");
|
|
19
|
+
//#endregion
|
|
20
|
+
// TODO idea of procees someday to change
|
|
21
|
+
/**
|
|
22
|
+
* - long buffer by default
|
|
23
|
+
* - easy catch output of commands
|
|
24
|
+
* - wrap with try catch
|
|
25
|
+
* - handle backgroud proceses
|
|
26
|
+
*/
|
|
27
|
+
// function childExc(command: string) {
|
|
28
|
+
// return {
|
|
29
|
+
// syncExecutedValue({ displayOutput = false }): string {
|
|
30
|
+
// return '';
|
|
31
|
+
// },
|
|
32
|
+
// asycRun({ hideOutput: 'all' | 'stdout' | 'stder' }) {
|
|
33
|
+
// }
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
|
+
var HelpersProcess = /** @class */ (function () {
|
|
37
|
+
function HelpersProcess() {
|
|
38
|
+
}
|
|
39
|
+
HelpersProcess.prototype.restartApplicationItself = function (nameOfApp) {
|
|
40
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
41
|
+
return tslib_1.__generator(this, function (_a) {
|
|
42
|
+
index_1.Helpers.log("Restarting ".concat(nameOfApp));
|
|
43
|
+
return [2 /*return*/, new Promise(function () {
|
|
44
|
+
setTimeout(function () {
|
|
45
|
+
process.on('exit', function () {
|
|
46
|
+
spawn(process.argv.shift(), tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(process.argv), false), ['--restarting'], false), {
|
|
47
|
+
cwd: (0, tnp_core_1.crossPlatformPath)(process.cwd()),
|
|
48
|
+
detached: true,
|
|
49
|
+
stdio: 'inherit'
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
process.exit();
|
|
53
|
+
}, 5000);
|
|
54
|
+
})];
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
HelpersProcess.prototype.osIsMacOs = function (versino) {
|
|
59
|
+
if (versino == 'big-sur') {
|
|
60
|
+
return tnp_core_1.os.release().startsWith('20.');
|
|
61
|
+
}
|
|
62
|
+
if (versino == 'catalina') {
|
|
63
|
+
return tnp_core_1.os.release().startsWith('19.');
|
|
64
|
+
}
|
|
65
|
+
// TODO other oses
|
|
66
|
+
};
|
|
67
|
+
HelpersProcess.prototype.generatedFileWrap = function (content) {
|
|
68
|
+
return "".concat(content, "\n // [").concat(tnp_config_1.config.frameworkName, "] GENERATED CONTENT FOR BACKEND VERSION\n // [").concat(tnp_config_1.config.frameworkName, "] GENERATED CONTENT FOR BACKEND VERSION\n ").trim();
|
|
69
|
+
};
|
|
70
|
+
HelpersProcess.prototype.changeCwdWrapper = function (dir, functionToExecure, logLevel) {
|
|
71
|
+
if (logLevel === void 0) { logLevel = ng2_logger_1.Level.__NOTHING; }
|
|
72
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
73
|
+
var currentCwd;
|
|
74
|
+
return tslib_1.__generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
currentCwd = (0, tnp_core_1.crossPlatformPath)(process.cwd());
|
|
78
|
+
index_1.Helpers.changeCwd(dir);
|
|
79
|
+
ng2_logger_1.Log.disableLogs(logLevel);
|
|
80
|
+
return [4 /*yield*/, index_1.Helpers.runSyncOrAsync(functionToExecure)];
|
|
81
|
+
case 1:
|
|
82
|
+
_a.sent();
|
|
83
|
+
ng2_logger_1.Log.enableLogs();
|
|
84
|
+
index_1.Helpers.changeCwd(currentCwd);
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
HelpersProcess.prototype.changeCwd = function (dir) {
|
|
91
|
+
if (!dir) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
index_1.Helpers.goToDir(dir);
|
|
95
|
+
};
|
|
96
|
+
HelpersProcess.prototype.goToDir = function (dir) {
|
|
97
|
+
if (dir === void 0) { dir = '..'; }
|
|
98
|
+
var previous = (0, tnp_core_1.crossPlatformPath)(process.cwd());
|
|
99
|
+
try {
|
|
100
|
+
dir = tnp_core_1.path.isAbsolute(dir) ? dir :
|
|
101
|
+
(0, tnp_core_1.crossPlatformPath)(tnp_core_1.path.resolve(tnp_core_1.path.join((0, tnp_core_1.crossPlatformPath)(process.cwd()), dir)));
|
|
102
|
+
if (tnp_core_1.path.basename(dir) === tnp_config_1.config.folder.external) {
|
|
103
|
+
var belowExternal = tnp_core_1.path.resolve(tnp_core_1.path.join(dir, '..'));
|
|
104
|
+
var classProject = typescript_class_helpers_1.CLASS.getBy('Project');
|
|
105
|
+
if (tnp_core_1.fse.existsSync(belowExternal) && !!classProject.From(belowExternal)) {
|
|
106
|
+
dir = belowExternal;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
process.chdir(dir);
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
this.goToDir(previous);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
};
|
|
117
|
+
HelpersProcess.prototype.pressKeyOrWait = function (message, printWaitMessages) {
|
|
118
|
+
if (message === void 0) { message = 'Press enter try again'; }
|
|
119
|
+
if (printWaitMessages === void 0) { printWaitMessages = 0; }
|
|
120
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
121
|
+
return tslib_1.__generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
if (!(tnp_core_1._.isNumber(printWaitMessages) && printWaitMessages > 0)) return [3 /*break*/, 2];
|
|
125
|
+
index_1.Helpers.log("Please wait (".concat(printWaitMessages, ") seconds"));
|
|
126
|
+
return [4 /*yield*/, index_1.Helpers.pressKeyOrWait(message, printWaitMessages - 1)];
|
|
127
|
+
case 1:
|
|
128
|
+
_a.sent();
|
|
129
|
+
return [2 /*return*/];
|
|
130
|
+
case 2: return [2 /*return*/, new Promise(function (resovle) {
|
|
131
|
+
index_1.Helpers.log(message);
|
|
132
|
+
process.stdin.once('data', function () {
|
|
133
|
+
resovle(void 0);
|
|
134
|
+
});
|
|
135
|
+
})];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
HelpersProcess.prototype.pressKeyAndContinue = function (message) {
|
|
141
|
+
if (message === void 0) { message = 'Press enter to continue..'; }
|
|
142
|
+
console.log(tnp_core_1.chalk.bold(message));
|
|
143
|
+
if (process.platform === 'win32') {
|
|
144
|
+
spawn.sync('pause', '', { shell: true, stdio: [0, 1, 2] });
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
require('child_process').spawnSync('read _ ', { shell: true, stdio: [0, 1, 2] });
|
|
148
|
+
// return new Promise((resovle) => {
|
|
149
|
+
// Helpers.log(message);
|
|
150
|
+
// process.stdin.once('data', function () {
|
|
151
|
+
// resovle()
|
|
152
|
+
// });
|
|
153
|
+
// })
|
|
154
|
+
};
|
|
155
|
+
HelpersProcess.prototype.list = function (question, choices) {
|
|
156
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
157
|
+
var res;
|
|
158
|
+
return tslib_1.__generator(this, function (_a) {
|
|
159
|
+
switch (_a.label) {
|
|
160
|
+
case 0: return [4 /*yield*/, inquirer.prompt({
|
|
161
|
+
type: 'list',
|
|
162
|
+
name: 'value',
|
|
163
|
+
message: question,
|
|
164
|
+
choices: choices,
|
|
165
|
+
pageSize: 10,
|
|
166
|
+
loop: false,
|
|
167
|
+
})];
|
|
168
|
+
case 1:
|
|
169
|
+
res = _a.sent();
|
|
170
|
+
return [2 /*return*/, res.value];
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
HelpersProcess.prototype.autocompleteAsk = function (question, choices, pageSize) {
|
|
176
|
+
if (pageSize === void 0) { pageSize = 10; }
|
|
177
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
178
|
+
function source(__, input) {
|
|
179
|
+
input = input || '';
|
|
180
|
+
return new Promise(function (resolve) {
|
|
181
|
+
var fuzzyResult = fuzzy.filter(input, choices.map(function (f) { return f.name; }));
|
|
182
|
+
resolve(fuzzyResult.map(function (el) {
|
|
183
|
+
return { name: el.original, value: choices.find(function (c) { return c.name === el.original; }).value };
|
|
184
|
+
}));
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
var res;
|
|
188
|
+
return tslib_1.__generator(this, function (_a) {
|
|
189
|
+
switch (_a.label) {
|
|
190
|
+
case 0: return [4 /*yield*/, inquirer.prompt({
|
|
191
|
+
type: 'autocomplete',
|
|
192
|
+
name: 'command',
|
|
193
|
+
pageSize: pageSize,
|
|
194
|
+
source: source,
|
|
195
|
+
message: question,
|
|
196
|
+
choices: choices
|
|
197
|
+
})];
|
|
198
|
+
case 1:
|
|
199
|
+
res = _a.sent();
|
|
200
|
+
return [2 /*return*/, res.command];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
HelpersProcess.prototype.questionYesNo = function (message, callbackTrue, callbackFalse, defaultValue) {
|
|
206
|
+
if (defaultValue === void 0) { defaultValue = true; }
|
|
207
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
208
|
+
var response;
|
|
209
|
+
return tslib_1.__generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
response = {
|
|
213
|
+
value: defaultValue
|
|
214
|
+
};
|
|
215
|
+
if (!global.tnpNonInteractive) return [3 /*break*/, 1];
|
|
216
|
+
index_1.Helpers.info("".concat(message, " - AUTORESPONSE: ").concat(defaultValue ? 'YES' : 'NO'));
|
|
217
|
+
return [3 /*break*/, 3];
|
|
218
|
+
case 1: return [4 /*yield*/, prompts({
|
|
219
|
+
type: 'toggle',
|
|
220
|
+
name: 'value',
|
|
221
|
+
message: message,
|
|
222
|
+
initial: defaultValue,
|
|
223
|
+
active: 'yes',
|
|
224
|
+
inactive: 'no'
|
|
225
|
+
})];
|
|
226
|
+
case 2:
|
|
227
|
+
response = _a.sent();
|
|
228
|
+
_a.label = 3;
|
|
229
|
+
case 3:
|
|
230
|
+
if (!response.value) return [3 /*break*/, 6];
|
|
231
|
+
if (!callbackTrue) return [3 /*break*/, 5];
|
|
232
|
+
return [4 /*yield*/, index_1.Helpers.runSyncOrAsync(callbackTrue)];
|
|
233
|
+
case 4:
|
|
234
|
+
_a.sent();
|
|
235
|
+
_a.label = 5;
|
|
236
|
+
case 5: return [3 /*break*/, 8];
|
|
237
|
+
case 6:
|
|
238
|
+
if (!callbackFalse) return [3 /*break*/, 8];
|
|
239
|
+
return [4 /*yield*/, index_1.Helpers.runSyncOrAsync(callbackFalse)];
|
|
240
|
+
case 7:
|
|
241
|
+
_a.sent();
|
|
242
|
+
_a.label = 8;
|
|
243
|
+
case 8: return [2 /*return*/, response.value];
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
Object.defineProperty(HelpersProcess.prototype, "isWsl", {
|
|
249
|
+
get: function () {
|
|
250
|
+
if (process.platform !== 'linux') {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
if (tnp_core_1.os.release().toLowerCase().includes('microsoft')) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
return tnp_core_1.fse.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft');
|
|
258
|
+
}
|
|
259
|
+
catch (_) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
enumerable: false,
|
|
264
|
+
configurable: true
|
|
265
|
+
});
|
|
266
|
+
;
|
|
267
|
+
HelpersProcess.prototype.getWorkingDirOfProcess = function (PID) {
|
|
268
|
+
try {
|
|
269
|
+
var cwd = tnp_core_1.child_process.execSync("lsof -p ".concat(PID, " | awk '$4==\"cwd\" {print $9}'")).toString().trim();
|
|
270
|
+
return cwd;
|
|
271
|
+
}
|
|
272
|
+
catch (e) {
|
|
273
|
+
index_1.Helpers.error(e);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
HelpersProcess.prototype.commnadOutputAsStringAsync = function (command, cwd, biggerBuffer, showWholeCommandNotOnlyLastLine) {
|
|
277
|
+
if (cwd === void 0) { cwd = (0, tnp_core_1.crossPlatformPath)(process.cwd()); }
|
|
278
|
+
if (biggerBuffer === void 0) { biggerBuffer = false; }
|
|
279
|
+
if (showWholeCommandNotOnlyLastLine === void 0) { showWholeCommandNotOnlyLastLine = false; }
|
|
280
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
281
|
+
var output, splited, e_1;
|
|
282
|
+
return tslib_1.__generator(this, function (_a) {
|
|
283
|
+
switch (_a.label) {
|
|
284
|
+
case 0:
|
|
285
|
+
output = '';
|
|
286
|
+
_a.label = 1;
|
|
287
|
+
case 1:
|
|
288
|
+
_a.trys.push([1, 3, , 4]);
|
|
289
|
+
return [4 /*yield*/, index_1.Helpers.command(command).getherOutput()];
|
|
290
|
+
case 2:
|
|
291
|
+
output = _a.sent();
|
|
292
|
+
// console.log({
|
|
293
|
+
// output
|
|
294
|
+
// })
|
|
295
|
+
if (showWholeCommandNotOnlyLastLine) {
|
|
296
|
+
// console.log('SHHOW WOLE', output)
|
|
297
|
+
return [2 /*return*/, output.replace(/[^\x00-\xFF]/g, '')];
|
|
298
|
+
}
|
|
299
|
+
splited = (output || '').split('\n');
|
|
300
|
+
output = (splited.pop() || '').replace(/[^\x00-\xFF]/g, '');
|
|
301
|
+
return [3 /*break*/, 4];
|
|
302
|
+
case 3:
|
|
303
|
+
e_1 = _a.sent();
|
|
304
|
+
index_1.Helpers.warn("[tnp-helepr] Not able to get output from command:\n \"".concat(command, "\"\n "));
|
|
305
|
+
return [3 /*break*/, 4];
|
|
306
|
+
case 4: return [2 /*return*/, output];
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
HelpersProcess.prototype.commnadOutputAsString = function (command, cwd, biggerBuffer, showWholeCommandNotOnlyLastLine) {
|
|
312
|
+
if (cwd === void 0) { cwd = (0, tnp_core_1.crossPlatformPath)(process.cwd()); }
|
|
313
|
+
if (biggerBuffer === void 0) { biggerBuffer = false; }
|
|
314
|
+
if (showWholeCommandNotOnlyLastLine === void 0) { showWholeCommandNotOnlyLastLine = false; }
|
|
315
|
+
var output = '';
|
|
316
|
+
try {
|
|
317
|
+
output = index_1.Helpers.run(command, { output: false, cwd: cwd, biggerBuffer: biggerBuffer }).sync().toString().trim();
|
|
318
|
+
// console.log({
|
|
319
|
+
// output
|
|
320
|
+
// })
|
|
321
|
+
if (showWholeCommandNotOnlyLastLine) {
|
|
322
|
+
return output.replace(/[^\x00-\xFF]/g, '');
|
|
323
|
+
}
|
|
324
|
+
var splited = (output || '').split('\n');
|
|
325
|
+
output = (splited.pop() || '').replace(/[^\x00-\xFF]/g, '');
|
|
326
|
+
}
|
|
327
|
+
catch (e) {
|
|
328
|
+
index_1.Helpers.warn("[tnp-helepr] Not able to get output from command:\n \"".concat(command, "\"\n "));
|
|
329
|
+
}
|
|
330
|
+
return output;
|
|
331
|
+
};
|
|
332
|
+
HelpersProcess.prototype.outputToVScode = function (data, disableEncode) {
|
|
333
|
+
if (disableEncode === void 0) { disableEncode = false; }
|
|
334
|
+
if (tnp_core_1._.isObject(data)) {
|
|
335
|
+
data = JSON.stringify(data);
|
|
336
|
+
}
|
|
337
|
+
if (disableEncode) {
|
|
338
|
+
console.log(data);
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
console.log(encodeURIComponent(data));
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
HelpersProcess.prototype.sleep = function (seconds) {
|
|
345
|
+
if (seconds === void 0) { seconds = 1; }
|
|
346
|
+
return index_1.Helpers.run("sleep ".concat(seconds)).sync();
|
|
347
|
+
};
|
|
348
|
+
HelpersProcess.prototype.actionWrapper = function (fn, taskName) {
|
|
349
|
+
if (taskName === void 0) { taskName = 'Task'; }
|
|
350
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
351
|
+
function currentDate() {
|
|
352
|
+
return "[".concat(dateformat(new Date(), 'HH:MM:ss'), "]");
|
|
353
|
+
}
|
|
354
|
+
return tslib_1.__generator(this, function (_a) {
|
|
355
|
+
switch (_a.label) {
|
|
356
|
+
case 0:
|
|
357
|
+
// global.spinner && global.spinner.start()
|
|
358
|
+
index_1.Helpers.taskStarted("".concat(currentDate(), " \"").concat(taskName, "\" Started.."));
|
|
359
|
+
return [4 /*yield*/, index_1.Helpers.runSyncOrAsync(fn)];
|
|
360
|
+
case 1:
|
|
361
|
+
_a.sent();
|
|
362
|
+
index_1.Helpers.taskDone("".concat(currentDate(), " \"").concat(taskName, "\" Done"));
|
|
363
|
+
return [2 /*return*/];
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
};
|
|
368
|
+
HelpersProcess.prototype.terminalLine = function () {
|
|
369
|
+
return tnp_core_1._.times(process.stdout.columns, function () { return '-'; }).join('');
|
|
370
|
+
};
|
|
371
|
+
HelpersProcess.prototype.killProcess = function (byPid) {
|
|
372
|
+
index_1.Helpers.run("kill -9 ".concat(byPid)).sync();
|
|
373
|
+
};
|
|
374
|
+
HelpersProcess.prototype.killProcessByPort = function (portOrPortsToKill) {
|
|
375
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
376
|
+
var index, port, org, e_2;
|
|
377
|
+
return tslib_1.__generator(this, function (_a) {
|
|
378
|
+
switch (_a.label) {
|
|
379
|
+
case 0:
|
|
380
|
+
if (!tnp_core_1._.isArray(portOrPortsToKill)) {
|
|
381
|
+
portOrPortsToKill = [portOrPortsToKill];
|
|
382
|
+
}
|
|
383
|
+
index = 0;
|
|
384
|
+
_a.label = 1;
|
|
385
|
+
case 1:
|
|
386
|
+
if (!(index < portOrPortsToKill.length)) return [3 /*break*/, 6];
|
|
387
|
+
port = portOrPortsToKill[index];
|
|
388
|
+
org = port;
|
|
389
|
+
port = Number(port);
|
|
390
|
+
if (!tnp_core_1._.isNumber(port)) {
|
|
391
|
+
index_1.Helpers.warn("[tnp-helpers] Can't kill on port: \"".concat(org, "\""));
|
|
392
|
+
return [2 /*return*/];
|
|
393
|
+
}
|
|
394
|
+
_a.label = 2;
|
|
395
|
+
case 2:
|
|
396
|
+
_a.trys.push([2, 4, , 5]);
|
|
397
|
+
return [4 /*yield*/, (0, tnp_core_1.fkill)(":".concat(port), { force: true })];
|
|
398
|
+
case 3:
|
|
399
|
+
_a.sent();
|
|
400
|
+
// run(`fkill -f :${port} &> /dev/null`, { output: false }).sync()
|
|
401
|
+
index_1.Helpers.info("Processs killed successfully on port: ".concat(port));
|
|
402
|
+
return [3 /*break*/, 5];
|
|
403
|
+
case 4:
|
|
404
|
+
e_2 = _a.sent();
|
|
405
|
+
index_1.Helpers.warn("No process to kill on port: ".concat(port, "... "));
|
|
406
|
+
return [3 /*break*/, 5];
|
|
407
|
+
case 5:
|
|
408
|
+
index++;
|
|
409
|
+
return [3 /*break*/, 1];
|
|
410
|
+
case 6: return [2 /*return*/];
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
};
|
|
415
|
+
HelpersProcess.prototype.clearConsole = function () {
|
|
416
|
+
index_1.Helpers.msgCacheClear();
|
|
417
|
+
console.log('\x1Bc');
|
|
418
|
+
// process.stdout.write('\033c\033[3J');
|
|
419
|
+
// try {
|
|
420
|
+
// run('clear').sync()
|
|
421
|
+
// } catch (error) {
|
|
422
|
+
// console.log('clear console not succedd')
|
|
423
|
+
// }
|
|
424
|
+
};
|
|
425
|
+
// process.on('uncaughtException', cleanExit)
|
|
426
|
+
// process.on('unhandledRejection', cleanExit)
|
|
427
|
+
// process.once('unhandledRejection', (err, aa) => {
|
|
428
|
+
// error(`'Exiting unhandledRejection
|
|
429
|
+
// Reason: ${err}
|
|
430
|
+
// ${JSON.stringify(aa)}
|
|
431
|
+
// `);
|
|
432
|
+
// })
|
|
433
|
+
HelpersProcess.prototype.formatPath = function (pathToFileOrFolder) {
|
|
434
|
+
if (!tnp_core_1._.isString(pathToFileOrFolder)) {
|
|
435
|
+
return "\n< provided path is not string: ".concat(pathToFileOrFolder, " >\n");
|
|
436
|
+
}
|
|
437
|
+
if (!tnp_core_1.path.isAbsolute(pathToFileOrFolder)) {
|
|
438
|
+
return "\n\n".concat(index_1.Helpers.terminalLine(), "\nrelativePath: ").concat(pathToFileOrFolder, "\n").concat(index_1.Helpers.terminalLine(), "\n");
|
|
439
|
+
}
|
|
440
|
+
if (!tnp_core_1.fse.existsSync(pathToFileOrFolder)) {
|
|
441
|
+
return "\n\n".concat(index_1.Helpers.terminalLine(), "\n< provided path does not exist: ").concat(pathToFileOrFolder, " >\n").concat(index_1.Helpers.terminalLine(), "\n");
|
|
442
|
+
}
|
|
443
|
+
var isDirectory = tnp_core_1.fse.lstatSync(pathToFileOrFolder).isDirectory();
|
|
444
|
+
return "\n".concat(index_1.Helpers.terminalLine(), "\n<-- ").concat(isDirectory ? 'Path to directory' : 'Path to file', ": -->\n").concat(isDirectory ? pathToFileOrFolder.split('/').map(function (c) { return "/".concat(c); }).join('').replace(/^\//, '') : (tnp_core_1.path.dirname(pathToFileOrFolder.split('/').map(function (c) { return "/".concat(c); }).join('').replace(/^\//, ''))
|
|
445
|
+
+ '\n/' + tnp_cli_1.CLI.chalk.bold(tnp_core_1.path.basename(pathToFileOrFolder))), "\n").concat(index_1.Helpers.terminalLine(), "\n");
|
|
446
|
+
};
|
|
447
|
+
;
|
|
448
|
+
HelpersProcess.prototype.waitForMessegeInStdout = function (proc, message) {
|
|
449
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
450
|
+
return tslib_1.__generator(this, function (_a) {
|
|
451
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
452
|
+
var resolved = false;
|
|
453
|
+
proc.stdout.on('data', function (data) {
|
|
454
|
+
// console.log(`
|
|
455
|
+
// [waitForMessegeInStdout] data: ${data}
|
|
456
|
+
// [waitForMessegeInStdout] data typeof: ${typeof data}
|
|
457
|
+
// `);
|
|
458
|
+
if (tnp_core_1._.isObject(data) && tnp_core_1._.isFunction(data.toString)) {
|
|
459
|
+
data = data.toString();
|
|
460
|
+
}
|
|
461
|
+
if (tnp_core_1._.isString(data) && data.search(message) !== -1) {
|
|
462
|
+
resolved = true;
|
|
463
|
+
resolve(void 0);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
proc.once('exit', function () {
|
|
467
|
+
// console.log(`
|
|
468
|
+
// [waitForMessegeInStdout] exit: ${code}
|
|
469
|
+
// `);
|
|
470
|
+
if (!resolved) {
|
|
471
|
+
reject();
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
})];
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
};
|
|
478
|
+
HelpersProcess.prototype.prepareWatchCommand = function (cmd) {
|
|
479
|
+
return tnp_core_1.os.platform() === 'win32' ? "\"".concat(cmd, "\"") : "'".concat(cmd, "'");
|
|
480
|
+
};
|
|
481
|
+
Object.defineProperty(HelpersProcess.prototype, "watcher", {
|
|
482
|
+
get: function () {
|
|
483
|
+
var that = index_1.Helpers;
|
|
484
|
+
return {
|
|
485
|
+
/**
|
|
486
|
+
* @deprecated
|
|
487
|
+
*/
|
|
488
|
+
run: function (command, folderPath, options) {
|
|
489
|
+
if (folderPath === void 0) { folderPath = 'src'; }
|
|
490
|
+
var _a = options.cwd, cwd = _a === void 0 ? (0, tnp_core_1.crossPlatformPath)(process.cwd()) : _a, wait = options.wait;
|
|
491
|
+
var cmd = "tnp command ".concat(command);
|
|
492
|
+
var toRun = "watch ".concat(that.prepareWatchCommand(cmd), " ").concat(folderPath, " ").concat(wait ? ('--wait=' + wait) : '');
|
|
493
|
+
index_1.Helpers.log("WATCH COMMAND ".concat(toRun));
|
|
494
|
+
return that.run(toRun, { cwd: cwd }).async();
|
|
495
|
+
},
|
|
496
|
+
/**
|
|
497
|
+
* @deprecated
|
|
498
|
+
*/
|
|
499
|
+
call: function (fn, params, folderPath, options) {
|
|
500
|
+
if (folderPath === void 0) { folderPath = 'src'; }
|
|
501
|
+
var _a = options.cwd, cwd = _a === void 0 ? (0, tnp_core_1.crossPlatformPath)(process.cwd()) : _a;
|
|
502
|
+
if (!fn) {
|
|
503
|
+
index_1.Helpers.error("Bad function: ".concat(fn, " for watcher on folder: ").concat(folderPath, ", with params: ").concat(params));
|
|
504
|
+
}
|
|
505
|
+
var fnName = typeof fn === 'function' ? typescript_class_helpers_1.CLASS.getName(fn) : fn;
|
|
506
|
+
// Helpers.log('Function name ', fnName)
|
|
507
|
+
var cmd = "".concat(tnp_config_1.config.frameworkName, " ").concat(index_1.Helpers.cliTool.simplifiedCmd(fnName), " ").concat(params);
|
|
508
|
+
var toRun = "watch ".concat(that.prepareWatchCommand(cmd), " ").concat(folderPath);
|
|
509
|
+
return that.run(toRun, { cwd: cwd }).async();
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
},
|
|
513
|
+
enumerable: false,
|
|
514
|
+
configurable: true
|
|
515
|
+
});
|
|
516
|
+
HelpersProcess.prototype.getStringFrom = function (command, descriptionOfCommand) {
|
|
517
|
+
try {
|
|
518
|
+
var res = index_1.Helpers.run(command, { output: false }).sync().toString();
|
|
519
|
+
return res;
|
|
520
|
+
}
|
|
521
|
+
catch (error) {
|
|
522
|
+
index_1.Helpers.warn("Not able to get string from \"".concat(descriptionOfCommand ? descriptionOfCommand : command, "\""));
|
|
523
|
+
return void 0;
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
return HelpersProcess;
|
|
527
|
+
}());
|
|
528
|
+
exports.HelpersProcess = HelpersProcess;
|
|
529
|
+
//# sourceMappingURL=C:/Users/darek/projects/npm/tnp-helpers/tmp-bundle-release/bundle/project/tnp-helpers/bundle-nocutsrc/lib/helpers-process.backend.js.map
|