Skip to content

Commit 9947cae

Browse files
committed
feat: US-187 - Add yaml project-matrix fixture
1 parent 9afb6e9 commit 9947cae

4 files changed

Lines changed: 64 additions & 0 deletions

File tree

docs/nodejs-compatibility.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ The [project-matrix test suite](https://github.com/rivet-dev/secure-exec/tree/ma
8484
| [chalk](https://npmjs.com/package/chalk) | Terminal | Terminal string styling, ANSI escape codes |
8585
| [lodash-es](https://npmjs.com/package/lodash-es) | Utility | Large ESM module resolution at scale |
8686
| [pino](https://npmjs.com/package/pino) | Logging | Structured JSON logging, child loggers, serializers |
87+
| [yaml](https://npmjs.com/package/yaml) | Utility | YAML parsing, stringifying, document API |
8788
| [zod](https://npmjs.com/package/zod) | Validation | Schema definition, parsing, safe parse, transforms |
8889
| [rivetkit](https://npmjs.com/package/rivetkit) | SDK | Local vendor package resolution |
8990
| crypto (builtin) | Crypto | `crypto.randomBytes`, `randomUUID`, `getRandomValues` |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"entry": "src/index.js",
3+
"expectation": "pass"
4+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "project-matrix-yaml-pass",
3+
"private": true,
4+
"type": "module",
5+
"dependencies": {
6+
"yaml": "2.8.0"
7+
}
8+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { parse, stringify, parseDocument } from "yaml";
2+
3+
// Parse a YAML string
4+
const yamlStr = `
5+
name: secure-exec
6+
version: 1.0.0
7+
features:
8+
- sandboxing
9+
- isolation
10+
- compatibility
11+
config:
12+
timeout: 30
13+
retries: 3
14+
nested:
15+
enabled: true
16+
level: 2
17+
`;
18+
19+
const parsed = parse(yamlStr);
20+
21+
// Stringify a JS object back to YAML
22+
const obj = {
23+
database: {
24+
host: "localhost",
25+
port: 5432,
26+
credentials: {
27+
user: "admin",
28+
pass: "secret",
29+
},
30+
},
31+
tags: ["prod", "us-east"],
32+
};
33+
34+
const stringified = stringify(obj);
35+
36+
// Re-parse the stringified output to verify round-trip
37+
const roundTrip = parse(stringified);
38+
39+
// Parse a document for node-level access
40+
const doc = parseDocument("key: value\nlist:\n - a\n - b");
41+
const docJSON = doc.toJSON();
42+
43+
const result = {
44+
parsed,
45+
stringified,
46+
roundTrip,
47+
roundTripMatch: JSON.stringify(obj) === JSON.stringify(roundTrip),
48+
docJSON,
49+
};
50+
51+
console.log(JSON.stringify(result));

0 commit comments

Comments
 (0)