-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add pnpm feature; persist Claude config in agents (agents v1.2.0) #3
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
Merged
+112
−14
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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,16 @@ | ||
| { | ||
| "id": "pnpm", | ||
| "version": "1.0.0", | ||
| "name": "pnpm via Corepack", | ||
| "description": "Enables Corepack and installs the pnpm version pinned in the workspace's package.json `packageManager` field. Optionally removes npm/npx to enforce pnpm.", | ||
| "documentationURL": "https://github.com/rocicorp/devcontainer-features/tree/main/src/pnpm", | ||
| "options": { | ||
| "removeNpm": { | ||
| "type": "boolean", | ||
| "default": true, | ||
| "description": "Remove the npm and npx binaries after setup to enforce pnpm-only usage. Set to false to keep npm available." | ||
| } | ||
| }, | ||
| "postCreateCommand": "/usr/local/share/rocicorp-pnpm/post-create.sh", | ||
| "installsAfter": ["ghcr.io/devcontainers/features/node"] | ||
| } |
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,39 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Option (booleans arrive as the strings "true"/"false"). | ||
| REMOVE_NPM="${REMOVENPM:-true}" | ||
|
|
||
| if ! command -v corepack >/dev/null 2>&1; then | ||
| echo "ERROR: corepack not found. This feature needs a Node.js install (base image or node feature)." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Enabling Corepack..." | ||
| corepack enable | ||
|
|
||
| # `corepack install` (pins pnpm from the workspace packageManager field) and the optional | ||
| # npm removal both have to run at postCreate, not here: | ||
| # - the workspace isn't mounted during the build, so package.json isn't readable yet; | ||
| # - npm must survive until other features (e.g. global npm installs) have run at build time. | ||
| # So we bake a hook script that the feature's postCreateCommand invokes. | ||
| HOOK_DIR=/usr/local/share/rocicorp-pnpm | ||
| HOOK="$HOOK_DIR/post-create.sh" | ||
| mkdir -p "$HOOK_DIR" | ||
|
|
||
| cat > "$HOOK" <<'EOS' | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| # Install the pnpm version pinned in the workspace's package.json (packageManager field). | ||
| corepack install 2>/dev/null || echo "pnpm feature: no packageManager field found; skipping 'corepack install'." | ||
| EOS | ||
|
|
||
| if [ "$REMOVE_NPM" = "true" ]; then | ||
| cat >> "$HOOK" <<'EOS' | ||
| # Enforce pnpm: drop npm/npx so they can't be used by mistake. | ||
| sudo rm -rf /usr/local/bin/npm /usr/local/bin/npx /usr/local/lib/node_modules/npm 2>/dev/null || true | ||
| EOS | ||
| fi | ||
|
|
||
| chmod +x "$HOOK" | ||
| echo "Wrote postCreate hook to $HOOK (removeNpm=$REMOVE_NPM)." | ||
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,13 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| source dev-container-features-test-lib | ||
|
|
||
| # corepack enable installs the pnpm shim onto PATH at build time. | ||
| check "pnpm shim on PATH" bash -c "command -v pnpm" | ||
| check "postCreate hook generated" bash -c "test -x /usr/local/share/rocicorp-pnpm/post-create.sh" | ||
| # removeNpm defaults to true, so the generated postCreate hook should drop npm/npx. | ||
| # (The removal itself runs at postCreate, after build-time installs.) | ||
| check "hook removes npm (removeNpm default true)" bash -c "grep -q 'rm -rf /usr/local/bin/npm' /usr/local/share/rocicorp-pnpm/post-create.sh" | ||
|
|
||
| reportResults |
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 think this causes
.pnpm-store/folder to be created in the repo dir?Here's how we fixed in cloudzero repo: https://github.com/rocicorp/cloudzero/blob/5c10238ad6cd2368b70c35e345d0803482ee0e13/.devcontainer/post-create.sh#L4-L10