Skip to content
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

Added nodejs-npm-install Buildpack #625

Merged
merged 36 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d436eb2
Added nodejs-npm-install Buildpack
colincasey Aug 16, 2023
88d4903
Merge branch 'main' into npm-buildpacks/nodejs-npm-install
colincasey Sep 7, 2023
3597967
Refactoring + output logging and error messages
colincasey Sep 8, 2023
bbf371c
Refactoring + output logging and error messages
colincasey Sep 8, 2023
5496b14
Refactoring + output logging and error messages
colincasey Sep 8, 2023
40dc2bc
Added README.md
colincasey Sep 29, 2023
aca3682
Added new line to buildpack.toml
colincasey Sep 29, 2023
99c3765
Added ending newline to several files
colincasey Sep 29, 2023
2728a94
Fix link
colincasey Sep 29, 2023
73ef5ad
Fix typo
colincasey Sep 29, 2023
27473cf
Merge branch 'main' into npm-buildpacks/nodejs-npm-install
colincasey Oct 4, 2023
d7b8993
Add npm install w/ no package-lock.json
colincasey Oct 4, 2023
4b05d74
Fix lint error
colincasey Oct 4, 2023
9912f70
Don't use -s flag when executing scripts
colincasey Oct 6, 2023
f141c2b
Fix typo in multiple lockfile error and include link
colincasey Oct 6, 2023
39e20f1
Include text from CX error review
colincasey Oct 11, 2023
3049052
Include text from CX error review
colincasey Oct 11, 2023
f3a9ff5
Merge branch 'main' into npm-buildpacks/nodejs-npm-install
colincasey Oct 11, 2023
cee513a
Include text from CX error review
colincasey Oct 11, 2023
fe58644
Fix tests
colincasey Oct 11, 2023
bac2552
Update buildpacks/nodejs-npm-install/buildpack.toml
colincasey Oct 13, 2023
5c1de0d
Update buildpacks/nodejs-npm-install/CHANGELOG.md
colincasey Oct 13, 2023
0d38455
Update buildpacks/nodejs-npm-install/buildpack.toml
colincasey Oct 13, 2023
54943f1
Added try_exist for package.json detection and updated errors
colincasey Oct 13, 2023
f669a1b
Fixed buildpack name
colincasey Oct 16, 2023
64ee342
Update buildpacks/nodejs-npm-install/src/errors.rs
colincasey Oct 16, 2023
99f30bc
Update buildpacks/nodejs-npm-install/src/errors.rs
colincasey Oct 16, 2023
fcb608a
Update buildpacks/nodejs-npm-install/README.md
colincasey Oct 16, 2023
0543ca2
More error corrections.
colincasey Oct 16, 2023
a84f802
Require package-lock to detect and remove support for install with no…
colincasey Oct 17, 2023
1b66b4d
Add package-lock.json to test fixtures
colincasey Oct 17, 2023
e06fcad
Adding exit status clarification
colincasey Oct 17, 2023
07a67c8
Merge branch 'main' into npm-buildpacks/nodejs-npm-install
colincasey Oct 17, 2023
3588650
Update buildpack.toml
colincasey Oct 17, 2023
0099bef
Merge branch 'main' into npm-buildpacks/nodejs-npm-install
colincasey Oct 17, 2023
e86466e
Update lockfile
colincasey Oct 17, 2023
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.idea
dist/
node_modules/
package-lock.json
.tool-versions

packaged/
Expand Down
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"buildpacks/nodejs-corepack",
"buildpacks/nodejs-function-invoker",
"buildpacks/nodejs-npm-engine",
"buildpacks/nodejs-npm-install",
"buildpacks/nodejs-pnpm-install",
"buildpacks/nodejs-yarn",
"common/nodejs-utils",
Expand Down
1 change: 1 addition & 0 deletions README.md

Large diffs are not rendered by default.

36 changes: 1 addition & 35 deletions buildpacks/nodejs-engine/tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![warn(clippy::pedantic)]

use libcnb_test::{assert_contains, assert_not_contains};
use libcnb_test::assert_contains;
use test_support::{
assert_web_response, nodejs_integration_test, nodejs_integration_test_with_config,
set_node_engine,
Expand Down Expand Up @@ -47,37 +47,3 @@ fn reinstalls_node_if_version_changes() {
},
);
}

// TODO: move this test & fixture to the npm buildpack once that is ready
#[test]
#[ignore]
fn npm_project_with_no_lockfile() {
nodejs_integration_test("../../../test/fixtures/npm-project", |ctx| {
assert_contains!(ctx.pack_stdout, "Installing Node");
assert_contains!(ctx.pack_stdout, "Installing node modules");

assert_not_contains!(ctx.pack_stdout, "Installing yarn");
assert_not_contains!(ctx.pack_stdout, "Installing node modules from ./yarn.lock");
assert_not_contains!(
ctx.pack_stdout,
"Installing node modules from ./package-lock.json"
);
});
}

// TODO: move this test & fixture to the npm buildpack once that is ready
#[test]
#[ignore]
fn npm_project_with_lockfile() {
nodejs_integration_test("../../../test/fixtures/npm-project-with-lockfile", |ctx| {
assert_contains!(ctx.pack_stdout, "Installing Node");
assert_contains!(ctx.pack_stdout, "Installing node modules");
assert_contains!(
ctx.pack_stdout,
"Installing node modules from ./package-lock.json"
);

assert_not_contains!(ctx.pack_stdout, "Installing yarn");
assert_not_contains!(ctx.pack_stdout, "Installing node modules from ./yarn.lock");
});
}
13 changes: 13 additions & 0 deletions buildpacks/nodejs-npm-install/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Initial release
colincasey marked this conversation as resolved.
Show resolved Hide resolved

22 changes: 22 additions & 0 deletions buildpacks/nodejs-npm-install/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "heroku-npm-install-buildpack"
description = "Heroku Node.js npm Install Cloud Native Buildpack"
version.workspace = true
rust-version.workspace = true
edition.workspace = true
publish.workspace = true

[dependencies]
commons.workspace = true
heroku-nodejs-utils.workspace = true
libcnb.workspace = true
libherokubuildpack.workspace = true
serde.workspace = true
indoc.workspace = true
toml.workspace = true

[dev-dependencies]
libcnb-test.workspace = true
serde_json.workspace = true
test_support.workspace = true
ureq.workspace = true
65 changes: 65 additions & 0 deletions buildpacks/nodejs-npm-install/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Heroku Cloud Native npm Install Buildpack

[![CI][CI BADGE]][CI LINK] [![Registry][Registry BADGE]][Registry LINK]

Heroku's official Cloud Native Buildpack for executing `npm install`.

## How it works

The buildpack will pass detection if:

- A `package-lock.json` file is found at the root of the application source.
colincasey marked this conversation as resolved.
Show resolved Hide resolved

### Step 1: Configure npm cache

Node modules downloaded during the [install step](#step-2-install-node-modules) will be cached. Subsequent builds will use
this cache speed up installs.

### Step 2: Install Node modules

Node modules are installed by executing `npm ci --production=false`.

### Step 3: Execute build scripts

The following scripts will be executed with `npm run <script>` in the order listed:

- `heroku-prebuild`
- `heroku-build` or `build` (if both are present, only `heroku-build` will execute)
- `heroku-postbuild`

If any of the above scripts are not defined in `package.json` they will be skipped.

### Step 4: Configure processes

If there is a `start` script defined in `package.json` a default `web` process will be
added that executes `npm start`.

## Build Plan

### Requires

| Name | Description |
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `node` | To execute `npm` a [Node.js][Node.js] runtime is required. It can be provided by the [`heroku/nodejs-engine`][heroku/nodejs-engine] buildpack. |
| `npm` | To install node modules, the [npm][npm] package manager is required. It can be provided by either the [`heroku/nodejs-engine`][heroku/nodejs-engine] or [`heroku/nodejs-npm-engine`][heroku/nodejs-npm-engine] buildpacks. |
| `node_modules` | This is not a strict requirement of the buildpack. Requiring `node_modules` ensures that this buildpack can be used even when no other buildpack requires `node_modules`. |


### Provides

| Name | Description |
|----------------|-----------------------------------------------------------------------------------|
| `node_modules` | Allows other buildpacks to depend on the Node modules provided by this buildpack. |

## License

See [LICENSE](../../LICENSE) file.

[CI BADGE]: https://github.com/heroku/buildpacks-nodejs/actions/workflows/ci.yml/badge.svg
[CI LINK]: https://github.com/heroku/buildpacks-nodejs/actions/workflows/ci.yml
[Registry BADGE]: https://img.shields.io/badge/dynamic/json?url=https://registry.buildpacks.io/api/v1/buildpacks/heroku/nodejs-npm-install&label=version&query=$.latest.version&color=DF0A6B&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAACSVJREFUaAXtWQ1sFMcVnp/9ub3zHT7AOEkNOMYYp4CQQFBLpY1TN05DidI2NSTF0CBFQAOBNrTlp0a14sipSBxIG6UYHKCO2ka4SXD4SUuaCqmoJJFMCapBtcGYGqMkDgQ4++52Z2e3b87es+/s+wNHVSUPsnZv9s2b97335v0MCI2NMQ2MaeD/WgP4FqQnX//2K4tVWfa0X+9+q/N4dfgWeESXPPjUUd+cu+5cYmMcPvzawQOtrdVG9GMaLxkD+OZDex6WVeUgwhiZnH1g62bNX4+sPpLGXvEkdPNzLd93e9y/cCnabIQJCnz+2Q9rNs9tjCdM9ltK9nGkb5jYxYjIyDJDSCLSV0yFHCr/XsObvQH92X+8u/b0SGvi5zZUn1joc/u2qapajglB4XAfUlQPoqpyRzxtqt8ZA+AIcQnZEb6WZSKCMSZUfSTLg8vv/86e3b03AztO/u3p7pE2fvInfy70TpiwRVKU5YqqygbTEWL9lISaiDFujbQu2VzGAIYzs5HFDUQo8WKibMzy0Yr7Ht5Td/Nyd0NLS3VQ0FesOjDurtwvPaWp6gZVc080TR2FQn0xrAgxkWVkLD8aBQD9cti2hWwAQimdImHpJTplcmXppF11hcV3Z/n92RsVVbuHc4bCod4YwZ0fHACYCCyS4Rg1AM6+ts2R+JOpNF/Okl/PyvLCeQc/j9O4Q+88hQWY/j+0gCOI84ycD0oRNxnSAVCqgYUFgDbTMeoWiBeAcRNRm8ZPD/uNCYfIZg6bTzXxxQKw4YCboH3SH7WSCRNxI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a8e08GICKC318xzpejrpUQ3UAkaZK4yoGU/HduWts72hsPpyFnSpL2wjWlFNFfSoSWipqIWVYP1J27rwcCL839eF9PMgYpATiLJ01eOs2jaU+D03508cK/9iHUkm6F4LBI+hTlc9m0BSsVSufcCBkvzu7afSHpgrGPYxoY00BEA/8FOPrYBqYsE44AAAAASUVORK5CYII=&labelColor=white
[Registry LINK]: https://registry.buildpacks.io/buildpacks/heroku/nodejs-npm-install
[Node.js]: https://nodejs.org/
[npm]: https://docs.npmjs.com/
[heroku/nodejs-engine]: ../nodejs-engine/README.md
[heroku/nodejs-npm-engine]: ../nodejs-npm-engine/README.md
19 changes: 19 additions & 0 deletions buildpacks/nodejs-npm-install/buildpack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
api = "0.9"

[buildpack]
id = "heroku/nodejs-npm-install"
version = "1.1.7"
name = "Heroku Node.js npm Install Buildpack"
homepage = "https://github.com/heroku/buildpacks-nodejs"
keywords = ["node", "node.js", "nodejs", "javascript", "js", "npm", "install"]

[[buildpack.licenses]]
type = "MIT"

[[stacks]]
id = "*"

[metadata]
[metadata.release]
[metadata.release.image]
repository = "docker.io/heroku/buildpack-nodejs-npm-install"
Loading