@tskmgr/client 2.0.2 → 2.0.5

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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -7
  3. package/package.json +6 -6
  4. package/src/{index.ts → index.d.ts} +0 -1
  5. package/src/index.js +22 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/client-example.d.ts +11 -0
  8. package/src/lib/client-example.js +120 -0
  9. package/src/lib/client-example.js.map +1 -0
  10. package/src/lib/client-factory.d.ts +6 -0
  11. package/src/lib/client-factory.js +14 -0
  12. package/src/lib/client-factory.js.map +1 -0
  13. package/src/lib/client-options.d.ts +12 -0
  14. package/src/lib/client-options.js +3 -0
  15. package/src/lib/client-options.js.map +1 -0
  16. package/src/lib/client.d.ts +24 -0
  17. package/src/lib/client.js +247 -0
  18. package/src/lib/client.js.map +1 -0
  19. package/src/lib/run-tasks-result.d.ts +9 -0
  20. package/src/lib/run-tasks-result.js +14 -0
  21. package/src/lib/run-tasks-result.js.map +1 -0
  22. package/src/lib/task-result.d.ts +10 -0
  23. package/src/lib/task-result.js +3 -0
  24. package/src/lib/task-result.js.map +1 -0
  25. package/src/lib/utils.d.ts +14 -0
  26. package/src/lib/utils.js +72 -0
  27. package/src/lib/utils.js.map +1 -0
  28. package/.babelrc +0 -10
  29. package/.eslintrc.json +0 -21
  30. package/jest.config.ts +0 -17
  31. package/project.json +0 -31
  32. package/src/lib/client-example.ts +0 -134
  33. package/src/lib/client-factory.ts +0 -17
  34. package/src/lib/client-options.ts +0 -12
  35. package/src/lib/client.spec.ts +0 -5
  36. package/src/lib/client.ts +0 -280
  37. package/src/lib/run-tasks-result.ts +0 -17
  38. package/src/lib/task-result.ts +0 -10
  39. package/src/lib/utils.ts +0 -68
  40. package/tsconfig.json +0 -13
  41. package/tsconfig.lib.json +0 -12
  42. package/tsconfig.spec.json +0 -20
package/src/lib/utils.ts DELETED
@@ -1,68 +0,0 @@
1
- import { ChildProcess, spawn, SpawnOptionsWithoutStdio } from 'child_process';
2
- import { createInterface } from 'readline';
3
- import { tmpdir } from 'os';
4
- import { join } from 'path';
5
-
6
- export interface SpawnAsyncOptions {
7
- dataCallback?: (data: string) => void;
8
- errorCallback?: (data: string) => void;
9
- }
10
-
11
- export async function spawnAsync(
12
- command: string,
13
- args?: ReadonlyArray<string>,
14
- options?: SpawnOptionsWithoutStdio,
15
- logging?: SpawnAsyncOptions
16
- ): Promise<ChildProcess> {
17
- return new Promise((resolve, reject) => {
18
- const childProcess = spawn(command, args, options);
19
-
20
- if (logging.dataCallback) {
21
- const readlineStdout = createInterface({ input: childProcess.stdout });
22
- readlineStdout.on('line', logging.dataCallback);
23
- }
24
-
25
- if (logging.errorCallback) {
26
- const readlineStderr = createInterface({ input: childProcess.stderr });
27
- readlineStderr.on('line', logging.errorCallback);
28
- }
29
-
30
- childProcess.on('close', (code) => {
31
- if (code === 0) {
32
- resolve(childProcess);
33
- } else {
34
- reject(childProcess);
35
- }
36
- });
37
-
38
- childProcess.on('error', (err: Error) => {
39
- reject(childProcess); // TODO: try to return error message
40
- });
41
- });
42
- }
43
-
44
- export function delay(ms: number): Promise<void> {
45
- return new Promise((resolve) => {
46
- setTimeout(resolve, ms);
47
- });
48
- }
49
-
50
- export function getTaskLogFilename(taskId: number): string {
51
- return join(tmpdir(), `task-${taskId}.log`);
52
- }
53
-
54
- export class HTTPResponseError extends Error {
55
- constructor(public readonly response) {
56
- super(`HTTP Error Response: ${response.status} ${response.statusText}`);
57
- this.response = response;
58
- }
59
- }
60
-
61
- export const checkStatus = (response) => {
62
- if (response.ok) {
63
- // response.status >= 200 && response.status < 300
64
- return response;
65
- } else {
66
- throw new HTTPResponseError(response);
67
- }
68
- };
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "files": [],
4
- "include": [],
5
- "references": [
6
- {
7
- "path": "./tsconfig.lib.json"
8
- },
9
- {
10
- "path": "./tsconfig.spec.json"
11
- }
12
- ]
13
- }
package/tsconfig.lib.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "outDir": "../../dist/out-tsc",
6
- "declaration": true,
7
- "types": ["node"],
8
- "importHelpers": false
9
- },
10
- "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"],
11
- "include": ["**/*.ts"]
12
- }
@@ -1,20 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "module": "commonjs",
6
- "types": ["jest", "node"]
7
- },
8
- "include": [
9
- "**/*.test.ts",
10
- "**/*.spec.ts",
11
- "**/*.test.tsx",
12
- "**/*.spec.tsx",
13
- "**/*.test.js",
14
- "**/*.spec.js",
15
- "**/*.test.jsx",
16
- "**/*.spec.jsx",
17
- "**/*.d.ts",
18
- "jest.config.ts"
19
- ]
20
- }