goke 6.7.0 → 6.8.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/dist/__test__/just-bash.test.js +90 -0
- package/dist/goke.d.ts +76 -2
- package/dist/goke.d.ts.map +1 -1
- package/dist/goke.js +54 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__test__/just-bash.test.ts +101 -1
- package/src/goke.ts +95 -12
- package/src/index.ts +1 -1
|
@@ -4,6 +4,31 @@
|
|
|
4
4
|
import { describe, expect, test } from 'vitest';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import goke from '../index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Build a minimal `GokeFs` stub where every method throws unless the
|
|
9
|
+
* caller overrides it. Used by `createExecutionContext` tests that
|
|
10
|
+
* only care about a single method (e.g. `readFile`) but still need
|
|
11
|
+
* an object that satisfies the full `GokeFs` interface.
|
|
12
|
+
*/
|
|
13
|
+
function stubGokeFs(overrides) {
|
|
14
|
+
const notImplemented = () => { throw new Error('not implemented in stub'); };
|
|
15
|
+
return {
|
|
16
|
+
appendFile: notImplemented,
|
|
17
|
+
chmod: notImplemented,
|
|
18
|
+
copyFile: notImplemented,
|
|
19
|
+
link: notImplemented,
|
|
20
|
+
mkdir: notImplemented,
|
|
21
|
+
readFile: notImplemented,
|
|
22
|
+
readlink: notImplemented,
|
|
23
|
+
realpath: notImplemented,
|
|
24
|
+
rename: notImplemented,
|
|
25
|
+
rm: notImplemented,
|
|
26
|
+
symlink: notImplemented,
|
|
27
|
+
utimes: notImplemented,
|
|
28
|
+
writeFile: notImplemented,
|
|
29
|
+
...overrides,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
7
32
|
const ANSI_RE = /\x1B\[[0-9;]*m/g;
|
|
8
33
|
const stripAnsi = (text) => text.replace(ANSI_RE, '');
|
|
9
34
|
function createTestOutputStream() {
|
|
@@ -62,6 +87,71 @@ describe('clone', () => {
|
|
|
62
87
|
expect(cli.matchedCommandName).toBeUndefined();
|
|
63
88
|
});
|
|
64
89
|
});
|
|
90
|
+
describe('createExecutionContext', () => {
|
|
91
|
+
test('returns a context that mirrors the cli defaults when called with no override', () => {
|
|
92
|
+
const stdout = createTestOutputStream();
|
|
93
|
+
const stderr = createTestOutputStream();
|
|
94
|
+
const cli = gokeTestable('mycli', {
|
|
95
|
+
cwd: '/workspace',
|
|
96
|
+
env: { TOKEN: 'abc' },
|
|
97
|
+
stdin: 'stdin-text',
|
|
98
|
+
stdout,
|
|
99
|
+
stderr,
|
|
100
|
+
});
|
|
101
|
+
const ctx = cli.createExecutionContext();
|
|
102
|
+
expect(ctx.process.cwd).toBe('/workspace');
|
|
103
|
+
expect(ctx.process.env.TOKEN).toBe('abc');
|
|
104
|
+
expect(ctx.process.stdin).toBe('stdin-text');
|
|
105
|
+
expect(ctx.process.stdout).toBe(stdout);
|
|
106
|
+
expect(ctx.process.stderr).toBe(stderr);
|
|
107
|
+
ctx.console.log('hi');
|
|
108
|
+
expect(stdout.text).toBe('hi\n');
|
|
109
|
+
});
|
|
110
|
+
test('honors per-call overrides for stdout, cwd, env, stdin, fs, and exit', async () => {
|
|
111
|
+
const defaultStdout = createTestOutputStream();
|
|
112
|
+
const defaultFs = stubGokeFs({ readFile: async () => 'default' });
|
|
113
|
+
const cli = gokeTestable('mycli', {
|
|
114
|
+
cwd: '/default',
|
|
115
|
+
env: { DEFAULT: '1' },
|
|
116
|
+
stdin: 'default-stdin',
|
|
117
|
+
stdout: defaultStdout,
|
|
118
|
+
fs: defaultFs,
|
|
119
|
+
});
|
|
120
|
+
const overrideStdout = createTestOutputStream();
|
|
121
|
+
const overrideStderr = createTestOutputStream();
|
|
122
|
+
const overrideFs = stubGokeFs({ readFile: async () => 'override' });
|
|
123
|
+
let receivedExitCode;
|
|
124
|
+
const ctx = cli.createExecutionContext({
|
|
125
|
+
cwd: '/tenant',
|
|
126
|
+
env: { TOKEN: 'xyz' },
|
|
127
|
+
stdin: 'tenant-stdin',
|
|
128
|
+
stdout: overrideStdout,
|
|
129
|
+
stderr: overrideStderr,
|
|
130
|
+
fs: overrideFs,
|
|
131
|
+
exit: (code) => {
|
|
132
|
+
receivedExitCode = code;
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
expect(ctx.process.cwd).toBe('/tenant');
|
|
136
|
+
expect(ctx.process.env.TOKEN).toBe('xyz');
|
|
137
|
+
expect(ctx.process.env.DEFAULT).toBeUndefined();
|
|
138
|
+
expect(ctx.process.stdin).toBe('tenant-stdin');
|
|
139
|
+
expect(ctx.process.stdout).toBe(overrideStdout);
|
|
140
|
+
expect(ctx.process.stderr).toBe(overrideStderr);
|
|
141
|
+
expect(ctx.fs).toBe(overrideFs);
|
|
142
|
+
expect(await ctx.fs.readFile('unused')).toBe('override');
|
|
143
|
+
// The cli's own stdout must NOT receive writes made through the
|
|
144
|
+
// override. This is what makes per-request capturing safe.
|
|
145
|
+
ctx.console.log('per-tenant');
|
|
146
|
+
expect(defaultStdout.text).toBe('');
|
|
147
|
+
expect(overrideStdout.text).toBe('per-tenant\n');
|
|
148
|
+
// Custom exit callback runs, then the wrapper throws GokeProcessExit
|
|
149
|
+
// so the action's code path stops at the exit site.
|
|
150
|
+
const { GokeProcessExit } = await import('../goke.js');
|
|
151
|
+
expect(() => ctx.process.exit(7)).toThrow(GokeProcessExit);
|
|
152
|
+
expect(receivedExitCode).toBe(7);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
65
155
|
describe('createJustBashCommand', () => {
|
|
66
156
|
test('runs multi-word goke subcommands through one just-bash command', async () => {
|
|
67
157
|
const cli = gokeTestable('parent');
|
package/dist/goke.d.ts
CHANGED
|
@@ -330,6 +330,44 @@ interface GokeExecutionContext {
|
|
|
330
330
|
fs: GokeFs;
|
|
331
331
|
process: GokeProcess;
|
|
332
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Per-request overrides accepted by `Goke#createExecutionContext()`.
|
|
335
|
+
*
|
|
336
|
+
* Any field left `undefined` falls back to the `Goke` instance's
|
|
337
|
+
* defaults (set via `GokeOptions`), which themselves fall back to the
|
|
338
|
+
* real Node.js `process.*`. Use this to construct an execution context
|
|
339
|
+
* with tenant-specific values — e.g. a per-user `cwd`/`env`/`fs` pair
|
|
340
|
+
* for a remote MCP server, or capture streams for stdout/stderr.
|
|
341
|
+
*
|
|
342
|
+
* Passing a custom `exit` replaces the default behavior of calling
|
|
343
|
+
* `this.exit(code)`. The returned `process.exit` still throws
|
|
344
|
+
* `GokeProcessExit` after the user-provided `exit` returns, so callers
|
|
345
|
+
* can catch the exit without the outer code needing to know about it.
|
|
346
|
+
*/
|
|
347
|
+
interface GokeExecutionContextOverride {
|
|
348
|
+
/** Override the argv array exposed as `process.argv`. Defaults to the cli's raw parsed argv. */
|
|
349
|
+
argv?: string[];
|
|
350
|
+
/** Override the working directory exposed as `process.cwd`. */
|
|
351
|
+
cwd?: string;
|
|
352
|
+
/** Override the environment exposed as `process.env`. */
|
|
353
|
+
env?: Record<string, string | undefined>;
|
|
354
|
+
/** Override the filesystem exposed as `ctx.fs`. */
|
|
355
|
+
fs?: GokeFs;
|
|
356
|
+
/** Override the stdin content exposed as `process.stdin`. */
|
|
357
|
+
stdin?: string;
|
|
358
|
+
/** Override the stdout stream used by `ctx.console.log` and exposed as `process.stdout`. */
|
|
359
|
+
stdout?: GokeOutputStream;
|
|
360
|
+
/** Override the stderr stream used by `ctx.console.error` and exposed as `process.stderr`. */
|
|
361
|
+
stderr?: GokeOutputStream;
|
|
362
|
+
/**
|
|
363
|
+
* Override the exit function called by `process.exit(code)`.
|
|
364
|
+
*
|
|
365
|
+
* The returned context still throws `GokeProcessExit` after this
|
|
366
|
+
* callback returns, so callers that want to capture the exit
|
|
367
|
+
* without killing the host process can pass `() => {}`.
|
|
368
|
+
*/
|
|
369
|
+
exit?: (code: number) => void;
|
|
370
|
+
}
|
|
333
371
|
declare class GokeProcessExit extends Error {
|
|
334
372
|
code: number;
|
|
335
373
|
constructor(code: number);
|
|
@@ -424,7 +462,43 @@ declare class Goke<Opts = {}> extends EventEmitter {
|
|
|
424
462
|
*/
|
|
425
463
|
constructor(name?: string, options?: GokeOptions);
|
|
426
464
|
clone(options?: GokeOptions): Goke<Opts>;
|
|
427
|
-
|
|
465
|
+
/**
|
|
466
|
+
* Build a `GokeExecutionContext` using this cli's defaults, optionally
|
|
467
|
+
* overridden per-request.
|
|
468
|
+
*
|
|
469
|
+
* `runMatchedCommand()` calls this internally with no arguments to
|
|
470
|
+
* construct the context passed to command actions and middlewares.
|
|
471
|
+
*
|
|
472
|
+
* The method is also public so adapters (MCP, remote RPC, batch
|
|
473
|
+
* runners, etc.) can build a context for a single invocation with
|
|
474
|
+
* tenant-specific values — e.g. capture streams for stdout/stderr,
|
|
475
|
+
* a per-user `cwd`/`env`/`fs`, or an `exit` that throws instead of
|
|
476
|
+
* killing the host process. See {@link GokeExecutionContextOverride}.
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```ts
|
|
480
|
+
* // Build an execution context that captures output into strings and
|
|
481
|
+
* // treats `ctx.process.exit(code)` as a `GokeProcessExit` throw
|
|
482
|
+
* // instead of terminating the host process.
|
|
483
|
+
* const stdout = createTextCaptureStream()
|
|
484
|
+
* const stderr = createTextCaptureStream()
|
|
485
|
+
* const ctx = cli.createExecutionContext({
|
|
486
|
+
* stdout,
|
|
487
|
+
* stderr,
|
|
488
|
+
* exit: () => {},
|
|
489
|
+
* })
|
|
490
|
+
* try {
|
|
491
|
+
* await action(...args, options, ctx)
|
|
492
|
+
* } catch (err) {
|
|
493
|
+
* if (err instanceof GokeProcessExit) {
|
|
494
|
+
* // handle exit code
|
|
495
|
+
* } else {
|
|
496
|
+
* throw err
|
|
497
|
+
* }
|
|
498
|
+
* }
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
createExecutionContext(override?: GokeExecutionContextOverride): GokeExecutionContext;
|
|
428
502
|
createJustBashCommand(options?: {
|
|
429
503
|
name?: string;
|
|
430
504
|
}): Promise<import("./just-bash.js").JustBashCommand>;
|
|
@@ -537,7 +611,7 @@ declare class Goke<Opts = {}> extends EventEmitter {
|
|
|
537
611
|
private mri;
|
|
538
612
|
runMatchedCommand(): any;
|
|
539
613
|
}
|
|
540
|
-
export type { GokeOutputStream, GokeConsole, GokeOptions, GokeProcess, GokeExecutionContext, GokeFs };
|
|
614
|
+
export type { GokeOutputStream, GokeConsole, GokeOptions, GokeProcess, GokeExecutionContext, GokeExecutionContextOverride, GokeFs };
|
|
541
615
|
export { createConsole, Command, GokeProcessExit, openInBrowser };
|
|
542
616
|
export default Goke;
|
|
543
617
|
//# sourceMappingURL=goke.d.ts.map
|
package/dist/goke.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goke.d.ts","sourceRoot":"","sources":["../src/goke.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAmB,aAAa,EAAW,MAAM,UAAU,CAAA;AAmNhF,cAAM,MAAM;IAwBD,OAAO,EAAE,MAAM;IAvBxB,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,8BAA8B;IAC9B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,qEAAqE;IACrE,MAAM,CAAC,EAAE,oBAAoB,CAAA;IAC7B,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB;;;;;OAKG;gBAEM,OAAO,EAAE,MAAM,EACtB,mBA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OAGG;IACH,aAAa;IAIb,OAAO,CAAC,aAAa;IAgBrB,mBAAmB;IAKnB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACH,KAAK,CACH,IAAI,WAAoB,EACxB;IACE,oDAAoD;IACpD,GAAU,GACX;;KAAK,GACL,UAAU;IA2Ib,OAAO,CAAC,GAAG;IAwJX,iBAAiB;CA0FlB;AAID,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,EAAE,CAAA;AACnI,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,CAAA;AACjE,eAAe,IAAI,CAAA"}
|
package/dist/goke.js
CHANGED
|
@@ -729,19 +729,63 @@ class Goke extends EventEmitter {
|
|
|
729
729
|
}
|
|
730
730
|
return cloned;
|
|
731
731
|
}
|
|
732
|
-
|
|
732
|
+
/**
|
|
733
|
+
* Build a `GokeExecutionContext` using this cli's defaults, optionally
|
|
734
|
+
* overridden per-request.
|
|
735
|
+
*
|
|
736
|
+
* `runMatchedCommand()` calls this internally with no arguments to
|
|
737
|
+
* construct the context passed to command actions and middlewares.
|
|
738
|
+
*
|
|
739
|
+
* The method is also public so adapters (MCP, remote RPC, batch
|
|
740
|
+
* runners, etc.) can build a context for a single invocation with
|
|
741
|
+
* tenant-specific values — e.g. capture streams for stdout/stderr,
|
|
742
|
+
* a per-user `cwd`/`env`/`fs`, or an `exit` that throws instead of
|
|
743
|
+
* killing the host process. See {@link GokeExecutionContextOverride}.
|
|
744
|
+
*
|
|
745
|
+
* @example
|
|
746
|
+
* ```ts
|
|
747
|
+
* // Build an execution context that captures output into strings and
|
|
748
|
+
* // treats `ctx.process.exit(code)` as a `GokeProcessExit` throw
|
|
749
|
+
* // instead of terminating the host process.
|
|
750
|
+
* const stdout = createTextCaptureStream()
|
|
751
|
+
* const stderr = createTextCaptureStream()
|
|
752
|
+
* const ctx = cli.createExecutionContext({
|
|
753
|
+
* stdout,
|
|
754
|
+
* stderr,
|
|
755
|
+
* exit: () => {},
|
|
756
|
+
* })
|
|
757
|
+
* try {
|
|
758
|
+
* await action(...args, options, ctx)
|
|
759
|
+
* } catch (err) {
|
|
760
|
+
* if (err instanceof GokeProcessExit) {
|
|
761
|
+
* // handle exit code
|
|
762
|
+
* } else {
|
|
763
|
+
* throw err
|
|
764
|
+
* }
|
|
765
|
+
* }
|
|
766
|
+
* ```
|
|
767
|
+
*/
|
|
768
|
+
createExecutionContext(override) {
|
|
769
|
+
const stdout = override?.stdout ?? this.stdout;
|
|
770
|
+
const stderr = override?.stderr ?? this.stderr;
|
|
771
|
+
// Reuse the cached console when streams aren't overridden; otherwise
|
|
772
|
+
// build a new one so ctx.console.log writes to the overridden streams.
|
|
773
|
+
const contextConsole = (override?.stdout !== undefined || override?.stderr !== undefined)
|
|
774
|
+
? createConsole(stdout, stderr)
|
|
775
|
+
: this.console;
|
|
776
|
+
const exitFn = override?.exit ?? this.exit;
|
|
733
777
|
return {
|
|
734
|
-
console:
|
|
735
|
-
fs: this.fs,
|
|
778
|
+
console: contextConsole,
|
|
779
|
+
fs: override?.fs ?? this.fs,
|
|
736
780
|
process: {
|
|
737
|
-
argv,
|
|
738
|
-
cwd: this.cwd ?? process.cwd(),
|
|
739
|
-
env: this.env ?? process.env,
|
|
740
|
-
stdin: this.stdin ?? '',
|
|
741
|
-
stdout
|
|
742
|
-
stderr
|
|
781
|
+
argv: override?.argv ?? this.rawArgs,
|
|
782
|
+
cwd: override?.cwd ?? this.cwd ?? process.cwd(),
|
|
783
|
+
env: override?.env ?? this.env ?? process.env,
|
|
784
|
+
stdin: override?.stdin ?? this.stdin ?? '',
|
|
785
|
+
stdout,
|
|
786
|
+
stderr,
|
|
743
787
|
exit: (code) => {
|
|
744
|
-
|
|
788
|
+
exitFn(code);
|
|
745
789
|
throw new GokeProcessExit(code);
|
|
746
790
|
},
|
|
747
791
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare const goke: (name?: string, options?: GokeOptions) => Goke<{}>;
|
|
|
9
9
|
export default goke;
|
|
10
10
|
export { goke, Goke, Command };
|
|
11
11
|
export { createConsole, GokeProcessExit, openInBrowser } from "./goke.js";
|
|
12
|
-
export type { GokeOutputStream, GokeConsole, GokeExecutionContext, GokeFs, GokeOptions, GokeProcess } from "./goke.js";
|
|
12
|
+
export type { GokeOutputStream, GokeConsole, GokeExecutionContext, GokeExecutionContextOverride, GokeFs, GokeOptions, GokeProcess } from "./goke.js";
|
|
13
13
|
export type { StandardTypedV1, StandardJSONSchemaV1, JsonSchema } from "./coerce.js";
|
|
14
14
|
export { GokeError, coerceBySchema, extractJsonSchema, wrapJsonSchema, isStandardSchema, extractSchemaMetadata } from "./coerce.js";
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC;;;GAGG;AACH,QAAA,MAAM,IAAI,GAAI,aAAS,EAAE,UAAU,WAAW,aAA4B,CAAA;AAE1E,eAAe,IAAI,CAAA;AACnB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC;;;GAGG;AACH,QAAA,MAAM,IAAI,GAAI,aAAS,EAAE,UAAU,WAAW,aAA4B,CAAA;AAE1E,eAAe,IAAI,CAAA;AACnB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACpJ,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA"}
|
package/package.json
CHANGED
|
@@ -5,7 +5,33 @@
|
|
|
5
5
|
import { describe, expect, test } from 'vitest'
|
|
6
6
|
import { z } from 'zod'
|
|
7
7
|
import goke from '../index.js'
|
|
8
|
-
import type { GokeOutputStream, GokeOptions } from '../index.js'
|
|
8
|
+
import type { GokeOutputStream, GokeOptions, GokeFs } from '../index.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Build a minimal `GokeFs` stub where every method throws unless the
|
|
12
|
+
* caller overrides it. Used by `createExecutionContext` tests that
|
|
13
|
+
* only care about a single method (e.g. `readFile`) but still need
|
|
14
|
+
* an object that satisfies the full `GokeFs` interface.
|
|
15
|
+
*/
|
|
16
|
+
function stubGokeFs(overrides: Partial<GokeFs>): GokeFs {
|
|
17
|
+
const notImplemented = () => { throw new Error('not implemented in stub') }
|
|
18
|
+
return {
|
|
19
|
+
appendFile: notImplemented,
|
|
20
|
+
chmod: notImplemented,
|
|
21
|
+
copyFile: notImplemented,
|
|
22
|
+
link: notImplemented,
|
|
23
|
+
mkdir: notImplemented,
|
|
24
|
+
readFile: notImplemented,
|
|
25
|
+
readlink: notImplemented,
|
|
26
|
+
realpath: notImplemented,
|
|
27
|
+
rename: notImplemented,
|
|
28
|
+
rm: notImplemented,
|
|
29
|
+
symlink: notImplemented,
|
|
30
|
+
utimes: notImplemented,
|
|
31
|
+
writeFile: notImplemented,
|
|
32
|
+
...overrides,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
9
35
|
|
|
10
36
|
const ANSI_RE = /\x1B\[[0-9;]*m/g
|
|
11
37
|
|
|
@@ -82,6 +108,80 @@ describe('clone', () => {
|
|
|
82
108
|
})
|
|
83
109
|
})
|
|
84
110
|
|
|
111
|
+
describe('createExecutionContext', () => {
|
|
112
|
+
test('returns a context that mirrors the cli defaults when called with no override', () => {
|
|
113
|
+
const stdout = createTestOutputStream()
|
|
114
|
+
const stderr = createTestOutputStream()
|
|
115
|
+
const cli = gokeTestable('mycli', {
|
|
116
|
+
cwd: '/workspace',
|
|
117
|
+
env: { TOKEN: 'abc' },
|
|
118
|
+
stdin: 'stdin-text',
|
|
119
|
+
stdout,
|
|
120
|
+
stderr,
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
const ctx = cli.createExecutionContext()
|
|
124
|
+
|
|
125
|
+
expect(ctx.process.cwd).toBe('/workspace')
|
|
126
|
+
expect(ctx.process.env.TOKEN).toBe('abc')
|
|
127
|
+
expect(ctx.process.stdin).toBe('stdin-text')
|
|
128
|
+
expect(ctx.process.stdout).toBe(stdout)
|
|
129
|
+
expect(ctx.process.stderr).toBe(stderr)
|
|
130
|
+
|
|
131
|
+
ctx.console.log('hi')
|
|
132
|
+
expect(stdout.text).toBe('hi\n')
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test('honors per-call overrides for stdout, cwd, env, stdin, fs, and exit', async () => {
|
|
136
|
+
const defaultStdout = createTestOutputStream()
|
|
137
|
+
const defaultFs = stubGokeFs({ readFile: async () => 'default' })
|
|
138
|
+
const cli = gokeTestable('mycli', {
|
|
139
|
+
cwd: '/default',
|
|
140
|
+
env: { DEFAULT: '1' },
|
|
141
|
+
stdin: 'default-stdin',
|
|
142
|
+
stdout: defaultStdout,
|
|
143
|
+
fs: defaultFs,
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const overrideStdout = createTestOutputStream()
|
|
147
|
+
const overrideStderr = createTestOutputStream()
|
|
148
|
+
const overrideFs = stubGokeFs({ readFile: async () => 'override' })
|
|
149
|
+
let receivedExitCode: number | undefined
|
|
150
|
+
const ctx = cli.createExecutionContext({
|
|
151
|
+
cwd: '/tenant',
|
|
152
|
+
env: { TOKEN: 'xyz' },
|
|
153
|
+
stdin: 'tenant-stdin',
|
|
154
|
+
stdout: overrideStdout,
|
|
155
|
+
stderr: overrideStderr,
|
|
156
|
+
fs: overrideFs,
|
|
157
|
+
exit: (code) => {
|
|
158
|
+
receivedExitCode = code
|
|
159
|
+
},
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
expect(ctx.process.cwd).toBe('/tenant')
|
|
163
|
+
expect(ctx.process.env.TOKEN).toBe('xyz')
|
|
164
|
+
expect(ctx.process.env.DEFAULT).toBeUndefined()
|
|
165
|
+
expect(ctx.process.stdin).toBe('tenant-stdin')
|
|
166
|
+
expect(ctx.process.stdout).toBe(overrideStdout)
|
|
167
|
+
expect(ctx.process.stderr).toBe(overrideStderr)
|
|
168
|
+
expect(ctx.fs).toBe(overrideFs)
|
|
169
|
+
expect(await ctx.fs.readFile('unused')).toBe('override')
|
|
170
|
+
|
|
171
|
+
// The cli's own stdout must NOT receive writes made through the
|
|
172
|
+
// override. This is what makes per-request capturing safe.
|
|
173
|
+
ctx.console.log('per-tenant')
|
|
174
|
+
expect(defaultStdout.text).toBe('')
|
|
175
|
+
expect(overrideStdout.text).toBe('per-tenant\n')
|
|
176
|
+
|
|
177
|
+
// Custom exit callback runs, then the wrapper throws GokeProcessExit
|
|
178
|
+
// so the action's code path stops at the exit site.
|
|
179
|
+
const { GokeProcessExit } = await import('../goke.js')
|
|
180
|
+
expect(() => ctx.process.exit(7)).toThrow(GokeProcessExit)
|
|
181
|
+
expect(receivedExitCode).toBe(7)
|
|
182
|
+
})
|
|
183
|
+
})
|
|
184
|
+
|
|
85
185
|
describe('createJustBashCommand', () => {
|
|
86
186
|
test('runs multi-word goke subcommands through one just-bash command', async () => {
|
|
87
187
|
const cli = gokeTestable('parent')
|
package/src/goke.ts
CHANGED
|
@@ -1000,6 +1000,45 @@ interface GokeExecutionContext {
|
|
|
1000
1000
|
process: GokeProcess
|
|
1001
1001
|
}
|
|
1002
1002
|
|
|
1003
|
+
/**
|
|
1004
|
+
* Per-request overrides accepted by `Goke#createExecutionContext()`.
|
|
1005
|
+
*
|
|
1006
|
+
* Any field left `undefined` falls back to the `Goke` instance's
|
|
1007
|
+
* defaults (set via `GokeOptions`), which themselves fall back to the
|
|
1008
|
+
* real Node.js `process.*`. Use this to construct an execution context
|
|
1009
|
+
* with tenant-specific values — e.g. a per-user `cwd`/`env`/`fs` pair
|
|
1010
|
+
* for a remote MCP server, or capture streams for stdout/stderr.
|
|
1011
|
+
*
|
|
1012
|
+
* Passing a custom `exit` replaces the default behavior of calling
|
|
1013
|
+
* `this.exit(code)`. The returned `process.exit` still throws
|
|
1014
|
+
* `GokeProcessExit` after the user-provided `exit` returns, so callers
|
|
1015
|
+
* can catch the exit without the outer code needing to know about it.
|
|
1016
|
+
*/
|
|
1017
|
+
interface GokeExecutionContextOverride {
|
|
1018
|
+
/** Override the argv array exposed as `process.argv`. Defaults to the cli's raw parsed argv. */
|
|
1019
|
+
argv?: string[]
|
|
1020
|
+
/** Override the working directory exposed as `process.cwd`. */
|
|
1021
|
+
cwd?: string
|
|
1022
|
+
/** Override the environment exposed as `process.env`. */
|
|
1023
|
+
env?: Record<string, string | undefined>
|
|
1024
|
+
/** Override the filesystem exposed as `ctx.fs`. */
|
|
1025
|
+
fs?: GokeFs
|
|
1026
|
+
/** Override the stdin content exposed as `process.stdin`. */
|
|
1027
|
+
stdin?: string
|
|
1028
|
+
/** Override the stdout stream used by `ctx.console.log` and exposed as `process.stdout`. */
|
|
1029
|
+
stdout?: GokeOutputStream
|
|
1030
|
+
/** Override the stderr stream used by `ctx.console.error` and exposed as `process.stderr`. */
|
|
1031
|
+
stderr?: GokeOutputStream
|
|
1032
|
+
/**
|
|
1033
|
+
* Override the exit function called by `process.exit(code)`.
|
|
1034
|
+
*
|
|
1035
|
+
* The returned context still throws `GokeProcessExit` after this
|
|
1036
|
+
* callback returns, so callers that want to capture the exit
|
|
1037
|
+
* without killing the host process can pass `() => {}`.
|
|
1038
|
+
*/
|
|
1039
|
+
exit?: (code: number) => void
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1003
1042
|
class GokeProcessExit extends Error {
|
|
1004
1043
|
code: number
|
|
1005
1044
|
|
|
@@ -1193,19 +1232,63 @@ class Goke<Opts = {}> extends EventEmitter {
|
|
|
1193
1232
|
return cloned
|
|
1194
1233
|
}
|
|
1195
1234
|
|
|
1196
|
-
|
|
1235
|
+
/**
|
|
1236
|
+
* Build a `GokeExecutionContext` using this cli's defaults, optionally
|
|
1237
|
+
* overridden per-request.
|
|
1238
|
+
*
|
|
1239
|
+
* `runMatchedCommand()` calls this internally with no arguments to
|
|
1240
|
+
* construct the context passed to command actions and middlewares.
|
|
1241
|
+
*
|
|
1242
|
+
* The method is also public so adapters (MCP, remote RPC, batch
|
|
1243
|
+
* runners, etc.) can build a context for a single invocation with
|
|
1244
|
+
* tenant-specific values — e.g. capture streams for stdout/stderr,
|
|
1245
|
+
* a per-user `cwd`/`env`/`fs`, or an `exit` that throws instead of
|
|
1246
|
+
* killing the host process. See {@link GokeExecutionContextOverride}.
|
|
1247
|
+
*
|
|
1248
|
+
* @example
|
|
1249
|
+
* ```ts
|
|
1250
|
+
* // Build an execution context that captures output into strings and
|
|
1251
|
+
* // treats `ctx.process.exit(code)` as a `GokeProcessExit` throw
|
|
1252
|
+
* // instead of terminating the host process.
|
|
1253
|
+
* const stdout = createTextCaptureStream()
|
|
1254
|
+
* const stderr = createTextCaptureStream()
|
|
1255
|
+
* const ctx = cli.createExecutionContext({
|
|
1256
|
+
* stdout,
|
|
1257
|
+
* stderr,
|
|
1258
|
+
* exit: () => {},
|
|
1259
|
+
* })
|
|
1260
|
+
* try {
|
|
1261
|
+
* await action(...args, options, ctx)
|
|
1262
|
+
* } catch (err) {
|
|
1263
|
+
* if (err instanceof GokeProcessExit) {
|
|
1264
|
+
* // handle exit code
|
|
1265
|
+
* } else {
|
|
1266
|
+
* throw err
|
|
1267
|
+
* }
|
|
1268
|
+
* }
|
|
1269
|
+
* ```
|
|
1270
|
+
*/
|
|
1271
|
+
createExecutionContext(override?: GokeExecutionContextOverride): GokeExecutionContext {
|
|
1272
|
+
const stdout = override?.stdout ?? this.stdout
|
|
1273
|
+
const stderr = override?.stderr ?? this.stderr
|
|
1274
|
+
// Reuse the cached console when streams aren't overridden; otherwise
|
|
1275
|
+
// build a new one so ctx.console.log writes to the overridden streams.
|
|
1276
|
+
const contextConsole = (override?.stdout !== undefined || override?.stderr !== undefined)
|
|
1277
|
+
? createConsole(stdout, stderr)
|
|
1278
|
+
: this.console
|
|
1279
|
+
const exitFn = override?.exit ?? this.exit
|
|
1197
1280
|
return {
|
|
1198
|
-
console:
|
|
1199
|
-
fs: this.fs,
|
|
1281
|
+
console: contextConsole,
|
|
1282
|
+
fs: override?.fs ?? this.fs,
|
|
1200
1283
|
process: {
|
|
1201
|
-
argv,
|
|
1202
|
-
cwd: this.cwd ?? process.cwd(),
|
|
1203
|
-
env: this.env ?? process.env,
|
|
1204
|
-
stdin: this.stdin ?? '',
|
|
1205
|
-
stdout
|
|
1206
|
-
stderr
|
|
1207
|
-
exit: (code
|
|
1208
|
-
|
|
1284
|
+
argv: override?.argv ?? this.rawArgs,
|
|
1285
|
+
cwd: override?.cwd ?? this.cwd ?? process.cwd(),
|
|
1286
|
+
env: override?.env ?? this.env ?? process.env,
|
|
1287
|
+
stdin: override?.stdin ?? this.stdin ?? '',
|
|
1288
|
+
stdout,
|
|
1289
|
+
stderr,
|
|
1290
|
+
exit: (code) => {
|
|
1291
|
+
exitFn(code)
|
|
1209
1292
|
throw new GokeProcessExit(code)
|
|
1210
1293
|
},
|
|
1211
1294
|
},
|
|
@@ -1828,6 +1911,6 @@ class Goke<Opts = {}> extends EventEmitter {
|
|
|
1828
1911
|
|
|
1829
1912
|
// ─── Exports ───
|
|
1830
1913
|
|
|
1831
|
-
export type { GokeOutputStream, GokeConsole, GokeOptions, GokeProcess, GokeExecutionContext, GokeFs }
|
|
1914
|
+
export type { GokeOutputStream, GokeConsole, GokeOptions, GokeProcess, GokeExecutionContext, GokeExecutionContextOverride, GokeFs }
|
|
1832
1915
|
export { createConsole, Command, GokeProcessExit, openInBrowser }
|
|
1833
1916
|
export default Goke
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,6 @@ const goke = (name = '', options?: GokeOptions) => new Goke(name, options)
|
|
|
11
11
|
export default goke
|
|
12
12
|
export { goke, Goke, Command }
|
|
13
13
|
export { createConsole, GokeProcessExit, openInBrowser } from "./goke.js"
|
|
14
|
-
export type { GokeOutputStream, GokeConsole, GokeExecutionContext, GokeFs, GokeOptions, GokeProcess } from "./goke.js"
|
|
14
|
+
export type { GokeOutputStream, GokeConsole, GokeExecutionContext, GokeExecutionContextOverride, GokeFs, GokeOptions, GokeProcess } from "./goke.js"
|
|
15
15
|
export type { StandardTypedV1, StandardJSONSchemaV1, JsonSchema } from "./coerce.js"
|
|
16
16
|
export { GokeError, coerceBySchema, extractJsonSchema, wrapJsonSchema, isStandardSchema, extractSchemaMetadata } from "./coerce.js"
|