Skip to content

Commit

Permalink
Add unmet deps warning
Browse files Browse the repository at this point in the history
- Refactor runner to include quiet mode
- Refactor npm version to use quiet mode

[#163528537]

Co-authored-by: Danny Joyce <[email protected]>
  • Loading branch information
dfreilich and Danny Joyce committed Feb 13, 2019
1 parent b3d7297 commit 761887f
Show file tree
Hide file tree
Showing 16 changed files with 375 additions and 33 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/cloudfoundry/npm-cnb
require (
github.com/Masterminds/semver v1.4.2
github.com/buildpack/libbuildpack v1.10.0
github.com/cloudfoundry/dagger v0.0.0-20190211213328-5a14d6d7438f
github.com/cloudfoundry/dagger v0.0.0-20190213192159-4348188594f6
github.com/cloudfoundry/libcfbuildpack v1.42.0
github.com/cloudfoundry/nodejs-cnb v0.0.3-0.20181217224909-e1533a296e07
github.com/cloudfoundry/nodejs-cnb v0.0.4
github.com/golang/mock v1.2.0
github.com/kr/pty v1.1.3 // indirect
github.com/onsi/gomega v1.4.3
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/cloudfoundry/dagger v0.0.0-20190204200826-d194e96e09ab h1:jx7sikzaAZA
github.com/cloudfoundry/dagger v0.0.0-20190204200826-d194e96e09ab/go.mod h1:lew8J5SVLq1xe9PXy+38XTiuuW31NWHU92oP6YRkn1w=
github.com/cloudfoundry/dagger v0.0.0-20190211213328-5a14d6d7438f h1:xhUh7luzCWNnXQqj3JtJ+gO+iFWoK4nTEW+y/x24Jc8=
github.com/cloudfoundry/dagger v0.0.0-20190211213328-5a14d6d7438f/go.mod h1:lew8J5SVLq1xe9PXy+38XTiuuW31NWHU92oP6YRkn1w=
github.com/cloudfoundry/dagger v0.0.0-20190213192159-4348188594f6 h1:aT5ZbNHQdfqQKwq8aH93Z/57m2UgkKYxMc5dhCTd+vA=
github.com/cloudfoundry/dagger v0.0.0-20190213192159-4348188594f6/go.mod h1:lew8J5SVLq1xe9PXy+38XTiuuW31NWHU92oP6YRkn1w=
github.com/cloudfoundry/libcfbuildpack v1.29.0/go.mod h1:OEwAwCqppAMwWrcrnxE0j0llq5HcvQHrUa6J5n8XMMc=
github.com/cloudfoundry/libcfbuildpack v1.37.0 h1:/jeSWneCY2QD0n91OgaEHJrv9FUTZV+uoorSAdPg0Ik=
github.com/cloudfoundry/libcfbuildpack v1.37.0/go.mod h1:WqW/cPLKqNnxhBt0JLTCQGpcKlFfC1T6vLHg0gNRtAA=
Expand All @@ -22,6 +24,8 @@ github.com/cloudfoundry/libcfbuildpack v1.42.0 h1:vHVF9t0Px4p0WsgCG2EkUTTyXxI3Qg
github.com/cloudfoundry/libcfbuildpack v1.42.0/go.mod h1:C2AOm63Ca1GIBP7NdVhd8Q2gKenz600PVWqtOAbrN4o=
github.com/cloudfoundry/nodejs-cnb v0.0.3-0.20181217224909-e1533a296e07 h1:o1rOurj5HLkRABMapPeXwlxUtwwLZlHcuurSDdMtH2U=
github.com/cloudfoundry/nodejs-cnb v0.0.3-0.20181217224909-e1533a296e07/go.mod h1:jIMmJN7byxXmRCqlTmhZ9IB2lZU3MpyVcWDIx6PGiVo=
github.com/cloudfoundry/nodejs-cnb v0.0.4 h1:1iet2dfSC+fZ/qNQKGkI2kMCb9QbEAUoHjNm4HdGjvU=
github.com/cloudfoundry/nodejs-cnb v0.0.4/go.mod h1:BkYMGwKyuBpqJMaxgipXOJctYRWtc4yutQVID/CGzeg=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
Expand Down
13 changes: 13 additions & 0 deletions integration/missing_node_modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,17 @@ func missingNodeModulesIntegration(t *testing.T, when spec.G, it spec.S) {
Expect(err).NotTo(HaveOccurred())
})
})

when("package manager is npm", func() {
it("warns that unmet dependencies may cause issues", func() {
app, err := dagger.PackBuild(filepath.Join("testdata", "unmet_dep_npm"), nodeBP, bp)
Expect(err).ToNot(HaveOccurred())
defer app.Destroy()

Expect(app.Start()).To(Succeed())

Expect(app.BuildLogs()).To(ContainSubstring("Unmet dependencies don't fail npm install but may cause runtime issues"))
})
})

}
1 change: 1 addition & 0 deletions integration/testdata/unmet_dep_npm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
1 change: 1 addition & 0 deletions integration/testdata/unmet_dep_npm/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ca=
1 change: 1 addition & 0 deletions integration/testdata/unmet_dep_npm/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node server.js
1 change: 1 addition & 0 deletions integration/testdata/unmet_dep_npm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file here to suppress "npm WARN package.json [email protected] No README data"
248 changes: 248 additions & 0 deletions integration/testdata/unmet_dep_npm/package-lock.json

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

23 changes: 23 additions & 0 deletions integration/testdata/unmet_dep_npm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "node_web_app",
"version": "0.0.0",
"description": "hello, world",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "BSD-2-Clause",
"dependencies": {
"logfmt": "~1.1.2",
"express": "~4.0.0",
"grunt-steroids": "0.2.3"
},
"engines": {
"node": "~>6"
},
"repository": {
"type": "git",
"url": "http://github.com/cloudfoundry/nodejs-buildpack.git"
}
}
1 change: 1 addition & 0 deletions integration/testdata/unmet_dep_npm/resolve
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.10.26
14 changes: 14 additions & 0 deletions integration/testdata/unmet_dep_npm/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var port = Number(process.env.PORT || 8080);
var express = require("express");
var logfmt = require("logfmt");
var app = express();

app.use(logfmt.requestLogger());

app.listen(port, function() {
console.log("Listening on " + port);
});

app.get('/', function(req, res) {
res.send('Hello, World!');
});
2 changes: 1 addition & 1 deletion integration/versioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func testVersioningIntegration(t *testing.T, when spec.G, it spec.S) {
defer app.Destroy()

Expect(app.Start()).To(Succeed())
Expect(app.BuildStdout.String()).To(MatchRegexp(`NodeJS[^\.\n]*6\.`)) //Allows it to ignore the control characters for color
Expect(app.BuildLogs()).To(MatchRegexp(`NodeJS 6\.`))
Expect(app.HTTPGetBody("/")).To(ContainSubstring("Hello, World!"))
})
})
Expand Down
16 changes: 8 additions & 8 deletions npm/mocks_test.go

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

Loading

0 comments on commit 761887f

Please sign in to comment.