Skip to content

feat: add cdb-converter CLI - #9

Merged
mpicciolli merged 7 commits into
mainfrom
feat/cli
Jul 1, 2026
Merged

mpicciolli merged 7 commits into
mainfrom
feat/cli

Conversation

@mpicciolli

@mpicciolli mpicciolli commented Jun 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds an installable cdb-converter command 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:

Input extension Direction Default output
.cdb CDB → SQLite <input>.sqlite
.sqlite / .db SQLite → CDB <input>.cdb
npx cdb-converter save.cdb              # → save.sqlite
npx cdb-converter save.sqlite           # → save.cdb
npx cdb-converter save.cdb out.sqlite   # explicit output
npx cdb-converter --help | --version

Changes

  • src/cli.ts — the CLI: arg parsing, --help/--version, bidirectional conversion. Pure helpers (parseArgs, detectDirection, getDefaultOutputPath) are exported for testability, and an isDirectRun guard prevents main() from running on import.
  • package.json — adds the bin entry (cdb-converter → dist/cli.mjs) and @types/sql.js as a devDependency.
  • tsup.config.ts — second build entry for the CLI (ESM, shebang preserved).
  • src/types.ts — relaxes the SqlDatabase.run param type so a real sql.js Database (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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts with arg parsing, direction detection by extension, and conversion execution.
  • Updates build/package metadata to ship an installable cdb-converter binary.
  • Adds unit tests for CLI helper functions and relaxes SqlDatabase.run typing 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.

Comment thread src/cli.ts
Comment thread src/cli.ts
Comment thread src/cli.ts
Comment thread src/cli.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Comment thread src/types.ts Outdated
Comment thread src/cli.ts
@mpicciolli mpicciolli changed the title feat(cli): add cdb-converter CLI feat: add cdb-converter CLI Jul 1, 2026
@mpicciolli
mpicciolli merged commit f5a04f6 into main Jul 1, 2026
5 checks passed
@mpicciolli
mpicciolli deleted the feat/cli branch July 1, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants