Skip to content

Commit

Permalink
Rollback to the old npm buildpack for Functions (#706)
Browse files Browse the repository at this point in the history
* Roll back to the old npm buildpack for Functions

This adds back the previous behavior for the functions npm process which allows for building an application without a `package-lock.json`.
  • Loading branch information
colincasey authored Oct 26, 2023
1 parent 8f6336c commit de057af
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"parserOptions": {
"ecmaVersion": 2017
},
"env": {
"es6": true
},
"rules": {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"test": "./**/*.test.js",
"recursive": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = async function (event, context, logger) {
logger.info("logging info is a fun 1")
return "Hello World".toLowerCase();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "myfn-function",
"version": "0.0.1",
"author": "TODO",
"description": "TODO",
"license": "UNLICENSED",
"main": "index.js",
"repository": {
"type": "git"
},
"engines": {
"node": "^14.0"
},
"scripts": {
"lint": "eslint . --ext .js --config .eslintrc",
"test": "mocha"
},
"devDependencies": {
"chai": "^4.3.4",
"eslint": "^6.8.0",
"mocha": "^8.4.0",
"sinon": "^10.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[_]
schema-version = "0.2"

[com.salesforce]
schema-version = "0.1"
id = "myfn"
description = "A Function"
type = "function"
salesforce-api-version = "53.0"
17 changes: 17 additions & 0 deletions buildpacks/nodejs-function-invoker/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ fn test_function_with_implicit_runtime_dependency_ts() {
});
}

#[test]
#[ignore]
fn function_with_no_lockfile() {
function_integration_test("./fixtures/function-with-no-lockfile", |ctx| {
assert_contains!(ctx.pack_stdout, "Installing Node.js Function Invoker");
assert_contains!(ctx.pack_stdout, "Running npm install without a package-lock.json is deprecated. Check in your lockfile to git.");
start_container(&ctx, |container, socket_addr| {
assert_health_check_responds(socket_addr);
let payload = serde_json::json!({});
let result = invoke_function(socket_addr, &payload);
assert_eq!(result, serde_json::Value::String("hello world".to_string()));
let container_logs = container.logs_now();
assert_contains!(container_logs.stdout, "logging info is a fun 1");
});
});
}

fn invoke_function(socket_addr: &SocketAddr, payload: &serde_json::Value) -> serde_json::Value {
let id = format!("MyFunction-{}", random_hex_string(10));

Expand Down
1 change: 1 addition & 0 deletions buildpacks/npm/lib/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ install_modules() {
npm install --production=false
fi
else
warning "Running npm install without a package-lock.json is deprecated. Check in your lockfile to git."
info "Installing node modules"
npm install --production=false --no-package-lock
fi
Expand Down
4 changes: 4 additions & 0 deletions meta-buildpacks/nodejs-function/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Rolled back the changes from [#686](https://github.com/heroku/buildpacks-nodejs/pull/686) to restore the previous npm buildpack due to issues with the detect requirement of `package-lock.json`. ([#706](https://github.com/heroku/buildpacks-nodejs/pull/706))

## [2.1.0] - 2023-10-26

### Changed
Expand Down
7 changes: 1 addition & 6 deletions meta-buildpacks/nodejs-function/buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ id = "heroku/nodejs-engine"
version = "2.1.0"

[[order.group]]
id = "heroku/nodejs-npm-engine"
version = "2.1.0"
optional = true

[[order.group]]
id = "heroku/nodejs-npm-install"
id = "heroku/nodejs-npm"
version = "2.1.0"

[[order.group]]
Expand Down
5 changes: 1 addition & 4 deletions meta-buildpacks/nodejs-function/package.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ uri = "."
uri = "libcnb:heroku/nodejs-engine"

[[dependencies]]
uri = "libcnb:heroku/nodejs-npm-engine"

[[dependencies]]
uri = "libcnb:heroku/nodejs-npm-install"
uri = "../../buildpacks/npm"

[[dependencies]]
uri = "libcnb:heroku/nodejs-function-invoker"

0 comments on commit de057af

Please sign in to comment.