@checksum-ai/runtime 1.1.3 → 1.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checksum-ai/runtime",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Checksum.ai test runtime",
5
5
  "main": "index.js",
6
6
  "dependencies": {
package/repl.js ADDED
@@ -0,0 +1,60 @@
1
+ // To connect to a test run, in the test itself add test.use({
2
+ // launchOptions: {
3
+ // args: ['--remote-debugging-port=9222']
4
+ // }
5
+ // });
6
+
7
+ const repl = require("repl");
8
+ const playwright = require("playwright");
9
+ const completions = [".help", ".exit", ".load", ".save", "playwright"];
10
+
11
+ const awaitSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
12
+
13
+ // https://nodejs.org/api/readline.html#readline_use_of_the_completer_function
14
+ function completer(line) {
15
+ const hits = completions.filter((c) => c.startsWith(line));
16
+ return [hits.length ? hits : completions, line];
17
+ }
18
+
19
+ async function connect() {
20
+ const port = "9222";
21
+ const browser = await playwright.chromium.connectOverCDP(
22
+ "http://127.0.0.1:" + port
23
+ );
24
+ const context = browser.contexts()[0];
25
+ context.setDefaultTimeout(0);
26
+ context.setDefaultNavigationTimeout(0);
27
+ let page = context.pages()[0];
28
+ while (!page) {
29
+ await awaitSleep(1000);
30
+ page = context.pages()[0];
31
+ }
32
+ return { browser, context, page };
33
+ }
34
+
35
+ async function start() {
36
+ const props = await connect();
37
+ console.log("Connected to test page");
38
+ completions.push(...Object.keys(props));
39
+ const r = repl.start({
40
+ prompt: "> ",
41
+ useColors: true,
42
+ preview: true,
43
+ completer,
44
+ });
45
+ Object.assign(r.context, props);
46
+ }
47
+
48
+ async function startWithRetry() {
49
+ try {
50
+ await start();
51
+ } catch (e) {
52
+ await awaitSleep(2000);
53
+ await startWithRetry();
54
+ }
55
+ }
56
+
57
+ (async () => {
58
+ console.log("Connecting to test page and starting REPL...");
59
+ await startWithRetry();
60
+ })();
package/scripts/patch.js CHANGED
@@ -248,11 +248,17 @@ function channelOwner(projectRoot) {
248
248
 
249
249
  const isRuntime = true || process.env.RUNTIME === "true";
250
250
  const projectRootFromEnv = process.env.PROJECT_ROOT;
251
+
251
252
  const projectPaths = projectRootFromEnv
252
253
  ? [projectRootFromEnv]
253
- : ["backend", "lib", "frontend", "runtime"].map((project) =>
254
- join(__dirname, "..", project)
255
- );
254
+ : [
255
+ ".",
256
+ "../checksum-ai-libs/lib",
257
+ "../backend",
258
+ "../libs/lib",
259
+ "../frontend",
260
+ "../runtime",
261
+ ].map((project) => join(process.cwd(), project));
256
262
 
257
263
  for (const projectPath of projectPaths) {
258
264
  try {
@@ -265,6 +271,8 @@ for (const projectPath of projectPaths) {
265
271
  testType(projectPath);
266
272
  channelOwner(projectPath);
267
273
  }
274
+ } else {
275
+ console.warn("Project path not found", projectPath);
268
276
  }
269
277
  } catch (e) {
270
278
  console.warn("Unable to patch playwright", projectPath, e);