@counterfact/repl 0.1.5 → 0.1.8

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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @counterfact/repl
2
2
 
3
+ ## 0.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ad9068d]
8
+ - Updated dependencies [9871d4c]
9
+ - @counterfact/runtime@0.3.1
10
+
11
+ ## 0.1.7
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [70cbe2e]
16
+ - Updated dependencies [b0d11b6]
17
+ - @counterfact/runtime@0.3.0
18
+
19
+ ## 0.1.6
20
+
21
+ ### Patch Changes
22
+
23
+ - 96b565d: Add simulator.reset() to reconstruct stores, dependent contexts, source routes and startup state without restarting HTTP, and simulator.scenario(path, group?) to await named scenarios with the REPL arguments. Document request gating, reset failure recovery, reference lifetimes, and worker-scoped Playwright integration.
24
+ - Updated dependencies [96b565d]
25
+ - Updated dependencies [376ec98]
26
+ - @counterfact/runtime@0.2.0
27
+ - @counterfact/client@0.2.1
28
+
3
29
  ## 0.1.5
4
30
 
5
31
  ### Patch Changes
package/dist/repl.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import repl from "node:repl";
2
+ import { resolveScenario } from "@counterfact/runtime";
2
3
  import { RawHttpClient, createRouteFunction, } from "@counterfact/client";
3
4
  function printToStdout(line) {
4
5
  process.stdout.write(`${line}\n`);
@@ -361,31 +362,14 @@ export function startRepl(contextRegistry, registry, config, print = printToStdo
361
362
  this.displayPrompt();
362
363
  return;
363
364
  }
364
- const parts = scenarioPath.split("/").filter(Boolean);
365
- if (parts.length === 0) {
366
- print(usage);
367
- this.clearBufferedCommand();
368
- this.displayPrompt();
369
- return;
370
- }
371
- if (parts.some((part) => part === ".." || part === ".")) {
372
- print("Error: Path must not contain '.' or '..' segments");
373
- this.clearBufferedCommand();
374
- this.displayPrompt();
375
- return;
376
- }
377
- const functionName = parts[parts.length - 1] ?? "";
378
- const fileKey = parts.length === 1 ? "index" : parts.slice(0, -1).join("/");
379
- const module = selectedBinding.scenarioRegistry?.getModule(fileKey);
380
- if (module === undefined) {
381
- print(`Error: Could not find scenario file "${fileKey}"`);
382
- this.clearBufferedCommand();
383
- this.displayPrompt();
384
- return;
365
+ let fn;
366
+ try {
367
+ fn = resolveScenario(selectedBinding.scenarioRegistry, scenarioPath);
385
368
  }
386
- const fn = module[functionName];
387
- if (typeof fn !== "function") {
388
- print(`Error: "${functionName}" is not a function exported from "${fileKey}"`);
369
+ catch (error) {
370
+ print(scenarioPath.split("/").filter(Boolean).length === 0
371
+ ? usage
372
+ : `Error: ${error instanceof Error ? error.message : String(error)}`);
389
373
  this.clearBufferedCommand();
390
374
  this.displayPrompt();
391
375
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@counterfact/repl",
3
- "version": "0.1.5",
3
+ "version": "0.1.8",
4
4
  "description": "Inspect and manipulate a running Counterfact simulator from a Node.js REPL.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -52,7 +52,7 @@
52
52
  "test:packed-consumer": "node test/package/repl-consumer-smoke.mjs"
53
53
  },
54
54
  "dependencies": {
55
- "@counterfact/client": "0.2.0",
56
- "@counterfact/runtime": "0.1.5"
55
+ "@counterfact/client": "0.2.1",
56
+ "@counterfact/runtime": "0.3.1"
57
57
  }
58
58
  }