@lakutata/core 1.0.27 → 1.0.31
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/README.md +4 -0
- package/build/Application.d.ts +4 -0
- package/build/Application.js +20 -7
- package/build/Application.js.map +1 -1
- package/build/ApplicationManagement.js +5 -0
- package/build/ApplicationManagement.js.map +1 -1
- package/build/base/BaseObject.js +1 -1
- package/build/base/BaseObject.js.map +1 -1
- package/build/base/Container.js +16 -0
- package/build/base/Container.js.map +1 -1
- package/build/base/ValidatorClass.d.ts +1 -0
- package/build/base/ValidatorClass.js +70 -53
- package/build/base/ValidatorClass.js.map +1 -1
- package/build/base/abstracts/Exception.js +5 -2
- package/build/base/abstracts/Exception.js.map +1 -1
- package/build/base/abstracts/Module.js +8 -8
- package/build/base/abstracts/Module.js.map +1 -1
- package/build/base/abstracts/Workflow.js +1 -1
- package/build/base/abstracts/Workflow.js.map +1 -1
- package/build/base/process/Process.d.ts +1 -1
- package/build/base/process/Process.js +2 -2
- package/build/base/process/Process.js.map +1 -1
- package/build/base/process/ProcessManager.d.ts +1 -1
- package/build/base/process/ProcessManager.js +2 -2
- package/build/base/process/ProcessManager.js.map +1 -1
- package/build/base/thread/Thread.d.ts +1 -1
- package/build/base/thread/Thread.js +2 -2
- package/build/base/thread/Thread.js.map +1 -1
- package/build/base/thread/ThreadManager.d.ts +1 -1
- package/build/base/thread/ThreadManager.js +2 -2
- package/build/base/thread/ThreadManager.js.map +1 -1
- package/build/decorators/MethodValidation.js.map +1 -1
- package/build/interfaces/IApplicationConfig.d.ts +1 -0
- package/build/interfaces/ShellJsInterfaces.d.ts +162 -0
- package/build/interfaces/ShellJsInterfaces.js +3 -0
- package/build/interfaces/ShellJsInterfaces.js.map +1 -0
- package/build/lib/multipleRunner/constants/Channel.d.ts +5 -0
- package/build/lib/multipleRunner/constants/Channel.js +9 -0
- package/build/lib/multipleRunner/constants/Channel.js.map +1 -0
- package/build/lib/multipleRunner/constants/MetadataKey.d.ts +2 -0
- package/build/lib/multipleRunner/constants/MetadataKey.js +6 -0
- package/build/lib/multipleRunner/constants/MetadataKey.js.map +1 -0
- package/build/lib/multipleRunner/containers/ContainerVolume.d.ts +4 -0
- package/build/lib/multipleRunner/containers/ContainerVolume.js +85 -0
- package/build/lib/multipleRunner/containers/ContainerVolume.js.map +1 -0
- package/build/lib/multipleRunner/definitions/interfaces/ClassConstructor.d.ts +3 -0
- package/build/lib/multipleRunner/definitions/interfaces/ClassConstructor.js +3 -0
- package/build/lib/multipleRunner/definitions/interfaces/ClassConstructor.js.map +1 -0
- package/build/lib/multipleRunner/definitions/interfaces/MultipleRunnerBaseClassConstructor.d.ts +4 -0
- package/build/lib/multipleRunner/definitions/interfaces/MultipleRunnerBaseClassConstructor.js +3 -0
- package/build/lib/multipleRunner/definitions/interfaces/MultipleRunnerBaseClassConstructor.js.map +1 -0
- package/build/lib/multipleRunner/definitions/interfaces/ProcessClassConstructor.d.ts +7 -0
- package/build/lib/multipleRunner/definitions/interfaces/ProcessClassConstructor.js +3 -0
- package/build/lib/multipleRunner/definitions/interfaces/ProcessClassConstructor.js.map +1 -0
- package/build/lib/multipleRunner/definitions/interfaces/ProxyClass.d.ts +3 -0
- package/build/lib/multipleRunner/definitions/interfaces/ProxyClass.js +3 -0
- package/build/lib/multipleRunner/definitions/interfaces/ProxyClass.js.map +1 -0
- package/build/lib/multipleRunner/definitions/interfaces/ThreadClassConstructor.d.ts +7 -0
- package/build/lib/multipleRunner/definitions/interfaces/ThreadClassConstructor.js +3 -0
- package/build/lib/multipleRunner/definitions/interfaces/ThreadClassConstructor.js.map +1 -0
- package/build/lib/multipleRunner/lib/Process.d.ts +5 -0
- package/build/lib/multipleRunner/lib/Process.js +44 -0
- package/build/lib/multipleRunner/lib/Process.js.map +1 -0
- package/build/lib/multipleRunner/lib/Thread.d.ts +5 -0
- package/build/lib/multipleRunner/lib/Thread.js +52 -0
- package/build/lib/multipleRunner/lib/Thread.js.map +1 -0
- package/build/lib/multipleRunner/lib/bridges/BaseBridge.d.ts +32 -0
- package/build/lib/multipleRunner/lib/bridges/BaseBridge.js +104 -0
- package/build/lib/multipleRunner/lib/bridges/BaseBridge.js.map +1 -0
- package/build/lib/multipleRunner/lib/bridges/ProcessBridge.d.ts +5 -0
- package/build/lib/multipleRunner/lib/bridges/ProcessBridge.js +20 -0
- package/build/lib/multipleRunner/lib/bridges/ProcessBridge.js.map +1 -0
- package/build/lib/multipleRunner/lib/bridges/ThreadBridge.d.ts +5 -0
- package/build/lib/multipleRunner/lib/bridges/ThreadBridge.js +17 -0
- package/build/lib/multipleRunner/lib/bridges/ThreadBridge.js.map +1 -0
- package/build/lib/multipleRunner/lib/cores/GenerateExecArgv.d.ts +2 -0
- package/build/lib/multipleRunner/lib/cores/GenerateExecArgv.js +35 -0
- package/build/lib/multipleRunner/lib/cores/GenerateExecArgv.js.map +1 -0
- package/build/lib/multipleRunner/lib/cores/IsElectron.d.ts +1 -0
- package/build/lib/multipleRunner/lib/cores/IsElectron.js +9 -0
- package/build/lib/multipleRunner/lib/cores/IsElectron.js.map +1 -0
- package/build/lib/multipleRunner/lib/cores/ProcessClass.d.ts +5 -0
- package/build/lib/multipleRunner/lib/cores/ProcessClass.js +12 -0
- package/build/lib/multipleRunner/lib/cores/ProcessClass.js.map +1 -0
- package/build/lib/multipleRunner/lib/cores/ThreadClass.d.ts +5 -0
- package/build/lib/multipleRunner/lib/cores/ThreadClass.js +12 -0
- package/build/lib/multipleRunner/lib/cores/ThreadClass.js.map +1 -0
- package/build/lib/multipleRunner/lib/cores/UniParentBridgeHandler.d.ts +2 -0
- package/build/lib/multipleRunner/lib/cores/UniParentBridgeHandler.js +104 -0
- package/build/lib/multipleRunner/lib/cores/UniParentBridgeHandler.js.map +1 -0
- package/build/lib/multipleRunner/lib/prototypes/MultipleRunnerBaseClass.d.ts +17 -0
- package/build/lib/multipleRunner/lib/prototypes/MultipleRunnerBaseClass.js +53 -0
- package/build/lib/multipleRunner/lib/prototypes/MultipleRunnerBaseClass.js.map +1 -0
- package/build/plugins/Crypto.js +2 -2
- package/build/plugins/Crypto.js.map +1 -1
- package/build/plugins/Formatter.d.ts +1 -0
- package/build/plugins/Formatter.js +9 -6
- package/build/plugins/Formatter.js.map +1 -1
- package/build/plugins/HttpRequest.js +8 -8
- package/build/plugins/HttpRequest.js.map +1 -1
- package/build/plugins/Logger.js +15 -6
- package/build/plugins/Logger.js.map +1 -1
- package/build/plugins/MessagePack.js +2 -2
- package/build/plugins/MessagePack.js.map +1 -1
- package/build/plugins/Security.js +24 -24
- package/build/plugins/Security.js.map +1 -1
- package/build/plugins/Shell.d.ts +39 -0
- package/build/plugins/Shell.js +58 -0
- package/build/plugins/Shell.js.map +1 -0
- package/build/types/TPluginsConfig.d.ts +1 -0
- package/build/utils/Delay.js +1 -1
- package/build/utils/Delay.js.map +1 -1
- package/build/utils/Timeout.js +1 -1
- package/build/utils/Timeout.js.map +1 -1
- package/build/utils/ValidDataUrl.d.ts +1 -0
- package/build/utils/ValidDataUrl.js +8 -0
- package/build/utils/ValidDataUrl.js.map +1 -0
- package/package.json +14 -14
- package/src/Application.ts +33 -11
- package/src/ApplicationManagement.ts +4 -1
- package/src/base/Container.ts +14 -1
- package/src/base/ValidatorClass.ts +44 -7
- package/src/base/abstracts/Exception.ts +2 -2
- package/src/base/abstracts/Module.ts +2 -1
- package/src/base/process/Process.ts +1 -1
- package/src/base/process/ProcessManager.ts +2 -2
- package/src/base/thread/Thread.ts +1 -1
- package/src/base/thread/ThreadManager.ts +2 -2
- package/src/decorators/MethodValidation.ts +6 -6
- package/src/interfaces/IApplicationConfig.ts +1 -0
- package/src/interfaces/ShellJsInterfaces.ts +858 -0
- package/src/lib/minified/ShellJs.min.js +1 -0
- package/src/lib/multipleRunner/constants/Channel.ts +5 -0
- package/src/lib/multipleRunner/constants/MetadataKey.ts +2 -0
- package/src/lib/multipleRunner/containers/ContainerVolume.ts +83 -0
- package/src/lib/multipleRunner/definitions/interfaces/ClassConstructor.ts +3 -0
- package/src/lib/multipleRunner/definitions/interfaces/MultipleRunnerBaseClassConstructor.ts +5 -0
- package/src/lib/multipleRunner/definitions/interfaces/ProcessClassConstructor.ts +10 -0
- package/src/lib/multipleRunner/definitions/interfaces/ProxyClass.ts +3 -0
- package/src/lib/multipleRunner/definitions/interfaces/ThreadClassConstructor.ts +10 -0
- package/src/lib/multipleRunner/lib/Process.ts +44 -0
- package/src/lib/multipleRunner/lib/Thread.ts +52 -0
- package/src/lib/multipleRunner/lib/bridges/BaseBridge.ts +115 -0
- package/src/lib/multipleRunner/lib/bridges/ProcessBridge.ts +18 -0
- package/src/lib/multipleRunner/lib/bridges/ThreadBridge.ts +15 -0
- package/src/lib/multipleRunner/lib/cores/GenerateExecArgv.ts +28 -0
- package/src/lib/multipleRunner/lib/cores/IsElectron.ts +3 -0
- package/src/lib/multipleRunner/lib/cores/ProcessClass.ts +8 -0
- package/src/lib/multipleRunner/lib/cores/ThreadClass.ts +8 -0
- package/src/lib/multipleRunner/lib/cores/UniParentBridgeHandler.ts +97 -0
- package/src/lib/multipleRunner/lib/prototypes/MultipleRunnerBaseClass.ts +66 -0
- package/src/plugins/Crypto.ts +3 -3
- package/src/plugins/Formatter.ts +10 -5
- package/src/plugins/Logger.ts +8 -2
- package/src/plugins/Shell.ts +371 -0
- package/src/tests/Main.spec.ts +11 -6
- package/src/tests/threads/TestThread.ts +3 -1
- package/src/types/TPluginsConfig.ts +1 -1
- package/src/utils/ValidDataUrl.ts +8 -0
- package/.idea/dbnavigator.xml +0 -558
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import {Plugin} from '../base/Plugin'
|
|
2
|
+
import {
|
|
3
|
+
CatFunction,
|
|
4
|
+
ChmodFunction,
|
|
5
|
+
CopyFunction,
|
|
6
|
+
DirsFunction,
|
|
7
|
+
EchoFunction,
|
|
8
|
+
ExecFunction,
|
|
9
|
+
FindFunction,
|
|
10
|
+
GrepFunction,
|
|
11
|
+
HeadFunction,
|
|
12
|
+
LinkFunction,
|
|
13
|
+
ListFunction,
|
|
14
|
+
MkdirFunction,
|
|
15
|
+
MoveFunction,
|
|
16
|
+
PopDirFunction,
|
|
17
|
+
PushDirFunction,
|
|
18
|
+
RemoveFunction,
|
|
19
|
+
SedFunction,
|
|
20
|
+
ShellString,
|
|
21
|
+
SortFunction,
|
|
22
|
+
TailFunction,
|
|
23
|
+
TestOptions,
|
|
24
|
+
TouchFunction,
|
|
25
|
+
UniqFunction
|
|
26
|
+
} from '../interfaces/ShellJsInterfaces'
|
|
27
|
+
|
|
28
|
+
const shelljs = require('../lib/minified/ShellJs.min')
|
|
29
|
+
|
|
30
|
+
declare module '../Core' {
|
|
31
|
+
interface Application {
|
|
32
|
+
Shell: Shell
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class Shell extends Plugin {
|
|
37
|
+
protected shelljs: any = shelljs
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Changes the current working directory dir for the duration of the script.
|
|
41
|
+
* Changes to the home directory if no argument is supplied.
|
|
42
|
+
*
|
|
43
|
+
* @param dir Directory to change to.
|
|
44
|
+
* @return Object with shell exit code, stderr and stdout.
|
|
45
|
+
*/
|
|
46
|
+
public cd(dir?: string): ShellString {
|
|
47
|
+
return this.shelljs.cd(dir)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns the current directory.
|
|
52
|
+
* @return The current directory.
|
|
53
|
+
*/
|
|
54
|
+
public pwd(): ShellString {
|
|
55
|
+
return this.shelljs.pwd()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Evaluates expression using the available primaries and returns corresponding value.
|
|
60
|
+
*
|
|
61
|
+
* @param option Valid options:
|
|
62
|
+
* - `-b`: true if path is a block device;
|
|
63
|
+
* - `-c`: true if path is a character device;
|
|
64
|
+
* - `-d`: true if path is a directory;
|
|
65
|
+
* - `-e`: true if path exists;
|
|
66
|
+
* - `-f`: true if path is a regular file;
|
|
67
|
+
* - `-L`: true if path is a symbolic link;
|
|
68
|
+
* - `-p`: true if path is a pipe (FIFO);
|
|
69
|
+
* - `-S`: true if path is a socket
|
|
70
|
+
* @param path The path.
|
|
71
|
+
* @return See option parameter.
|
|
72
|
+
*/
|
|
73
|
+
public test(option: TestOptions, path: string): boolean {
|
|
74
|
+
return this.shelljs.test(option, path)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Searches for command in the system's PATH. On Windows looks for .exe, .cmd, and .bat extensions.
|
|
79
|
+
*
|
|
80
|
+
* @param command The command to search for.
|
|
81
|
+
* @return Returns string containing the absolute path to the command.
|
|
82
|
+
*/
|
|
83
|
+
public which(command: string): ShellString {
|
|
84
|
+
return this.shelljs.which(command)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Exits the current process with the given exit code.
|
|
89
|
+
*
|
|
90
|
+
* Equivalent to calling `process.exit(code)`.
|
|
91
|
+
*
|
|
92
|
+
* @param code The exit code.
|
|
93
|
+
*/
|
|
94
|
+
public exit(code?: number): never {
|
|
95
|
+
return this.shelljs.exit(code) as never
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Searches and returns string containing a writeable, platform-dependent temporary directory.
|
|
100
|
+
* Follows Python's tempfile algorithm.
|
|
101
|
+
*
|
|
102
|
+
* @return The temp file path.
|
|
103
|
+
*/
|
|
104
|
+
public tempdir(): ShellString {
|
|
105
|
+
return this.shelljs.tempdir()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Tests if error occurred in the last command.
|
|
110
|
+
*
|
|
111
|
+
* @return Returns null if no error occurred, otherwise returns string explaining the error
|
|
112
|
+
*/
|
|
113
|
+
public error(): ShellString {
|
|
114
|
+
return this.shelljs.error()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Sets global configuration variables
|
|
119
|
+
* @param options Available options:
|
|
120
|
+
* - `+/-e`: exit upon error (`config.fatal`),
|
|
121
|
+
* - `+/-v`: verbose: show all commands (`config.verbose`),
|
|
122
|
+
* - `+/-f`: disable filename expansion (globbing)
|
|
123
|
+
*/
|
|
124
|
+
public set(options: string): void {
|
|
125
|
+
return this.shelljs.set(options)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Returns array of files in the given path, or in current directory if no path provided.
|
|
130
|
+
*
|
|
131
|
+
* @param options Available options:
|
|
132
|
+
* - `-R`: recursive
|
|
133
|
+
* - `-A`: all files (include files beginning with ., except for . and ..)
|
|
134
|
+
* - `-L`: follow symlinks
|
|
135
|
+
* - `-d`: list directories themselves, not their contents
|
|
136
|
+
* - `-l`: list objects representing each file, each with fields containing
|
|
137
|
+
* `ls -l` output fields. See fs.Stats for more info
|
|
138
|
+
* @param paths Paths to search.
|
|
139
|
+
* @return An array of files in the given path(s).
|
|
140
|
+
*/
|
|
141
|
+
public ls: ListFunction = this.shelljs.ls
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Returns array of all files (however deep) in the given paths.
|
|
145
|
+
*
|
|
146
|
+
* @param path The path(s) to search.
|
|
147
|
+
* @return An array of all files (however deep) in the given path(s).
|
|
148
|
+
*/
|
|
149
|
+
public find: FindFunction = this.shelljs.find
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Copies files. The wildcard `*` is accepted.
|
|
153
|
+
*
|
|
154
|
+
* @param options Available options:
|
|
155
|
+
* - `-f`: force (default behavior)
|
|
156
|
+
* - `-n`: no-clobber
|
|
157
|
+
* - `-u`: only copy if source is newer than dest
|
|
158
|
+
* - `-r`, -R: recursive
|
|
159
|
+
* - `-L`: follow symlinks
|
|
160
|
+
* - `-P`: don't follow symlinks
|
|
161
|
+
* @param source The source.
|
|
162
|
+
* @param dest The destination.
|
|
163
|
+
* @return Object with shell exit code, stderr and stdout.
|
|
164
|
+
*/
|
|
165
|
+
public cp: CopyFunction = this.shelljs.cp
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Removes files. The wildcard `*` is accepted.
|
|
169
|
+
*
|
|
170
|
+
* @param options Available options:
|
|
171
|
+
* - `-f` (force),
|
|
172
|
+
* - `-r`, `-R` (recursive)
|
|
173
|
+
* @param files Files to remove.
|
|
174
|
+
* @return Object with shell exit code, stderr and stdout.
|
|
175
|
+
*/
|
|
176
|
+
public rm: RemoveFunction = this.shelljs.rm
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Moves files. The wildcard `*` is accepted.
|
|
180
|
+
*
|
|
181
|
+
* @param options Available options:
|
|
182
|
+
* - `-f`: force (default behavior)
|
|
183
|
+
* - `-n`: no-clobber
|
|
184
|
+
* @param source The source.
|
|
185
|
+
* @param dest The destination.
|
|
186
|
+
* @return Object with shell exit code, stderr and stdout.
|
|
187
|
+
*/
|
|
188
|
+
public mv: MoveFunction = this.shelljs.mv
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Creates directories.
|
|
192
|
+
*
|
|
193
|
+
* @param options Available options:
|
|
194
|
+
* - `-p`: full paths, will create intermediate dirs if necessary
|
|
195
|
+
* @param dir The directories to create.
|
|
196
|
+
* @return Object with shell exit code, stderr and stdout.
|
|
197
|
+
*/
|
|
198
|
+
public mkdir: MkdirFunction = this.shelljs.mkdir
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Returns a string containing the given file, or a concatenated string
|
|
202
|
+
* containing the files if more than one file is given (a new line character
|
|
203
|
+
* is introduced between each file).
|
|
204
|
+
*
|
|
205
|
+
* @param files Files to use. Wildcard `*` accepted.
|
|
206
|
+
* @return A string containing the given file, or a concatenated string
|
|
207
|
+
* containing the files if more than one file is given
|
|
208
|
+
* (a new line character is introduced between each file).
|
|
209
|
+
*/
|
|
210
|
+
public cat: CatFunction = this.shelljs.cat
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Reads an input string from file and performs a JavaScript `replace()`
|
|
214
|
+
* on the input using the given search regex and replacement string or function.
|
|
215
|
+
*
|
|
216
|
+
* @param options Available options:
|
|
217
|
+
* - `-i`: Replace contents of 'file' in-place. Note that no backups will be created!
|
|
218
|
+
* @param searchRegex The regular expression to use for search.
|
|
219
|
+
* @param replacement The replacement.
|
|
220
|
+
* @param files The files to process.
|
|
221
|
+
* @return The new string after replacement.
|
|
222
|
+
*/
|
|
223
|
+
public sed: SedFunction = this.shelljs.sed
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Reads input string from given files and returns a string containing all lines
|
|
227
|
+
* of the file that match the given `regex_filter`. Wildcard `*` accepted.
|
|
228
|
+
*
|
|
229
|
+
* @param options Available options:
|
|
230
|
+
* - `-v`: Inverse the sense of the regex and print
|
|
231
|
+
* the lines not matching the criteria.
|
|
232
|
+
* - `-l`: Print only filenames of matching files
|
|
233
|
+
* @param regex_filter The regular expression to use.
|
|
234
|
+
* @param files The files to process.
|
|
235
|
+
* @return Returns a string containing all lines of the file that match the given `regex_filter`.
|
|
236
|
+
*/
|
|
237
|
+
public grep: GrepFunction = this.shelljs.grep
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Prints string to stdout, and returns string with additional utility methods like .to().
|
|
241
|
+
*
|
|
242
|
+
* @param options Available options:
|
|
243
|
+
* - `-e`: interpret backslash escapes (default)
|
|
244
|
+
* - `-n`: remove trailing newline from output
|
|
245
|
+
* @param text The text to print.
|
|
246
|
+
* @return Returns the string that was passed as argument.
|
|
247
|
+
*/
|
|
248
|
+
public echo: EchoFunction = this.shelljs.echo
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Saves the current directory on the top of the directory stack and then cd to dir.
|
|
252
|
+
* With no arguments, `pushd` exchanges the top two directories.
|
|
253
|
+
*
|
|
254
|
+
* @param options Available options:
|
|
255
|
+
* - `-n`: Suppresses the normal change of directory when adding directories
|
|
256
|
+
* to the stack, so that only the stack is manipulated
|
|
257
|
+
* - `-q`: Suppresses output to the console.
|
|
258
|
+
* @param dir Makes the current working directory be the top of the stack,
|
|
259
|
+
* and then executes the equivalent of `cd dir`.
|
|
260
|
+
* @return Returns an array of paths in the stack.
|
|
261
|
+
*/
|
|
262
|
+
public pushd: PushDirFunction = this.shelljs.pushd
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* When no arguments are given, popd removes the top directory from the stack
|
|
266
|
+
* and performs a `cd` to the new top directory.
|
|
267
|
+
*
|
|
268
|
+
* The elements are numbered from 0 starting at the first directory listed with dirs;
|
|
269
|
+
* i.e., `popd` is equivalent to `popd +0`. Returns an array of paths in the stack.
|
|
270
|
+
*
|
|
271
|
+
* @param options Available options:
|
|
272
|
+
* - `-n`: Suppresses the normal change of directory when removing directories
|
|
273
|
+
* from the stack, so that only the stack is manipulated
|
|
274
|
+
* - `-q`: Suppresses output to the console.
|
|
275
|
+
* @param dir You can only use -N and +N.
|
|
276
|
+
* @return Returns an array of paths in the stack.
|
|
277
|
+
*/
|
|
278
|
+
public popd: PopDirFunction = this.shelljs.popd
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Displays the list of currently remembered directories.
|
|
282
|
+
*
|
|
283
|
+
* @param options Available options:
|
|
284
|
+
* - `-c`: Clears the directory stack by deleting all of the elements.
|
|
285
|
+
* - `-N`: Displays the Nth directory (counting from the right of the list
|
|
286
|
+
* printed by dirs when invoked without options), starting with zero.
|
|
287
|
+
* - `+N`: Displays the Nth directory (counting from the left of the list
|
|
288
|
+
* printed by dirs when invoked without options), starting with zero.
|
|
289
|
+
* @return Returns an array of paths in the stack, or a single path if +N or -N was specified.
|
|
290
|
+
*/
|
|
291
|
+
public dirs: DirsFunction = this.shelljs.dirs
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Links source to dest. Use `-f` to force the link, should dest already exist.
|
|
295
|
+
*
|
|
296
|
+
* @param options Available options:
|
|
297
|
+
* - `-s`: Create a symbolic link, defaults to a hardlink
|
|
298
|
+
* - `-f`: Force creation
|
|
299
|
+
* @param source The source.
|
|
300
|
+
* @param dest The destination.
|
|
301
|
+
* @return Object with shell exit code, stderr and stdout.
|
|
302
|
+
*/
|
|
303
|
+
public ln: LinkFunction = this.shelljs.ln
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Executes the given command.
|
|
307
|
+
*
|
|
308
|
+
* @param command The command to execute.
|
|
309
|
+
* @param options Silence and synchronous options.
|
|
310
|
+
* @param [callback] Receives code and output asynchronously.
|
|
311
|
+
* @return Returns an object containing the return code and output as string,
|
|
312
|
+
* or if `{async: true}` or a `callback` was passed, a `ChildProcess`.
|
|
313
|
+
*/
|
|
314
|
+
public exec: ExecFunction = this.shelljs.exec
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Alters the permissions of a file or directory by either specifying the absolute
|
|
318
|
+
* permissions in octal form or expressing the changes in symbols.
|
|
319
|
+
*
|
|
320
|
+
* This command tries to mimic the POSIX behavior as much as possible.
|
|
321
|
+
*
|
|
322
|
+
* Notable exceptions:
|
|
323
|
+
* - In symbolic modes, 'a-r' and '-r' are identical. No consideration is given to the umask.
|
|
324
|
+
* - There is no "quiet" option since default behavior is to run silent.
|
|
325
|
+
*
|
|
326
|
+
* @param options Available options:
|
|
327
|
+
* - `-v`: output a diagnostic for every file processed
|
|
328
|
+
* - `-c`: like -v but report only when a change is made
|
|
329
|
+
* - `-R`: change files and directories recursively
|
|
330
|
+
* @param mode The access mode. Can be an octal string or a symbolic mode string.
|
|
331
|
+
* @param file The file to use.
|
|
332
|
+
* @return Object with shell exit code, stderr and stdout.
|
|
333
|
+
*/
|
|
334
|
+
public chmod: ChmodFunction = this.shelljs.chmod
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Update the access and modification times of each FILE to the current time.
|
|
338
|
+
* A FILE argument that does not exist is created empty, unless `-c` is supplied
|
|
339
|
+
*/
|
|
340
|
+
public touch: TouchFunction = this.shelljs.touch
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Read the start of a file.
|
|
344
|
+
*/
|
|
345
|
+
public head: HeadFunction = this.shelljs.head
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Return the contents of the files, sorted line-by-line.
|
|
349
|
+
* Sorting multiple files mixes their content (just as unix sort does).
|
|
350
|
+
*
|
|
351
|
+
* @param options Available options:
|
|
352
|
+
* - `-r`: Reverse the results
|
|
353
|
+
* - `-n`: Compare according to numerical value
|
|
354
|
+
*/
|
|
355
|
+
public sort: SortFunction = this.shelljs.sort
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Read the end of a file.
|
|
359
|
+
*/
|
|
360
|
+
public tail: TailFunction = this.shelljs.tail
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Filter adjacent matching lines from input.
|
|
364
|
+
*
|
|
365
|
+
* @param options Available options:
|
|
366
|
+
* - `-i`: Ignore case while comparing
|
|
367
|
+
* - `-c`: Prefix lines by the number of occurrences
|
|
368
|
+
* - `-d`: Only print duplicate lines, one for each group of identical lines
|
|
369
|
+
*/
|
|
370
|
+
public uniq: UniqFunction = this.shelljs.uniq
|
|
371
|
+
}
|
package/src/tests/Main.spec.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {TestException} from './exceptions/TestException'
|
|
|
29
29
|
const config: IApplicationConfig = {
|
|
30
30
|
id: 'test.app',
|
|
31
31
|
name: 'test app',
|
|
32
|
+
timezone: 'America/Mazatlan',
|
|
32
33
|
processes: [TestProcess],
|
|
33
34
|
threads: [TestThread],
|
|
34
35
|
plugins: [
|
|
@@ -38,12 +39,12 @@ import {TestException} from './exceptions/TestException'
|
|
|
38
39
|
},
|
|
39
40
|
{
|
|
40
41
|
class: Formatter,
|
|
41
|
-
dateFormat: 'YYYY'
|
|
42
|
+
dateFormat: 'YYYY-MM-DD HH:mm:ss'
|
|
42
43
|
},
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
44
|
+
// {
|
|
45
|
+
// class: Logger,
|
|
46
|
+
// level: 'debug'
|
|
47
|
+
// }
|
|
47
48
|
],
|
|
48
49
|
components: {
|
|
49
50
|
tc1: {
|
|
@@ -147,7 +148,10 @@ import {TestException} from './exceptions/TestException'
|
|
|
147
148
|
app.Logger.debug('this is debug')
|
|
148
149
|
// new TestThread()
|
|
149
150
|
const tt = app.Threads.get(TestThread)
|
|
150
|
-
await tt.test()
|
|
151
|
+
const threadResult = await tt.test('a', 'b', 'c', (timestamp: number) => {
|
|
152
|
+
console.log('fn', timestamp)
|
|
153
|
+
})
|
|
154
|
+
console.log('==========> threadResult:', threadResult)
|
|
151
155
|
await app.Threads.destroy(TestThread)
|
|
152
156
|
const tp = app.Processes.get(TestProcess)
|
|
153
157
|
await tp.procTest()
|
|
@@ -155,6 +159,7 @@ import {TestException} from './exceptions/TestException'
|
|
|
155
159
|
const excep = new TestException('hhhh')
|
|
156
160
|
const ssss = app.JSON.stringify(excep)
|
|
157
161
|
console.log(app.JSON.parse(ssss))
|
|
162
|
+
app.Shell.exec('echo "hello world!!!!!"')
|
|
158
163
|
} catch (e) {
|
|
159
164
|
console.error(e)
|
|
160
165
|
}
|
|
@@ -5,7 +5,9 @@ export class TestThread extends Thread {
|
|
|
5
5
|
console.log('this is test thread')
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
public async test() {
|
|
8
|
+
public async test(a, b, c, callback) {
|
|
9
9
|
console.log('this is thread test function')
|
|
10
|
+
callback(Date.now())
|
|
11
|
+
return a + b + c + 'sfsdfasdfasdfasdfasdfasdf'
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -2,4 +2,4 @@ import {IConstructor} from '../interfaces/IConstructor'
|
|
|
2
2
|
import {Plugin} from '../base/Plugin'
|
|
3
3
|
|
|
4
4
|
export type TPluginsConfig<TPlugin extends Plugin = Plugin> =
|
|
5
|
-
({ class: IConstructor<TPlugin>, [propertyKey: string]: any } | IConstructor<TPlugin>)[]
|
|
5
|
+
({ class: IConstructor<TPlugin>, scope?: 'Transient' | 'Singleton'; [propertyKey: string]: any } | IConstructor<TPlugin>)[]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ya验证DataUrl
|
|
3
|
+
* @param {string} candidate
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export function validDataUrl(candidate: string): boolean {
|
|
7
|
+
return /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(candidate)
|
|
8
|
+
}
|