@typecad/expect 1.0.0-alpha.3 → 1.0.0-alpha.6

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/README.md CHANGED
@@ -152,13 +152,13 @@ All numeric matchers return the parent `Suite`, so you can continue the chain wi
152
152
 
153
153
  ```bash
154
154
  # Run a specific file
155
- npx cuttlefish-test examples/my-sensor.test.ts
155
+ npx --package=@typecad/expect cuttlefish-test examples/my-sensor.test.ts
156
156
 
157
157
  # Run all test files matched by config include patterns
158
- npx cuttlefish-test
158
+ npx --package=@typecad/expect cuttlefish-test
159
159
 
160
160
  # Override the port at run-time
161
- npx cuttlefish-test --port /dev/ttyACM0 examples/my-sensor.test.ts
161
+ npx --package=@typecad/expect cuttlefish-test --port /dev/ttyACM0 examples/my-sensor.test.ts
162
162
  ```
163
163
 
164
164
  Or via the npm script defined in the root `package.json`:
@@ -253,10 +253,10 @@ Example flow:
253
253
 
254
254
  ```bash
255
255
  # 1. Compile and upload the serial-output showcase
256
- npx cuttlefish src/23-transpiler-showcase.ts --compile --upload --port COM4
256
+ npx @typecad/cuttlefish src/23-transpiler-showcase.ts --compile --upload --port COM4
257
257
 
258
258
  # 2. Run the on-hardware expect test against the connected Uno
259
- npx cuttlefish-test examples/24-uno-validation.test.ts --port COM4
259
+ npx --package=@typecad/expect cuttlefish-test examples/24-uno-validation.test.ts --port COM4
260
260
  ```
261
261
 
262
262
  This hybrid workflow is the recommended way to confirm that simple variables, arithmetic, arrays, enums, functions, GPIO, and analog input are behaving correctly on real Uno hardware.
@@ -8,6 +8,14 @@ import path from 'node:path';
8
8
  import fs from 'node:fs';
9
9
  import { spawnSync } from 'node:child_process';
10
10
  import { parseConfigAST } from './config.js';
11
+ import { checkArduinoEnv } from '@typecad/arduino-cli';
12
+ /** Format a check failure into the `error` field used by CompileResult/UploadResult. */
13
+ function formatEnvFailure(failure) {
14
+ const lines = [...failure.messages];
15
+ if (failure.fixCommand)
16
+ lines.push(` Fix: ${failure.fixCommand}`);
17
+ return lines.join('\n');
18
+ }
11
19
  /**
12
20
  * Transpile preprocessed TypeScript source to a C++ Arduino sketch.
13
21
  *
@@ -77,6 +85,14 @@ export function transpileTestFile(preprocessedSource, originalFilePath, projectR
77
85
  * Compile the Arduino sketch using arduino-cli.
78
86
  */
79
87
  export function compileSketch(sketchDir, buildTarget) {
88
+ // Hard gate: verify arduino-cli + core before spawning.
89
+ {
90
+ const gate = checkArduinoEnv(buildTarget);
91
+ if (!gate.ok) {
92
+ const message = formatEnvFailure(gate);
93
+ return { success: false, sketchDir, sketchPath: '', output: message, error: message };
94
+ }
95
+ }
80
96
  const result = spawnSync('arduino-cli', ['compile', '--fqbn', buildTarget, sketchDir], { encoding: 'utf8', timeout: 120000 });
81
97
  const output = `${result.stdout ?? ''}\n${result.stderr ?? ''}`.trim();
82
98
  return {
@@ -91,6 +107,14 @@ export function compileSketch(sketchDir, buildTarget) {
91
107
  * Upload the compiled sketch to the board.
92
108
  */
93
109
  export function uploadSketch(sketchDir, buildTarget, port) {
110
+ // Hard gate: verify arduino-cli + core before spawning.
111
+ {
112
+ const gate = checkArduinoEnv(buildTarget);
113
+ if (!gate.ok) {
114
+ const message = formatEnvFailure(gate);
115
+ return { success: false, output: message, error: message };
116
+ }
117
+ }
94
118
  const result = spawnSync('arduino-cli', ['upload', '--fqbn', buildTarget, '--port', port, sketchDir], { encoding: 'utf8', timeout: 60000 });
95
119
  const output = `${result.stdout ?? ''}\n${result.stderr ?? ''}`.trim();
96
120
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typecad/expect",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.6",
4
4
  "description": "Hardware test framework for TypeCAD — vitest-style assertions over serial",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,10 +39,11 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "typescript": "^5.7.3",
42
- "serialport": "^12.0.0"
42
+ "serialport": "^12.0.0",
43
+ "@typecad/arduino-cli": "1.0.0-alpha.6"
43
44
  },
44
45
  "devDependencies": {
45
- "@typecad/cuttlefish": "1.0.0-alpha.3",
46
+ "@typecad/cuttlefish": "1.0.0-alpha.6",
46
47
  "@types/node": "^22.10.7"
47
48
  },
48
49
  "license": "MIT",