chore: bump 0.2.2, fix lint, biome format
- Bump all packages to 0.2.2 - Fix noNonNullAssertion in cli/index.ts - Fix unused imports in fs/sqlite-store.ts - Biome 2.4.16 migration + format all files - Update snapshots for version change
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ocas/cli",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"ocas": "dist/index.js"
|
||||
|
||||
@@ -1040,7 +1040,7 @@ async function cmdList(_args: string[]): Promise<void> {
|
||||
...(opts.desc !== undefined ? { desc: opts.desc } : {}),
|
||||
});
|
||||
const filtered: ListEntry[] = allOfType.filter((e) =>
|
||||
intersection!.has(e.hash),
|
||||
intersection?.has(e.hash),
|
||||
);
|
||||
const paged = applyListOptions(filtered, opts);
|
||||
await out(await wrapEnvelope(store, "@ocas/output/list", paged), store);
|
||||
|
||||
@@ -375,381 +375,6 @@ exports[`Phase 3: Variable System > 3.10 var delete removes variable 1`] = `
|
||||
|
||||
exports[`Phase 3: Variable System > 3.11 var get deleted variable returns not found 1`] = `"Error: Variable not found: name=@myapp/config, schema=FRBAB1BF0ZBCS"`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.1 var set creates variable 1`] = `
|
||||
{
|
||||
"type": "0Q5EMYK4SYSS9",
|
||||
"value": {
|
||||
"labels": [],
|
||||
"name": "@myapp/config",
|
||||
"schema": "FRBAB1BF0ZBCS",
|
||||
"tags": {},
|
||||
"value": "9W3MGR3184QYE",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.2 var get returns variable 1`] = `
|
||||
{
|
||||
"type": "F5RRJTXP8Z99D",
|
||||
"value": {
|
||||
"labels": [],
|
||||
"name": "@myapp/config",
|
||||
"schema": "FRBAB1BF0ZBCS",
|
||||
"tags": {},
|
||||
"value": "9W3MGR3184QYE",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.3 var list shows all variables 1`] = `
|
||||
{
|
||||
"type": "AF0XACGXHPMC1",
|
||||
"value": [
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@myapp/config",
|
||||
"schema": "FRBAB1BF0ZBCS",
|
||||
"tags": {},
|
||||
"value": "9W3MGR3184QYE",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/array",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "D45CW047XS17Y",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/bool",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "1AVHCXEJVDCPP",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/boolean",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "1AVHCXEJVDCPP",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/integer",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "B26JM4PBHPAFK",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/null",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "8E33KAS0HMAZ7",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/number",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "BEAZQGKVXMZT8",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/object",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "944RT37WX1PQ5",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/gc",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "7KHZTY010988K",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/get",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "7V5G8E2VW8B2G",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/has",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "FHXQQZMVHW924",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/hash",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "1B24CBF95Q5G6",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/list",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "7BWZ3JKKMSH4N",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/list-meta",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "1WQ7C0EV8QGA4",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/list-schema",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "7FYGS2KQ3REM9",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/put",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "4ZHWK21APCFZ5",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/refs",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "2TKP4RGBJ4V43",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/tag",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "CPSWA9TB2JMWP",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/template-delete",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "BY7BGZJND3N7R",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/template-get",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "0B0HBHZGYHR84",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/template-list",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "8917JQTD1R5JF",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/template-set",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "BJDHPAE4Q8TXM",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/untag",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "BPEQMRQNJK80Z",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/var-delete",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "C3MYPR5RGQFZT",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/var-get",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "F5RRJTXP8Z99D",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/var-history",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "EVZJS80TRFKE1",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/var-list",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "AF0XACGXHPMC1",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/var-set",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "0Q5EMYK4SYSS9",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/verify",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "52HEFB52BD0GF",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/output/walk",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "4HG6MD3XG5H5C",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/schema",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "CTS5P6RD8HMCS",
|
||||
},
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@ocas/string",
|
||||
"schema": "CTS5P6RD8HMCS",
|
||||
"tags": {},
|
||||
"value": "7VQ43ZSJTEWA7",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.4 var list prefix filters by prefix 1`] = `
|
||||
{
|
||||
"type": "AF0XACGXHPMC1",
|
||||
"value": [
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@myapp/config",
|
||||
"schema": "FRBAB1BF0ZBCS",
|
||||
"tags": {},
|
||||
"value": "9W3MGR3184QYE",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.5 var set upsert updates existing variable 1`] = `
|
||||
{
|
||||
"type": "0Q5EMYK4SYSS9",
|
||||
"value": {
|
||||
"labels": [],
|
||||
"name": "@myapp/config",
|
||||
"schema": "FRBAB1BF0ZBCS",
|
||||
"tags": {},
|
||||
"value": "A6QPKJAFR68NP",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.6 var set with tag and label adds them 1`] = `
|
||||
{
|
||||
"type": "0Q5EMYK4SYSS9",
|
||||
"value": {
|
||||
"labels": [
|
||||
"important",
|
||||
],
|
||||
"name": "@myapp/config",
|
||||
"schema": "FRBAB1BF0ZBCS",
|
||||
"tags": {
|
||||
"env": "prod",
|
||||
},
|
||||
"value": "9W3MGR3184QYE",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.7 var list --tag env:prod filters by kv tag 1`] = `
|
||||
{
|
||||
"type": "AF0XACGXHPMC1",
|
||||
"value": [
|
||||
{
|
||||
"labels": [
|
||||
"important",
|
||||
],
|
||||
"name": "@myapp/config",
|
||||
"schema": "FRBAB1BF0ZBCS",
|
||||
"tags": {
|
||||
"env": "prod",
|
||||
},
|
||||
"value": "9W3MGR3184QYE",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.8 var list --tag important filters by label 1`] = `
|
||||
{
|
||||
"type": "AF0XACGXHPMC1",
|
||||
"value": [
|
||||
{
|
||||
"labels": [
|
||||
"important",
|
||||
],
|
||||
"name": "@myapp/config",
|
||||
"schema": "FRBAB1BF0ZBCS",
|
||||
"tags": {
|
||||
"env": "prod",
|
||||
},
|
||||
"value": "9W3MGR3184QYE",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.9 var set without label removes it 1`] = `
|
||||
{
|
||||
"type": "0Q5EMYK4SYSS9",
|
||||
"value": {
|
||||
"labels": [],
|
||||
"name": "@myapp/config",
|
||||
"schema": "FRBAB1BF0ZBCS",
|
||||
"tags": {
|
||||
"env": "prod",
|
||||
},
|
||||
"value": "9W3MGR3184QYE",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.10 var delete removes variable 1`] = `
|
||||
{
|
||||
"type": "C3MYPR5RGQFZT",
|
||||
"value": [
|
||||
{
|
||||
"labels": [],
|
||||
"name": "@myapp/config",
|
||||
"schema": "FRBAB1BF0ZBCS",
|
||||
"tags": {
|
||||
"env": "prod",
|
||||
},
|
||||
"value": "9W3MGR3184QYE",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 3: Variable System 3.11 var get deleted variable returns not found 1`] = `"Error: Variable not found: name=@myapp/config, schema=FRBAB1BF0ZBCS"`;
|
||||
|
||||
exports[`Phase 4: Template System > 4.1 template set registers template 1`] = `
|
||||
{
|
||||
"type": "BJDHPAE4Q8TXM",
|
||||
@@ -790,46 +415,6 @@ exports[`Phase 4: Template System > 4.4 template delete removes template 1`] = `
|
||||
|
||||
exports[`Phase 4: Template System > 4.5 template get deleted template returns not found 1`] = `"Error: Template not found for schema: FRBAB1BF0ZBCS"`;
|
||||
|
||||
exports[`Phase 4: Template System 4.1 template set registers template 1`] = `
|
||||
{
|
||||
"type": "BJDHPAE4Q8TXM",
|
||||
"value": {
|
||||
"contentHash": "6WW8WNB38GTTP",
|
||||
"schemaHash": "FRBAB1BF0ZBCS",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 4: Template System 4.2 template get returns template text 1`] = `
|
||||
{
|
||||
"type": "0B0HBHZGYHR84",
|
||||
"value": "Name: {{ payload.name }}, Age: {{ payload.age }}",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 4: Template System 4.3 template list shows registered templates 1`] = `
|
||||
{
|
||||
"type": "8917JQTD1R5JF",
|
||||
"value": [
|
||||
{
|
||||
"contentHash": "6WW8WNB38GTTP",
|
||||
"schemaHash": "FRBAB1BF0ZBCS",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 4: Template System 4.4 template delete removes template 1`] = `
|
||||
{
|
||||
"type": "BY7BGZJND3N7R",
|
||||
"value": {
|
||||
"deleted": true,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 4: Template System 4.5 template get deleted template returns not found 1`] = `"Error: Template not found for schema: FRBAB1BF0ZBCS"`;
|
||||
|
||||
exports[`Phase 7: Edge Cases > 7.1 get non-existent hash errors gracefully 1`] = `"Node not found: AAAAAAAAAAAAA"`;
|
||||
|
||||
exports[`Phase 7: Edge Cases > 7.3 var set empty name errors 1`] = `"Usage: ocas var set <name> <hash> [--tag <tag>...]"`;
|
||||
@@ -881,59 +466,5 @@ Flags:
|
||||
--epsilon <n> Cutoff threshold for render (default: 0.01)
|
||||
--pipe, -p Read from stdin (put/hash: raw JSON payload; render: { type, value } envelope)
|
||||
|
||||
Agent: If you have not installed the ocas skill for this version (0.2.0), run \`ocas prompt setup\` and follow the instructions."
|
||||
`;
|
||||
|
||||
exports[`Phase 7: Edge Cases 7.1 get non-existent hash errors gracefully 1`] = `"Node not found: AAAAAAAAAAAAA"`;
|
||||
|
||||
exports[`Phase 7: Edge Cases 7.3 var set empty name errors 1`] = `"Usage: ocas var set <name> <hash> [--tag <tag>...]"`;
|
||||
|
||||
exports[`Phase 7: Edge Cases 7.4 var set name with invalid chars errors 1`] = `"Error: Invalid variable name "invalid name!": Name must follow @scope/name format (e.g. @myapp/config)"`;
|
||||
|
||||
exports[`Phase 7: Edge Cases 7.5 no subcommand shows help text 1`] = `
|
||||
"Usage: ocas [--home <path>] [--json] <command> [args]
|
||||
|
||||
All JSON commands emit a { type, value } envelope. The type is the hash of the
|
||||
command's @ocas/output/* schema (shown in parentheses); pipe any envelope into
|
||||
\`render -p\` to render its value (ocas_ref hashes are expanded).
|
||||
|
||||
Commands:
|
||||
put <type-hash> <file.json|--pipe> Store node, print envelope (value=hash) (@ocas/output/put)
|
||||
get <hash> Print node as envelope (@ocas/output/get)
|
||||
has <hash> Print envelope (value=boolean) (@ocas/output/has)
|
||||
verify <hash> Verify integrity + schema (value=ok/corrupted/invalid) (@ocas/output/verify)
|
||||
refs <hash> List direct ocas_ref edges (@ocas/output/refs)
|
||||
walk <hash> [--format tree] Recursive traversal (@ocas/output/walk)
|
||||
hash <type-hash> <file.json|--pipe> Compute hash without storing (@ocas/output/hash)
|
||||
render <hash> [options] Render node as text with resolution decay (raw output)
|
||||
render --pipe/-p [options] Render { type, value } from stdin (raw output)
|
||||
list --type <hash-or-name> [--tag <tag>...] List hashes for a type, optionally filtered by tags (@ocas/output/list)
|
||||
list-meta List meta-schema hashes (value=string[]) (@ocas/output/list-meta)
|
||||
list-schema List all schema hashes (value=string[]) (@ocas/output/list-schema)
|
||||
tag <target> <tag>... Apply tags/labels to a target (@ocas/output/tag)
|
||||
untag <target> <tag>... Remove tags/labels from a target (@ocas/output/untag)
|
||||
var set <name> <hash> [--tag <tag>...] Create/update a variable (@ocas/output/var-set)
|
||||
var get <name> --schema <hash> Get a variable by name + schema (@ocas/output/var-get)
|
||||
var delete <name> [--schema <hash>] Delete variable(s) (@ocas/output/var-delete)
|
||||
var list [prefix] [--schema <hash>] [--tag <tag>...] List variables (@ocas/output/var-list)
|
||||
var history <name> [--schema <hash>] Show value history (LRU) (@ocas/output/var-history)
|
||||
template set <schema-hash> <file> | --inline <text> Set template for schema (@ocas/output/template-set)
|
||||
template get <schema-hash> Get template content (value=string) (@ocas/output/template-get)
|
||||
template list List all templates (@ocas/output/template-list)
|
||||
template delete <schema-hash> Delete template for schema (@ocas/output/template-delete)
|
||||
gc Run garbage collection (@ocas/output/gc)
|
||||
|
||||
Flags:
|
||||
--home <path> Store directory (default: $OCAS_HOME or ~/.ocas)
|
||||
--json Compact JSON output
|
||||
--render, -r Render output inline (equivalent to | ocas render -p)
|
||||
--schema <hash> Schema hash filter for var get/delete/tag/list
|
||||
--tag <tag> Tag/label (can be repeated): key:value (tag), name (label), :name (delete)
|
||||
--inline <text> Inline text content for template set
|
||||
--resolution <n> Initial resolution for render (default: 1.0)
|
||||
--decay <n> Decay factor for render (default: 0.5)
|
||||
--epsilon <n> Cutoff threshold for render (default: 0.01)
|
||||
--pipe, -p Read from stdin (put/hash: raw JSON payload; render: { type, value } envelope)
|
||||
|
||||
Agent: If you have not installed the ocas skill for this version (0.2.0), run \`ocas prompt setup\` and follow the instructions."
|
||||
Agent: If you have not installed the ocas skill for this version (0.2.2), run \`ocas prompt setup\` and follow the instructions."
|
||||
`;
|
||||
|
||||
@@ -12,16 +12,3 @@ exports[`Phase 1: CAS Core > 1.6 get returns node JSON (snapshot) 1`] = `
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 1: CAS Core 1.6 get returns node JSON (snapshot) 1`] = `
|
||||
{
|
||||
"type": "7V5G8E2VW8B2G",
|
||||
"value": {
|
||||
"payload": {
|
||||
"age": 30,
|
||||
"name": "Alice",
|
||||
},
|
||||
"type": "FRBAB1BF0ZBCS",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -3,7 +3,3 @@
|
||||
exports[`Phase 5: Render > 5.1 render fills payload variables 1`] = `"Hello Alice!"`;
|
||||
|
||||
exports[`Phase 5: Render > 5.2 render --resolution with different value 1`] = `"Hello Alice!"`;
|
||||
|
||||
exports[`Phase 5: Render 5.1 render fills payload variables 1`] = `"Hello Alice!"`;
|
||||
|
||||
exports[`Phase 5: Render 5.2 render --resolution with different value 1`] = `"Hello Alice!"`;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Phase 2: Schema Validation > 2.3 put against non-existent schema hash fails 1`] = `"Schema not found: AAAAAAAAAAAAA"`;
|
||||
|
||||
exports[`Phase 2: Schema Validation 2.3 put against non-existent schema hash fails 1`] = `"Schema not found: AAAAAAAAAAAAA"`;
|
||||
|
||||
@@ -22,26 +22,3 @@ exports[`Phase 1: CAS Core > 1.11 walk shows traversal tree (snapshot) 1`] = `
|
||||
]
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`Phase 1: CAS Core 1.9 verify returns ok for valid node 1`] = `
|
||||
{
|
||||
"type": "52HEFB52BD0GF",
|
||||
"value": "ok",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Phase 1: CAS Core 1.10 refs lists direct references (snapshot) 1`] = `
|
||||
"{
|
||||
"type": "2TKP4RGBJ4V43",
|
||||
"value": []
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`Phase 1: CAS Core 1.11 walk shows traversal tree (snapshot) 1`] = `
|
||||
"{
|
||||
"type": "4HG6MD3XG5H5C",
|
||||
"value": [
|
||||
"9W3MGR3184QYE"
|
||||
]
|
||||
}"
|
||||
`;
|
||||
|
||||
@@ -35,17 +35,29 @@ afterEach(() => {
|
||||
/**
|
||||
* Run CLI command and return stdout, stderr, and exit code
|
||||
*/
|
||||
function runCliAlias(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCliAlias(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[cliPath, "--home", storePath, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,17 +39,29 @@ describe("Phase 7: Edge Cases", () => {
|
||||
let typeHash: string;
|
||||
let nodeHash: string;
|
||||
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,10 +140,14 @@ describe("Phase 7: Edge Cases", () => {
|
||||
const fileAsStore = join(tmpStore, "not-a-directory");
|
||||
writeFileSync(fileAsStore, "test");
|
||||
try {
|
||||
execFileSync("node", [entrypoint, "--home", fileAsStore, "get", "AAAAAAAAAAAAA"], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", fileAsStore, "get", "AAAAAAAAAAAAA"],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
expect.unreachable("should have thrown");
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stderr?: string; status?: number };
|
||||
@@ -148,17 +164,29 @@ describe("Phase 3: Variable System", () => {
|
||||
let typeHash: string;
|
||||
let nodeHash: string;
|
||||
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,17 +366,29 @@ describe("Phase 4: Template System", () => {
|
||||
let tmpStore: string;
|
||||
let typeHash: string;
|
||||
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,17 +42,29 @@ afterAll(() => {
|
||||
rmSync(tmpStore, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +89,15 @@ describe("Phase 6: GC", () => {
|
||||
const { stdout: gcOut, exitCode: gcExit } = runCli(["gc"]);
|
||||
expect(gcExit).toBe(0);
|
||||
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, "render", "--pipe"], {
|
||||
input: gcOut,
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
}).trim();
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, "render", "--pipe"],
|
||||
{
|
||||
input: gcOut,
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
).trim();
|
||||
// gc value is an object { total, reachable, collected, scanned }
|
||||
expect(stdout).toContain("total:");
|
||||
});
|
||||
|
||||
@@ -30,17 +30,29 @@ afterEach(() => {
|
||||
}
|
||||
});
|
||||
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[cliPath, "--home", storePath, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,11 @@ export function runCli(
|
||||
return { stdout, stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: err.stdout ?? "", stderr: err.stderr ?? "", exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: err.stdout ?? "",
|
||||
stderr: err.stderr ?? "",
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +89,11 @@ export function runCliWithStdin(
|
||||
return { stdout, stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: err.stdout ?? "", stderr: err.stderr ?? "", exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: err.stdout ?? "",
|
||||
stderr: err.stderr ?? "",
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,15 @@ afterEach(() => {
|
||||
|
||||
async function putString(text: string): Promise<string> {
|
||||
const entrypoint = join(import.meta.dirname, "../dist/index.js");
|
||||
const out = execFileSync("node", [entrypoint, "--home", storePath, "put", "@ocas/string", "--pipe"], {
|
||||
input: JSON.stringify(text),
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const out = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", storePath, "put", "@ocas/string", "--pipe"],
|
||||
{
|
||||
input: JSON.stringify(text),
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return (JSON.parse(out) as { value: string }).value;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,27 +27,43 @@ afterEach(() => {
|
||||
}
|
||||
});
|
||||
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[cliPath, "--home", storePath, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function putString(value: string): string {
|
||||
try {
|
||||
const out = execFileSync("node", [cliPath, "--home", storePath, "put", "@ocas/string", "--pipe"], {
|
||||
input: JSON.stringify(value),
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const out = execFileSync(
|
||||
"node",
|
||||
[cliPath, "--home", storePath, "put", "@ocas/string", "--pipe"],
|
||||
{
|
||||
input: JSON.stringify(value),
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return JSON.parse(out.trim()).value as string;
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stderr?: string };
|
||||
|
||||
@@ -44,17 +44,29 @@ afterAll(() => {
|
||||
rmSync(tmpStore, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,15 +75,23 @@ function runCliWithStdin(
|
||||
stdin: string,
|
||||
): { stdout: string; stderr: string; exitCode: number } {
|
||||
try {
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
|
||||
input: stdin,
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, ...args],
|
||||
{
|
||||
input: stdin,
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,18 +42,28 @@ afterAll(() => {
|
||||
rmSync(tmpStore, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
function runCli(
|
||||
args: string[],
|
||||
): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(args: string[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
try {
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,17 +58,29 @@ describe("Phase 5: Render", () => {
|
||||
let typeHash: string;
|
||||
let nodeHash: string;
|
||||
|
||||
function runCliE2e(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCliE2e(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,15 +89,23 @@ describe("Phase 5: Render", () => {
|
||||
stdin: string,
|
||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||
try {
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
|
||||
input: stdin,
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, ...args],
|
||||
{
|
||||
input: stdin,
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -582,10 +582,14 @@ describe("Phase 2: Schema Validation", () => {
|
||||
|
||||
const nodeFile = join(tmpStore, "test-node.json");
|
||||
writeFileSync(nodeFile, JSON.stringify({ name: "Alice", age: 30 }));
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, "put", typeHash, nodeFile], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
}).trim();
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, "put", typeHash, nodeFile],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
).trim();
|
||||
_nodeHash = envValue(stdout) as string;
|
||||
});
|
||||
|
||||
@@ -596,12 +600,18 @@ describe("Phase 2: Schema Validation", () => {
|
||||
test("2.1 put {name:123} against string-schema fails with non-zero exit", async () => {
|
||||
const badFile = join(tmpStore, "bad-node.json");
|
||||
writeFileSync(badFile, JSON.stringify({ name: 123 }));
|
||||
let stdout = "", stderr = "", exitCode = 0;
|
||||
let stdout = "",
|
||||
stderr = "",
|
||||
exitCode = 0;
|
||||
try {
|
||||
stdout = execFileSync("node", [entrypoint, "--home", tmpStore, "put", typeHash, badFile], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
}).trim();
|
||||
stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, "put", typeHash, badFile],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
).trim();
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
stdout = (err.stdout ?? "").trim();
|
||||
@@ -616,12 +626,17 @@ describe("Phase 2: Schema Validation", () => {
|
||||
|
||||
test("2.3 put against non-existent schema hash fails", async () => {
|
||||
const nodeFile = join(tmpStore, "test-node.json");
|
||||
let exitCode = 0, stderr = "";
|
||||
let exitCode = 0,
|
||||
stderr = "";
|
||||
try {
|
||||
execFileSync("node", [entrypoint, "--home", tmpStore, "put", "AAAAAAAAAAAAA", nodeFile], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, "put", "AAAAAAAAAAAAA", nodeFile],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stderr?: string; status?: number };
|
||||
stderr = (err.stderr ?? "").trim();
|
||||
|
||||
@@ -30,17 +30,29 @@ afterEach(() => {
|
||||
}
|
||||
});
|
||||
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[cliPath, "--home", storePath, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,17 +38,29 @@ afterEach(() => {
|
||||
/**
|
||||
* Run CLI command and return stdout, stderr, and exit code
|
||||
*/
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[cliPath, "--home", storePath, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,17 +31,29 @@ afterEach(() => {
|
||||
}
|
||||
});
|
||||
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[cliPath, "--home", storePath, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,17 +38,29 @@ afterEach(() => {
|
||||
/**
|
||||
* Run CLI command and return stdout, stderr, and exit code
|
||||
*/
|
||||
function runCli(...rawArgs: (string | string[])[]): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(...rawArgs: (string | string[])[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
const args = rawArgs.flat();
|
||||
try {
|
||||
const stdout = execFileSync("node", [cliPath, "--home", storePath, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[cliPath, "--home", storePath, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,10 +783,14 @@ describe("global options", () => {
|
||||
const hash = await createTestNode(store, typeHash, { test: "data" });
|
||||
|
||||
// Override with custom store path
|
||||
execFileSync("node", [cliPath, "--home", customStorePath, "var", "set", "@test/x", hash], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
execFileSync(
|
||||
"node",
|
||||
[cliPath, "--home", customStorePath, "var", "set", "@test/x", hash],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -39,18 +39,28 @@ afterAll(() => {
|
||||
rmSync(tmpStore, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
function runCli(
|
||||
args: string[],
|
||||
): { stdout: string; stderr: string; exitCode: number } {
|
||||
function runCli(args: string[]): {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
} {
|
||||
try {
|
||||
const stdout = execFileSync("node", [entrypoint, "--home", tmpStore, ...args], {
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
});
|
||||
const stdout = execFileSync(
|
||||
"node",
|
||||
[entrypoint, "--home", tmpStore, ...args],
|
||||
{
|
||||
encoding: "utf-8",
|
||||
timeout: 10000,
|
||||
},
|
||||
);
|
||||
return { stdout: stdout.trim(), stderr: "", exitCode: 0 };
|
||||
} catch (e: unknown) {
|
||||
const err = e as { stdout?: string; stderr?: string; status?: number };
|
||||
return { stdout: (err.stdout ?? "").trim(), stderr: (err.stderr ?? "").trim(), exitCode: err.status ?? 1 };
|
||||
return {
|
||||
stdout: (err.stdout ?? "").trim(),
|
||||
stderr: (err.stderr ?? "").trim(),
|
||||
exitCode: err.status ?? 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,5 @@
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["src/**/*.test.ts"],
|
||||
"references": [
|
||||
{ "path": "../core" },
|
||||
{ "path": "../fs" }
|
||||
]
|
||||
"references": [{ "path": "../core" }, { "path": "../fs" }]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ocas/core",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
||||
@@ -258,7 +258,9 @@ describe("Test Suite 3: putSchema Validation - Invalid Schemas", () => {
|
||||
test("3.1: Reject schema with invalid type value", async () => {
|
||||
const store = new MemStore();
|
||||
bootstrap(store);
|
||||
await expect(async () => putSchema(store, { type: "garbage" })).rejects.toThrow();
|
||||
await expect(async () =>
|
||||
putSchema(store, { type: "garbage" }),
|
||||
).rejects.toThrow();
|
||||
});
|
||||
|
||||
test("3.2: Reject schema with type as number", async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ocas/fs",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
||||
@@ -5,7 +5,6 @@ import type {
|
||||
CasStore,
|
||||
Hash,
|
||||
HistoryEntry,
|
||||
ListEntry,
|
||||
ListOptions,
|
||||
Tag,
|
||||
TagOp,
|
||||
@@ -20,14 +19,12 @@ import {
|
||||
checkTagLabelConflict,
|
||||
extractSchema,
|
||||
MAX_HISTORY,
|
||||
pushHistory,
|
||||
removeNameIndex,
|
||||
SchemaMismatchError,
|
||||
VariableNotFoundError,
|
||||
type VarRecord,
|
||||
validateName,
|
||||
varKey,
|
||||
cloneVarRecord,
|
||||
} from "@ocas/core";
|
||||
|
||||
const DB_FILE = "_store.db";
|
||||
@@ -96,7 +93,7 @@ type StoredTag = {
|
||||
function migrateJsonlVars(
|
||||
db: Database.Database,
|
||||
dir: string,
|
||||
cas: CasStore,
|
||||
_cas: CasStore,
|
||||
): void {
|
||||
const path = join(dir, VARS_FILE);
|
||||
if (!existsSync(path)) return;
|
||||
@@ -622,9 +619,9 @@ export function createSqliteVarStore(
|
||||
tag(target: Hash, operations: TagOp[]): Tag[] {
|
||||
const now = Date.now();
|
||||
txnTagOps(target, operations, now);
|
||||
return (
|
||||
stmtGetTagsByTarget.all(target) as Record<string, unknown>[]
|
||||
).map((r) => toTag(r, target));
|
||||
return (stmtGetTagsByTarget.all(target) as Record<string, unknown>[]).map(
|
||||
(r) => toTag(r, target),
|
||||
);
|
||||
},
|
||||
|
||||
untag(target: Hash, keys: string[]): void {
|
||||
@@ -632,9 +629,9 @@ export function createSqliteVarStore(
|
||||
},
|
||||
|
||||
tags(target: Hash): Tag[] {
|
||||
return (
|
||||
stmtGetTagsByTarget.all(target) as Record<string, unknown>[]
|
||||
).map((r) => toTag(r, target));
|
||||
return (stmtGetTagsByTarget.all(target) as Record<string, unknown>[]).map(
|
||||
(r) => toTag(r, target),
|
||||
);
|
||||
},
|
||||
|
||||
listByTag(tag: string, options?: ListOptions): Hash[] {
|
||||
|
||||
Reference in New Issue
Block a user