ab7c760872
Created by Github action <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/21493?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. --> Co-authored-by: github-actions <github-actions@twenty.com>
106 lines
3.6 KiB
Plaintext
106 lines
3.6 KiB
Plaintext
---
|
|
title: CLI
|
|
description: comandos `yarn twenty` para executar funções, transmitir logs, gerenciar instalações de aplicativos e alternar remotos.
|
|
icon: terminal
|
|
---
|
|
|
|
Além de `dev`, `dev:build`, `dev:add` e `dev:typecheck`, a CLI `yarn twenty` fornece comandos para executar funções, visualizar logs e gerenciar instalações de aplicativos.
|
|
|
|
## Executando funções (`yarn twenty dev:function:exec`)
|
|
|
|
Execute manualmente uma função de lógica sem acioná-la via HTTP, cron ou evento de banco de dados:
|
|
|
|
```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
|
|
```
|
|
|
|
## Visualizando logs de funções (`yarn twenty dev:function:logs`)
|
|
|
|
Transmita os logs de execução das funções de lógica do seu aplicativo:
|
|
|
|
```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>
|
|
Isso é diferente de `yarn twenty docker:logs`, que mostra os logs do contêiner Docker. `yarn twenty dev:function:logs` mostra os logs de execução de funções do seu aplicativo a partir do servidor Twenty.
|
|
</Note>
|
|
|
|
## Gerando o cliente tipado (`yarn twenty dev:generate-client`)
|
|
|
|
Regenerar o cliente de API tipado (`twenty-client-sdk`) a partir do esquema do remoto ativo, sem compilar nem sincronizar um aplicativo. Use-o para obter um cliente tipado em qualquer projeto — como um serviço de backend em um repositório separado — que se comunica com a sua instância do Twenty:
|
|
|
|
```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
|
|
```
|
|
|
|
Em seguida, importe o cliente no seu código:
|
|
|
|
```typescript
|
|
import { CoreApiClient } from 'twenty-client-sdk/core';
|
|
```
|
|
|
|
Execute novamente o comando sempre que o seu modelo de dados for alterado para atualizar os tipos gerados.
|
|
|
|
<Note>
|
|
O cliente é gerado dentro de `node_modules`, portanto não é incluído no commit junto com o seu código. Execute `yarn twenty dev:generate-client` após cada instalação (por exemplo, em um script `postinstall` ou no CI).
|
|
</Note>
|
|
|
|
## Desinstalando um aplicativo (`yarn twenty app:uninstall`)
|
|
|
|
Remova seu aplicativo do espaço de trabalho ativo:
|
|
|
|
```bash filename="Terminal"
|
|
yarn twenty app:uninstall
|
|
|
|
# Skip the confirmation prompt
|
|
yarn twenty app:uninstall --yes
|
|
```
|
|
|
|
## Gerenciando remotos
|
|
|
|
Um **remoto** é um servidor Twenty ao qual seu aplicativo se conecta. Durante a configuração, o gerador de scaffold cria um para você automaticamente. Você pode adicionar mais remotos ou alternar entre eles a qualquer momento.
|
|
|
|
```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>
|
|
```
|
|
|
|
Suas credenciais são armazenadas em `~/.twenty/config.json`.
|