@tskmgr/client 2.0.2 → 2.0.3
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/LICENSE +21 -0
- package/README.md +7 -7
- package/package.json +5 -3
- package/src/{index.ts → index.d.ts} +0 -1
- package/src/index.js +22 -0
- package/src/index.js.map +1 -0
- package/src/lib/client-example.d.ts +11 -0
- package/src/lib/client-example.js +120 -0
- package/src/lib/client-example.js.map +1 -0
- package/src/lib/client-factory.d.ts +6 -0
- package/src/lib/client-factory.js +14 -0
- package/src/lib/client-factory.js.map +1 -0
- package/src/lib/client-options.d.ts +12 -0
- package/src/lib/client-options.js +3 -0
- package/src/lib/client-options.js.map +1 -0
- package/src/lib/client.d.ts +24 -0
- package/src/lib/client.js +249 -0
- package/src/lib/client.js.map +1 -0
- package/src/lib/run-tasks-result.d.ts +9 -0
- package/src/lib/run-tasks-result.js +14 -0
- package/src/lib/run-tasks-result.js.map +1 -0
- package/src/lib/task-result.d.ts +10 -0
- package/src/lib/task-result.js +3 -0
- package/src/lib/task-result.js.map +1 -0
- package/src/lib/utils.d.ts +14 -0
- package/src/lib/utils.js +72 -0
- package/src/lib/utils.js.map +1 -0
- package/.babelrc +0 -10
- package/.eslintrc.json +0 -21
- package/jest.config.ts +0 -17
- package/project.json +0 -31
- package/src/lib/client-example.ts +0 -134
- package/src/lib/client-factory.ts +0 -17
- package/src/lib/client-options.ts +0 -12
- package/src/lib/client.spec.ts +0 -5
- package/src/lib/client.ts +0 -280
- package/src/lib/run-tasks-result.ts +0 -17
- package/src/lib/task-result.ts +0 -10
- package/src/lib/utils.ts +0 -68
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -12
- 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
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
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -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
|
-
}
|