Repository navigation
feat(dev): add devenv for pnpm #627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| install_pnpm(pnpm_version, reporoot) | ||
|
|
||
| return 0 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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!