TitanbaseDocs

CLI

Status: Planned

A Titanbase command-line interface is part of the roadmap. It is not available yet — there is no titanbase package to install, and the commands below are a planned design sketch, not a shipped API.

Warning

Do not try to npm install -g titanbase or npx titanbase — the package does not exist yet. In the meantime, the same operations are available by importing @titanbase/core and the exporter packages directly in a script.

Planned commands#

These are the commands being considered (planned API sketch — names and flags may change):

  • titanbase validate — validate a .titan.json and exit non-zero on errors, for CI gates.
  • titanbase export — generate output for an available target.
  • titanbase import — bring an existing schema into .titan.json (the SQL import library already ships).
  • titanbase diff — compare two .titan.json versions structurally (the schema diff library already ships).

Planned use cases#

  • CI validation — fail a build when a schema has errors.
  • Deterministic exports — generate schema files as part of a pipeline.
  • Schema diff checks — detect structural changes between versions.
  • Automation — script schema operations without the editor.

Today: use the library directly#

Until the CLI ships, you can run the same logic from a Node script:

import { validateTitanSchema } from "@titanbase/core";
import { exportPostgres } from "@titanbase/export-postgres";

const schema = JSON.parse(await readFile("schema.titan.json", "utf8"));

const { success, diagnostics } = validateTitanSchema(schema);
if (!success) {
  for (const d of diagnostics) console.error(`${d.severity} ${d.code}: ${d.message}`);
  process.exit(1);
}

const { sql } = exportPostgres(schema);
await writeFile("schema.sql", sql);

The CLI will package this kind of workflow once the public API is stabilized. The SQL import and schema diff libraries are already usable from scripts today.