@onivoro/server-process 1.14.0 → 1.18.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 +3 -0
- package/{cjs → dist}/index.d.ts +8 -8
- package/dist/index.es.js +1352 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +1363 -0
- package/dist/index.js.map +1 -0
- package/{cjs → dist}/lib/docker.d.ts +9 -9
- package/{cjs → dist}/lib/exec-promise.d.ts +4 -4
- package/{cjs → dist}/lib/exec-rx-as-json.d.ts +2 -3
- package/dist/lib/exec-rx-as-lines.d.ts +2 -0
- package/{cjs → dist}/lib/exec-rx.d.ts +5 -5
- package/{cjs → dist}/lib/exec-rx.spec.d.ts +1 -1
- package/dist/lib/exit.d.ts +1 -0
- package/{cjs → dist}/lib/listen.d.ts +5 -5
- package/{cjs → dist}/lib/psql.d.ts +6 -6
- package/package.json +14 -7
- package/cjs/index.js +0 -19
- package/cjs/lib/docker.js +0 -14
- package/cjs/lib/exec-promise.js +0 -17
- package/cjs/lib/exec-rx-as-json.js +0 -8
- package/cjs/lib/exec-rx-as-lines.d.ts +0 -3
- package/cjs/lib/exec-rx-as-lines.js +0 -9
- package/cjs/lib/exec-rx.js +0 -19
- package/cjs/lib/exec-rx.spec.js +0 -21
- package/cjs/lib/exit.d.ts +0 -1
- package/cjs/lib/exit.js +0 -4
- package/cjs/lib/listen.js +0 -11
- package/cjs/lib/psql.js +0 -20
- package/index.d.ts +0 -8
- package/index.js +0 -8
- package/lib/docker.d.ts +0 -9
- package/lib/docker.js +0 -10
- package/lib/exec-promise.d.ts +0 -4
- package/lib/exec-promise.js +0 -13
- package/lib/exec-rx-as-json.d.ts +0 -3
- package/lib/exec-rx-as-json.js +0 -5
- package/lib/exec-rx-as-lines.d.ts +0 -3
- package/lib/exec-rx-as-lines.js +0 -6
- package/lib/exec-rx.d.ts +0 -5
- package/lib/exec-rx.js +0 -15
- package/lib/exec-rx.spec.d.ts +0 -1
- package/lib/exec-rx.spec.js +0 -19
- package/lib/exit.d.ts +0 -1
- package/lib/exit.js +0 -1
- package/lib/listen.d.ts +0 -5
- package/lib/listen.js +0 -8
- package/lib/psql.d.ts +0 -6
- package/lib/psql.js +0 -16
package/lib/docker.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ExecOptions } from "child_process";
|
|
3
|
-
import { BaseEncodingOptions } from "fs";
|
|
4
|
-
export declare class Docker {
|
|
5
|
-
readonly containerName: string;
|
|
6
|
-
readonly binaryName: string;
|
|
7
|
-
constructor(containerName: string, binaryName: string);
|
|
8
|
-
execRx(cmd: string, options?: BaseEncodingOptions & ExecOptions, emitStdErr?: boolean): import("rxjs").Observable<any>;
|
|
9
|
-
}
|
package/lib/docker.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { execRx } from "./exec-rx";
|
|
2
|
-
export class Docker {
|
|
3
|
-
constructor(containerName, binaryName) {
|
|
4
|
-
this.containerName = containerName;
|
|
5
|
-
this.binaryName = binaryName;
|
|
6
|
-
}
|
|
7
|
-
execRx(cmd, options, emitStdErr = true) {
|
|
8
|
-
return execRx(`docker exec ${this.containerName} ${this.binaryName} ${cmd}`, options, emitStdErr);
|
|
9
|
-
}
|
|
10
|
-
}
|
package/lib/exec-promise.d.ts
DELETED
package/lib/exec-promise.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { exec } from "child_process";
|
|
2
|
-
export function execPromise(cmd, options) {
|
|
3
|
-
return new Promise((resolve, reject) => {
|
|
4
|
-
exec(cmd, options, (err, stdout) => {
|
|
5
|
-
if (err) {
|
|
6
|
-
reject(err);
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
resolve(stdout.toString());
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
}
|
package/lib/exec-rx-as-json.d.ts
DELETED
package/lib/exec-rx-as-json.js
DELETED
package/lib/exec-rx-as-lines.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { from } from 'rxjs';
|
|
2
|
-
import { concatMap } from 'rxjs/operators';
|
|
3
|
-
import { execRx } from './exec-rx';
|
|
4
|
-
export const execRxAsLines = (cmd, options, emitStdErr = true) => {
|
|
5
|
-
return execRx(cmd, options, emitStdErr).pipe(concatMap((s) => from(s.split('\n'))));
|
|
6
|
-
};
|
package/lib/exec-rx.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ExecOptions } from "child_process";
|
|
3
|
-
import { BaseEncodingOptions } from 'fs';
|
|
4
|
-
import { Observable } from "rxjs";
|
|
5
|
-
export declare function execRx(cmd: string, options?: BaseEncodingOptions & ExecOptions, emitStdErr?: boolean): Observable<any>;
|
package/lib/exec-rx.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { exec } from "child_process";
|
|
2
|
-
import { Observable } from "rxjs";
|
|
3
|
-
export function execRx(cmd, options, emitStdErr = true) {
|
|
4
|
-
return new Observable((observer) => {
|
|
5
|
-
exec(cmd, options, (err, stdout, stderr) => {
|
|
6
|
-
if (err) {
|
|
7
|
-
observer.error(err);
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
observer.next(`${stdout}${emitStdErr && ` ${stderr}`}`);
|
|
11
|
-
observer.complete();
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
}
|
package/lib/exec-rx.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/exec-rx.spec.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { execRx } from './exec-rx';
|
|
2
|
-
import { of } from 'rxjs';
|
|
3
|
-
import { catchError } from 'rxjs/operators';
|
|
4
|
-
describe(execRx.name, () => {
|
|
5
|
-
describe('GIVEN command succeeds', () => {
|
|
6
|
-
it('returns the stdout', (done) => {
|
|
7
|
-
execRx(`cat ${__filename}`).subscribe((d) => {
|
|
8
|
-
expect(d).toEqual(expect.stringContaining('execRx worx!'));
|
|
9
|
-
done();
|
|
10
|
-
}, fail);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
describe('GIVEN command fails', () => {
|
|
14
|
-
it('emits error', (done) => {
|
|
15
|
-
execRx(`cat ${__filename + 'blah'}`).pipe(catchError(() => of(done())))
|
|
16
|
-
.subscribe();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|
package/lib/exit.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const exit: (code: number) => () => never;
|
package/lib/exit.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const exit = (code) => process.exit.bind(process, code);
|
package/lib/listen.d.ts
DELETED
package/lib/listen.js
DELETED
package/lib/psql.d.ts
DELETED
package/lib/psql.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Docker } from "./docker";
|
|
2
|
-
import { execRx } from "./exec-rx";
|
|
3
|
-
const binaryName = 'psql';
|
|
4
|
-
export class PSql {
|
|
5
|
-
constructor(containerName) {
|
|
6
|
-
this.containerName = containerName;
|
|
7
|
-
this.container = new Docker(this.containerName, binaryName);
|
|
8
|
-
}
|
|
9
|
-
execRx(cmd, db, username) {
|
|
10
|
-
const dbOptions = db ? ['-d', db] : [];
|
|
11
|
-
const commonArgs = ['-qtAX', '-U', username, ...dbOptions, '-c'].join(' ') + cmd;
|
|
12
|
-
return this.containerName
|
|
13
|
-
? this.container.execRx(commonArgs)
|
|
14
|
-
: execRx([binaryName, commonArgs].join(' '));
|
|
15
|
-
}
|
|
16
|
-
}
|