Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/docs/content/docs/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"---Core Features---",
"core-features",
"---How to Guides---",
"guides"
"guides",
"setup-teardown-scripts"
]
}
76 changes: 76 additions & 0 deletions apps/docs/content/docs/setup-teardown-scripts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: Setup & Teardown Scripts
description: Automate workspace initialization and cleanup with config.json
---

## Overview

Superset can automatically run commands when creating or deleting workspaces. This is useful for:

- Installing dependencies
- Running database migrations
- Starting background services
- Cleaning up resources when done

## Configuration

Create a `config.json` file in your project's `.superset` directory:

```
your-project/.superset/config.json
```

## Schema

The config file has two optional arrays:

```json
{
"setup": [
"bun install",
"bun run db:migrate"
],
"teardown": [
"docker-compose down"
]
}
```

### setup

Array of shell commands to run when a new workspace is created. Commands run sequentially in the workspace's worktree directory.

### teardown

Array of shell commands to run when a workspace is deleted. Useful for cleaning up resources like Docker containers or temporary files.

## Using Shell Scripts

For complex setup logic, reference shell scripts instead of inline commands:

```json
{
"setup": ["./.superset/setup.sh"],
"teardown": ["./.superset/teardown.sh"]
}
```

Make sure your scripts are executable:

```bash
chmod +x .superset/setup.sh
```

## How It Works

1. When you create a new workspace, Superset creates a git worktree for your branch
2. If `config.json` exists with setup commands, they run automatically in the new worktree
3. Commands execute in a terminal tab so you can see output
4. When deleting a workspace, teardown commands run before the worktree is removed

## Tips

- Keep setup scripts fast - they run every time you create a workspace
- Use `&&` to chain commands that depend on each other
- Commit `.superset/` to share workspace setup with your team
- For machine-specific values, use environment variables in your scripts instead of hardcoding paths
10 changes: 3 additions & 7 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.