Skip to content

Commit 9fdef57

Browse files
authored
chore: change sbom generation to happen on prepublishOnly (#268)
By having the sbom generated during the `postinstall` step, we have inadvertently made the package impossible to install as a dependency. This is because when installing this as a dependency in a project, `npm install` is run under the hood. Subsequently, `npm run postinstall` happens, but the published package does not contain a package-lock.json file and the sbom generation fails, therefore failing the installation of the module altogether. This commit modifies the npm scripts so that the sbom generation happens only when publishing, and the publish will fail if there are any modified files in the repo, i.e. if the sbom was updated. This means it is incumbent on maintainers of this package to keep the sbom up to date by periodically running `npm run sbom` when modifying dependencies. If in the course of making changes on this module, the package.json or package-lock.json files are modified, the developer MUST run the command `npm run sbom`. Signed-off-by: Lance Ball <lball@redhat.com>
1 parent f0d8415 commit 9fdef57

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"test:source": "nyc --reporter=lcovonly tape test/test*.js | colortape",
1818
"test:types": "tsd",
1919
"pretest": "npm run lint",
20-
"postinstall": "npx @cyclonedx/cyclonedx-npm --omit dev --package-lock-only --output-file sbom.json"
20+
"sbom": "npx @cyclonedx/cyclonedx-npm --omit dev --package-lock-only --output-file sbom.json",
21+
"prepublishOnly": "npm run sbom && git diff-files --quiet"
2122
},
2223
"description": "A Node.js framework for executing arbitrary functions in response to HTTP or cloud events",
2324
"files": [

sbom.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"bomFormat": "CycloneDX",
44
"specVersion": "1.4",
55
"version": 1,
6-
"serialNumber": "urn:uuid:ed7e6bd5-f552-401a-ae15-05f899c57933",
6+
"serialNumber": "urn:uuid:1a3adee4-7f98-4b19-8c50-97eda0e1d650",
77
"metadata": {
8-
"timestamp": "2023-07-10T20:34:21.993Z",
8+
"timestamp": "2023-07-13T21:02:27.796Z",
99
"tools": [
1010
{
1111
"vendor": "@cyclonedx",
@@ -55,8 +55,8 @@
5555
"component": {
5656
"type": "application",
5757
"name": "faas-js-runtime",
58-
"version": "2.1.2",
59-
"bom-ref": "faas-js-runtime@2.1.2",
58+
"version": "2.2.0",
59+
"bom-ref": "faas-js-runtime@2.2.0",
6060
"author": "Red Hat, Inc.",
6161
"description": "A Node.js framework for executing arbitrary functions in response to HTTP or cloud events",
6262
"licenses": [
@@ -66,7 +66,7 @@
6666
}
6767
}
6868
],
69-
"purl": "pkg:npm/faas-js-runtime@2.1.2?vcs_url=git%2Bhttps%3A//github.com/nodeshift/faas-js-runtime.git",
69+
"purl": "pkg:npm/faas-js-runtime@2.2.0?vcs_url=git%2Bhttps%3A//github.com/nodeshift/faas-js-runtime.git",
7070
"externalReferences": [
7171
{
7272
"url": "git+https://github.com/nodeshift/faas-js-runtime.git",
@@ -2764,7 +2764,7 @@
27642764
],
27652765
"dependencies": [
27662766
{
2767-
"ref": "faas-js-runtime@2.1.2",
2767+
"ref": "faas-js-runtime@2.2.0",
27682768
"dependsOn": [
27692769
"cloudevents@7.0.1",
27702770
"commander@11.0.0",

0 commit comments

Comments
 (0)