Skip to content
Closed
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
16 changes: 16 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/not/executable/bash

if [[ -f "${PWD}/.env" ]]; then
dotenv
fi

PATH_add "${HOME}/.local/share/sentry-devenv/bin"

if ! command -v devenv >/dev/null; then
echo "install devenv: https://github.com/getsentry/devenv#install"
return 1
fi

PATH_add "${PWD}/.devenv/bin"

PATH_add "${PWD}/node_modules/.bin"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ coverage
# Generated files
packages/mcp-server/src/toolDefinitions.json
packages/mcp-server/src/skillDefinitions.json

__pycache__
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
clean:
@echo "🧹 Cleaning build outputs, caches, and dependencies..."
@echo ""

@# Remove all node_modules directories
@echo "Removing node_modules..."
@find . -name "node_modules" -type d -prune -exec rm -rf {} + 2>/dev/null || true

@# Remove all dist directories (build outputs)
@echo "Removing dist directories..."
@find . -name "dist" -type d -prune -exec rm -rf {} + 2>/dev/null || true

@# Remove all .turbo directories (turbo cache)
@echo "Removing .turbo cache directories..."
@find . -name ".turbo" -type d -prune -exec rm -rf {} + 2>/dev/null || true

@# Remove coverage directories
@echo "Removing coverage directories..."
@find . -name "coverage" -type d -prune -exec rm -rf {} + 2>/dev/null || true

@# Remove Cloudflare wrangler cache
@echo "Removing .wrangler cache directories..."
@find . -name ".wrangler" -type d -prune -exec rm -rf {} + 2>/dev/null || true

@# Remove pnpm store (optional - uncomment if you want to clean the global pnpm cache too)
@# pnpm store prune

@echo ""
@echo "✅ Clean complete!"
@echo ""
Expand All @@ -37,7 +37,7 @@ clean:
setup-env:
@echo "Setting up environment files for local development..."
@echo ""

@# Create root .env if it doesn't exist
@if [ ! -f .env ]; then \
echo "Creating root .env from .env.example..."; \
Expand All @@ -49,7 +49,7 @@ setup-env:
echo "✅ Root .env already exists"; \
fi
@echo ""

@# Create cloudflare .env if it doesn't exist
@if [ ! -f packages/mcp-cloudflare/.env ]; then \
echo "Creating packages/mcp-cloudflare/.env from .env.example..."; \
Expand All @@ -70,4 +70,4 @@ setup-env:
@echo ""
@echo "Next steps:"
@echo "1. Edit the .env files with your credentials"
@echo "2. Run 'pnpm dev' to start the development server"
@echo "2. Run 'pnpm dev' to start the development server"
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,36 @@ Note: If you have issues with your OAuth flow when accessing the inspector on `1

To contribute changes, you'll need to set up your local environment:

1. **Set up environment files:**
1. **Install node and pnpm:**

You can either install it your own way or use [devenv](https://github.com/getsentry/devenv) to perform an isolated install of node + pnpm:

```shell
devenv sync
direnv allow
```

2. **Set up environment files:**

```shell
make setup-env # Creates both .env files from examples
```

2. **Create an OAuth App in Sentry** (Settings => API => [Applications](https://sentry.io/settings/account/api/applications/)):
3. **Create an OAuth App in Sentry** (Settings => API => [Applications](https://sentry.io/settings/account/api/applications/)):

- Homepage URL: `http://localhost:5173`
- Authorized Redirect URIs: `http://localhost:5173/oauth/callback`
- Note your Client ID and generate a Client secret

3. **Configure your credentials:**
4. **Configure your credentials:**

- Edit `.env` in the root directory and add your `OPENAI_API_KEY`
- Edit `packages/mcp-cloudflare/.env` and add:
- `SENTRY_CLIENT_ID=your_development_sentry_client_id`
- `SENTRY_CLIENT_SECRET=your_development_sentry_client_secret`
- `COOKIE_SECRET=my-super-secret-cookie`

4. **Start the development server:**
5. **Start the development server:**

```shell
pnpm dev
Expand Down
14 changes: 14 additions & 0 deletions devenv/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[devenv]
minimum_version = 1.22.2

[node]
# upstream (https://nodejs.org/dist/) is not reliable enough
# ask someone in team-devinfra to upload for you
darwin_x86_64 = https://storage.googleapis.com/sentry-dev-infra-assets/node/node-v22.16.0-darwin-x64.tar.xz
darwin_x86_64_sha256 = 5c34638f2c0e3f3aaa7b3a94b58304765a169730da1896ebba8515ea4d987a9c
darwin_arm64 = https://storage.googleapis.com/sentry-dev-infra-assets/node/node-v22.16.0-darwin-arm64.tar.xz
darwin_arm64_sha256 = aaf7fc3c936f1b359bc312b63638e41f258689ac2303966ad932cda18c54ea00
linux_x86_64 = https://storage.googleapis.com/sentry-dev-infra-assets/node/node-v22.16.0-linux-x64.tar.xz
linux_x86_64_sha256 = f4cb75bb036f0d0eddf6b79d9596df1aaab9ddccd6a20bf489be5abe9467e84e
# used for autoupdate
version = v22.16.0
67 changes: 67 additions & 0 deletions devenv/sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from __future__ import annotations

import json
import os
import shutil

from devenv import constants
from devenv.lib import config, fs, proc


def installed_pnpm(version: str, binroot: str) -> bool:
if shutil.which("pnpm", path=binroot) != f"{binroot}/pnpm" or not os.path.exists(
f"{binroot}/node-env/bin/pnpm"
):
return False

stdout = proc.run((f"{binroot}/pnpm", "--version"), stdout=True)
installed_version = stdout.strip()
return version == installed_version


def install_pnpm(version: str, reporoot: str) -> None:
binroot = fs.ensure_binroot(reporoot)

if installed_pnpm(version, binroot):
return

print(f"installing pnpm {version}...")

# {binroot}/npm is a devenv-managed shim, so
# this install -g ends up putting pnpm into
# .devenv/bin/node-env/bin/pnpm which is pointed
# to by the {binroot}/pnpm shim
proc.run((f"{binroot}/npm", "install", "-g", f"pnpm@{version}"), stdout=True)

fs.write_script(
f"{binroot}/pnpm",
"""#!/bin/sh
export PATH={binroot}/node-env/bin:"${{PATH}}"
exec {binroot}/node-env/bin/pnpm "$@"
""",
shell_escape={"binroot": binroot},
)


def main(context: dict[str, str]) -> int:
reporoot = context["reporoot"]
cfg = config.get_repo(reporoot)

from devenv.lib import node

node.install(
cfg["node"]["version"],
cfg["node"][constants.SYSTEM_MACHINE],
cfg["node"][f"{constants.SYSTEM_MACHINE}_sha256"],
reporoot,
)

with open(f"{reporoot}/package.json") as f:
package_json = json.load(f)
pnpm = package_json["packageManager"]
pnpm_version = pnpm.split("@")[-1]

# TODO: move pnpm install into devenv

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've been procrastinating a bit on https://linear.app/getsentry/issue/DI-1012/devenv-install-pnpm but since more repos are using pnpm i'll probably get around to it next week!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will update this PR after getsentry/devenv#210 gets merged + new release!

install_pnpm(pnpm_version, reporoot)

return 0