tnp-helpers 19.0.44 → 19.0.46
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 +703 -124
- package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base/classes/base-cli-worker/base-cli-worker-database-config.d.ts +10 -0
- package/browser/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.d.ts +10 -9
- package/browser/lib/base/classes/base-cli-worker/base-cli-worker.d.ts +9 -3
- package/browser/lib/base/classes/base-cli-worker/index.d.ts +1 -0
- package/browser/lib/base/classes/base-java-jdk.d.ts +1 -1
- package/browser/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.d.ts +2 -2
- package/browser/lib/build-info._auto-generated_.d.ts +1 -1
- package/browser/lib/helpers/for-backend/helpers-file-folders.d.ts +1 -1
- package/browser/lib/models.d.ts +0 -2
- package/browser/lib/utils.d.ts +51 -29
- package/browser/package.json +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-database-config.d.ts +14 -0
- package/lib/base/classes/base-cli-worker/base-cli-worker-database-config.js +31 -0
- package/lib/base/classes/base-cli-worker/base-cli-worker-database-config.js.map +1 -0
- package/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.d.ts +11 -10
- package/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.js +3 -15
- package/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker.d.ts +9 -3
- package/lib/base/classes/base-cli-worker/base-cli-worker.js +32 -10
- package/lib/base/classes/base-cli-worker/base-cli-worker.js.map +1 -1
- package/lib/base/classes/base-cli-worker/index.d.ts +1 -0
- package/lib/base/classes/base-cli-worker/index.js +1 -0
- package/lib/base/classes/base-cli-worker/index.js.map +1 -1
- package/lib/base/classes/base-global-command-line.backend.d.ts +5 -0
- package/lib/base/classes/base-global-command-line.backend.js +156 -7
- package/lib/base/classes/base-global-command-line.backend.js.map +1 -1
- package/lib/base/classes/base-java-jdk.d.ts +1 -1
- package/lib/base/classes/base-java-jdk.js +5 -261
- package/lib/base/classes/base-java-jdk.js.map +1 -1
- package/lib/base/classes/base-project.js +6 -2
- package/lib/base/classes/base-project.js.map +1 -1
- package/lib/base/classes/base-release-process.js +2 -2
- package/lib/base/classes/base-release-process.js.map +1 -1
- package/lib/base/core-project.js +0 -2
- package/lib/base/core-project.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.js +2 -18
- package/lib/base/tcp-udp-ports/tcp-udp-ports.context.js.map +1 -1
- package/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.d.ts +3 -3
- package/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.js +15 -5
- package/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.js.map +1 -1
- 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.d.ts +1 -1
- package/lib/helpers/for-backend/helpers-file-folders.js +2 -0
- package/lib/helpers/for-backend/helpers-file-folders.js.map +1 -1
- package/lib/helpers/for-browser/angular.helper.js +2 -2
- package/lib/models.d.ts +0 -2
- package/lib/models.js.map +1 -1
- package/lib/old/base-component.js +2 -2
- package/lib/old/base-formly-component.js +2 -2
- package/lib/old/dual-component-ctrl.js +2 -2
- package/lib/utils.d.ts +51 -29
- package/lib/utils.js +476 -4
- package/lib/utils.js.map +1 -1
- package/package.json +1 -1
- package/tmp-environment.json +11 -7
- package/websql/fesm2022/tnp-helpers.mjs +703 -124
- package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base/classes/base-cli-worker/base-cli-worker-database-config.d.ts +10 -0
- package/websql/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.d.ts +10 -9
- package/websql/lib/base/classes/base-cli-worker/base-cli-worker.d.ts +9 -3
- package/websql/lib/base/classes/base-cli-worker/index.d.ts +1 -0
- package/websql/lib/base/classes/base-java-jdk.d.ts +1 -1
- package/websql/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.d.ts +2 -2
- package/websql/lib/build-info._auto-generated_.d.ts +1 -1
- package/websql/lib/helpers/for-backend/helpers-file-folders.d.ts +1 -1
- package/websql/lib/models.d.ts +0 -2
- package/websql/lib/utils.d.ts +51 -29
- package/websql/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { Models } from 'taon/browser';
|
|
3
|
+
/**
|
|
4
|
+
* Get taon service database config
|
|
5
|
+
* (database is stored in user's home directory)
|
|
6
|
+
* @param serviceNameUniqueInSystem - unique name of the service in the system
|
|
7
|
+
* @param recreateMode - mode of database recreation, default is 'DROP_DB+MIGRATIONS'
|
|
8
|
+
* @returns DatabaseConfig object with location and recreateMode
|
|
9
|
+
*/
|
|
10
|
+
export declare const getBaseCliWorkerDatabaseConfig: (serviceNameUniqueInSystem: string, recreateMode?: Models.DBRecreateMode) => any;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import
|
|
2
|
+
import { CoreModels } from 'tnp-core/browser';
|
|
3
3
|
import type { BaseCliWorker } from './base-cli-worker';
|
|
4
4
|
import type { BaseCliWorkerController } from './base-cli-worker-controller';
|
|
5
|
+
export type BaseWorkerTerminalActionReturnType = {
|
|
6
|
+
[uniqeActionName: string]: {
|
|
7
|
+
name: string;
|
|
8
|
+
action: () => unknown | Promise<unknown>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
5
11
|
export declare class BaseCliWorkerTerminalUI<WORKER extends BaseCliWorker<BaseCliWorkerController, any>> {
|
|
6
12
|
protected worker: WORKER;
|
|
7
13
|
constructor(worker: WORKER);
|
|
8
14
|
protected headerText(): Promise<string>;
|
|
9
|
-
protected textHeaderStyle(): CfontStyle;
|
|
10
|
-
protected headerTextAlign(): CfontAlign;
|
|
15
|
+
protected textHeaderStyle(): CoreModels.CfontStyle;
|
|
16
|
+
protected headerTextAlign(): CoreModels.CfontAlign;
|
|
11
17
|
/**
|
|
12
18
|
* override whole terminal header
|
|
13
19
|
*/
|
|
@@ -27,12 +33,7 @@ export declare class BaseCliWorkerTerminalUI<WORKER extends BaseCliWorker<BaseCl
|
|
|
27
33
|
protected getWorkerTerminalActions(options?: {
|
|
28
34
|
exitIsOnlyReturn?: boolean;
|
|
29
35
|
chooseAction?: boolean;
|
|
30
|
-
}):
|
|
31
|
-
[uniqeActionName: string]: {
|
|
32
|
-
name: string;
|
|
33
|
-
action: () => unknown | Promise<unknown>;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
+
}): BaseWorkerTerminalActionReturnType;
|
|
36
37
|
infoScreen(options?: {
|
|
37
38
|
exitIsOnlyReturn?: boolean;
|
|
38
39
|
}): Promise<void>;
|
|
@@ -39,11 +39,15 @@ export declare abstract class BaseCliWorker<REMOTE_CTRL extends BaseCliWorkerCon
|
|
|
39
39
|
*/
|
|
40
40
|
serviceVersion: string);
|
|
41
41
|
/**
|
|
42
|
+
* <strong>IMPORTANT USE ONLY IN DEVELOPMENT !!!</strong>
|
|
43
|
+
* for production use startDetachedIfNeedsToBeStarted()
|
|
42
44
|
* start normally process
|
|
43
45
|
* this will crash if process already started
|
|
44
46
|
*/
|
|
45
|
-
|
|
46
|
-
getControllerForRemoteConnection(
|
|
47
|
+
startNormallyInCurrentProcess(): Promise<void>;
|
|
48
|
+
getControllerForRemoteConnection(options?: {
|
|
49
|
+
calledFrom?: string;
|
|
50
|
+
}): Promise<REMOTE_CTRL>;
|
|
47
51
|
startDetachedIfNeedsToBeStarted(options?: {
|
|
48
52
|
useCurrentWindowForDetach?: boolean;
|
|
49
53
|
}): Promise<any>;
|
|
@@ -85,6 +89,8 @@ export declare abstract class BaseCliWorker<REMOTE_CTRL extends BaseCliWorkerCon
|
|
|
85
89
|
}): Promise<void>;
|
|
86
90
|
private saveProcessInfo;
|
|
87
91
|
protected initializeWorkerMetadata(): Promise<any>;
|
|
88
|
-
protected waitForProcessPortSavedToDisk(
|
|
92
|
+
protected waitForProcessPortSavedToDisk(options?: {
|
|
93
|
+
calledFrom?: string;
|
|
94
|
+
}): Promise<void>;
|
|
89
95
|
getServicePort(): Promise<number>;
|
|
90
96
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { BaseFeatureForProject } from './base-feature-for-project';
|
|
3
3
|
import { BaseProject } from './base-project';
|
|
4
4
|
export declare class BaseJavaJdk<PROJECT extends BaseProject = any> extends BaseFeatureForProject<PROJECT> {
|
|
5
|
-
selectJdkVersion(): Promise<string>;
|
|
5
|
+
selectJdkVersion(): Promise<string | undefined>;
|
|
6
6
|
updateJavaHomePath(selectedPath: string): void;
|
|
7
7
|
selectTomcatVersion(): Promise<string>;
|
|
8
8
|
updateTomcatHomePath(selectedPath: string): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
import { CoreModels } from 'tnp-core/browser';
|
|
2
3
|
import { Port } from '../../index';
|
|
3
|
-
import { CfontStyle } from '../../models';
|
|
4
4
|
import { BaseCliWorkerTerminalUI } from '../classes/base-cli-worker/base-cli-worker-terminal-ui';
|
|
5
5
|
import { PortStatus } from './ports.entity';
|
|
6
6
|
import type { PortsWorker } from './tcp-upd-ports.worker';
|
|
7
7
|
export declare class TcpUdpPortsTerminalUI extends BaseCliWorkerTerminalUI<PortsWorker> {
|
|
8
8
|
protected headerText(): Promise<string>;
|
|
9
|
-
protected textHeaderStyle(): CfontStyle;
|
|
9
|
+
protected textHeaderStyle(): CoreModels.CfontStyle;
|
|
10
10
|
protected crudMenuForTakeByOsPorts(): Promise<void>;
|
|
11
11
|
protected addPortTerminalUiProcess(): Promise<void>;
|
|
12
12
|
protected selectPortProcess(ports: Port[], title: string): Promise<Port>;
|
|
@@ -101,7 +101,7 @@ export declare class HelpersFileFolders {
|
|
|
101
101
|
} & CopyOptionsSync): void;
|
|
102
102
|
filterDontCopy(basePathFoldersTosSkip: string[], projectOrBasepath: string): any;
|
|
103
103
|
filterOnlyCopy(basePathFoldersOnlyToInclude: string[], projectOrBasepath: string): any;
|
|
104
|
-
copyFile(sourcePath: string, destinationPath: string, options?: {
|
|
104
|
+
copyFile(sourcePath: string | string[], destinationPath: string | string[], options?: {
|
|
105
105
|
transformTextFn?: (input: string) => string;
|
|
106
106
|
debugMode?: boolean;
|
|
107
107
|
fast?: boolean;
|
package/browser/lib/models.d.ts
CHANGED
|
@@ -137,8 +137,6 @@ export declare class CommandProcess {
|
|
|
137
137
|
start(options?: CommandProcessRunOptions): Promise<void>;
|
|
138
138
|
stop(): Promise<void>;
|
|
139
139
|
}
|
|
140
|
-
export type CfontStyle = 'block' | 'slick' | 'tiny' | 'grid' | 'pallet' | 'shade' | 'chrome' | 'simple' | 'simpleBlock' | '3d' | 'simple3d' | 'huge';
|
|
141
|
-
export type CfontAlign = 'left' | 'center' | 'right' | 'block';
|
|
142
140
|
export interface DockerComposeFile {
|
|
143
141
|
version: string;
|
|
144
142
|
services: Record<string, DockerService>;
|
package/browser/lib/utils.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare namespace UtilsTypescript {
|
|
|
19
19
|
* @param regionName - The name of the region to remove.
|
|
20
20
|
* @returns Modified TypeScript code without the specified regions.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
const removeRegionByName: (sourceCode: string, regionName: string) => string;
|
|
23
23
|
interface ExportInfo {
|
|
24
24
|
type: 'class' | 'function' | 'const' | 'let' | 'var' | 'enum' | 'type' | 'interface' | 'default' | 'module' | 'namespace';
|
|
25
25
|
name: string;
|
|
@@ -27,34 +27,34 @@ export declare namespace UtilsTypescript {
|
|
|
27
27
|
/**
|
|
28
28
|
* Function to extract exports from a TypeScript file
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
const exportsFromFile: (filePath: string) => ExportInfo[];
|
|
31
31
|
/**
|
|
32
32
|
* Function to extract exports from a TypeScript file
|
|
33
33
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
const exportsFromContent: (fileContent: string) => ExportInfo[];
|
|
35
|
+
const extractDefaultClassNameFromString: (sourceCode: string) => string | undefined;
|
|
36
|
+
const extractClassNameFromString: (sourceCode: string) => string[];
|
|
37
|
+
const extractClassNamesFromFile: (absoluteFilePath: string) => string[];
|
|
38
|
+
const extractDefaultClassNameFromFile: (absoluteFilePath: string) => any;
|
|
39
|
+
const formatFile: (absPathToFile: string | string[]) => void;
|
|
40
|
+
const formatAllFilesInsideFolder: (absPathToFolder: string) => void;
|
|
41
|
+
const eslintFixFile: (absPathToFile: string | string[]) => void;
|
|
42
|
+
const eslintFixAllFilesInsideFolder: (absPathToFolder: string | string[]) => void;
|
|
43
|
+
const getTaonContextFromContent: (fileContent: string) => string[];
|
|
44
|
+
const getTaonContextsNamesFromFile: (tsAbsFilePath: string) => string[];
|
|
45
|
+
const extractAngularComponentSelectors: (fileAbsPath: string) => {
|
|
46
46
|
className: string;
|
|
47
47
|
selector: string;
|
|
48
48
|
}[];
|
|
49
|
-
|
|
49
|
+
const wrapWithComment: (oneLineComment: string, absDestFilePath: string) => any;
|
|
50
50
|
/**
|
|
51
51
|
* Attempts to set or add an exported const with given name and value.
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
const setValueToVariableInTsFile: (tsAbsFilePath: string, variableName: string, valueOfVariable: any, options?: {
|
|
54
54
|
skipAddIfNotExists?: boolean;
|
|
55
55
|
useRawStringValue?: boolean;
|
|
56
56
|
}) => void;
|
|
57
|
-
|
|
57
|
+
class TsImportExport {
|
|
58
58
|
/**
|
|
59
59
|
* for external modification
|
|
60
60
|
*/
|
|
@@ -96,27 +96,26 @@ export declare namespace UtilsTypescript {
|
|
|
96
96
|
getStringPartFrom(wholeContentOfFile: string): string;
|
|
97
97
|
wrapInParenthesis(str: string): string;
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
const recognizeImportsFromFile: (fileAbsPAth: string) => TsImportExport[];
|
|
100
|
+
const recognizeImportsFromContent: (fileContent: string) => TsImportExport[];
|
|
101
101
|
/**
|
|
102
102
|
* Transition methods ng18 => ng19
|
|
103
103
|
* Remove standalone:true from component decorator
|
|
104
104
|
* and add standalone: false if not exists
|
|
105
105
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
function transformComponentStandaloneOption(sourceText: string): string;
|
|
107
|
+
const fixHtmlTemplatesInDir: (directoryPath: string) => void;
|
|
108
|
+
function removeTaggedImportExport(tsFileContent: string, tags: string[]): string;
|
|
109
|
+
const wrapFirstImportsInImportsRegion: (fileContent: string) => string;
|
|
110
110
|
/**
|
|
111
111
|
* wrap class field with decorators
|
|
112
112
|
* wrap class methods with decorators
|
|
113
113
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
function wrapContentClassMembersDecoratorsWithRegion(classFileContent: string, wrapTag?: string): string;
|
|
115
|
+
const clearRequireCacheRecursive: (modulePath: string, seen?: Set<string>) => void;
|
|
116
|
+
type DeepWritable<T> = {
|
|
117
117
|
-readonly [P in keyof T]: T[P] extends object ? T[P] extends Function ? T[P] : DeepWritable<T[P]> : T[P];
|
|
118
118
|
};
|
|
119
|
-
export {};
|
|
120
119
|
}
|
|
121
120
|
export declare namespace UtilsHttp {
|
|
122
121
|
const startHttpServer: (cwd: string, port: number) => Promise<any>;
|
|
@@ -157,7 +156,8 @@ export declare namespace UtilsVSCode {
|
|
|
157
156
|
const vscodeImport: () => any;
|
|
158
157
|
}
|
|
159
158
|
export declare namespace UtilsDotFile {
|
|
160
|
-
const setValueToDotFile: (dotFileAbsPath: string | string[],
|
|
159
|
+
const setValueToDotFile: (dotFileAbsPath: string | string[], key: string, value: string | number | boolean) => void;
|
|
160
|
+
const setCommentToKeyInDotFile: (dotFileAbsPath: string | string[], key: string, comment: string) => void;
|
|
161
161
|
const getValueFromDotFile: (dotFileAbsPath: string | string[], key: string) => string | number | boolean;
|
|
162
162
|
const setValuesKeysFromObject: (dotFileAbsPath: string | string[], obj: Record<string, string | number | boolean>, options?: {
|
|
163
163
|
/**
|
|
@@ -166,6 +166,10 @@ export declare namespace UtilsDotFile {
|
|
|
166
166
|
setAsNewFile?: boolean;
|
|
167
167
|
}) => void;
|
|
168
168
|
const getValuesKeysAsJsonObject: <T = Record<string, string | number | boolean>>(dotFileAbsPath: string | string[]) => T;
|
|
169
|
+
/**
|
|
170
|
+
* @returns key|comment pairs as json object
|
|
171
|
+
*/
|
|
172
|
+
const getCommentsKeysAsJsonObject: <T = Record<string, string>>(dotFileAbsPath: string | string[]) => T;
|
|
169
173
|
}
|
|
170
174
|
export declare namespace UtilsZipBrowser {
|
|
171
175
|
const zipDirBrowser: (fileList: FileList) => Promise<Blob>;
|
|
@@ -178,6 +182,24 @@ export declare namespace UtilsZip {
|
|
|
178
182
|
* @returns true if file was split, false if not needed
|
|
179
183
|
*/
|
|
180
184
|
const splitFile: (inputPath: string, partSizeMB?: number) => Promise<number>;
|
|
181
|
-
|
|
185
|
+
/**
|
|
186
|
+
* @returns absolute path to zip file
|
|
187
|
+
*/
|
|
188
|
+
const zipDir: (absPathToDir: string, options?: {
|
|
189
|
+
/**
|
|
190
|
+
* default false
|
|
191
|
+
*/
|
|
192
|
+
overrideIfZipFileExists?: boolean;
|
|
193
|
+
}) => Promise<string>;
|
|
182
194
|
const unzipArchive: (absPathToZip: string) => Promise<void>;
|
|
195
|
+
}
|
|
196
|
+
export declare namespace UtilsTaonWorker {
|
|
197
|
+
const getUniqueForTask: (task: string, location: string | string[]) => string;
|
|
198
|
+
}
|
|
199
|
+
export declare namespace UtilsJava {
|
|
200
|
+
const selectJdkVersion: () => Promise<string | undefined>;
|
|
201
|
+
const detectJavaVersionMacOS: (javaHome: string) => string;
|
|
202
|
+
const updateJavaHomePath: (selectedPath: string) => void;
|
|
203
|
+
const selectTomcatVersion: () => Promise<string>;
|
|
204
|
+
const updateTomcatHomePath: (selectedPath: string) => void;
|
|
183
205
|
}
|
package/browser/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Models } from 'taon';
|
|
2
|
+
/**
|
|
3
|
+
* Get taon service database config
|
|
4
|
+
* (database is stored in user's home directory)
|
|
5
|
+
* @param serviceNameUniqueInSystem - unique name of the service in the system
|
|
6
|
+
* @param recreateMode - mode of database recreation, default is 'DROP_DB+MIGRATIONS'
|
|
7
|
+
* @returns DatabaseConfig object with location and recreateMode
|
|
8
|
+
*/
|
|
9
|
+
export declare const getBaseCliWorkerDatabaseConfig: (serviceNameUniqueInSystem: string, recreateMode?: Models.DBRecreateMode) => {
|
|
10
|
+
database: {
|
|
11
|
+
recreateMode: Models.DBRecreateMode;
|
|
12
|
+
location: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBaseCliWorkerDatabaseConfig = void 0;
|
|
4
|
+
const lib_1 = require("tnp-core/lib");
|
|
5
|
+
/**
|
|
6
|
+
* Get taon service database config
|
|
7
|
+
* (database is stored in user's home directory)
|
|
8
|
+
* @param serviceNameUniqueInSystem - unique name of the service in the system
|
|
9
|
+
* @param recreateMode - mode of database recreation, default is 'DROP_DB+MIGRATIONS'
|
|
10
|
+
* @returns DatabaseConfig object with location and recreateMode
|
|
11
|
+
*/
|
|
12
|
+
const getBaseCliWorkerDatabaseConfig = (serviceNameUniqueInSystem, recreateMode = 'DROP_DB+MIGRATIONS') => {
|
|
13
|
+
//#region @backendFunc
|
|
14
|
+
const serviceLocation = (0, lib_1.crossPlatformPath)([
|
|
15
|
+
lib_1.UtilsOs.getRealHomeDir(),
|
|
16
|
+
`.taon/databases-for-services/${serviceNameUniqueInSystem}.sqlite`,
|
|
17
|
+
]);
|
|
18
|
+
if (!lib_1.Helpers.exists(lib_1.path.dirname(serviceLocation))) {
|
|
19
|
+
lib_1.Helpers.mkdirp(lib_1.path.dirname(serviceLocation));
|
|
20
|
+
}
|
|
21
|
+
// console.log('portsWorkerDatabaseLocation', portsWorkerDatabaseLocation);
|
|
22
|
+
return {
|
|
23
|
+
database: {
|
|
24
|
+
recreateMode,
|
|
25
|
+
location: serviceLocation,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
};
|
|
30
|
+
exports.getBaseCliWorkerDatabaseConfig = getBaseCliWorkerDatabaseConfig;
|
|
31
|
+
//# sourceMappingURL=base-cli-worker-database-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-cli-worker-database-config.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AACA,sCAAyE;AAEzE;;;;;;GAMG;AACI,MAAM,8BAA8B,GAAG,CAC5C,yBAAiC,EACjC,eAAsC,oBAAoB,EAC1D,EAAE;IACF,sBAAsB;IACtB,MAAM,eAAe,GAAG,IAAA,uBAAiB,EAAC;QACxC,aAAO,CAAC,cAAc,EAAE;QACxB,gCAAgC,yBAAyB,SAAS;KACnE,CAAC,CAAC;IACH,IAAI,CAAC,aAAO,CAAC,MAAM,CAAC,UAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC;QACnD,aAAO,CAAC,MAAM,CAAC,UAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,2EAA2E;IAC3E,OAAO;QACL,QAAQ,EAAE;YACR,YAAY;YACZ,QAAQ,EAAE,eAAe;SAC1B;KACF,CAAC;IACF,YAAY;AACd,CAAC,CAAC;AApBW,QAAA,8BAA8B,kCAoBzC"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CoreModels } from 'tnp-core';
|
|
2
2
|
import type { BaseCliWorker } from './base-cli-worker';
|
|
3
3
|
import type { BaseCliWorkerController } from './base-cli-worker-controller';
|
|
4
|
+
export type BaseWorkerTerminalActionReturnType = {
|
|
5
|
+
[uniqeActionName: string]: {
|
|
6
|
+
name: string;
|
|
7
|
+
action: () => unknown | Promise<unknown>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
4
10
|
export declare class BaseCliWorkerTerminalUI<WORKER extends BaseCliWorker<BaseCliWorkerController, any>> {
|
|
5
11
|
protected worker: WORKER;
|
|
6
12
|
constructor(worker: WORKER);
|
|
7
13
|
protected headerText(): Promise<string>;
|
|
8
|
-
protected textHeaderStyle(): CfontStyle;
|
|
9
|
-
protected headerTextAlign(): CfontAlign;
|
|
14
|
+
protected textHeaderStyle(): CoreModels.CfontStyle;
|
|
15
|
+
protected headerTextAlign(): CoreModels.CfontAlign;
|
|
10
16
|
/**
|
|
11
17
|
* override whole terminal header
|
|
12
18
|
*/
|
|
@@ -26,14 +32,9 @@ export declare class BaseCliWorkerTerminalUI<WORKER extends BaseCliWorker<BaseCl
|
|
|
26
32
|
protected getWorkerTerminalActions(options?: {
|
|
27
33
|
exitIsOnlyReturn?: boolean;
|
|
28
34
|
chooseAction?: boolean;
|
|
29
|
-
}):
|
|
30
|
-
[uniqeActionName: string]: {
|
|
31
|
-
name: string;
|
|
32
|
-
action: () => unknown | Promise<unknown>;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
+
}): BaseWorkerTerminalActionReturnType;
|
|
35
36
|
infoScreen(options?: {
|
|
36
37
|
exitIsOnlyReturn?: boolean;
|
|
37
38
|
}): Promise<void>;
|
|
38
39
|
displaySpecialWorkerReadyMessage(): void;
|
|
39
|
-
}
|
|
40
|
+
}
|
|
@@ -5,7 +5,6 @@ exports.BaseCliWorkerTerminalUI = void 0;
|
|
|
5
5
|
const lib_1 = require("tnp-config/lib");
|
|
6
6
|
const lib_2 = require("tnp-core/lib");
|
|
7
7
|
const lib_3 = require("tnp-core/lib");
|
|
8
|
-
//#endregion
|
|
9
8
|
class BaseCliWorkerTerminalUI {
|
|
10
9
|
worker;
|
|
11
10
|
constructor(worker) {
|
|
@@ -32,22 +31,10 @@ class BaseCliWorkerTerminalUI {
|
|
|
32
31
|
*/
|
|
33
32
|
async header() {
|
|
34
33
|
//#region @backendFunc
|
|
35
|
-
|
|
36
|
-
const output = cfonts.render(await this.headerText(), {
|
|
37
|
-
font: this.textHeaderStyle(),
|
|
34
|
+
lib_2.UtilsTerminal.drawBigText(await this.headerText(), {
|
|
38
35
|
align: this.headerTextAlign(),
|
|
39
|
-
|
|
40
|
-
background: 'transparent',
|
|
41
|
-
letterSpacing: 1,
|
|
42
|
-
lineHeight: 1,
|
|
43
|
-
space: true,
|
|
44
|
-
maxLength: '0',
|
|
45
|
-
gradient: false,
|
|
46
|
-
independentGradient: false,
|
|
47
|
-
transitionGradient: false,
|
|
48
|
-
env: 'node',
|
|
36
|
+
style: this.textHeaderStyle(),
|
|
49
37
|
});
|
|
50
|
-
console.log(output.string);
|
|
51
38
|
//#endregion
|
|
52
39
|
}
|
|
53
40
|
//#endregion
|
|
@@ -60,6 +47,7 @@ class BaseCliWorkerTerminalUI {
|
|
|
60
47
|
` (version: ${this.worker.serviceVersion}) started..
|
|
61
48
|
Check info here http://localhost:${lib_3.chalk.bold(this.worker.processLocalInfoObj?.port?.toString())}/${'info'}
|
|
62
49
|
Worker started by ${lib_3.chalk.bold(lib_1.config.frameworkName)}
|
|
50
|
+
(cwd: ${process.cwd()})
|
|
63
51
|
|
|
64
52
|
`);
|
|
65
53
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-cli-worker-terminal-ui.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AAAA,iBAAiB;AACjB,wCAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"base-cli-worker-terminal-ui.js","sourceRoot":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ACvD,CAAC,EACF,CAAC;wBACD,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;wBACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBAClB,CAAC;gBACH,CAAC;aACF;SACF,CAAC;QACF,YAAY;IACd,CAAC;IACD,YAAY;IAEZ,yCAAyC;IAClC,KAAK,CAAC,UAAU,CAAC,OAEvB;QACC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,EAAE,CAAC;YACZ,aAAO,CAAC,YAAY,EAAE,CAAC;YAEvB,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;YAEpB,MAAM,IAAI,CAAC,sBAAsB,EAAE,CAAC;YACpC,MAAM,OAAO,GAAG,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;YACvD,MAAM,MAAM,GAAG,MAAM,mBAAa,CAAC,MAAM,CAAuB;gBAC9D,OAAO;gBACP,QAAQ,EAAE,eAAe;aAC1B,CAAC,CAAC;YACH,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;YACtC,MAAM,MAAM,GAAG,MAAM,MAAM,EAAE,CAAC;YAC9B,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,EAAE,CAAC;gBAChC,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IACD,YAAY;IAEZ,kEAAkE;IAC3D,gCAAgC;QACrC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC;IACxD,CAAC;CAEF;AA1JD,0DA0JC"}
|
|
@@ -38,11 +38,15 @@ export declare abstract class BaseCliWorker<REMOTE_CTRL extends BaseCliWorkerCon
|
|
|
38
38
|
*/
|
|
39
39
|
serviceVersion: string);
|
|
40
40
|
/**
|
|
41
|
+
* <strong>IMPORTANT USE ONLY IN DEVELOPMENT !!!</strong>
|
|
42
|
+
* for production use startDetachedIfNeedsToBeStarted()
|
|
41
43
|
* start normally process
|
|
42
44
|
* this will crash if process already started
|
|
43
45
|
*/
|
|
44
|
-
|
|
45
|
-
getControllerForRemoteConnection(
|
|
46
|
+
startNormallyInCurrentProcess(): Promise<void>;
|
|
47
|
+
getControllerForRemoteConnection(options?: {
|
|
48
|
+
calledFrom?: string;
|
|
49
|
+
}): Promise<REMOTE_CTRL>;
|
|
46
50
|
startDetachedIfNeedsToBeStarted(options?: {
|
|
47
51
|
useCurrentWindowForDetach?: boolean;
|
|
48
52
|
}): Promise<void>;
|
|
@@ -84,6 +88,8 @@ export declare abstract class BaseCliWorker<REMOTE_CTRL extends BaseCliWorkerCon
|
|
|
84
88
|
}): Promise<void>;
|
|
85
89
|
private saveProcessInfo;
|
|
86
90
|
protected initializeWorkerMetadata(): Promise<void>;
|
|
87
|
-
protected waitForProcessPortSavedToDisk(
|
|
91
|
+
protected waitForProcessPortSavedToDisk(options?: {
|
|
92
|
+
calledFrom?: string;
|
|
93
|
+
}): Promise<void>;
|
|
88
94
|
getServicePort(): Promise<number>;
|
|
89
95
|
}
|
|
@@ -69,6 +69,8 @@ class BaseCliWorker {
|
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region methods / start normally in current process
|
|
71
71
|
/**
|
|
72
|
+
* <strong>IMPORTANT USE ONLY IN DEVELOPMENT !!!</strong>
|
|
73
|
+
* for production use startDetachedIfNeedsToBeStarted()
|
|
72
74
|
* start normally process
|
|
73
75
|
* this will crash if process already started
|
|
74
76
|
*/
|
|
@@ -91,9 +93,14 @@ class BaseCliWorker {
|
|
|
91
93
|
}
|
|
92
94
|
//#endregion
|
|
93
95
|
//#region methods / get controller for remote connection
|
|
94
|
-
async getControllerForRemoteConnection() {
|
|
96
|
+
async getControllerForRemoteConnection(options) {
|
|
95
97
|
//#region @backendFunc
|
|
96
|
-
|
|
98
|
+
options = options || {};
|
|
99
|
+
// ! TODO this waiting is called for every generated port in app.host.ts
|
|
100
|
+
// ! this may be expensive in future
|
|
101
|
+
// if (!options.skipWaitingForWorkerProcessPortToBeSaved) {
|
|
102
|
+
await this.waitForProcessPortSavedToDisk(options);
|
|
103
|
+
// }
|
|
97
104
|
if (this.contextForRemoteConnection &&
|
|
98
105
|
!lib_1._.isNaN(this.contextForRemoteConnection.port) &&
|
|
99
106
|
!lib_1._.isNaN(this.processLocalInfoObj.port) &&
|
|
@@ -147,7 +154,9 @@ class BaseCliWorker {
|
|
|
147
154
|
index_1.Helpers.log(`Service "${this.serviceID}" not started - nothing to kill...`);
|
|
148
155
|
return;
|
|
149
156
|
}
|
|
150
|
-
const ctrl = await this.getControllerForRemoteConnection(
|
|
157
|
+
const ctrl = await this.getControllerForRemoteConnection({
|
|
158
|
+
calledFrom: 'kill',
|
|
159
|
+
});
|
|
151
160
|
try {
|
|
152
161
|
if (!options.dontRemoveConfigFile) {
|
|
153
162
|
index_1.Helpers.removeFileIfExists(this.pathToProcessLocalInfoJson);
|
|
@@ -245,7 +254,9 @@ class BaseCliWorker {
|
|
|
245
254
|
//#region @backendFunc
|
|
246
255
|
index_1.Helpers.taskStarted(`[${this.serviceID}] Checking if current working version is up to date...`);
|
|
247
256
|
try {
|
|
248
|
-
const ctrl = await this.getControllerForRemoteConnection(
|
|
257
|
+
const ctrl = await this.getControllerForRemoteConnection({
|
|
258
|
+
calledFrom: 'killWorkerWithLowerVersion',
|
|
259
|
+
});
|
|
249
260
|
index_1.Helpers.logInfo(`[${this.serviceID}] Checking if current working version is up to date...`);
|
|
250
261
|
// console.log('this.processLocalInfoObj', this.processLocalInfoObj);
|
|
251
262
|
const req = await ctrl.baseCLiWorkerCommand_hasUpToDateVersion(lib_1._.merge(this.processLocalInfoObj, {
|
|
@@ -286,6 +297,12 @@ class BaseCliWorker {
|
|
|
286
297
|
break;
|
|
287
298
|
}
|
|
288
299
|
if (i > WORKER_INIT_START_TIME_LIMIT) {
|
|
300
|
+
index_1.Helpers.logInfo(`[${this.serviceID}][timestamp-checking] Worker "${this.serviceID}" did not start in time...`);
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
const compareTimestamp = Date.now() - this.processLocalInfoObj.startTimestamp;
|
|
304
|
+
if (compareTimestamp > 60000) {
|
|
305
|
+
index_1.Helpers.logInfo(`[${this.serviceID}][timestamp-checking] Worker "${this.serviceID}" exceeds start time...`);
|
|
289
306
|
return false;
|
|
290
307
|
}
|
|
291
308
|
index_1.Helpers.log('[timestamp-checking] Waiting 500 miliseonds for service to start...');
|
|
@@ -306,7 +323,9 @@ class BaseCliWorker {
|
|
|
306
323
|
index_1.Helpers.log(`[${this.serviceID}] Checking if service "${this.serviceID}" ` +
|
|
307
324
|
`is healthy...`);
|
|
308
325
|
}
|
|
309
|
-
const ctrl = await this.getControllerForRemoteConnection(
|
|
326
|
+
const ctrl = await this.getControllerForRemoteConnection({
|
|
327
|
+
calledFrom: 'isServiceHealthy',
|
|
328
|
+
});
|
|
310
329
|
index_1.Helpers.log(`Sending is healthy request...`);
|
|
311
330
|
// console.log('this.processLocalInfoObj', this.processLocalInfoObj);
|
|
312
331
|
const req = await ctrl.baseCLiWorkerCommand_isHealthy(this.processLocalInfoObj).received;
|
|
@@ -353,7 +372,7 @@ class BaseCliWorker {
|
|
|
353
372
|
//#region @backendFunc
|
|
354
373
|
options = options || {};
|
|
355
374
|
if (options.useCurrentWindowForDetach) {
|
|
356
|
-
index_1.Helpers.logInfo(`[${this.serviceID}][startDetached]
|
|
375
|
+
index_1.Helpers.logInfo(`[${this.serviceID}][startDetached] Starting in current terminal "${lib_1.chalk.bold(this.startCommand)}"...`);
|
|
357
376
|
await lib_1.UtilsProcess.startAsyncChildProcessCommandUntil(this.startCommand, {
|
|
358
377
|
untilOptions: {
|
|
359
378
|
stdout: [this.SPECIAL_WORKER_READY_MESSAGE],
|
|
@@ -363,7 +382,7 @@ class BaseCliWorker {
|
|
|
363
382
|
});
|
|
364
383
|
}
|
|
365
384
|
else {
|
|
366
|
-
index_1.Helpers.logInfo(`[${this.serviceID}][startDetached] Starting in
|
|
385
|
+
index_1.Helpers.logInfo(`[${this.serviceID}][startDetached] Starting in new terminal "${lib_1.chalk.bold(this.startCommand)}"...`);
|
|
367
386
|
await lib_1.UtilsProcess.startInNewTerminalWindow(this.startCommand);
|
|
368
387
|
}
|
|
369
388
|
index_1.Helpers.logInfo(`"${lib_1.chalk.bold(this.serviceID)}" - waiting until healthy (Infinite health check trys )...`);
|
|
@@ -399,7 +418,9 @@ class BaseCliWorker {
|
|
|
399
418
|
//#region @backendFunc
|
|
400
419
|
while (true) {
|
|
401
420
|
try {
|
|
402
|
-
const portControllerInstance = await this.getControllerForRemoteConnection(
|
|
421
|
+
const portControllerInstance = await this.getControllerForRemoteConnection({
|
|
422
|
+
calledFrom: 'initializeWorkerMetadata',
|
|
423
|
+
});
|
|
403
424
|
await portControllerInstance.baseCLiWorkerCommand_initializeMetadata(this.serviceID, this.serviceVersion).received;
|
|
404
425
|
this.saveProcessInfo({
|
|
405
426
|
startTimestamp: null,
|
|
@@ -422,9 +443,10 @@ class BaseCliWorker {
|
|
|
422
443
|
}
|
|
423
444
|
//#endregion
|
|
424
445
|
//#region wait for process port saved to disk
|
|
425
|
-
async waitForProcessPortSavedToDisk() {
|
|
446
|
+
async waitForProcessPortSavedToDisk(options) {
|
|
426
447
|
//#region @backendFunc
|
|
427
|
-
|
|
448
|
+
options = options || {};
|
|
449
|
+
index_1.Helpers.logInfo(`[${this.serviceID}][${options.calledFrom}] Waiting for process port saved to disk...`);
|
|
428
450
|
index_1.Helpers.log(`in ${this.pathToProcessLocalInfoJson}`);
|
|
429
451
|
let portForRemote = this.processLocalInfoObj.port;
|
|
430
452
|
const MAX_TRYS = 10;
|