@hpx7/delta-pack-cli 0.1.1 → 0.1.2
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 +14 -0
- package/dist/index.js +21 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -138,6 +138,20 @@ delta-pack encode-diff schema.yml -t GameState --old state1.json --new state2.js
|
|
|
138
138
|
delta-pack decode-diff schema.yml -t GameState --old state1.json
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
+
## Inspecting Binary Output
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# View binary as hex dump
|
|
145
|
+
delta-pack encode schema.yml -t Player -i player.json | xxd
|
|
146
|
+
|
|
147
|
+
# Check encoded size in bytes
|
|
148
|
+
delta-pack encode schema.yml -t Player -i player.json | wc -c
|
|
149
|
+
|
|
150
|
+
# Compare full encode vs diff size
|
|
151
|
+
delta-pack encode schema.yml -t GameState -i state2.json | wc -c
|
|
152
|
+
delta-pack encode-diff schema.yml -t GameState --old state1.json --new state2.json | wc -c
|
|
153
|
+
```
|
|
154
|
+
|
|
141
155
|
## Exit Codes
|
|
142
156
|
|
|
143
157
|
| Code | Meaning |
|
package/dist/index.js
CHANGED
|
@@ -10367,12 +10367,12 @@ async function writeOutput(path, data) {
|
|
|
10367
10367
|
// src/commands/generate.ts
|
|
10368
10368
|
async function generate(schemaPath, flags) {
|
|
10369
10369
|
if (!schemaPath) {
|
|
10370
|
-
throw new Error("
|
|
10370
|
+
throw new Error("generate: schema file required");
|
|
10371
10371
|
}
|
|
10372
10372
|
const lang = flags.get("l") ?? flags.get("language");
|
|
10373
10373
|
const output = flags.get("o") ?? flags.get("output");
|
|
10374
10374
|
if (!lang || lang === true) {
|
|
10375
|
-
throw new Error("
|
|
10375
|
+
throw new Error("generate: language required (-l <typescript|csharp>)");
|
|
10376
10376
|
}
|
|
10377
10377
|
const content = await readFile2(schemaPath, "utf-8");
|
|
10378
10378
|
const schema2 = parseSchemaYml(content);
|
|
@@ -10384,9 +10384,9 @@ async function generate(schemaPath, flags) {
|
|
|
10384
10384
|
break;
|
|
10385
10385
|
case "csharp":
|
|
10386
10386
|
case "cs":
|
|
10387
|
-
throw new Error("C# codegen not yet implemented");
|
|
10387
|
+
throw new Error("generate: C# codegen not yet implemented");
|
|
10388
10388
|
default:
|
|
10389
|
-
throw new Error(`
|
|
10389
|
+
throw new Error(`generate: unknown language '${lang}'`);
|
|
10390
10390
|
}
|
|
10391
10391
|
await writeOutput(output === true ? undefined : output, code);
|
|
10392
10392
|
}
|
|
@@ -10411,13 +10411,13 @@ function getRootType(schema2, typeName) {
|
|
|
10411
10411
|
// src/commands/encode.ts
|
|
10412
10412
|
async function encode(schemaPath, flags) {
|
|
10413
10413
|
if (!schemaPath) {
|
|
10414
|
-
throw new Error("
|
|
10414
|
+
throw new Error("encode: schema file required");
|
|
10415
10415
|
}
|
|
10416
10416
|
const typeName = flags.get("t") ?? flags.get("type");
|
|
10417
10417
|
const input = flags.get("i") ?? flags.get("input");
|
|
10418
10418
|
const output = flags.get("o") ?? flags.get("output");
|
|
10419
10419
|
if (!typeName || typeName === true) {
|
|
10420
|
-
throw new Error("
|
|
10420
|
+
throw new Error("encode: type required (-t <name>)");
|
|
10421
10421
|
}
|
|
10422
10422
|
const schema2 = await loadSchema(schemaPath);
|
|
10423
10423
|
const rootType = getRootType(schema2, typeName);
|
|
@@ -10431,13 +10431,13 @@ async function encode(schemaPath, flags) {
|
|
|
10431
10431
|
// src/commands/decode.ts
|
|
10432
10432
|
async function decode(schemaPath, flags) {
|
|
10433
10433
|
if (!schemaPath) {
|
|
10434
|
-
throw new Error("
|
|
10434
|
+
throw new Error("decode: schema file required");
|
|
10435
10435
|
}
|
|
10436
10436
|
const typeName = flags.get("t") ?? flags.get("type");
|
|
10437
10437
|
const input = flags.get("i") ?? flags.get("input");
|
|
10438
10438
|
const output = flags.get("o") ?? flags.get("output");
|
|
10439
10439
|
if (!typeName || typeName === true) {
|
|
10440
|
-
throw new Error("
|
|
10440
|
+
throw new Error("decode: type required (-t <name>)");
|
|
10441
10441
|
}
|
|
10442
10442
|
const schema2 = await loadSchema(schemaPath);
|
|
10443
10443
|
const rootType = getRootType(schema2, typeName);
|
|
@@ -10453,20 +10453,20 @@ async function decode(schemaPath, flags) {
|
|
|
10453
10453
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
10454
10454
|
async function encodeDiff(schemaPath, flags) {
|
|
10455
10455
|
if (!schemaPath) {
|
|
10456
|
-
throw new Error("
|
|
10456
|
+
throw new Error("encode-diff: schema file required");
|
|
10457
10457
|
}
|
|
10458
10458
|
const typeName = flags.get("t") ?? flags.get("type");
|
|
10459
10459
|
const oldPath = flags.get("old");
|
|
10460
10460
|
const newPath = flags.get("new");
|
|
10461
10461
|
const output = flags.get("o") ?? flags.get("output");
|
|
10462
10462
|
if (!typeName || typeName === true) {
|
|
10463
|
-
throw new Error("
|
|
10463
|
+
throw new Error("encode-diff: type required (-t <name>)");
|
|
10464
10464
|
}
|
|
10465
10465
|
if (!oldPath || oldPath === true) {
|
|
10466
|
-
throw new Error("
|
|
10466
|
+
throw new Error("encode-diff: old state required (--old <file>)");
|
|
10467
10467
|
}
|
|
10468
10468
|
if (!newPath || newPath === true) {
|
|
10469
|
-
throw new Error("
|
|
10469
|
+
throw new Error("encode-diff: new state required (--new <file>)");
|
|
10470
10470
|
}
|
|
10471
10471
|
const schema2 = await loadSchema(schemaPath);
|
|
10472
10472
|
const rootType = getRootType(schema2, typeName);
|
|
@@ -10483,17 +10483,17 @@ async function encodeDiff(schemaPath, flags) {
|
|
|
10483
10483
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
10484
10484
|
async function decodeDiff(schemaPath, flags) {
|
|
10485
10485
|
if (!schemaPath) {
|
|
10486
|
-
throw new Error("
|
|
10486
|
+
throw new Error("decode-diff: schema file required");
|
|
10487
10487
|
}
|
|
10488
10488
|
const typeName = flags.get("t") ?? flags.get("type");
|
|
10489
10489
|
const oldPath = flags.get("old");
|
|
10490
10490
|
const diffPath = flags.get("diff");
|
|
10491
10491
|
const output = flags.get("o") ?? flags.get("output");
|
|
10492
10492
|
if (!typeName || typeName === true) {
|
|
10493
|
-
throw new Error("
|
|
10493
|
+
throw new Error("decode-diff: type required (-t <name>)");
|
|
10494
10494
|
}
|
|
10495
10495
|
if (!oldPath || oldPath === true) {
|
|
10496
|
-
throw new Error("
|
|
10496
|
+
throw new Error("decode-diff: old state required (--old <file>)");
|
|
10497
10497
|
}
|
|
10498
10498
|
const schema2 = await loadSchema(schemaPath);
|
|
10499
10499
|
const rootType = getRootType(schema2, typeName);
|
|
@@ -10508,6 +10508,12 @@ async function decodeDiff(schemaPath, flags) {
|
|
|
10508
10508
|
}
|
|
10509
10509
|
|
|
10510
10510
|
// src/index.ts
|
|
10511
|
+
process.stdout.on("error", (err) => {
|
|
10512
|
+
if (err.code === "EPIPE") {
|
|
10513
|
+
process.exit(0);
|
|
10514
|
+
}
|
|
10515
|
+
throw err;
|
|
10516
|
+
});
|
|
10511
10517
|
var args = process.argv.slice(2);
|
|
10512
10518
|
var command = args[0];
|
|
10513
10519
|
function parseFlags(args2) {
|