Skip to content

Commit

Permalink
Make Corepack installed binaries available at runtime (#1250)
Browse files Browse the repository at this point in the history
  • Loading branch information
colincasey authored May 2, 2024
1 parent 80b9382 commit 35cf1ea
Show file tree
Hide file tree
Showing 15 changed files with 9,357 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Make [Corepack](https://nodejs.org/api/corepack.html) installed binaries available at runtime. ([#1250](https://github.com/heroku/heroku-buildpack-nodejs/pull/1250))

## [v245] - 2024-04-29

Expand Down
2 changes: 2 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ source "$BP_DIR/lib/yarn-2.sh"

export PATH="$BUILD_DIR/.heroku/node/bin:$BUILD_DIR/.heroku/yarn/bin":$PATH

export COREPACK_HOME="$BUILD_DIR/.heroku/corepack"

LOG_FILE=$(mktemp -t node-build-log.XXXXX)
echo "" > "$LOG_FILE"

Expand Down
2 changes: 2 additions & 0 deletions profile/nodejs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export PATH="$HOME/.heroku/node/bin:$HOME/.heroku/yarn/bin:$PATH:$HOME/bin:$HOME/node_modules/.bin"
export NODE_HOME="$HOME/.heroku/node"
export NODE_ENV=${NODE_ENV:-production}
export COREPACK_HOME="$HOME/.heroku/corepack"


# If the user has opted into the feature
if [[ -n "$HEROKU_METRICS_URL" ]] && \
Expand Down
18 changes: 18 additions & 0 deletions spec/ci/corepack_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require_relative '../spec_helper'

describe "corepack support" do
it "should be able to run an app that installs pnpm using corepack" do
app = Hatchet::Runner.new("spec/fixtures/repos/corepack-pnpm")
app.deploy do |app|
expect(successful_body(app).strip).to eq("Hello from corepack-pnpm")
end
end

it "should be able to run an app that installs yarn using corepack" do
app = Hatchet::Runner.new("spec/fixtures/repos/corepack-yarn")
app.deploy do |app|
expect(successful_body(app).strip).to eq("Hello from corepack-yarn")
end
end
end

1 change: 1 addition & 0 deletions spec/fixtures/repos/corepack-pnpm/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: pnpm run start
12 changes: 12 additions & 0 deletions spec/fixtures/repos/corepack-pnpm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const express = require('express')

const app = express()
const port = process.env.PORT || 3000

app.get('/', (req, res) => {
res.send('Hello from corepack-pnpm')
})

app.listen(port, () => {
console.log(`corepack-pnpm app listening on port ${port}`)
})
16 changes: 16 additions & 0 deletions spec/fixtures/repos/corepack-pnpm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "corepack-pnpm",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"packageManager": "[email protected]+sha256.0624e30eff866cdeb363b15061bdb7fd9425b17bc1bb42c22f5f4efdea21f6b3",
"dependencies": {
"express": "^4.19.2"
}
}
Loading

0 comments on commit 35cf1ea

Please sign in to comment.