@lakutata/core 1.0.30 → 1.0.35

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.
Files changed (69) hide show
  1. package/build/Application.d.ts +1 -0
  2. package/build/Application.js +5 -7
  3. package/build/Application.js.map +1 -1
  4. package/build/ApplicationManagement.js.map +1 -1
  5. package/build/base/BaseObject.js +1 -1
  6. package/build/base/BaseObject.js.map +1 -1
  7. package/build/base/Container.js +2 -2
  8. package/build/base/Container.js.map +1 -1
  9. package/build/base/ValidatorClass.d.ts +1 -0
  10. package/build/base/ValidatorClass.js +70 -53
  11. package/build/base/ValidatorClass.js.map +1 -1
  12. package/build/base/abstracts/Module.js +8 -8
  13. package/build/base/abstracts/Module.js.map +1 -1
  14. package/build/base/abstracts/Workflow.js +1 -1
  15. package/build/base/abstracts/Workflow.js.map +1 -1
  16. package/build/base/process/ProcessManager.js +2 -3
  17. package/build/base/process/ProcessManager.js.map +1 -1
  18. package/build/base/thread/ThreadManager.js +2 -3
  19. package/build/base/thread/ThreadManager.js.map +1 -1
  20. package/build/decorators/MethodValidation.js.map +1 -1
  21. package/build/interfaces/ShellJsInterfaces.d.ts +162 -0
  22. package/build/interfaces/ShellJsInterfaces.js +3 -0
  23. package/build/interfaces/ShellJsInterfaces.js.map +1 -0
  24. package/build/lib/minified/ShellJs.d.ts +2 -0
  25. package/build/lib/minified/ShellJs.js +3699 -0
  26. package/build/lib/minified/ShellJs.js.map +1 -0
  27. package/build/lib/multipleRunner/lib/Process.js +3 -3
  28. package/build/lib/multipleRunner/lib/Process.js.map +1 -1
  29. package/build/lib/multipleRunner/lib/Thread.js +4 -4
  30. package/build/lib/multipleRunner/lib/Thread.js.map +1 -1
  31. package/build/lib/multipleRunner/lib/cores/IsElectron.js +1 -2
  32. package/build/lib/multipleRunner/lib/cores/IsElectron.js.map +1 -1
  33. package/build/plugins/Crypto.js +2 -2
  34. package/build/plugins/Crypto.js.map +1 -1
  35. package/build/plugins/Formatter.js +1 -1
  36. package/build/plugins/Formatter.js.map +1 -1
  37. package/build/plugins/HttpRequest.js +8 -8
  38. package/build/plugins/HttpRequest.js.map +1 -1
  39. package/build/plugins/Logger.js +12 -7
  40. package/build/plugins/Logger.js.map +1 -1
  41. package/build/plugins/MessagePack.d.ts +1 -0
  42. package/build/plugins/MessagePack.js +2 -2
  43. package/build/plugins/MessagePack.js.map +1 -1
  44. package/build/plugins/Security.js +24 -24
  45. package/build/plugins/Security.js.map +1 -1
  46. package/build/plugins/Shell.d.ts +39 -0
  47. package/build/plugins/Shell.js +58 -0
  48. package/build/plugins/Shell.js.map +1 -0
  49. package/build/utils/Delay.js +1 -1
  50. package/build/utils/Delay.js.map +1 -1
  51. package/build/utils/Timeout.js +1 -1
  52. package/build/utils/Timeout.js.map +1 -1
  53. package/build/utils/ValidDataUrl.d.ts +1 -0
  54. package/build/utils/ValidDataUrl.js +8 -0
  55. package/build/utils/ValidDataUrl.js.map +1 -0
  56. package/package.json +16 -20
  57. package/src/Application.ts +5 -11
  58. package/src/ApplicationManagement.ts +1 -1
  59. package/src/base/ValidatorClass.ts +44 -7
  60. package/src/base/abstracts/Exception.ts +1 -1
  61. package/src/decorators/MethodValidation.ts +6 -6
  62. package/src/interfaces/ShellJsInterfaces.ts +858 -0
  63. package/src/lib/minified/ShellJs.js +1 -0
  64. package/src/plugins/Crypto.ts +3 -3
  65. package/src/plugins/Logger.ts +8 -3
  66. package/src/plugins/Shell.ts +371 -0
  67. package/src/tests/Main.spec.ts +2 -1
  68. package/src/utils/ValidDataUrl.ts +8 -0
  69. package/tsconfig.json +3 -3
@@ -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')
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
+ }
@@ -29,7 +29,7 @@ import {TestException} from './exceptions/TestException'
29
29
  const config: IApplicationConfig = {
30
30
  id: 'test.app',
31
31
  name: 'test app',
32
- timezone: 'US/Alpine',
32
+ timezone: 'America/Mazatlan',
33
33
  processes: [TestProcess],
34
34
  threads: [TestThread],
35
35
  plugins: [
@@ -159,6 +159,7 @@ import {TestException} from './exceptions/TestException'
159
159
  const excep = new TestException('hhhh')
160
160
  const ssss = app.JSON.stringify(excep)
161
161
  console.log(app.JSON.parse(ssss))
162
+ app.Shell.exec('echo "hello world!!!!!"')
162
163
  } catch (e) {
163
164
  console.error(e)
164
165
  }
@@ -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
+ }
package/tsconfig.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "compilerOptions": {
3
3
  "strict": true,
4
4
  "module": "CommonJS",
5
- "target": "ES2017",
5
+ "target": "ES2020",
6
6
  "declaration": true,
7
7
  "sourceMap": true,
8
8
  "emitDecoratorMetadata": true,
@@ -18,13 +18,13 @@
18
18
  "moduleResolution": "Node",
19
19
  "esModuleInterop": true,
20
20
  "strictPropertyInitialization": false,
21
+ "resolveJsonModule": true,
21
22
  "types": [
22
23
  "reflect-metadata",
23
24
  "node"
24
25
  ],
25
26
  "lib": [
26
- "ESNext",
27
- "ES2017",
27
+ "ES2020",
28
28
  "dom"
29
29
  ]
30
30
  },