@onivoro/server-process 22.0.2 → 24.0.0
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 +526 -0
- package/jest.config.ts +11 -0
- package/package.json +8 -40
- package/project.json +23 -0
- package/src/lib/docker.ts +14 -0
- package/src/lib/exec-promise.spec.ts +17 -0
- package/src/lib/exec-promise.ts +14 -0
- package/src/lib/exec-rx-as-json.ts +9 -0
- package/src/lib/exec-rx-as-lines.ts +10 -0
- package/src/lib/exec-rx.spec.ts +22 -0
- package/src/lib/exec-rx.ts +16 -0
- package/src/lib/exit.ts +1 -0
- package/src/lib/listen.ts +12 -0
- package/src/lib/psql.ts +16 -0
- package/src/lib/spawn-promise.spec.ts +17 -0
- package/src/lib/spawn-promise.ts +31 -0
- package/tsconfig.json +16 -0
- package/tsconfig.lib.json +8 -0
- package/tsconfig.spec.json +21 -0
- package/dist/cjs/index.js +0 -21
- package/dist/cjs/lib/docker.d.ts +0 -8
- package/dist/cjs/lib/docker.js +0 -16
- package/dist/cjs/lib/exec-promise.d.ts +0 -3
- package/dist/cjs/lib/exec-promise.js +0 -16
- package/dist/cjs/lib/exec-rx-as-json.d.ts +0 -2
- package/dist/cjs/lib/exec-rx-as-json.js +0 -9
- package/dist/cjs/lib/exec-rx-as-lines.d.ts +0 -2
- package/dist/cjs/lib/exec-rx-as-lines.js +0 -10
- package/dist/cjs/lib/exec-rx.d.ts +0 -4
- package/dist/cjs/lib/exec-rx.js +0 -18
- package/dist/cjs/lib/exit.d.ts +0 -1
- package/dist/cjs/lib/exit.js +0 -5
- package/dist/cjs/lib/listen.d.ts +0 -5
- package/dist/cjs/lib/listen.js +0 -12
- package/dist/cjs/lib/psql.d.ts +0 -5
- package/dist/cjs/lib/psql.js +0 -20
- package/dist/cjs/lib/spawn-promise.d.ts +0 -1
- package/dist/cjs/lib/spawn-promise.js +0 -28
- package/dist/esm/index.d.ts +0 -9
- package/dist/esm/index.js +0 -21
- package/dist/esm/lib/docker.d.ts +0 -8
- package/dist/esm/lib/docker.js +0 -16
- package/dist/esm/lib/exec-promise.d.ts +0 -3
- package/dist/esm/lib/exec-promise.js +0 -16
- package/dist/esm/lib/exec-rx-as-json.d.ts +0 -2
- package/dist/esm/lib/exec-rx-as-json.js +0 -9
- package/dist/esm/lib/exec-rx-as-lines.d.ts +0 -2
- package/dist/esm/lib/exec-rx-as-lines.js +0 -10
- package/dist/esm/lib/exec-rx.d.ts +0 -4
- package/dist/esm/lib/exec-rx.js +0 -18
- package/dist/esm/lib/exit.d.ts +0 -1
- package/dist/esm/lib/exit.js +0 -5
- package/dist/esm/lib/listen.d.ts +0 -5
- package/dist/esm/lib/listen.js +0 -12
- package/dist/esm/lib/psql.d.ts +0 -5
- package/dist/esm/lib/psql.js +0 -20
- package/dist/esm/lib/spawn-promise.d.ts +0 -1
- package/dist/esm/lib/spawn-promise.js +0 -28
- package/dist/types/index.d.ts +0 -9
- package/dist/types/lib/docker.d.ts +0 -8
- package/dist/types/lib/exec-promise.d.ts +0 -3
- package/dist/types/lib/exec-rx-as-json.d.ts +0 -2
- package/dist/types/lib/exec-rx-as-lines.d.ts +0 -2
- package/dist/types/lib/exec-rx.d.ts +0 -4
- package/dist/types/lib/exit.d.ts +0 -1
- package/dist/types/lib/listen.d.ts +0 -5
- package/dist/types/lib/psql.d.ts +0 -5
- package/dist/types/lib/spawn-promise.d.ts +0 -1
- /package/{dist/cjs/index.d.ts → src/index.ts} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { exec, ExecOptions } from "child_process";
|
|
2
|
+
import { EncodingOption } from "fs";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
|
|
5
|
+
export function execRx(cmd: string, options?: EncodingOption & ExecOptions, emitStdErr=true): Observable<any> {
|
|
6
|
+
return new Observable((observer) => {
|
|
7
|
+
exec(cmd, options, (err, stdout, stderr) => {
|
|
8
|
+
if (err) {
|
|
9
|
+
observer.error(err);
|
|
10
|
+
} else {
|
|
11
|
+
observer.next(`${stdout}${emitStdErr && ` ${stderr}`}`);
|
|
12
|
+
observer.complete();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
package/src/lib/exit.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const exit = (code: number) => process.exit.bind(process, code);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Subject } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
const stdin = new Subject();
|
|
4
|
+
const stdout = new Subject();
|
|
5
|
+
|
|
6
|
+
export const listen = () => {
|
|
7
|
+
|
|
8
|
+
process.stdin.on('data', d => stdin.next(d));
|
|
9
|
+
process.stdin.on('close', () => stdin.complete());
|
|
10
|
+
|
|
11
|
+
return { stdout, stdin };
|
|
12
|
+
}
|
package/src/lib/psql.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Docker } from "./docker";
|
|
2
|
+
import { execRx } from "./exec-rx";
|
|
3
|
+
|
|
4
|
+
const binaryName = 'psql';
|
|
5
|
+
|
|
6
|
+
export class PSql {
|
|
7
|
+
constructor(public readonly containerName: string = '') { }
|
|
8
|
+
|
|
9
|
+
execRx(cmd: string, db: string, username: string) {
|
|
10
|
+
const dbOptions = db ? ['-d', db] : [];
|
|
11
|
+
const commonArgs = ['-qtAX', '-U', username, ...dbOptions, '-c'].join(' ') + cmd;
|
|
12
|
+
return this.containerName
|
|
13
|
+
? (new Docker(this.containerName, binaryName)).execRx(commonArgs)
|
|
14
|
+
: execRx([binaryName, commonArgs].join(' '));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parse } from 'path';
|
|
2
|
+
import { spawnPromise } from './spawn-promise';
|
|
3
|
+
|
|
4
|
+
describe('spawnPromise', () => {
|
|
5
|
+
it('resolves with stdout', async () => {
|
|
6
|
+
const result = await spawnPromise(`ls`, [__dirname]);
|
|
7
|
+
expect(result).toContain(parse(__filename).base);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('rejects with stderr', async () => {
|
|
11
|
+
try {
|
|
12
|
+
await spawnPromise(`ls`, ['no way jose']);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
expect(e).toContain('No such file or directory');
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
|
|
3
|
+
const data = 'data';
|
|
4
|
+
|
|
5
|
+
export function spawnPromise(program: string, args?: string[], options?: any) {
|
|
6
|
+
return new Promise((res, rej) => {
|
|
7
|
+
let stdout: string[] = [];
|
|
8
|
+
let stderr: string[] = [];
|
|
9
|
+
|
|
10
|
+
const proc = spawn(program, args, options);
|
|
11
|
+
|
|
12
|
+
proc.stdout.on(data, (data) => {
|
|
13
|
+
stdout.push(`${data}`);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
proc.stderr.on(data, (data) => {
|
|
17
|
+
stderr.push(`${data}`);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
proc.on('close', (code) => {
|
|
21
|
+
if (code) {
|
|
22
|
+
rej(stderr.join(' '));
|
|
23
|
+
} else {
|
|
24
|
+
res(stdout.join(' '));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
stdout = undefined as any;
|
|
28
|
+
stderr = undefined as any;
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.server.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../../dist/out-tsc"
|
|
5
|
+
},
|
|
6
|
+
"files": [],
|
|
7
|
+
"include": [],
|
|
8
|
+
"references": [
|
|
9
|
+
{
|
|
10
|
+
"path": "./tsconfig.lib.json"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"path": "./tsconfig.spec.json"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"types": [
|
|
5
|
+
"jest",
|
|
6
|
+
"node"
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"jest.config.ts",
|
|
11
|
+
"**/*.test.ts",
|
|
12
|
+
"**/*.spec.ts",
|
|
13
|
+
"**/*.test.tsx",
|
|
14
|
+
"**/*.spec.tsx",
|
|
15
|
+
"**/*.test.js",
|
|
16
|
+
"**/*.spec.js",
|
|
17
|
+
"**/*.test.jsx",
|
|
18
|
+
"**/*.spec.jsx",
|
|
19
|
+
"**/*.d.ts"
|
|
20
|
+
]
|
|
21
|
+
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.spawnPromise = exports.PSql = exports.listen = exports.exit = exports.execRx = exports.execRxAsLines = exports.execRxAsJson = exports.execPromise = exports.Docker = void 0;
|
|
4
|
-
var docker_1 = require("./lib/docker");
|
|
5
|
-
Object.defineProperty(exports, "Docker", { enumerable: true, get: function () { return docker_1.Docker; } });
|
|
6
|
-
var exec_promise_1 = require("./lib/exec-promise");
|
|
7
|
-
Object.defineProperty(exports, "execPromise", { enumerable: true, get: function () { return exec_promise_1.execPromise; } });
|
|
8
|
-
var exec_rx_as_json_1 = require("./lib/exec-rx-as-json");
|
|
9
|
-
Object.defineProperty(exports, "execRxAsJson", { enumerable: true, get: function () { return exec_rx_as_json_1.execRxAsJson; } });
|
|
10
|
-
var exec_rx_as_lines_1 = require("./lib/exec-rx-as-lines");
|
|
11
|
-
Object.defineProperty(exports, "execRxAsLines", { enumerable: true, get: function () { return exec_rx_as_lines_1.execRxAsLines; } });
|
|
12
|
-
var exec_rx_1 = require("./lib/exec-rx");
|
|
13
|
-
Object.defineProperty(exports, "execRx", { enumerable: true, get: function () { return exec_rx_1.execRx; } });
|
|
14
|
-
var exit_1 = require("./lib/exit");
|
|
15
|
-
Object.defineProperty(exports, "exit", { enumerable: true, get: function () { return exit_1.exit; } });
|
|
16
|
-
var listen_1 = require("./lib/listen");
|
|
17
|
-
Object.defineProperty(exports, "listen", { enumerable: true, get: function () { return listen_1.listen; } });
|
|
18
|
-
var psql_1 = require("./lib/psql");
|
|
19
|
-
Object.defineProperty(exports, "PSql", { enumerable: true, get: function () { return psql_1.PSql; } });
|
|
20
|
-
var spawn_promise_1 = require("./lib/spawn-promise");
|
|
21
|
-
Object.defineProperty(exports, "spawnPromise", { enumerable: true, get: function () { return spawn_promise_1.spawnPromise; } });
|
package/dist/cjs/lib/docker.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ExecOptions } from "child_process";
|
|
2
|
-
import { EncodingOption } from "fs";
|
|
3
|
-
export declare class Docker {
|
|
4
|
-
readonly containerName: string;
|
|
5
|
-
readonly binaryName: string;
|
|
6
|
-
constructor(containerName: string, binaryName: string);
|
|
7
|
-
execRx(cmd: string, options?: EncodingOption & ExecOptions, emitStdErr?: boolean): import("rxjs").Observable<any>;
|
|
8
|
-
}
|
package/dist/cjs/lib/docker.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Docker = void 0;
|
|
4
|
-
const exec_rx_1 = require("./exec-rx");
|
|
5
|
-
class Docker {
|
|
6
|
-
containerName;
|
|
7
|
-
binaryName;
|
|
8
|
-
constructor(containerName, binaryName) {
|
|
9
|
-
this.containerName = containerName;
|
|
10
|
-
this.binaryName = binaryName;
|
|
11
|
-
}
|
|
12
|
-
execRx(cmd, options, emitStdErr = true) {
|
|
13
|
-
return (0, exec_rx_1.execRx)(`docker exec ${this.containerName} ${this.binaryName} ${cmd}`, options, emitStdErr);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.Docker = Docker;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execPromise = execPromise;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
function execPromise(cmd, options) {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
(0, child_process_1.exec)(cmd, options, (err, stdout) => {
|
|
8
|
-
if (err) {
|
|
9
|
-
reject(err);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
resolve(stdout.toString());
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execRxAsJson = void 0;
|
|
4
|
-
const operators_1 = require("rxjs/operators");
|
|
5
|
-
const exec_rx_1 = require("./exec-rx");
|
|
6
|
-
const execRxAsJson = (cmd, options, emitStdErr = true) => {
|
|
7
|
-
return (0, exec_rx_1.execRx)(cmd, options, emitStdErr).pipe((0, operators_1.map)((s) => JSON.parse(s)));
|
|
8
|
-
};
|
|
9
|
-
exports.execRxAsJson = execRxAsJson;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execRxAsLines = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const exec_rx_1 = require("./exec-rx");
|
|
7
|
-
const execRxAsLines = (cmd, options, emitStdErr = true) => {
|
|
8
|
-
return (0, exec_rx_1.execRx)(cmd, options, emitStdErr).pipe((0, operators_1.concatMap)((s) => (0, rxjs_1.from)(s.split('\n'))));
|
|
9
|
-
};
|
|
10
|
-
exports.execRxAsLines = execRxAsLines;
|
package/dist/cjs/lib/exec-rx.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execRx = execRx;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
const rxjs_1 = require("rxjs");
|
|
6
|
-
function execRx(cmd, options, emitStdErr = true) {
|
|
7
|
-
return new rxjs_1.Observable((observer) => {
|
|
8
|
-
(0, child_process_1.exec)(cmd, options, (err, stdout, stderr) => {
|
|
9
|
-
if (err) {
|
|
10
|
-
observer.error(err);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
observer.next(`${stdout}${emitStdErr && ` ${stderr}`}`);
|
|
14
|
-
observer.complete();
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}
|
package/dist/cjs/lib/exit.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const exit: (code: number) => () => never;
|
package/dist/cjs/lib/exit.js
DELETED
package/dist/cjs/lib/listen.d.ts
DELETED
package/dist/cjs/lib/listen.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listen = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const stdin = new rxjs_1.Subject();
|
|
6
|
-
const stdout = new rxjs_1.Subject();
|
|
7
|
-
const listen = () => {
|
|
8
|
-
process.stdin.on('data', d => stdin.next(d));
|
|
9
|
-
process.stdin.on('close', () => stdin.complete());
|
|
10
|
-
return { stdout, stdin };
|
|
11
|
-
};
|
|
12
|
-
exports.listen = listen;
|
package/dist/cjs/lib/psql.d.ts
DELETED
package/dist/cjs/lib/psql.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PSql = void 0;
|
|
4
|
-
const docker_1 = require("./docker");
|
|
5
|
-
const exec_rx_1 = require("./exec-rx");
|
|
6
|
-
const binaryName = 'psql';
|
|
7
|
-
class PSql {
|
|
8
|
-
containerName;
|
|
9
|
-
constructor(containerName = '') {
|
|
10
|
-
this.containerName = containerName;
|
|
11
|
-
}
|
|
12
|
-
execRx(cmd, db, username) {
|
|
13
|
-
const dbOptions = db ? ['-d', db] : [];
|
|
14
|
-
const commonArgs = ['-qtAX', '-U', username, ...dbOptions, '-c'].join(' ') + cmd;
|
|
15
|
-
return this.containerName
|
|
16
|
-
? (new docker_1.Docker(this.containerName, binaryName)).execRx(commonArgs)
|
|
17
|
-
: (0, exec_rx_1.execRx)([binaryName, commonArgs].join(' '));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.PSql = PSql;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function spawnPromise(program: string, args?: string[], options?: any): Promise<unknown>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.spawnPromise = spawnPromise;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
const data = 'data';
|
|
6
|
-
function spawnPromise(program, args, options) {
|
|
7
|
-
return new Promise((res, rej) => {
|
|
8
|
-
let stdout = [];
|
|
9
|
-
let stderr = [];
|
|
10
|
-
const proc = (0, child_process_1.spawn)(program, args, options);
|
|
11
|
-
proc.stdout.on(data, (data) => {
|
|
12
|
-
stdout.push(`${data}`);
|
|
13
|
-
});
|
|
14
|
-
proc.stderr.on(data, (data) => {
|
|
15
|
-
stderr.push(`${data}`);
|
|
16
|
-
});
|
|
17
|
-
proc.on('close', (code) => {
|
|
18
|
-
if (code) {
|
|
19
|
-
rej(stderr.join(' '));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
res(stdout.join(' '));
|
|
23
|
-
}
|
|
24
|
-
stdout = undefined;
|
|
25
|
-
stderr = undefined;
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { Docker } from './lib/docker';
|
|
2
|
-
export { execPromise } from './lib/exec-promise';
|
|
3
|
-
export { execRxAsJson } from './lib/exec-rx-as-json';
|
|
4
|
-
export { execRxAsLines } from './lib/exec-rx-as-lines';
|
|
5
|
-
export { execRx } from './lib/exec-rx';
|
|
6
|
-
export { exit } from './lib/exit';
|
|
7
|
-
export { listen } from './lib/listen';
|
|
8
|
-
export { PSql } from './lib/psql';
|
|
9
|
-
export { spawnPromise } from './lib/spawn-promise';
|
package/dist/esm/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.spawnPromise = exports.PSql = exports.listen = exports.exit = exports.execRx = exports.execRxAsLines = exports.execRxAsJson = exports.execPromise = exports.Docker = void 0;
|
|
4
|
-
var docker_1 = require("./lib/docker");
|
|
5
|
-
Object.defineProperty(exports, "Docker", { enumerable: true, get: function () { return docker_1.Docker; } });
|
|
6
|
-
var exec_promise_1 = require("./lib/exec-promise");
|
|
7
|
-
Object.defineProperty(exports, "execPromise", { enumerable: true, get: function () { return exec_promise_1.execPromise; } });
|
|
8
|
-
var exec_rx_as_json_1 = require("./lib/exec-rx-as-json");
|
|
9
|
-
Object.defineProperty(exports, "execRxAsJson", { enumerable: true, get: function () { return exec_rx_as_json_1.execRxAsJson; } });
|
|
10
|
-
var exec_rx_as_lines_1 = require("./lib/exec-rx-as-lines");
|
|
11
|
-
Object.defineProperty(exports, "execRxAsLines", { enumerable: true, get: function () { return exec_rx_as_lines_1.execRxAsLines; } });
|
|
12
|
-
var exec_rx_1 = require("./lib/exec-rx");
|
|
13
|
-
Object.defineProperty(exports, "execRx", { enumerable: true, get: function () { return exec_rx_1.execRx; } });
|
|
14
|
-
var exit_1 = require("./lib/exit");
|
|
15
|
-
Object.defineProperty(exports, "exit", { enumerable: true, get: function () { return exit_1.exit; } });
|
|
16
|
-
var listen_1 = require("./lib/listen");
|
|
17
|
-
Object.defineProperty(exports, "listen", { enumerable: true, get: function () { return listen_1.listen; } });
|
|
18
|
-
var psql_1 = require("./lib/psql");
|
|
19
|
-
Object.defineProperty(exports, "PSql", { enumerable: true, get: function () { return psql_1.PSql; } });
|
|
20
|
-
var spawn_promise_1 = require("./lib/spawn-promise");
|
|
21
|
-
Object.defineProperty(exports, "spawnPromise", { enumerable: true, get: function () { return spawn_promise_1.spawnPromise; } });
|
package/dist/esm/lib/docker.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ExecOptions } from "child_process";
|
|
2
|
-
import { EncodingOption } from "fs";
|
|
3
|
-
export declare class Docker {
|
|
4
|
-
readonly containerName: string;
|
|
5
|
-
readonly binaryName: string;
|
|
6
|
-
constructor(containerName: string, binaryName: string);
|
|
7
|
-
execRx(cmd: string, options?: EncodingOption & ExecOptions, emitStdErr?: boolean): import("rxjs").Observable<any>;
|
|
8
|
-
}
|
package/dist/esm/lib/docker.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Docker = void 0;
|
|
4
|
-
const exec_rx_1 = require("./exec-rx");
|
|
5
|
-
class Docker {
|
|
6
|
-
containerName;
|
|
7
|
-
binaryName;
|
|
8
|
-
constructor(containerName, binaryName) {
|
|
9
|
-
this.containerName = containerName;
|
|
10
|
-
this.binaryName = binaryName;
|
|
11
|
-
}
|
|
12
|
-
execRx(cmd, options, emitStdErr = true) {
|
|
13
|
-
return (0, exec_rx_1.execRx)(`docker exec ${this.containerName} ${this.binaryName} ${cmd}`, options, emitStdErr);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.Docker = Docker;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execPromise = execPromise;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
function execPromise(cmd, options) {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
(0, child_process_1.exec)(cmd, options, (err, stdout) => {
|
|
8
|
-
if (err) {
|
|
9
|
-
reject(err);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
resolve(stdout.toString());
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execRxAsJson = void 0;
|
|
4
|
-
const operators_1 = require("rxjs/operators");
|
|
5
|
-
const exec_rx_1 = require("./exec-rx");
|
|
6
|
-
const execRxAsJson = (cmd, options, emitStdErr = true) => {
|
|
7
|
-
return (0, exec_rx_1.execRx)(cmd, options, emitStdErr).pipe((0, operators_1.map)((s) => JSON.parse(s)));
|
|
8
|
-
};
|
|
9
|
-
exports.execRxAsJson = execRxAsJson;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execRxAsLines = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const exec_rx_1 = require("./exec-rx");
|
|
7
|
-
const execRxAsLines = (cmd, options, emitStdErr = true) => {
|
|
8
|
-
return (0, exec_rx_1.execRx)(cmd, options, emitStdErr).pipe((0, operators_1.concatMap)((s) => (0, rxjs_1.from)(s.split('\n'))));
|
|
9
|
-
};
|
|
10
|
-
exports.execRxAsLines = execRxAsLines;
|
package/dist/esm/lib/exec-rx.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execRx = execRx;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
const rxjs_1 = require("rxjs");
|
|
6
|
-
function execRx(cmd, options, emitStdErr = true) {
|
|
7
|
-
return new rxjs_1.Observable((observer) => {
|
|
8
|
-
(0, child_process_1.exec)(cmd, options, (err, stdout, stderr) => {
|
|
9
|
-
if (err) {
|
|
10
|
-
observer.error(err);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
observer.next(`${stdout}${emitStdErr && ` ${stderr}`}`);
|
|
14
|
-
observer.complete();
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}
|
package/dist/esm/lib/exit.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const exit: (code: number) => () => never;
|
package/dist/esm/lib/exit.js
DELETED
package/dist/esm/lib/listen.d.ts
DELETED
package/dist/esm/lib/listen.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listen = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const stdin = new rxjs_1.Subject();
|
|
6
|
-
const stdout = new rxjs_1.Subject();
|
|
7
|
-
const listen = () => {
|
|
8
|
-
process.stdin.on('data', d => stdin.next(d));
|
|
9
|
-
process.stdin.on('close', () => stdin.complete());
|
|
10
|
-
return { stdout, stdin };
|
|
11
|
-
};
|
|
12
|
-
exports.listen = listen;
|
package/dist/esm/lib/psql.d.ts
DELETED
package/dist/esm/lib/psql.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PSql = void 0;
|
|
4
|
-
const docker_1 = require("./docker");
|
|
5
|
-
const exec_rx_1 = require("./exec-rx");
|
|
6
|
-
const binaryName = 'psql';
|
|
7
|
-
class PSql {
|
|
8
|
-
containerName;
|
|
9
|
-
constructor(containerName = '') {
|
|
10
|
-
this.containerName = containerName;
|
|
11
|
-
}
|
|
12
|
-
execRx(cmd, db, username) {
|
|
13
|
-
const dbOptions = db ? ['-d', db] : [];
|
|
14
|
-
const commonArgs = ['-qtAX', '-U', username, ...dbOptions, '-c'].join(' ') + cmd;
|
|
15
|
-
return this.containerName
|
|
16
|
-
? (new docker_1.Docker(this.containerName, binaryName)).execRx(commonArgs)
|
|
17
|
-
: (0, exec_rx_1.execRx)([binaryName, commonArgs].join(' '));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.PSql = PSql;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function spawnPromise(program: string, args?: string[], options?: any): Promise<unknown>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.spawnPromise = spawnPromise;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
const data = 'data';
|
|
6
|
-
function spawnPromise(program, args, options) {
|
|
7
|
-
return new Promise((res, rej) => {
|
|
8
|
-
let stdout = [];
|
|
9
|
-
let stderr = [];
|
|
10
|
-
const proc = (0, child_process_1.spawn)(program, args, options);
|
|
11
|
-
proc.stdout.on(data, (data) => {
|
|
12
|
-
stdout.push(`${data}`);
|
|
13
|
-
});
|
|
14
|
-
proc.stderr.on(data, (data) => {
|
|
15
|
-
stderr.push(`${data}`);
|
|
16
|
-
});
|
|
17
|
-
proc.on('close', (code) => {
|
|
18
|
-
if (code) {
|
|
19
|
-
rej(stderr.join(' '));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
res(stdout.join(' '));
|
|
23
|
-
}
|
|
24
|
-
stdout = undefined;
|
|
25
|
-
stderr = undefined;
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { Docker } from './lib/docker';
|
|
2
|
-
export { execPromise } from './lib/exec-promise';
|
|
3
|
-
export { execRxAsJson } from './lib/exec-rx-as-json';
|
|
4
|
-
export { execRxAsLines } from './lib/exec-rx-as-lines';
|
|
5
|
-
export { execRx } from './lib/exec-rx';
|
|
6
|
-
export { exit } from './lib/exit';
|
|
7
|
-
export { listen } from './lib/listen';
|
|
8
|
-
export { PSql } from './lib/psql';
|
|
9
|
-
export { spawnPromise } from './lib/spawn-promise';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ExecOptions } from "child_process";
|
|
2
|
-
import { EncodingOption } from "fs";
|
|
3
|
-
export declare class Docker {
|
|
4
|
-
readonly containerName: string;
|
|
5
|
-
readonly binaryName: string;
|
|
6
|
-
constructor(containerName: string, binaryName: string);
|
|
7
|
-
execRx(cmd: string, options?: EncodingOption & ExecOptions, emitStdErr?: boolean): import("rxjs").Observable<any>;
|
|
8
|
-
}
|