Skip to content

Commands API

New Command

ok_cli.commands.new

Functions

new(name)

Create a new React Native app.

Source code in ok_cli/commands/new.py
def new(name: str):
    """Create a new React Native app."""
    typer.echo(f"🚀 Creating app '{name}'...")
    try:
        copy(
            TEMPLATE_PATH,
            name,
            data={"project_slug": name},
            quiet=True,
        )
        typer.echo(f"✅ App '{name}' created successfully!")
    except Exception as e:
        typer.echo(f"❌ Error creating app: {str(e)}", err=True)
        raise typer.Exit(code=1)

Generate Command

ok_cli.commands.generate

Functions

generate(type, name)

Generate a component, service, or page.

Source code in ok_cli/commands/generate.py
def generate(type: str, name: str):
    """Generate a component, service, or page."""
    type = type.lower()
    if type not in TEMPLATES:
        typer.echo("❌ Invalid type. Use one of: component, service, page.")
        return

    template_path = TEMPLATES[type]
    if not os.path.exists(template_path):
        typer.echo(f"❌ Template '{type}' not found at {template_path}")
        return

    typer.echo(f"✨ Generating {type}: {name}")
    try:
        copy(
            template_path,
            name,
            data={"name": name},
            quiet=True,
        )
        typer.echo(f"✅ {type.capitalize()} '{name}' generated successfully!")
    except Exception as e:
        typer.echo(f"❌ Error generating {type}: {str(e)}", err=True)
        raise typer.Exit(code=1)

Other Commands

ok_cli.commands.add

Functions

add(collection)

Add support for an external library.

Source code in ok_cli/commands/add.py
4
5
6
7
def add(collection: str):
    """Add support for an external library."""
    typer.echo(f"📦 Installing {collection} via npm...")
    subprocess.run(["npm", "install", collection])

ok_cli.commands.analytics

Functions

analytics()

Toggle analytics (placeholder).

Source code in ok_cli/commands/analytics.py
3
4
5
def analytics():
    """Toggle analytics (placeholder)."""
    typer.echo("📊 Analytics are not implemented, but could be tracked in the future.")

ok_cli.commands.build

Functions

build()

Build the project (EAS Build or custom scripts).

Source code in ok_cli/commands/build.py
5
6
7
8
def build():
    """Build the project (EAS Build or custom scripts)."""
    typer.echo("🔧 Building app with EAS...")
    subprocess.run(["eas", "build"], check=False)

ok_cli.commands.cache

Functions

cache(clear=typer.Option(False, '--clear', help='Clear cache directory'))

Configure or clear build cache.

Source code in ok_cli/commands/cache.py
def cache(clear: bool = typer.Option(False, "--clear", help="Clear cache directory")):
    """Configure or clear build cache."""
    if clear:
        if os.path.exists(CACHE_DIR):
            shutil.rmtree(CACHE_DIR)
            typer.echo("🧹 Expo cache cleared.")
        else:
            typer.echo("⚠️ No cache directory found.")
    else:
        typer.echo(f"📂 Cache directory: {CACHE_DIR}")

ok_cli.commands.completion

Functions

completion()

Set up shell autocompletion (for bash/zsh).

Source code in ok_cli/commands/completion.py
4
5
6
7
def completion():
    """Set up shell autocompletion (for bash/zsh)."""
    typer.echo("⚙️ Add this to your ~/.bashrc or ~/.zshrc:\n")
    typer.echo('  eval "$(_RN_CLI_COMPLETE=source_bash rn)"')

ok_cli.commands.config

Functions

config(key=None)

Show config (reads from package.json or .env).

Source code in ok_cli/commands/config.py
def config(key: Optional[str] = None):
    """Show config (reads from package.json or .env)."""
    import json
    try:
        with open("package.json") as f:
            pkg = json.load(f)
        if key:
            typer.echo(pkg.get(key, f"Key '{key}' not found"))
        else:
            typer.echo(json.dumps(pkg, indent=2))
    except FileNotFoundError:
        typer.echo("❌ package.json not found.")

ok_cli.commands.deploy

Functions

deploy()

Deploy app (e.g., using EAS Submit or Expo updates).

Source code in ok_cli/commands/deploy.py
5
6
7
8
9
def deploy():
    """Deploy app (e.g., using EAS Submit or Expo updates)."""
    typer.echo("🚀 Deploying app (placeholder)...")
    # Replace with real deploy command
    subprocess.run(["echo", "Deploy logic here..."], check=False)

ok_cli.commands.e2e

Functions

e2e()

Run end-to-end tests (e.g., Detox).

Source code in ok_cli/commands/e2e.py
5
6
7
8
9
def e2e():
    """Run end-to-end tests (e.g., Detox)."""
    typer.echo("🧪 Running E2E tests (Detox not configured yet)...")
    # Customize based on detox or other tooling
    subprocess.run(["echo", "Detox tests would run here."], check=False)

ok_cli.commands.extract_i18n

Functions

extract_i18n(project=None)

Extract i18n strings (placeholder).

Source code in ok_cli/commands/extract_i18n.py
5
6
7
def extract_i18n(project: Optional[str] = None):
    """Extract i18n strings (placeholder)."""
    typer.echo(f"🌐 Extracting i18n messages from project: {project or 'default'}")

ok_cli.commands.generate

Functions

generate(type, name)

Generate a component, service, or page.

Source code in ok_cli/commands/generate.py
def generate(type: str, name: str):
    """Generate a component, service, or page."""
    type = type.lower()
    if type not in TEMPLATES:
        typer.echo("❌ Invalid type. Use one of: component, service, page.")
        return

    template_path = TEMPLATES[type]
    if not os.path.exists(template_path):
        typer.echo(f"❌ Template '{type}' not found at {template_path}")
        return

    typer.echo(f"✨ Generating {type}: {name}")
    try:
        copy(
            template_path,
            name,
            data={"name": name},
            quiet=True,
        )
        typer.echo(f"✅ {type.capitalize()} '{name}' generated successfully!")
    except Exception as e:
        typer.echo(f"❌ Error generating {type}: {str(e)}", err=True)
        raise typer.Exit(code=1)

ok_cli.commands.lint

Functions

lint(project=None)

Run ESLint on the project.

Source code in ok_cli/commands/lint.py
def lint(project: Optional[str] = None):
    """Run ESLint on the project."""
    target = project or "."
    typer.echo(f"🔍 Linting {target}")
    subprocess.run(["npx", "eslint", target])

ok_cli.commands.run_task

Functions

run_task(target)

Run a custom script from package.json

Source code in ok_cli/commands/run_task.py
4
5
6
7
def run_task(target: str):
    """Run a custom script from package.json"""
    typer.echo(f"🚀 Running target: {target}")
    subprocess.run(["npm", "run", target])

ok_cli.commands.run

Functions

run()

Start the Expo dev server.

Source code in ok_cli/commands/run.py
5
6
7
8
def run():
    """Start the Expo dev server."""
    typer.echo("🏃 Starting Expo server...")
    subprocess.run(["npx", "expo", "start"], check=False)

ok_cli.commands.test

Functions

test()

Run unit tests (Jest).

Source code in ok_cli/commands/test.py
5
6
7
8
def test():
    """Run unit tests (Jest)."""
    typer.echo("🧪 Running tests...")
    subprocess.run(["npm", "test"], check=False)

ok_cli.commands.update

Functions

update()

Update all dependencies.

Source code in ok_cli/commands/update.py
5
6
7
8
9
def update():
    """Update all dependencies."""
    typer.echo("⬆️ Updating dependencies...")
    subprocess.run(["npx", "npm-check-updates", "-u"], check=False)
    subprocess.run(["npm", "install"], check=False)

ok_cli.commands.version

Functions

version()

Show CLI version (from pyproject.toml)

Source code in ok_cli/commands/version.py
def version():
    """Show CLI version (from pyproject.toml)"""
    pyproject_path = os.path.join(os.path.dirname(__file__), "../..", "pyproject.toml")
    try:
        with open(pyproject_path, "rb") as f:
            data = tomllib.load(f)
            cli_version = data["project"]["version"]
            typer.echo(f"🛠️  CLI Version: {cli_version}")
    except Exception as e:
        typer.echo(f"❌ Failed to read version from pyproject.toml: {e}")