Skip to content

Commit ada8591

Browse files
authored
Merge branch 'twentyhq:main' into rahman_husain
2 parents 7c6f814 + 2f095c8 commit ada8591

File tree

170 files changed

+2748
-674
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+2748
-674
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.git
22
.env
3-
node_modules
3+
**/node_modules
44
.nx/cache
55
packages/twenty-server/.env

packages/create-twenty-app/README.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ See Twenty application documentation https://docs.twenty.com/developers/extend/c
2525
## Prerequisites
2626

2727
- Node.js 24+ (recommended) and Yarn 4
28-
- A Twenty workspace and an API key (create one at https://app.twenty.com/settings/api-webhooks)
28+
- Docker (for the local Twenty dev server)
2929

3030
## Quick start
3131

3232
```bash
33+
# Scaffold a new app — the CLI will offer to start a local Twenty server
3334
npx create-twenty-app@latest my-twenty-app
3435
cd my-twenty-app
3536

36-
# Get help and list all available commands
37-
yarn twenty help
37+
# The scaffolder can automatically:
38+
# 1. Start a local Twenty server (Docker)
39+
# 2. Open the browser to log in (tim@apple.dev / tim@apple.dev)
40+
# 3. Authenticate your app via OAuth
3841

39-
# Authenticate with your Twenty server
40-
yarn twenty remote add --local
41-
42-
# Add a new entity to your application (guided)
43-
yarn twenty add
42+
# Or do it manually:
43+
yarn twenty server start # Start local Twenty server
44+
yarn twenty remote add --local # Authenticate via OAuth
4445

4546
# Start dev mode: watches, builds, and syncs local changes to your workspace
46-
# (also auto-generates typed CoreApiClient — MetadataApiClient ships pre-built with the SDK — both available via `twenty-sdk/clients`)
4747
yarn twenty dev
4848

4949
# Watch your application's function logs
@@ -107,10 +107,24 @@ npx create-twenty-app@latest my-app -m
107107
- `skills/example-skill.ts` — Example AI agent skill definition
108108
- `__tests__/app-install.integration-test.ts` — Integration test that builds, installs, and verifies the app (includes `vitest.config.ts`, `tsconfig.spec.json`, and a setup file)
109109

110+
## Local server
111+
112+
The scaffolder can start a local Twenty dev server for you (all-in-one Docker image with PostgreSQL, Redis, server, and worker). You can also manage it manually:
113+
114+
```bash
115+
yarn twenty server start # Start (pulls image if needed)
116+
yarn twenty server status # Check if it's healthy
117+
yarn twenty server logs # Stream logs
118+
yarn twenty server stop # Stop (data is preserved)
119+
yarn twenty server reset # Wipe all data and start fresh
120+
```
121+
122+
The server is pre-seeded with a workspace and user (`tim@apple.dev` / `tim@apple.dev`).
123+
110124
## Next steps
111125

112126
- Run `yarn twenty help` to see all available commands.
113-
- Use `yarn twenty remote add --local` to authenticate with your Twenty workspace.
127+
- Use `yarn twenty remote add --local` to authenticate with your Twenty workspace via OAuth.
114128
- Explore the generated project and add your first entity with `yarn twenty add` (logic functions, front components, objects, roles, views, navigation menu items, skills).
115129
- Use `yarn twenty dev` while you iterate — it watches, builds, and syncs changes to your workspace in real time.
116130
- `CoreApiClient` (for workspace data via `/graphql`) is auto-generated by `yarn twenty dev`. `MetadataApiClient` (for workspace configuration and file uploads via `/metadata`) ships pre-built with the SDK. Both are available via `import { CoreApiClient, MetadataApiClient } from 'twenty-sdk/clients'`.
@@ -153,8 +167,9 @@ Our team reviews contributions for quality, security, and reusability before mer
153167

154168
## Troubleshooting
155169

156-
- Auth prompts not appearing: run `yarn twenty remote add --local` again and verify the API key permissions.
157-
- Types not generated: ensure `yarn twenty dev` is running — it auto‑generates the typed client.
170+
- Server not starting: check Docker is running (`docker info`), then try `yarn twenty server logs`.
171+
- Auth not working: make sure you're logged in to Twenty in the browser first, then run `yarn twenty remote add --local`.
172+
- Types not generated: ensure `yarn twenty dev` is running — it auto-generates the typed client.
158173

159174
## Contributing
160175

packages/create-twenty-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-twenty-app",
3-
"version": "0.8.0-canary.0",
3+
"version": "0.8.0-canary.1",
44
"description": "Command-line interface to create Twenty application",
55
"main": "dist/cli.cjs",
66
"bin": "dist/cli.cjs",
Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,11 @@
1-
This is a [Twenty](https://twenty.com) application project bootstrapped with [`create-twenty-app`](https://www.npmjs.com/package/create-twenty-app).
1+
This is a [Twenty](https://twenty.com) application bootstrapped with [`create-twenty-app`](https://www.npmjs.com/package/create-twenty-app).
22

33
## Getting Started
44

5-
Start development mode — it auto-connects to your local Twenty server at localhost:3000:
6-
7-
```bash
8-
yarn twenty dev
9-
```
10-
11-
Open your Twenty instance and go to `/settings/applications` section to see the result.
12-
13-
## Available Commands
14-
15-
Run `yarn twenty help` to list all available commands. Common commands:
16-
17-
```bash
18-
# Remotes & authentication
19-
yarn twenty remote add --local # Connect to local Twenty server
20-
yarn twenty remote add <url> # Connect to a remote server (OAuth)
21-
yarn twenty remote list # List all configured remotes
22-
yarn twenty remote switch # Switch default remote
23-
yarn twenty remote status # Check auth status
24-
yarn twenty remote remove <name> # Remove a remote
25-
26-
# Development
27-
yarn twenty dev # Start dev mode (watch, build, sync, and auto-generate typed client)
28-
yarn twenty build # Build the application
29-
yarn twenty deploy # Deploy to a Twenty server
30-
yarn twenty publish # Publish to npm
31-
yarn twenty add # Add a new entity (object, field, function, front-component, role, view, navigation-menu-item)
32-
yarn twenty exec # Execute a function with JSON payload
33-
yarn twenty logs # Stream function logs
34-
yarn twenty uninstall # Uninstall app from server
35-
```
36-
37-
## Integration Tests
38-
39-
If your project includes the example integration test (`src/__tests__/app-install.integration-test.ts`), you can run it with:
40-
41-
```bash
42-
# Make sure a Twenty server is running at http://localhost:3000
43-
yarn test
44-
```
45-
46-
The test builds and installs the app, then verifies it appears in the applications list. Test configuration (API URL and API key) is defined in `vitest.config.ts`.
47-
48-
## LLMs instructions
49-
50-
Main docs and pitfalls are available in LLMS.md file.
5+
Run `yarn twenty help` to list all available commands.
516

527
## Learn More
538

54-
To learn more about Twenty applications, take a look at the following resources:
55-
56-
- [twenty-sdk](https://www.npmjs.com/package/twenty-sdk) - learn about `twenty-sdk` tool.
57-
- [Twenty doc](https://docs.twenty.com/) - Twenty's documentation.
58-
- Join our [Discord](https://discord.gg/cx5n4Jzs57)
59-
60-
You can check out [the Twenty GitHub repository](https://github.com/twentyhq/twenty) - your feedback and contributions are welcome!
9+
- [Twenty Apps documentation](https://docs.twenty.com/developers/extend/capabilities/apps)
10+
- [twenty-sdk CLI reference](https://www.npmjs.com/package/twenty-sdk)
11+
- [Discord](https://discord.gg/cx5n4Jzs57)

packages/create-twenty-app/src/create-app.command.ts

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class CreateAppCommand {
4646

4747
await fs.ensureDir(appDirectory);
4848

49+
console.log(chalk.gray(' Scaffolding project files...'));
4950
await copyBaseApplicationProject({
5051
appName,
5152
appDisplayName,
@@ -54,29 +55,20 @@ export class CreateAppCommand {
5455
exampleOptions,
5556
});
5657

58+
console.log(chalk.gray(' Installing dependencies...'));
5759
await install(appDirectory);
5860

61+
console.log(chalk.gray(' Initializing git repository...'));
5962
await tryGitInit(appDirectory);
6063

6164
let localResult: LocalInstanceResult = { running: false };
6265

6366
if (!options.skipLocalInstance) {
64-
const { needsLocalInstance } = await inquirer.prompt([
65-
{
66-
type: 'confirm',
67-
name: 'needsLocalInstance',
68-
message:
69-
'Do you need a local instance of Twenty? Recommended if you not have one already.',
70-
default: true,
71-
},
72-
]);
73-
74-
if (needsLocalInstance) {
75-
localResult = await setupLocalInstance();
76-
}
67+
// Auto-detect a running server first
68+
localResult = await setupLocalInstance(appDirectory);
7769

78-
if (isDefined(localResult.apiKey)) {
79-
this.runAuthLogin(appDirectory, localResult.apiKey);
70+
if (localResult.running && localResult.serverUrl) {
71+
await this.connectToLocal(appDirectory, localResult.serverUrl);
8072
}
8173
}
8274

@@ -201,23 +193,29 @@ export class CreateAppCommand {
201193
appDirectory: string;
202194
appName: string;
203195
}): void {
204-
console.log(chalk.blue('🎯 Creating Twenty Application'));
205-
console.log(chalk.gray(`📁 Directory: ${appDirectory}`));
206-
console.log(chalk.gray(`📝 Name: ${appName}`));
196+
console.log(chalk.blue('Creating Twenty Application'));
197+
console.log(chalk.gray(` Directory: ${appDirectory}`));
198+
console.log(chalk.gray(` Name: ${appName}`));
207199
console.log('');
208200
}
209201

210-
private runAuthLogin(appDirectory: string, apiKey: string): void {
202+
private async connectToLocal(
203+
appDirectory: string,
204+
serverUrl: string,
205+
): Promise<void> {
211206
try {
212207
execSync(
213-
`yarn twenty auth:login --api-key "${apiKey}" --api-url http://localhost:3000`,
214-
{ cwd: appDirectory, stdio: 'inherit' },
208+
`npx nx run twenty-sdk:start -- remote add ${serverUrl} --as local`,
209+
{
210+
cwd: appDirectory,
211+
stdio: 'inherit',
212+
},
215213
);
216-
console.log(chalk.green('Authenticated with local Twenty instance.'));
214+
console.log(chalk.green('Authenticated with local Twenty instance.'));
217215
} catch {
218216
console.log(
219217
chalk.yellow(
220-
'⚠️ Auto auth:login failed. Run `yarn twenty auth:login` manually.',
218+
'Authentication skipped. Run `npx nx run twenty-sdk:start -- remote add --local` manually.',
221219
),
222220
);
223221
}
@@ -229,27 +227,21 @@ export class CreateAppCommand {
229227
): void {
230228
const dirName = appDirectory.split('/').reverse()[0] ?? '';
231229

232-
console.log(chalk.green('Application created!'));
230+
console.log(chalk.green('Application created!'));
233231
console.log('');
234232
console.log(chalk.blue('Next steps:'));
235233
console.log(chalk.gray(` cd ${dirName}`));
236234

237-
if (localResult.apiKey) {
238-
console.log(chalk.gray(' yarn twenty app:dev # Start dev mode'));
239-
} else if (localResult.running) {
235+
if (!localResult.running) {
240236
console.log(
241237
chalk.gray(
242238
' yarn twenty remote add --local # Authenticate with Twenty',
243239
),
244240
);
245-
console.log(chalk.gray(' yarn twenty app:dev # Start dev mode'));
246-
} else {
247-
console.log(
248-
chalk.gray(
249-
' yarn twenty remote add --local # Authenticate with Twenty',
250-
),
251-
);
252-
console.log(chalk.gray(' yarn twenty app:dev # Start dev mode'));
253241
}
242+
243+
console.log(
244+
chalk.gray(' yarn twenty dev # Start dev mode'),
245+
);
254246
}
255247
}

0 commit comments

Comments
 (0)