Repository navigation
feat: add cdb-converter CLI - #9
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Node.js CLI entrypoint (cdb-converter) to run CDB↔SQLite conversions without writing code, integrating it into the package build and adding unit tests for CLI helper logic.
Changes:
- Introduces
src/cli.tswith arg parsing, direction detection by extension, and conversion execution. - Updates build/package metadata to ship an installable
cdb-converterbinary. - Adds unit tests for CLI helper functions and relaxes
SqlDatabase.runtyping for better sql.js compatibility.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tsup.config.ts | Adds a second tsup entry to build the CLI as ESM (dist/cli.mjs). |
| test/cli.test.ts | Adds Vitest coverage for CLI helper functions (parseArgs, detectDirection, getDefaultOutputPath). |
| src/types.ts | Widens SqlDatabase.run parameter type to align with sql.js bind params. |
| src/cli.ts | Implements the CLI command, including help/version output and conversion logic. |
| README.md | Documents CLI usage and extension-to-direction mapping. |
| package.json | Adds bin mapping for cdb-converter and includes @types/sql.js in dev deps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an installable
cdb-convertercommand so files can be converted without writing any code — fulfilling the most visible gap (the repo only shipped sample scripts before).The conversion direction is auto-detected from the input file extension:
.cdb<input>.sqlite.sqlite/.db<input>.cdbChanges
src/cli.ts— the CLI: arg parsing,--help/--version, bidirectional conversion. Pure helpers (parseArgs,detectDirection,getDefaultOutputPath) are exported for testability, and anisDirectRunguard preventsmain()from running on import.package.json— adds thebinentry (cdb-converter→dist/cli.mjs) and@types/sql.jsas a devDependency.tsup.config.ts— second build entry for the CLI (ESM, shebang preserved).src/types.ts— relaxes theSqlDatabase.runparam type so a real sql.jsDatabase(typed via@types/sql.js) is structurally assignable to the library's minimal shim, while still accepting the loosely-typed arrays built internally.README.md— new CLI section + direction table.test/cli.test.ts— unit tests for the CLI helpers.Notes / follow-ups
Direction is currently inferred from the input extension. A discussed follow-up is to detect the format from magic bytes (CDB
0xFFFFFFFF/0xAAAAAAAA, SQLite"SQLite format 3\0") for robustness against mis-named files — not included here.