diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..cc1944dc --- /dev/null +++ b/.envrc @@ -0,0 +1,25 @@ +# Runs `devenv sync` to install `uv`, `yarn install`, and installs the `pre-commit` hook. + +if [[ -x "${PWD}/.devenv/bin/devenv" ]]; then + DEVENV="${PWD}/.devenv/bin/devenv" +elif command -v devenv >/dev/null 2>&1; then + DEVENV="devenv" +fi + +if [[ -n "$DEVENV" ]]; then + $DEVENV sync + PATH_add "${PWD}/.devenv/bin" +fi + +if ! command -v uv >/dev/null 2>&1; then + echo "ERROR: Please install devenv (https://github.com/getsentry/devenv) or uv (https://docs.astral.sh/uv/)" + return 1 +fi + +if [ ! -d "node_modules" ]; then + yarn install +fi + +if command -v uvx >/dev/null 2>&1 && [ ! -f ".git/hooks/pre-commit" ]; then + uvx pre-commit@latest install +fi diff --git a/.gitignore b/.gitignore index 868f4471..013db6fd 100644 --- a/.gitignore +++ b/.gitignore @@ -146,4 +146,7 @@ dist # Turborepo .turbo -.DS_Store \ No newline at end of file +.DS_Store + +# Devenv +**/__pycache__ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..7d0898a9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,15 @@ +repos: + - repo: local + hooks: + - id: format + name: format + description: yarn format + entry: yarn format + language: system + pass_filenames: false + - id: lint + name: lint + description: yarn lint + entry: yarn lint + language: system + pass_filenames: false diff --git a/biome.json b/biome.json index 9f8e97d0..a466299f 100644 --- a/biome.json +++ b/biome.json @@ -3,7 +3,7 @@ "vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false }, "files": { "ignoreUnknown": false, - "ignore": ["dist/*", "javascript/sentry-conventions/package.json", "rust/*", "python/*"] + "ignore": [".devenv/*", "dist/*", "javascript/sentry-conventions/package.json", "rust/*", "python/*"] }, "formatter": { "enabled": true, diff --git a/devenv/config.ini b/devenv/config.ini new file mode 100644 index 00000000..9c6d4725 --- /dev/null +++ b/devenv/config.ini @@ -0,0 +1,21 @@ +[devenv] +minimum_version = 1.22.0 + +[uv] +darwin_arm64 = https://github.com/astral-sh/uv/releases/download/0.9.3/uv-aarch64-apple-darwin.tar.gz +darwin_arm64_sha256 = d6b2eaa1025b24b4779602763ad92f20112cbf19732fc6e0c72bb57a6a592c6c +# used for autoupdate +version = 0.9.3 + +[node] +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 + +[yarn] +version = 1.22.22 diff --git a/devenv/sync.py b/devenv/sync.py new file mode 100644 index 00000000..989ae963 --- /dev/null +++ b/devenv/sync.py @@ -0,0 +1,25 @@ +from devenv import constants +from devenv.lib import config, node, uv + + +def main(context: dict[str, str]) -> int: + reporoot = context["reporoot"] + cfg = config.get_repo(reporoot) + + uv.install( + cfg["uv"]["version"], + cfg["uv"][constants.SYSTEM_MACHINE], + cfg["uv"][f"{constants.SYSTEM_MACHINE}_sha256"], + reporoot, + ) + + node.install( + cfg["node"]["version"], + cfg["node"][constants.SYSTEM_MACHINE], + cfg["node"][f"{constants.SYSTEM_MACHINE}_sha256"], + reporoot, + ) + + node.install_yarn(cfg["yarn"]["version"], reporoot) + + return 0