Skip to content

Commit 48cbc02

Browse files
authored
refactor: pluggable optional deps funcs centralized (#1084)
in preparation to a possible change or addition of optioanl dependencies. see #1079 --------- Signed-off-by: Jan Kowalleck <[email protected]>
1 parent f6acb83 commit 48cbc02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+923
-551
lines changed

.c8rc.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"all": true,
33
"src": [
4-
"src",
5-
"libs/universal-node-xml"
4+
"src"
65
],
76
"exclude": [
87
"**/*.web.ts",

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
/res/schema/
1313

1414
!/src/**
15-
!/libs/**
1615

1716
!/tools/schema-downloader/**
1817

.github/workflows/nodejs.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ jobs:
152152
# do not use caching, use fresh version always, since some deps are not pinned -- since this is a library.
153153
- name: setup project
154154
shell: bash
155+
env:
156+
NODE_VERSION: '${{ matrix.node-version }}'
155157
run: |
156158
set -ex
157159
dep_constraints=''
158160
dev_requirements='c8 mocha npm-run-all fast-glob'
159161
# as long as npm cannot auto-resolve engine-constraints, we need to help here
160-
case '${{ matrix.node-version }}' in
162+
case "$NODE_VERSION" in
161163
'16')
162164
# for some stupid reason, NPM tries to resolve dev-packages, event hey are to be omitted.
163165
# this is frustrating when NPM is not resolving to compatible versions ...so drop them here
@@ -184,7 +186,9 @@ jobs:
184186
name: dist.node
185187
path: dist.node
186188
- name: test
187-
run: npm run test:node
189+
run: >
190+
npm run -- test:node
191+
${{ startsWith(matrix.node-version, env.NODE_ACTIVE_LTS) && ' --forbid-pending' || '' }}
188192
- name: collect coverage
189193
if: ${{ failure() || success() }}
190194
run: >

.mocharc.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
2626
module.exports = {
2727
timeout: 10000,
2828
spec: [
29-
'tests',
30-
'libs'
29+
'tests'
3130
],
3231
recursive: true,
3332
parallel: false, // if true, then some IDEs cannot run it

HISTORY.md

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ All notable changes to this project will be documented in this file.
66

77
<!-- add unreleased items here -->
88

9+
* Changed
10+
* Exising `Serialize.XmlSerializer.serialize()` for _Node.js_ may throw `Serialize.MissingOptionalDependencyError` (via [#1084])
11+
This is considered a non-breaking change, as the docs always told that any `Error` may be thrown.
12+
* Added
13+
* New class `Serialize.MissingOptionalDependencyError` (via [#1084])
14+
* Misc
15+
* Refactored functionality around optional/pluggable dependencies (via [#1083], [#1084])
16+
This was done in preparation for [#1079]
17+
18+
[#1079]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1079
19+
[#1083]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1083
20+
[#1084]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1084
21+
922
## 6.9.5 -- 2024-05-23
1023

1124
Maintenance release.

libs/universal-node-xml/__stringifiers/xmlbuilder2.spec.js

-129
This file was deleted.

libs/universal-node-xml/stringify.js

-52
This file was deleted.

res/schema/README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Currently using version
1515
| [`bom-1.4.SNAPSHOT.xsd`](bom-1.4.SNAPSHOT.xsd) | applied changes: 1 |
1616
| [`bom-1.5.SNAPSHOT.xsd`](bom-1.5.SNAPSHOT.xsd) | applied changes: 1 |
1717
| [`bom-1.6.SNAPSHOT.xsd`](bom-1.6.SNAPSHOT.xsd) | applied changes: 1 |
18-
| [`bom-1.2.SNAPSHOT.schema.json`](bom-1.2.SNAPSHOT.schema.json) | applied changes: 2,3,4,5 |
19-
| [`bom-1.3.SNAPSHOT.schema.json`](bom-1.3.SNAPSHOT.schema.json) | applied changes: 2,3,4,5 |
20-
| [`bom-1.4.SNAPSHOT.schema.json`](bom-1.4.SNAPSHOT.schema.json) | applied changes: 2,3,4,5 |
21-
| [`bom-1.5.SNAPSHOT.schema.json`](bom-1.5.SNAPSHOT.schema.json) | applied changes: 2,3,4,5 |
22-
| [`bom-1.6.SNAPSHOT.schema.json`](bom-1.6.SNAPSHOT.schema.json) | applied changes: 2,3,4,5 |
23-
| [`bom-1.2-strict.SNAPSHOT.schema.json`](bom-1.2-strict.SNAPSHOT.schema.json) | applied changes: 2,3,4,5 |
24-
| [`bom-1.3-strict.SNAPSHOT.schema.json`](bom-1.3-strict.SNAPSHOT.schema.json) | applied changes: 2,3,4,5 |
18+
| [`bom-1.2.SNAPSHOT.schema.json`](bom-1.2.SNAPSHOT.schema.json) | applied changes: 2,3,4,5,6 |
19+
| [`bom-1.3.SNAPSHOT.schema.json`](bom-1.3.SNAPSHOT.schema.json) | applied changes: 2,3,4,5,6 |
20+
| [`bom-1.4.SNAPSHOT.schema.json`](bom-1.4.SNAPSHOT.schema.json) | applied changes: 2,3,4,5,6 |
21+
| [`bom-1.5.SNAPSHOT.schema.json`](bom-1.5.SNAPSHOT.schema.json) | applied changes: 2,3,4,5,6 |
22+
| [`bom-1.6.SNAPSHOT.schema.json`](bom-1.6.SNAPSHOT.schema.json) | applied changes: 2,3,4,5,6 |
23+
| [`bom-1.2-strict.SNAPSHOT.schema.json`](bom-1.2-strict.SNAPSHOT.schema.json) | applied changes: 2,3,4,5,6 |
24+
| [`bom-1.3-strict.SNAPSHOT.schema.json`](bom-1.3-strict.SNAPSHOT.schema.json) | applied changes: 2,3,4,5,6 |
2525
| [`spdx.SNAPSHOT.xsd`](spdx.SNAPSHOT.xsd) | |
2626
| [`spdx.SNAPSHOT.schema.json`](spdx.SNAPSHOT.schema.json) | |
2727
| [`jsf-0.82.SNAPSHOT.schema.json`](jsf-0.82.SNAPSHOT.schema.json) | |
@@ -32,3 +32,4 @@ changes:
3232
3. `jsf-0.82.schema.json` was replaced with `jsf-0.82.SNAPSHOT.schema.json`
3333
4. `properties.$schema.enum` was fixed to match `$id`
3434
5. `required.version` removed, as it is actually optional with default value
35+
6. `"format": "string"` removed, as it is unknown to JSON spec

res/schema/bom-1.2-strict.SNAPSHOT.schema.json

-3
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,16 @@
135135
"properties": {
136136
"vendor": {
137137
"type": "string",
138-
"format": "string",
139138
"title": "Tool Vendor",
140139
"description": "The date and time (timestamp) when the document was created."
141140
},
142141
"name": {
143142
"type": "string",
144-
"format": "string",
145143
"title": "Tool Name",
146144
"description": "The date and time (timestamp) when the document was created."
147145
},
148146
"version": {
149147
"type": "string",
150-
"format": "string",
151148
"title": "Tool Version",
152149
"description": "The date and time (timestamp) when the document was created."
153150
},

res/schema/bom-1.2.SNAPSHOT.schema.json

-4
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,16 @@
129129
"properties": {
130130
"vendor": {
131131
"type": "string",
132-
"format": "string",
133132
"title": "Tool Vendor",
134133
"description": "The date and time (timestamp) when the document was created."
135134
},
136135
"name": {
137136
"type": "string",
138-
"format": "string",
139137
"title": "Tool Name",
140138
"description": "The date and time (timestamp) when the document was created."
141139
},
142140
"version": {
143141
"type": "string",
144-
"format": "string",
145142
"title": "Tool Version",
146143
"description": "The date and time (timestamp) when the document was created."
147144
},
@@ -837,7 +834,6 @@
837834
"properties": {
838835
"ref": {
839836
"$ref": "#/definitions/refType",
840-
"format": "string",
841837
"title": "Reference",
842838
"description": "References a component by the components bom-ref attribute"
843839
},

src/_helpers/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
These are _internal_ helpers, that are not intended to be exported/published.
44

5-
The helpers shall **not** be marked as `@internal`, so that TypeScript might pick up on them and still render definitions for them.
6-
The internal defined interfaces, classes, functions are required for proper type checking downstream, but should not be utilized/called downstream.
5+
The helpers SHALL **NOT** be marked as `@internal`, so that TypeScript might pick up on them and still render definitions for them.
6+
The internal defined interfaces, classes, functions are required for proper type checking downstream, but SHOULD NOT be utilized/called downstream.

src/_optPlug.node/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Optional Pluggable for node
2+
3+
These are _internal_ helpers, that are not intended to be exported/published.
4+
5+
The helpers SHALL **NOT** be marked as `@internal`, so that TypeScript might pick up on them and still render definitions for them.
6+
The internal defined interfaces, classes, functions are required for proper type checking downstream, but SHOULD NOT be utilized/called downstream.
7+
8+
Some functionality is private.
9+
These exports **MUST** be marked as `@internal`.
10+
Respective files **MUST NOT** export or declare any relevant types or symbols.
11+
Respective files **MUST** be prefixed with double-underscore ("dunder" - `__`).

0 commit comments

Comments
 (0)