@elench/testkit 0.1.135 → 0.1.137

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.
Files changed (43) hide show
  1. package/README.md +38 -0
  2. package/lib/cli/commands/local/down.mjs +37 -0
  3. package/lib/cli/commands/local/env.mjs +31 -0
  4. package/lib/cli/commands/local/logs.mjs +35 -0
  5. package/lib/cli/commands/local/shell.mjs +49 -0
  6. package/lib/cli/commands/local/status.mjs +34 -0
  7. package/lib/cli/commands/local/up.mjs +39 -0
  8. package/lib/cli/entrypoint.mjs +6 -0
  9. package/lib/cli/renderers/status/text.mjs +14 -0
  10. package/lib/config/index.mjs +154 -0
  11. package/lib/config/validation.mjs +9 -0
  12. package/lib/config-api/index.d.ts +53 -0
  13. package/lib/config-api/index.mjs +14 -0
  14. package/lib/database/fingerprint.mjs +13 -33
  15. package/lib/database/index.mjs +27 -12
  16. package/lib/database/schema-source.mjs +3 -1
  17. package/lib/docker-compat/matrix.mjs +135 -0
  18. package/lib/env/index.d.ts +1 -0
  19. package/lib/env/index.mjs +5 -1
  20. package/lib/kiln/client.mjs +100 -0
  21. package/lib/local/kiln-driver.mjs +544 -0
  22. package/lib/local/lifecycle.mjs +289 -0
  23. package/lib/local/orchestrator.mjs +343 -0
  24. package/lib/repo/fingerprint-policy.mjs +145 -0
  25. package/lib/repo/state.mjs +46 -44
  26. package/lib/runner/maintenance.mjs +23 -0
  27. package/lib/runner/processes.mjs +45 -6
  28. package/lib/runner/readiness.mjs +12 -1
  29. package/lib/runner/runtime-preparation.mjs +10 -5
  30. package/lib/runner/services.mjs +24 -18
  31. package/lib/runner/status-model.mjs +27 -0
  32. package/lib/runner/template.mjs +39 -1
  33. package/node_modules/@elench/next-analysis/package.json +1 -1
  34. package/node_modules/@elench/testkit-bridge/package.json +2 -2
  35. package/node_modules/@elench/testkit-protocol/package.json +1 -1
  36. package/node_modules/@elench/ts-analysis/package.json +1 -1
  37. package/node_modules/es-toolkit/CHANGELOG.md +801 -0
  38. package/node_modules/es-toolkit/src/compat/_internal/Equals.d.ts +1 -0
  39. package/node_modules/es-toolkit/src/compat/_internal/IsWritable.d.ts +3 -0
  40. package/node_modules/es-toolkit/src/compat/_internal/MutableList.d.ts +4 -0
  41. package/node_modules/es-toolkit/src/compat/_internal/RejectReadonly.d.ts +4 -0
  42. package/node_modules/esprima/ChangeLog +235 -0
  43. package/package.json +8 -5
@@ -12,9 +12,11 @@ export function resolveRuntimeInstanceConfigs(runtimeConfigs, runtimeId, runtime
12
12
  const portMap = buildPortMap(runtimeConfigs, runtimeId, {
13
13
  index: options.portNamespaceIndex || 0,
14
14
  stride: options.portNamespaceStride || 1,
15
+ portOffset: options.portOffset || 0,
15
16
  });
16
17
  const baseUrlByService = new Map();
17
18
  const readyUrlByService = new Map();
19
+ const publicBaseUrlByService = new Map();
18
20
  const stateDirByService = new Map();
19
21
 
20
22
  for (const config of runtimeConfigs) {
@@ -48,6 +50,9 @@ export function resolveRuntimeInstanceConfigs(runtimeConfigs, runtimeId, runtime
48
50
  })
49
51
  );
50
52
  }
53
+ for (const [serviceName, baseUrl] of baseUrlByService.entries()) {
54
+ publicBaseUrlByService.set(serviceName, publicUrl(baseUrl, options.publicHost || null));
55
+ }
51
56
 
52
57
  const urlMappings = [];
53
58
  for (const config of runtimeConfigs) {
@@ -67,6 +72,8 @@ export function resolveRuntimeInstanceConfigs(runtimeConfigs, runtimeId, runtime
67
72
  portMap,
68
73
  baseUrlByService,
69
74
  readyUrlByService,
75
+ publicBaseUrlByService,
76
+ options.publicHost || null,
70
77
  stateDirByService,
71
78
  urlMappings
72
79
  )
@@ -76,7 +83,7 @@ export function resolveRuntimeInstanceConfigs(runtimeConfigs, runtimeId, runtime
76
83
  export function buildPortMap(runtimeConfigs, runtimeId, namespace = {}) {
77
84
  const portMap = new Map();
78
85
  const seen = new Map();
79
- const offset = runtimePortOffset(runtimeId, namespace);
86
+ const offset = runtimePortOffset(runtimeId, namespace) + Number(namespace.portOffset || 0);
80
87
 
81
88
  for (const config of runtimeConfigs) {
82
89
  if (!config.testkit.local) continue;
@@ -113,6 +120,8 @@ export function resolveRuntimeConfig(
113
120
  portMap,
114
121
  baseUrlByService,
115
122
  readyUrlByService,
123
+ publicBaseUrlByService,
124
+ publicHost,
116
125
  stateDirByService,
117
126
  urlMappings
118
127
  ) {
@@ -129,6 +138,8 @@ export function resolveRuntimeConfig(
129
138
  portMap,
130
139
  baseUrlByService,
131
140
  readyUrlByService,
141
+ publicBaseUrlByService,
142
+ publicHost,
132
143
  stateDirByService,
133
144
  urlMappings,
134
145
  leaseId: null,
@@ -242,7 +253,11 @@ function buildExecutionEnvWithContext(config, lease, extraEnv, processEnv, optio
242
253
  ...resolveEnvTemplates(localEnv, templateContext),
243
254
  ...resolveEnvTemplates(extraEnv, templateContext),
244
255
  TESTKIT_ACTIVE: "1",
256
+ TESTKIT_MODE: options.mode || config.testkit?.mode || "test",
245
257
  ...(config.runtimeId ? { TESTKIT_RUNTIME_ID: String(config.runtimeId) } : {}),
258
+ ...(config.testkit?.localEnvironmentName
259
+ ? { TESTKIT_LOCAL_ENV: String(config.testkit.localEnvironmentName) }
260
+ : {}),
246
261
  ...(lease?.leaseId ? { TESTKIT_LEASE_ID: String(lease.leaseId) } : {}),
247
262
  ...(lease?.leaseDir ? { TESTKIT_LEASE_DIR: lease.leaseDir } : {}),
248
263
  };
@@ -357,6 +372,16 @@ export function resolveTemplateString(value, context) {
357
372
  }
358
373
  return readyUrl;
359
374
  }
375
+ case "publicHost":
376
+ return context.publicHost || "127.0.0.1";
377
+ case "publicBaseUrl": {
378
+ const serviceName = arg || context.serviceName;
379
+ const publicBaseUrl = context.publicBaseUrlByService?.get(serviceName) || context.baseUrlByService.get(serviceName);
380
+ if (!publicBaseUrl) {
381
+ throw new Error(`Unknown publicBaseUrl placeholder for service "${serviceName}"`);
382
+ }
383
+ return publicBaseUrl;
384
+ }
360
385
  case "dbUrl":
361
386
  case "dbHost":
362
387
  case "dbPort":
@@ -372,6 +397,19 @@ export function resolveTemplateString(value, context) {
372
397
  });
373
398
  }
374
399
 
400
+ function publicUrl(rawUrl, publicHost) {
401
+ if (!publicHost) return rawUrl;
402
+ try {
403
+ const url = new URL(rawUrl);
404
+ url.hostname = publicHost;
405
+ let next = url.toString();
406
+ if (!rawUrl.endsWith("/") && url.pathname === "/" && next.endsWith("/")) next = next.slice(0, -1);
407
+ return next;
408
+ } catch {
409
+ return rawUrl;
410
+ }
411
+ }
412
+
375
413
  function resolveEnvTemplates(values, templateContext) {
376
414
  return Object.fromEntries(
377
415
  Object.entries(values || {}).map(([key, value]) => [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/next-analysis",
3
- "version": "0.1.135",
3
+ "version": "0.1.137",
4
4
  "description": "SWC-backed Next.js source analysis primitives for Erench tools",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit-bridge",
3
- "version": "0.1.135",
3
+ "version": "0.1.137",
4
4
  "description": "Browser bridge helpers for testkit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "typecheck": "tsc -p tsconfig.json --noEmit"
23
23
  },
24
24
  "dependencies": {
25
- "@elench/testkit-protocol": "0.1.135"
25
+ "@elench/testkit-protocol": "0.1.137"
26
26
  },
27
27
  "private": false
28
28
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit-protocol",
3
- "version": "0.1.135",
3
+ "version": "0.1.137",
4
4
  "description": "Shared browser protocol for testkit bridge and extension consumers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/ts-analysis",
3
- "version": "0.1.135",
3
+ "version": "0.1.137",
4
4
  "description": "TypeScript compiler-backed source analysis primitives for Erench tools",
5
5
  "type": "module",
6
6
  "exports": {