Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@objectdocs/cli

The central CLI orchestration tool for the ObjectStack documentation platform.

Overview

This CLI acts as the unified interface for developing, building, and translating the ObjectStack documentation. It wraps the application logic in @objectdocs/site and adds workflow automation.

Features

  • Site Orchestration: Manages the Next.js development server and static build process.
  • AI Translation: Automatically translates MDX documentation from English to Chinese using OpenAI.
  • Artifact Management: Handles build output movement and directory structure organization.
  • Smart Updates: Can process specific files or bulk translate the entire documentation.

Installation

This package is part of the monorepo workspace. Install dependencies from the root:

pnpm install

Usage

Initialize Site

Before using the development or build commands, you need to initialize the site:

# Initialize ObjectDocs site in content/.fumadocs
pnpm objectdocs init

This command:

  • Copies the @objectdocs/site package to content/.fumadocs
  • Installs necessary dependencies
  • Automatically adds content/.fumadocs to .gitignore
  • Prepares your project for local development

Site Management

The CLI can also be used to run the documentation site locally with a VitePress-like experience.

# Start Dev Server
# Usage: pnpm objectdocs dev [docs-directory]
pnpm objectdocs dev ./content/docs

# Build Static Site
# Usage: pnpm objectdocs build [docs-directory]
pnpm objectdocs build ./content/docs

Translate Documentation

The translate command reads English documentation from content/docs/*.mdx and generates Chinese translations as *.cn.mdx files in the same directory using the dot parser convention.

Prerequisites: You must set the following environment variables (in .env or your shell):

OPENAI_API_KEY=sk-...
OPENAI_BASE_URL=https://api.openai.com/v1 # Optional

Commands:

# Translate a specific file
pnpm objectdocs translate content/docs/00-intro/index.mdx

# Translate multiple files
pnpm objectdocs translate content/docs/00-intro/index.mdx content/docs/01-quickstart/index.mdx

# Translate all files in content/docs
pnpm objectdocs translate --all

# Specify a custom model (default: gpt-4o)
pnpm objectdocs translate --all --model gpt-4-turbo

CI/CD Integration

In CI environments, you can use the CHANGED_FILES environment variable to translate only modified files:

export CHANGED_FILES="content/docs/new-page.mdx"
pnpm objectdocs translate