mirror of
https://github.com/twentyhq/twenty.git
synced 2026-06-12 09:57:03 -04:00
## after `yarn twenty dev:generate-client` <img width="1149" height="246" alt="image" src="https://github.com/user-attachments/assets/1edcba03-2647-4bc8-8188-7ad69362ac52" /> <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/21489?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
106 lines
3.4 KiB
Plaintext
106 lines
3.4 KiB
Plaintext
---
|
|
title: CLI
|
|
description: yarn twenty commands for executing functions, streaming logs, managing app installations, and switching remotes.
|
|
icon: "terminal"
|
|
---
|
|
|
|
Beyond `dev`, `dev:build`, `dev:add`, and `dev:typecheck`, the `yarn twenty` CLI provides commands for executing functions, viewing logs, and managing app installations.
|
|
|
|
## Executing functions (`yarn twenty dev:function:exec`)
|
|
|
|
Run a logic function manually without triggering it via HTTP, cron, or database event:
|
|
|
|
```bash filename="Terminal"
|
|
# Execute by function name
|
|
yarn twenty dev:function:exec -n create-new-post-card
|
|
|
|
# Execute by universalIdentifier
|
|
yarn twenty dev:function:exec -u e56d363b-0bdc-4d8a-a393-6f0d1c75bdcf
|
|
|
|
# Pass a JSON payload
|
|
yarn twenty dev:function:exec -n create-new-post-card -p '{"name": "Hello"}'
|
|
|
|
# Execute the post-install function
|
|
yarn twenty dev:function:exec --postInstall
|
|
```
|
|
|
|
## Viewing function logs (`yarn twenty dev:function:logs`)
|
|
|
|
Stream execution logs for your app's logic functions:
|
|
|
|
```bash filename="Terminal"
|
|
# Stream all function logs
|
|
yarn twenty dev:function:logs
|
|
|
|
# Filter by function name
|
|
yarn twenty dev:function:logs -n create-new-post-card
|
|
|
|
# Filter by universalIdentifier
|
|
yarn twenty dev:function:logs -u e56d363b-0bdc-4d8a-a393-6f0d1c75bdcf
|
|
```
|
|
|
|
<Note>
|
|
This is different from `yarn twenty docker:logs`, which shows the Docker container logs. `yarn twenty dev:function:logs` shows your app's function execution logs from the Twenty server.
|
|
</Note>
|
|
|
|
## Generating the typed client (`yarn twenty dev:generate-client`)
|
|
|
|
Regenerate the typed API client (`twenty-client-sdk`) from the active remote's schema, without building or syncing an app. Use it to get a typed client in any project — like a backend service living in a separate repository — that talks to your Twenty instance:
|
|
|
|
```bash filename="Terminal"
|
|
# In your project (no Twenty app definition required)
|
|
yarn add twenty-sdk twenty-client-sdk
|
|
|
|
# Connect to the Twenty instance to generate the client from
|
|
yarn twenty remote:add
|
|
|
|
# Generate the typed client into node_modules/twenty-client-sdk
|
|
yarn twenty dev:generate-client
|
|
```
|
|
|
|
Then import the client in your code:
|
|
|
|
```typescript
|
|
import { CoreApiClient } from 'twenty-client-sdk/core';
|
|
```
|
|
|
|
Re-run the command whenever your data model changes to refresh the generated types.
|
|
|
|
<Note>
|
|
The client is generated inside `node_modules`, so it is not committed with your code. Run `yarn twenty dev:generate-client` after every install (for example in a `postinstall` script or in CI).
|
|
</Note>
|
|
|
|
## Uninstalling an app (`yarn twenty app:uninstall`)
|
|
|
|
Remove your app from the active workspace:
|
|
|
|
```bash filename="Terminal"
|
|
yarn twenty app:uninstall
|
|
|
|
# Skip the confirmation prompt
|
|
yarn twenty app:uninstall --yes
|
|
```
|
|
|
|
## Managing remotes
|
|
|
|
A **remote** is a Twenty server that your app connects to. During setup, the scaffolder creates one for you automatically. You can add more remotes or switch between them at any time.
|
|
|
|
```bash filename="Terminal"
|
|
# Add a new remote (opens a browser for OAuth login)
|
|
yarn twenty remote:add
|
|
|
|
# Connect to a local Twenty server (auto-detects port 2020 or 3000)
|
|
yarn twenty remote:add --local
|
|
|
|
# Add a remote non-interactively (useful for CI)
|
|
yarn twenty remote:add --url https://your-twenty-server.com --api-key $TWENTY_API_KEY --as my-remote
|
|
|
|
# List all configured remotes
|
|
yarn twenty remote:list
|
|
|
|
# Set the active remote
|
|
yarn twenty remote:use <name>
|
|
```
|
|
|
|
Your credentials are stored in `~/.twenty/config.json`.
|