@effectionx/process 0.6.1 → 0.7.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/CHANGELOG.md +269 -0
- package/dist/mod.d.ts +3 -0
- package/dist/mod.d.ts.map +1 -0
- package/{esm → dist}/src/daemon.d.ts +1 -1
- package/dist/src/daemon.d.ts.map +1 -0
- package/{script → dist}/src/exec/api.d.ts +2 -4
- package/dist/src/exec/api.d.ts.map +1 -0
- package/{script → dist}/src/exec/error.d.ts +1 -1
- package/dist/src/exec/error.d.ts.map +1 -0
- package/dist/src/exec/error.js +29 -0
- package/dist/src/exec/posix.d.ts +3 -0
- package/dist/src/exec/posix.d.ts.map +1 -0
- package/{esm → dist}/src/exec/posix.js +12 -13
- package/{esm → dist}/src/exec/win32.d.ts +1 -1
- package/dist/src/exec/win32.d.ts.map +1 -0
- package/{esm → dist}/src/exec/win32.js +20 -13
- package/{script → dist}/src/exec.d.ts +3 -3
- package/dist/src/exec.d.ts.map +1 -0
- package/{esm → dist}/src/exec.js +3 -5
- package/dist/src/helpers.d.ts +4 -0
- package/dist/src/helpers.d.ts.map +1 -0
- package/dist/src/helpers.js +10 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/mod.ts +2 -0
- package/package.json +25 -19
- package/src/daemon.ts +34 -0
- package/src/exec/api.ts +83 -0
- package/src/exec/error.ts +43 -0
- package/src/exec/posix.ts +133 -0
- package/src/exec/win32.ts +217 -0
- package/src/exec.ts +100 -0
- package/src/helpers.ts +12 -0
- package/test/daemon.test.ts +106 -0
- package/test/eventemitter.test.ts +82 -0
- package/test/exec.test.ts +481 -0
- package/test/fixtures/dump-args.js +13 -0
- package/test/fixtures/echo-server.ts +49 -0
- package/test/fixtures/hello-world-failed.js +5 -0
- package/test/fixtures/hello-world.js +5 -0
- package/test/helpers.ts +69 -0
- package/test/output-stream.test.ts +73 -0
- package/tsconfig.json +20 -0
- package/esm/mod.d.ts +0 -3
- package/esm/mod.d.ts.map +0 -1
- package/esm/package.json +0 -3
- package/esm/src/daemon.d.ts.map +0 -1
- package/esm/src/eventemitter.d.ts +0 -22
- package/esm/src/eventemitter.d.ts.map +0 -1
- package/esm/src/eventemitter.js +0 -40
- package/esm/src/exec/api.d.ts +0 -70
- package/esm/src/exec/api.d.ts.map +0 -1
- package/esm/src/exec/error.d.ts +0 -14
- package/esm/src/exec/error.d.ts.map +0 -1
- package/esm/src/exec/error.js +0 -54
- package/esm/src/exec/posix.d.ts +0 -3
- package/esm/src/exec/posix.d.ts.map +0 -1
- package/esm/src/exec/win32.d.ts.map +0 -1
- package/esm/src/exec.d.ts +0 -16
- package/esm/src/exec.d.ts.map +0 -1
- package/esm/src/helpers.d.ts +0 -12
- package/esm/src/helpers.d.ts.map +0 -1
- package/esm/src/helpers.js +0 -71
- package/script/mod.d.ts +0 -3
- package/script/mod.d.ts.map +0 -1
- package/script/mod.js +0 -20
- package/script/package.json +0 -3
- package/script/src/daemon.d.ts +0 -11
- package/script/src/daemon.d.ts.map +0 -1
- package/script/src/daemon.js +0 -23
- package/script/src/eventemitter.d.ts +0 -22
- package/script/src/eventemitter.d.ts.map +0 -1
- package/script/src/eventemitter.js +0 -44
- package/script/src/exec/api.d.ts.map +0 -1
- package/script/src/exec/api.js +0 -2
- package/script/src/exec/error.d.ts.map +0 -1
- package/script/src/exec/error.js +0 -59
- package/script/src/exec/posix.d.ts +0 -3
- package/script/src/exec/posix.d.ts.map +0 -1
- package/script/src/exec/posix.js +0 -117
- package/script/src/exec/win32.d.ts +0 -4
- package/script/src/exec/win32.d.ts.map +0 -1
- package/script/src/exec/win32.js +0 -177
- package/script/src/exec.d.ts.map +0 -1
- package/script/src/exec.js +0 -92
- package/script/src/helpers.d.ts +0 -12
- package/script/src/helpers.d.ts.map +0 -1
- package/script/src/helpers.js +0 -76
- /package/{esm → dist}/mod.js +0 -0
- /package/{esm → dist}/src/daemon.js +0 -0
- /package/{esm → dist}/src/exec/api.js +0 -0
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"rootDir": "."
|
|
6
|
+
},
|
|
7
|
+
"include": ["**/*.ts"],
|
|
8
|
+
"exclude": ["**/*.test.ts", "test/**", "dist"],
|
|
9
|
+
"references": [
|
|
10
|
+
{
|
|
11
|
+
"path": "../bdd"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"path": "../node"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "../stream-helpers"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
package/esm/mod.d.ts
DELETED
package/esm/mod.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC"}
|
package/esm/package.json
DELETED
package/esm/src/daemon.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../../src/src/daemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,WAAW,CAAC;AAErD,OAAO,EAGL,KAAK,WAAW,EAEhB,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,MAAO,SAAQ,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO;CACvD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,WAAgB,GACxB,SAAS,CAAC,MAAM,CAAC,CAanB"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Operation, Stream } from "effection";
|
|
2
|
-
import type { EventEmitter } from "node:stream";
|
|
3
|
-
/**
|
|
4
|
-
* Create a {@link Stream} of events from any EventEmitter.
|
|
5
|
-
*
|
|
6
|
-
* See the guide on [Streams and Subscriptions](https://frontside.com/effection/docs/collections)
|
|
7
|
-
* for details on how to use streams.
|
|
8
|
-
*
|
|
9
|
-
* @param target - the event target whose events will be streamed
|
|
10
|
-
* @param name - the name of the event to stream. E.g. "click"
|
|
11
|
-
* @returns a stream that will see one item for each event
|
|
12
|
-
*/
|
|
13
|
-
export declare function on<T extends unknown[]>(target: EventEmitter | null, eventName: string): Stream<T, never>;
|
|
14
|
-
/**
|
|
15
|
-
* Create an {@link Operation} that yields the next event to be emitted by an EventEmitter.
|
|
16
|
-
*
|
|
17
|
-
* @param target - the event target to be watched
|
|
18
|
-
* @param name - the name of the event to watch. E.g. "click"
|
|
19
|
-
* @returns an Operation that yields the next emitted event
|
|
20
|
-
*/
|
|
21
|
-
export declare function once<TArgs extends unknown[] = unknown[]>(source: EventEmitter | null, eventName: string): Operation<TArgs>;
|
|
22
|
-
//# sourceMappingURL=eventemitter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventemitter.d.ts","sourceRoot":"","sources":["../../src/src/eventemitter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAgB,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,EAAE,CAChB,CAAC,SAAS,OAAO,EAAE,EACnB,MAAM,EAAE,YAAY,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAkBlE;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EACtD,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,SAAS,EAAE,MAAM,GAChB,SAAS,CAAC,KAAK,CAAC,CAWlB"}
|
package/esm/src/eventemitter.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { createSignal, resource, withResolvers } from "effection";
|
|
2
|
-
/**
|
|
3
|
-
* Create a {@link Stream} of events from any EventEmitter.
|
|
4
|
-
*
|
|
5
|
-
* See the guide on [Streams and Subscriptions](https://frontside.com/effection/docs/collections)
|
|
6
|
-
* for details on how to use streams.
|
|
7
|
-
*
|
|
8
|
-
* @param target - the event target whose events will be streamed
|
|
9
|
-
* @param name - the name of the event to stream. E.g. "click"
|
|
10
|
-
* @returns a stream that will see one item for each event
|
|
11
|
-
*/
|
|
12
|
-
export function on(target, eventName) {
|
|
13
|
-
return resource(function* (provide) {
|
|
14
|
-
let signal = createSignal();
|
|
15
|
-
let listener = (...args) => signal.send(args);
|
|
16
|
-
target?.on(eventName, listener);
|
|
17
|
-
try {
|
|
18
|
-
yield* provide(yield* signal);
|
|
19
|
-
}
|
|
20
|
-
finally {
|
|
21
|
-
target?.off(eventName, listener);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Create an {@link Operation} that yields the next event to be emitted by an EventEmitter.
|
|
27
|
-
*
|
|
28
|
-
* @param target - the event target to be watched
|
|
29
|
-
* @param name - the name of the event to watch. E.g. "click"
|
|
30
|
-
* @returns an Operation that yields the next emitted event
|
|
31
|
-
*/
|
|
32
|
-
export function once(source, eventName) {
|
|
33
|
-
const result = withResolvers();
|
|
34
|
-
let listener = (...args) => {
|
|
35
|
-
result.resolve(args);
|
|
36
|
-
source?.off(eventName, listener);
|
|
37
|
-
};
|
|
38
|
-
source?.on(eventName, listener);
|
|
39
|
-
return result.operation;
|
|
40
|
-
}
|
package/esm/src/exec/api.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { Operation } from "effection";
|
|
2
|
-
import type { OutputStream } from "../helpers.js";
|
|
3
|
-
export interface Writable<T> {
|
|
4
|
-
send(message: T): void;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* The process type is what is returned by the `exec` operation. It has all of
|
|
8
|
-
* standard io handles, and methods for synchronizing on return.
|
|
9
|
-
*/
|
|
10
|
-
export interface Process extends StdIO {
|
|
11
|
-
readonly pid: number;
|
|
12
|
-
/**
|
|
13
|
-
* Completes once the process has finished regardless of whether it was
|
|
14
|
-
* successful or not.
|
|
15
|
-
*/
|
|
16
|
-
join(): Operation<ExitStatus>;
|
|
17
|
-
/**
|
|
18
|
-
* Completes once the process has finished successfully. If the process does
|
|
19
|
-
* not complete successfully, it will raise an ExecError.
|
|
20
|
-
*/
|
|
21
|
-
expect(): Operation<ExitStatus>;
|
|
22
|
-
}
|
|
23
|
-
export interface ExecOptions {
|
|
24
|
-
/**
|
|
25
|
-
* When not using passing the `shell` option all arguments must be passed
|
|
26
|
-
* as an array.
|
|
27
|
-
*/
|
|
28
|
-
arguments?: string[];
|
|
29
|
-
/**
|
|
30
|
-
* Map of environment variables to use for the process.
|
|
31
|
-
*/
|
|
32
|
-
env?: Record<string, string>;
|
|
33
|
-
/**
|
|
34
|
-
* Create an intermediate shell process; defaults to `false`. Useful if you
|
|
35
|
-
* need to handle glob expansion or passing environment variables. A truthy value
|
|
36
|
-
* will use an intermediate shell to interpret the command using the default system shell.
|
|
37
|
-
* However, if the value is a string, that will be used as the executable path
|
|
38
|
-
* for the intermediate shell.
|
|
39
|
-
*/
|
|
40
|
-
shell?: boolean | string;
|
|
41
|
-
/**
|
|
42
|
-
* Sets the working directory of the process
|
|
43
|
-
*/
|
|
44
|
-
cwd?: string;
|
|
45
|
-
}
|
|
46
|
-
export interface StdIO {
|
|
47
|
-
stdout: OutputStream;
|
|
48
|
-
stderr: OutputStream;
|
|
49
|
-
stdin: Writable<string>;
|
|
50
|
-
}
|
|
51
|
-
export interface ExitStatus {
|
|
52
|
-
/**
|
|
53
|
-
* exit code
|
|
54
|
-
* //TODO: is this pertinent on Windows? Do we need an 'OK' flag
|
|
55
|
-
*/
|
|
56
|
-
code?: number;
|
|
57
|
-
/**
|
|
58
|
-
* If the process exited with a signal instead of an exit code, it
|
|
59
|
-
* is recorded here.
|
|
60
|
-
*/
|
|
61
|
-
signal?: string;
|
|
62
|
-
}
|
|
63
|
-
export interface ProcessResult extends ExitStatus {
|
|
64
|
-
stdout: string;
|
|
65
|
-
stderr: string;
|
|
66
|
-
}
|
|
67
|
-
export interface CreateOSProcess {
|
|
68
|
-
(command: string, options: ExecOptions): Operation<Process>;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/src/exec/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,OAAQ,SAAQ,KAAK;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,IAAI,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC;IAE9B;;;OAGG;IACH,MAAM,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7B;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,eAAe;IAC9B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;CAC7D"}
|
package/esm/src/exec/error.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ExecOptions, ExitStatus } from "./api.js";
|
|
2
|
-
export declare class ExecError extends Error {
|
|
3
|
-
status: ExitStatus;
|
|
4
|
-
command: string;
|
|
5
|
-
options: ExecOptions;
|
|
6
|
-
constructor(status: ExitStatus, command: string, options: ExecOptions);
|
|
7
|
-
name: string;
|
|
8
|
-
get message(): string;
|
|
9
|
-
}
|
|
10
|
-
export declare class DaemonExitError extends ExecError {
|
|
11
|
-
name: string;
|
|
12
|
-
get message(): string;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=error.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/src/exec/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAExD,qBAAa,SAAU,SAAQ,KAAK;IAEzB,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,WAAW;gBAFpB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,WAAW;IAKpB,IAAI,SAAe;IAE5B,IAAa,OAAO,IAAI,MAAM,CAgB7B;CACF;AAED,qBAAa,eAAgB,SAAQ,SAAS;IACnC,IAAI,SAAqB;IAElC,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF"}
|
package/esm/src/exec/error.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export class ExecError extends Error {
|
|
2
|
-
constructor(status, command, options) {
|
|
3
|
-
super();
|
|
4
|
-
Object.defineProperty(this, "status", {
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true,
|
|
8
|
-
value: status
|
|
9
|
-
});
|
|
10
|
-
Object.defineProperty(this, "command", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
value: command
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(this, "options", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true,
|
|
20
|
-
value: options
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(this, "name", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true,
|
|
26
|
-
value: "ExecError"
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
get message() {
|
|
30
|
-
let code = this.status.code ? `code: ${this.status.code}` : null;
|
|
31
|
-
let signal = this.status.signal ? `signal: ${this.status.signal}` : null;
|
|
32
|
-
let env = `env: ${JSON.stringify(this.options.env || {})}`;
|
|
33
|
-
let shell = this.options.shell ? `shell: ${this.options.shell}` : null;
|
|
34
|
-
let cwd = this.options.cwd ? `cwd: ${this.options.cwd}` : null;
|
|
35
|
-
let command = `$ ${this.command} ${this.options.arguments?.join(" ")}`
|
|
36
|
-
.trim();
|
|
37
|
-
return [code, signal, env, shell, cwd, command].filter((item) => !!item)
|
|
38
|
-
.join("\n");
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export class DaemonExitError extends ExecError {
|
|
42
|
-
constructor() {
|
|
43
|
-
super(...arguments);
|
|
44
|
-
Object.defineProperty(this, "name", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true,
|
|
48
|
-
value: "DaemonExitError"
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
get message() {
|
|
52
|
-
return `daemon process quit unexpectedly\n${super.message}`;
|
|
53
|
-
}
|
|
54
|
-
}
|
package/esm/src/exec/posix.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"posix.d.ts","sourceRoot":"","sources":["../../../src/src/exec/posix.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,UAAU,CAAC;AAKtE,eAAO,MAAM,kBAAkB,EAAE,eAkHhC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"win32.d.ts","sourceRoot":"","sources":["../../../src/src/exec/win32.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,UAAU,CAAC;AAkBtE,eAAO,MAAM,kBAAkB,EAAE,eA4KhC,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,OAAiC,CAAC"}
|
package/esm/src/exec.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { type Operation } from "effection";
|
|
2
|
-
import type { ExecOptions, Process, ProcessResult } from "./exec/api.js";
|
|
3
|
-
export * from "./exec/api.js";
|
|
4
|
-
export * from "./exec/error.js";
|
|
5
|
-
export interface Exec extends Operation<Process> {
|
|
6
|
-
join(): Operation<ProcessResult>;
|
|
7
|
-
expect(): Operation<ProcessResult>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Execute `command` with `options`. You should use this operation for processes
|
|
11
|
-
* that have a finite lifetime and on which you may wish to synchronize on the
|
|
12
|
-
* exit status. If you want to start a process like a server that spins up and runs
|
|
13
|
-
* forever, consider using `daemon()`
|
|
14
|
-
*/
|
|
15
|
-
export declare function exec(command: string, options?: ExecOptions): Exec;
|
|
16
|
-
//# sourceMappingURL=exec.d.ts.map
|
package/esm/src/exec.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/src/exec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAS,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAEV,WAAW,EAEX,OAAO,EACP,aAAa,EACd,MAAM,eAAe,CAAC;AAIvB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC,MAAM,WAAW,IAAK,SAAQ,SAAS,CAAC,OAAO,CAAC;IAC9C,IAAI,IAAI,SAAS,CAAC,aAAa,CAAC,CAAC;IACjC,MAAM,IAAI,SAAS,CAAC,aAAa,CAAC,CAAC;CACpC;AAUD;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAiErE"}
|
package/esm/src/helpers.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Operation, type Result, type Stream } from "effection";
|
|
2
|
-
import type { Readable } from "node:stream";
|
|
3
|
-
export type OutputStream = Stream<Uint8Array, void>;
|
|
4
|
-
export declare function useReadable(target: Readable | null): Stream<Uint8Array, void>;
|
|
5
|
-
interface Remainder<T> {
|
|
6
|
-
remainder: string;
|
|
7
|
-
result: T;
|
|
8
|
-
}
|
|
9
|
-
export declare function lines(): <T extends Uint8Array, TReturn>(stream: Stream<T, TReturn>) => Stream<string, Remainder<TReturn>>;
|
|
10
|
-
export declare function box<T>(op: () => Operation<T>): Operation<Result<T>>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=helpers.d.ts.map
|
package/esm/src/helpers.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EAEd,KAAK,MAAM,EACX,KAAK,MAAM,EACZ,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAEpD,wBAAgB,WAAW,CACzB,MAAM,EAAE,QAAQ,GAAG,IAAI,GACtB,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAoB1B;AAED,UAAU,SAAS,CAAC,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,CAAC;CACX;AAED,wBAAgB,KAAK,IAAI,CAAC,CAAC,SAAS,UAAU,EAAE,OAAO,EACrD,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,KACvB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAyCtC;AAED,wBAAiB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAOpE"}
|
package/esm/src/helpers.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { createSignal, Err, Ok, resource, } from "effection";
|
|
2
|
-
export function useReadable(target) {
|
|
3
|
-
return resource(function* (provide) {
|
|
4
|
-
let signal = createSignal();
|
|
5
|
-
let listener = (chunk) => {
|
|
6
|
-
signal.send(chunk);
|
|
7
|
-
};
|
|
8
|
-
target?.on("data", listener);
|
|
9
|
-
target?.on("end", signal.close);
|
|
10
|
-
try {
|
|
11
|
-
yield* provide(yield* signal);
|
|
12
|
-
}
|
|
13
|
-
finally {
|
|
14
|
-
target?.off("data", listener);
|
|
15
|
-
target?.off("end", signal.close);
|
|
16
|
-
signal.close();
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
export function lines() {
|
|
21
|
-
const decoder = new TextDecoder();
|
|
22
|
-
return function (stream) {
|
|
23
|
-
return {
|
|
24
|
-
*[Symbol.iterator]() {
|
|
25
|
-
let subscription = yield* stream;
|
|
26
|
-
let buffer = [];
|
|
27
|
-
let remainder = "";
|
|
28
|
-
return {
|
|
29
|
-
*next() {
|
|
30
|
-
while (buffer.length === 0) {
|
|
31
|
-
let next = yield* subscription.next();
|
|
32
|
-
if (next.done) {
|
|
33
|
-
return {
|
|
34
|
-
done: true,
|
|
35
|
-
value: {
|
|
36
|
-
remainder,
|
|
37
|
-
result: next.value,
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
let current = remainder + decoder.decode(next.value);
|
|
43
|
-
let lines = current.split("\n");
|
|
44
|
-
if (lines.length > 0) {
|
|
45
|
-
buffer.push(...lines.slice(0, -1));
|
|
46
|
-
remainder = lines.slice(-1)[0];
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
remainder = current;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
done: false,
|
|
55
|
-
value: buffer.pop(),
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export function* box(op) {
|
|
64
|
-
try {
|
|
65
|
-
let value = yield* op();
|
|
66
|
-
return Ok(value);
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
return Err(e);
|
|
70
|
-
}
|
|
71
|
-
}
|
package/script/mod.d.ts
DELETED
package/script/mod.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC"}
|
package/script/mod.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.daemon = void 0;
|
|
18
|
-
__exportStar(require("./src/exec.js"), exports);
|
|
19
|
-
var daemon_js_1 = require("./src/daemon.js");
|
|
20
|
-
Object.defineProperty(exports, "daemon", { enumerable: true, get: function () { return daemon_js_1.daemon; } });
|
package/script/package.json
DELETED
package/script/src/daemon.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Operation } from "effection";
|
|
2
|
-
import { type ExecOptions, type Process } from "./exec.js";
|
|
3
|
-
export interface Daemon extends Operation<void>, Process {
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Start a long-running process, like a web server that run perpetually.
|
|
7
|
-
* Daemon operations are expected to run forever, and if they exit pre-maturely
|
|
8
|
-
* before the operation containing them passes out of scope it raises an error.
|
|
9
|
-
*/
|
|
10
|
-
export declare function daemon(command: string, options?: ExecOptions): Operation<Daemon>;
|
|
11
|
-
//# sourceMappingURL=daemon.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../../src/src/daemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,WAAW,CAAC;AAErD,OAAO,EAGL,KAAK,WAAW,EAEhB,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,MAAO,SAAQ,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO;CACvD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,WAAgB,GACxB,SAAS,CAAC,MAAM,CAAC,CAanB"}
|
package/script/src/daemon.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.daemon = daemon;
|
|
4
|
-
const effection_1 = require("effection");
|
|
5
|
-
const exec_js_1 = require("./exec.js");
|
|
6
|
-
/**
|
|
7
|
-
* Start a long-running process, like a web server that run perpetually.
|
|
8
|
-
* Daemon operations are expected to run forever, and if they exit pre-maturely
|
|
9
|
-
* before the operation containing them passes out of scope it raises an error.
|
|
10
|
-
*/
|
|
11
|
-
function daemon(command, options = {}) {
|
|
12
|
-
return (0, effection_1.resource)(function* (provide) {
|
|
13
|
-
// TODO: should we be able to terminate the process from here?
|
|
14
|
-
let process = yield* (0, exec_js_1.exec)(command, options);
|
|
15
|
-
yield* provide({
|
|
16
|
-
*[Symbol.iterator]() {
|
|
17
|
-
let status = yield* process.join();
|
|
18
|
-
throw new exec_js_1.DaemonExitError(status, command, options);
|
|
19
|
-
},
|
|
20
|
-
...process,
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Operation, Stream } from "effection";
|
|
2
|
-
import type { EventEmitter } from "node:stream";
|
|
3
|
-
/**
|
|
4
|
-
* Create a {@link Stream} of events from any EventEmitter.
|
|
5
|
-
*
|
|
6
|
-
* See the guide on [Streams and Subscriptions](https://frontside.com/effection/docs/collections)
|
|
7
|
-
* for details on how to use streams.
|
|
8
|
-
*
|
|
9
|
-
* @param target - the event target whose events will be streamed
|
|
10
|
-
* @param name - the name of the event to stream. E.g. "click"
|
|
11
|
-
* @returns a stream that will see one item for each event
|
|
12
|
-
*/
|
|
13
|
-
export declare function on<T extends unknown[]>(target: EventEmitter | null, eventName: string): Stream<T, never>;
|
|
14
|
-
/**
|
|
15
|
-
* Create an {@link Operation} that yields the next event to be emitted by an EventEmitter.
|
|
16
|
-
*
|
|
17
|
-
* @param target - the event target to be watched
|
|
18
|
-
* @param name - the name of the event to watch. E.g. "click"
|
|
19
|
-
* @returns an Operation that yields the next emitted event
|
|
20
|
-
*/
|
|
21
|
-
export declare function once<TArgs extends unknown[] = unknown[]>(source: EventEmitter | null, eventName: string): Operation<TArgs>;
|
|
22
|
-
//# sourceMappingURL=eventemitter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventemitter.d.ts","sourceRoot":"","sources":["../../src/src/eventemitter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAgB,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,EAAE,CAChB,CAAC,SAAS,OAAO,EAAE,EACnB,MAAM,EAAE,YAAY,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAkBlE;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EACtD,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,SAAS,EAAE,MAAM,GAChB,SAAS,CAAC,KAAK,CAAC,CAWlB"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.on = on;
|
|
4
|
-
exports.once = once;
|
|
5
|
-
const effection_1 = require("effection");
|
|
6
|
-
/**
|
|
7
|
-
* Create a {@link Stream} of events from any EventEmitter.
|
|
8
|
-
*
|
|
9
|
-
* See the guide on [Streams and Subscriptions](https://frontside.com/effection/docs/collections)
|
|
10
|
-
* for details on how to use streams.
|
|
11
|
-
*
|
|
12
|
-
* @param target - the event target whose events will be streamed
|
|
13
|
-
* @param name - the name of the event to stream. E.g. "click"
|
|
14
|
-
* @returns a stream that will see one item for each event
|
|
15
|
-
*/
|
|
16
|
-
function on(target, eventName) {
|
|
17
|
-
return (0, effection_1.resource)(function* (provide) {
|
|
18
|
-
let signal = (0, effection_1.createSignal)();
|
|
19
|
-
let listener = (...args) => signal.send(args);
|
|
20
|
-
target?.on(eventName, listener);
|
|
21
|
-
try {
|
|
22
|
-
yield* provide(yield* signal);
|
|
23
|
-
}
|
|
24
|
-
finally {
|
|
25
|
-
target?.off(eventName, listener);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Create an {@link Operation} that yields the next event to be emitted by an EventEmitter.
|
|
31
|
-
*
|
|
32
|
-
* @param target - the event target to be watched
|
|
33
|
-
* @param name - the name of the event to watch. E.g. "click"
|
|
34
|
-
* @returns an Operation that yields the next emitted event
|
|
35
|
-
*/
|
|
36
|
-
function once(source, eventName) {
|
|
37
|
-
const result = (0, effection_1.withResolvers)();
|
|
38
|
-
let listener = (...args) => {
|
|
39
|
-
result.resolve(args);
|
|
40
|
-
source?.off(eventName, listener);
|
|
41
|
-
};
|
|
42
|
-
source?.on(eventName, listener);
|
|
43
|
-
return result.operation;
|
|
44
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/src/exec/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,OAAQ,SAAQ,KAAK;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,IAAI,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC;IAE9B;;;OAGG;IACH,MAAM,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7B;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,MAAM,WAAW,eAAe;IAC9B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;CAC7D"}
|
package/script/src/exec/api.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/src/exec/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAExD,qBAAa,SAAU,SAAQ,KAAK;IAEzB,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,WAAW;gBAFpB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,WAAW;IAKpB,IAAI,SAAe;IAE5B,IAAa,OAAO,IAAI,MAAM,CAgB7B;CACF;AAED,qBAAa,eAAgB,SAAQ,SAAS;IACnC,IAAI,SAAqB;IAElC,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF"}
|
package/script/src/exec/error.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DaemonExitError = exports.ExecError = void 0;
|
|
4
|
-
class ExecError extends Error {
|
|
5
|
-
constructor(status, command, options) {
|
|
6
|
-
super();
|
|
7
|
-
Object.defineProperty(this, "status", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value: status
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(this, "command", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: command
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "options", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: options
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(this, "name", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: "ExecError"
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
get message() {
|
|
33
|
-
let code = this.status.code ? `code: ${this.status.code}` : null;
|
|
34
|
-
let signal = this.status.signal ? `signal: ${this.status.signal}` : null;
|
|
35
|
-
let env = `env: ${JSON.stringify(this.options.env || {})}`;
|
|
36
|
-
let shell = this.options.shell ? `shell: ${this.options.shell}` : null;
|
|
37
|
-
let cwd = this.options.cwd ? `cwd: ${this.options.cwd}` : null;
|
|
38
|
-
let command = `$ ${this.command} ${this.options.arguments?.join(" ")}`
|
|
39
|
-
.trim();
|
|
40
|
-
return [code, signal, env, shell, cwd, command].filter((item) => !!item)
|
|
41
|
-
.join("\n");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.ExecError = ExecError;
|
|
45
|
-
class DaemonExitError extends ExecError {
|
|
46
|
-
constructor() {
|
|
47
|
-
super(...arguments);
|
|
48
|
-
Object.defineProperty(this, "name", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
configurable: true,
|
|
51
|
-
writable: true,
|
|
52
|
-
value: "DaemonExitError"
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
get message() {
|
|
56
|
-
return `daemon process quit unexpectedly\n${super.message}`;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.DaemonExitError = DaemonExitError;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"posix.d.ts","sourceRoot":"","sources":["../../../src/src/exec/posix.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,UAAU,CAAC;AAKtE,eAAO,MAAM,kBAAkB,EAAE,eAkHhC,CAAC"}
|