Skip to content

Commit 452a4bb

Browse files
authored
@cyclonedx/bom:^3.8 & node >= 12.0.0 & tests (#51)
fixes #50 * Changed * Requires node `>= 12.0.0` now, was `8.0.0`. (via [#287]) * Requires `@cyclonedx/bom` `^3.8.0` now, was `^3.1.1`. (via [#287]) * Misc * Added reproducible test environments for unit an integration tests. (via [#51])
1 parent e60ea78 commit 452a4bb

20 files changed

+24478
-803
lines changed

.github/workflows/nodejs.yml

+12-8
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ env:
1414
NODE_ACTIVE_LTS: "16"
1515

1616
jobs:
17-
unit-test:
18-
name: UnitTest (node${{ matrix.node-version }}, ${{ matrix.os }})
17+
test-jest:
18+
name: test:Jest (node${{ matrix.node-version }}, ${{ matrix.os }})
1919
timeout-minutes: 30
2020
runs-on: ${{ matrix.os }}
2121
strategy:
@@ -29,8 +29,6 @@ jobs:
2929
- "16" # active LTS
3030
- "14"
3131
- "12"
32-
- "10"
33-
- "8" # lowest supported
3432
env:
3533
REPORTS_ARTIFACT: tests-reports
3634
steps:
@@ -44,11 +42,17 @@ jobs:
4442
node-version: ${{ matrix.node-version }}
4543
cache: "npm"
4644
cache-dependency-path: "**/package-lock.json"
47-
- name: display node version
48-
run: node --version
45+
- name: update npm
46+
run: npm i -g npm
47+
- name: display version
48+
run: |-
49+
node --version
50+
npm --version
4951
- name: install project
5052
run: npm ci
5153
- name: build
5254
run: npm run build --if-present
53-
- name: run tests
54-
run: npm test --if-present
55+
- name: set up tests
56+
run: npm run setup-tests
57+
- name: test
58+
run: npm run test:jest

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/CI_reports/
33
/release_assets/
44

5+
*.cache
6+
57
## taken from https://github.com/github/gitignore/blob/main/Node.gitignore
68

79
# Logs

.lift.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Lift config. See:
2+
# https://help.sonatype.com/lift/configuring-lift
3+
4+
ignoreFiles = """
5+
tests/integration/*/
6+
"""

CONTRIBUTING.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contributing
2+
3+
Pull requests are welcome.
4+
But please read the
5+
[CycloneDX contributing guidelines](https://github.com/CycloneDX/.github/blob/master/CONTRIBUTING.md)
6+
first.
7+
8+
## Setup
9+
10+
To start developing simply run `npm ci` to install dev-dependencies and tools.
11+
12+
## Testing
13+
14+
Set up the tests once, via:
15+
16+
```shell
17+
npm run setup-tests
18+
```
19+
20+
Run to have a proper test suite pass:
21+
22+
```shell
23+
npm test
24+
```
25+
26+
## Sign your commits
27+
28+
Please sign your commits,
29+
to show that you agree to publish your changes under the current terms and licenses of the project.
30+
31+
```shell
32+
git commit --signed-off ...
33+
```

HISTORY.md

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44

55
## unreleased
66

7+
* Changed
8+
* Requires node `>= 12.0.0` now, was `8.0.0`. (via [#287])
9+
* Requires `@cyclonedx/bom` `^3.8.0` now, was `^3.1.1`. (via [#287])
10+
* Misc
11+
* Added reproducible test environments for unit an integration tests. (via [#51])
12+
13+
[#51]: https://github.com/CycloneDX/cyclonedx-webpack-plugin/pull/51
14+
715
## 1.0.2 - 2922-04-22
816

917
* Fixed

README.md

+20-19
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,37 @@ https://img.shields.io/npm/v/@cyclonedx/webpack-plugin)](https://www.npmjs.com/p
77
[![Group Discussion](https://img.shields.io/badge/discussion-groups.io-blue.svg)](https://groups.io/g/CycloneDX)
88
[![Twitter](https://img.shields.io/twitter/url/http/shields.io.svg?style=social&label=Follow)](https://twitter.com/CycloneDX_Spec)
99

10-
CycloneDX Webpack Plugin
11-
=========
10+
# CycloneDX Webpack Plugin
1211

1312
The CycloneDX plugin for Webpack creates a valid CycloneDX Software Bill of Materials (SBOM) containing an aggregate of
1413
all bundled dependencies. This plugin uses the linkages generated by webpack to create a dependency graph which only
1514
contain the dependencies that are actually used.
1615

17-
Requirements
18-
-------------------
19-
- Node.js v8.0.0 or higher
16+
## Requirements
17+
- Node.js v12.0.0 or higher
2018
- Webpack v4.0.0 or higher
2119

22-
Usage
23-
-------------------
20+
However, there are older versions of this plugin, that support
21+
- Node.js v8.0.0 or higher
22+
- Webpack v4.0.0 or higher
2423

25-
#### Installing
24+
## Installing
2625

27-
```bash
26+
```shell
2827
npm i -D @cyclonedx/webpack-plugin
2928
```
3029

30+
## Usage
31+
32+
### Example
3133

32-
#### Example
3334
In your [webpack config](https://webpack.js.org/configuration/) add the CycloneDX plugin:
34-
```js
35+
36+
```javascript
3537
const { CycloneDxWebpackPlugin } = require('@cyclonedx/webpack-plugin');
3638

3739
module.exports = {
38-
...
39-
40+
// ...
4041
plugins: [
4142
new CycloneDxWebpackPlugin({
4243
context: '../',
@@ -46,7 +47,8 @@ module.exports = {
4647
};
4748
```
4849

49-
#### Support for IETF /.well-known/sbom
50+
### Support for IETF /.well-known/sbom
51+
5052
The CycloneDX Webpack plugin supports placing the CycloneDX SBOM in a pre-defined location, specifically in
5153
`/.well-known/sbom`. This option is enabled by default. The behavior can be changed by overriding the values
5254
of `includeWellknown` and `wellknownLocation`.
@@ -55,12 +57,12 @@ See [draft-lear-opsawg-sbom-access](https://datatracker.ietf.org/doc/html/draft-
5557
information on the specification, currently an IETF draft.
5658

5759
In your [webpack config](https://webpack.js.org/configuration/) add the CycloneDX plugin:
58-
```js
60+
61+
```javascript
5962
const { CycloneDxWebpackPlugin } = require('@cyclonedx/webpack-plugin');
6063

6164
module.exports = {
62-
...
63-
65+
// ...
6466
plugins: [
6567
new CycloneDxWebpackPlugin({
6668
context: '../',
@@ -72,8 +74,7 @@ module.exports = {
7274
};
7375
```
7476

75-
License
76-
-------------------
77+
## License
7778

7879
Permission to modify and redistribute is granted under the terms of the Apache 2.0 license. See the [LICENSE] file for the full license.
7980

jest.config.js

+197
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
module.exports = {
7+
// All imported modules in your tests should be mocked automatically
8+
// automock: false,
9+
10+
// Stop running tests after `n` failures
11+
// bail: 0,
12+
13+
// The directory where Jest should store its cached dependency information
14+
cacheDirectory: ".jest.cache",
15+
16+
// Automatically clear mock calls, instances and results before every test
17+
clearMocks: true,
18+
19+
// Indicates whether the coverage information should be collected while executing the test
20+
collectCoverage: true,
21+
22+
// An array of glob patterns indicating a set of files for which coverage information should be collected
23+
// collectCoverageFrom: undefined,
24+
25+
// The directory where Jest should output its coverage files
26+
coverageDirectory: "reports/jest/coverage",
27+
28+
// An array of regexp pattern strings used to skip coverage collection
29+
// coveragePathIgnorePatterns: [
30+
// "/node_modules/"
31+
// ],
32+
33+
// Indicates which provider should be used to instrument code for coverage
34+
coverageProvider: "v8",
35+
36+
// A list of reporter names that Jest uses when writing coverage reports
37+
// coverageReporters: [
38+
// "json",
39+
// "text",
40+
// "lcov",
41+
// "clover"
42+
// ],
43+
44+
// An object that configures minimum threshold enforcement for coverage results
45+
// coverageThreshold: undefined,
46+
47+
// A path to a custom dependency extractor
48+
// dependencyExtractor: undefined,
49+
50+
// Make calling deprecated APIs throw helpful error messages
51+
// errorOnDeprecated: false,
52+
53+
// Force coverage collection from ignored files using an array of glob patterns
54+
// forceCoverageMatch: [],
55+
56+
// A path to a module which exports an async function that is triggered once before all test suites
57+
// globalSetup: undefined,
58+
59+
// A path to a module which exports an async function that is triggered once after all test suites
60+
// globalTeardown: undefined,
61+
62+
// A set of global variables that need to be available in all test environments
63+
// globals: {},
64+
65+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
66+
// maxWorkers: "50%",
67+
68+
// An array of directory names to be searched recursively up from the requiring module's location
69+
// moduleDirectories: [
70+
// "node_modules"
71+
// ],
72+
73+
// An array of file extensions your modules use
74+
// moduleFileExtensions: [
75+
// "js",
76+
// "jsx",
77+
// "ts",
78+
// "tsx",
79+
// "json",
80+
// "node"
81+
// ],
82+
83+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
84+
// moduleNameMapper: {},
85+
86+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
87+
// modulePathIgnorePatterns: [],
88+
89+
// Activates notifications for test results
90+
// notify: false,
91+
92+
// An enum that specifies notification mode. Requires { notify: true }
93+
// notifyMode: "failure-change",
94+
95+
// A preset that is used as a base for Jest's configuration
96+
// preset: undefined,
97+
98+
// Run tests from one or more projects
99+
// projects: undefined,
100+
101+
// Use this configuration option to add custom reporters to Jest
102+
reporters: [
103+
"default",
104+
"jest-junit"
105+
],
106+
107+
// Automatically reset mock state before every test
108+
// resetMocks: false,
109+
110+
// Reset the module registry before running each individual test
111+
// resetModules: false,
112+
113+
// A path to a custom resolver
114+
// resolver: undefined,
115+
116+
// Automatically restore mock state and implementation before every test
117+
// restoreMocks: false,
118+
119+
// The root directory that Jest should scan for tests and modules within
120+
// rootDir: undefined,
121+
122+
// A list of paths to directories that Jest should use to search for files in
123+
roots: [
124+
"<rootDir>/tests"
125+
],
126+
127+
// Allows you to use a custom runner instead of Jest's default test runner
128+
// runner: "jest-runner",
129+
130+
// The paths to modules that run some code to configure or set up the testing environment before each test
131+
// setupFiles: [],
132+
133+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
134+
// setupFilesAfterEnv: [],
135+
136+
// The number of seconds after which a test is considered as slow and reported as such in the results.
137+
// slowTestThreshold: 5,
138+
139+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
140+
// snapshotSerializers: [],
141+
142+
// The test environment that will be used for testing
143+
// testEnvironment: "jest-environment-node",
144+
145+
// Options that will be passed to the testEnvironment
146+
// testEnvironmentOptions: {},
147+
148+
// Adds a location field to test results
149+
// testLocationInResults: false,
150+
151+
// The glob patterns Jest uses to detect test files
152+
testMatch: [
153+
// "**/__tests__/**/*.[jt]s?(x)",
154+
"**/?(*.)+(spec|test).js"
155+
],
156+
157+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
158+
// testPathIgnorePatterns: [
159+
// "/node_modules/"
160+
// ],
161+
162+
// The regexp pattern or array of patterns that Jest uses to detect test files
163+
// testRegex: [],
164+
165+
// This option allows the use of a custom results processor
166+
// testResultsProcessor: undefined,
167+
168+
// This option allows use of a custom test runner
169+
// testRunner: "jest-circus/runner",
170+
171+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
172+
// testURL: "http://localhost",
173+
174+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
175+
// timers: "real",
176+
177+
// A map from regular expressions to paths to transformers
178+
// transform: undefined,
179+
180+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
181+
// transformIgnorePatterns: [
182+
// "/node_modules/",
183+
// "\\.pnp\\.[^\\/]+$"
184+
// ],
185+
186+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
187+
// unmockedModulePathPatterns: undefined,
188+
189+
// Indicates whether each individual test should be reported during the run
190+
// verbose: undefined,
191+
192+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
193+
// watchPathIgnorePatterns: [],
194+
195+
// Whether to use watchman for file crawling
196+
// watchman: true,
197+
};

0 commit comments

Comments
 (0)