@dotuix/cli
Advanced tools
+40
-1
@@ -22,3 +22,4 @@ #!/usr/bin/env node | ||
| sign, | ||
| verify | ||
| verify, | ||
| createDataDb | ||
| } from "@dotuix/core"; | ||
@@ -520,2 +521,34 @@ var __dirname = dirname(fileURLToPath(import.meta.url)); | ||
| } | ||
| async function cmdSeed(args) { | ||
| const positional = positionals(args); | ||
| const input = positional[0]; | ||
| if (!input) { | ||
| console.error( | ||
| c.red("\u2717") + " Usage: dotuix seed <records.json> [-o data.db]\n records.json must be a JSON array of { id?, type, body } objects." | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| const inputPath = resolve(input); | ||
| if (!existsSync(inputPath)) { | ||
| console.error(c.red("\u2717") + ` File not found: ${inputPath}`); | ||
| process.exit(1); | ||
| } | ||
| let records; | ||
| try { | ||
| records = JSON.parse(readFileSync(inputPath, "utf8")); | ||
| if (!Array.isArray(records)) | ||
| throw new Error("Root value must be a JSON array"); | ||
| } catch (e) { | ||
| console.error( | ||
| c.red("\u2717") + ` Invalid JSON in ${input}: ${e.message}` | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| const outPath = resolve(flag(args, "-o", "--output") ?? "data.db"); | ||
| const bytes = await createDataDb(records); | ||
| writeFileSync(outPath, bytes); | ||
| console.log( | ||
| c.green("\u2713") + ` Seeded ${c.bold(String(records.length))} records \u2192 ${c.cyan(outPath)}` | ||
| ); | ||
| } | ||
| function printHelp() { | ||
@@ -553,2 +586,5 @@ console.log(` | ||
| )} <file.uix> --pin <PIN> [-o out] AES-256-GCM encrypt files | ||
| ${c.cyan( | ||
| "seed" | ||
| )} <records.json> [-o data.db] Create data.db from JSON records | ||
@@ -605,2 +641,5 @@ ${c.bold("Examples:")} | ||
| break; | ||
| case "seed": | ||
| await cmdSeed(rest); | ||
| break; | ||
| default: | ||
@@ -607,0 +646,0 @@ console.error( |
+2
-2
| { | ||
| "name": "@dotuix/cli", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "CLI for packing, unpacking, and validating .uix files", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@dotuix/core": "0.2.0" | ||
| "@dotuix/core": "0.2.1" | ||
| }, | ||
@@ -38,0 +38,0 @@ "devDependencies": { |
71270
1.75%2216
1.79%+ Added
- Removed
Updated