baobao_codegen_typescript/lib.rs
1//! TypeScript code generator for Bao CLI generator.
2//!
3//! This crate generates TypeScript CLI applications using [boune](https://www.npmjs.com/package/boune)
4//! a CLI library targeting [Bun](https://bun.com/) runtime.
5//!
6//! # Usage
7//!
8//! This crate is used internally by the `baobao` CLI tool. You typically don't need
9//! to use it directly.
10//!
11//! ```ignore
12//! use baobao_codegen_typescript::Generator;
13//! use baobao_codegen::LanguageCodegen;
14//! use baobao_manifest::Manifest;
15//! use std::path::Path;
16//!
17//! let manifest = Manifest::from_file("bao.toml")?;
18//! let generator = Generator::new(&manifest);
19//!
20//! // Preview files without writing
21//! let files = generator.preview();
22//!
23//! // Generate files to disk
24//! let result = generator.generate(Path::new("output"))?;
25//! ```
26//!
27//! # Generated Output
28//!
29//! The generator produces a TypeScript CLI project structure:
30//!
31//! - `src/cli.ts` - Main CLI setup with boune
32//! - `src/context.ts` - Shared context (database pools, HTTP clients)
33//! - `src/index.ts` - Entry point
34//! - `src/commands/*.ts` - Command definitions
35//! - `src/handlers/*.ts` - Handler stubs for implementation
36//! - `package.json`, `tsconfig.json`, `bao.toml`, `.gitignore`
37
38mod code_file;
39mod generator;
40mod naming;
41mod type_mapper;
42
43pub mod adapters;
44pub mod ast;
45pub mod files;
46
47pub use adapters::{BouneAdapter, BunSqliteAdapter};
48pub use ast::{ArrowFn, Import, JsObject, MethodChain};
49pub use baobao_codegen::language::{GenerateResult, LanguageCodegen, PreviewFile};
50pub use code_file::{CodeFile, RawCode};
51pub use generator::Generator;
52pub use naming::TS_NAMING;
53pub use type_mapper::TypeScriptTypeMapper;