Skip to content

Commit bf2f95d

Browse files
authored
chore: tool-belts to workspaces (#1102)
converted tool-belts (groups of dependencies that formed a (group of) tool) to workspaces. this should allow installing and running the library, and have some additional tools not installed in this setup. this would enable us to have certain tool-belts runnable only in specific setups. and these setups would not be installed or interfere in usual test-/build-related setups. --------- Signed-off-by: Jan Kowalleck <[email protected]>
1 parent e5b8904 commit bf2f95d

File tree

15 files changed

+122
-47
lines changed

15 files changed

+122
-47
lines changed

.eslintrc.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20+
const path = require('path')
21+
2022
/* eslint-disable jsdoc/valid-types */
2123

2224
/**
@@ -53,7 +55,7 @@ module.exports = {
5355
// endregion sort imports/exports
5456
// region license-header
5557
/* see https://github.com/Stuk/eslint-plugin-header#readme */
56-
'header/header': ['error', './.license-header.js'],
58+
'header/header': ['error', path.join(__dirname, '.license-header.js')],
5759
// endregion license-header
5860
// indent is managed by plugin '*standard'
5961
'editorconfig/indent': 'off'
@@ -105,19 +107,19 @@ module.exports = {
105107
// endregion docs
106108
},
107109
parserOptions: {
108-
project: './tsconfig.json'
110+
project: path.join(__dirname, 'tsconfig.json')
109111
}
110112
},
111113
{
112114
files: ['examples/node/typescript/example.cjs/src/*.ts'],
113115
parserOptions: {
114-
project: './examples/node/typescript/example.cjs/tsconfig.json'
116+
project: path.join(__dirname, '/examples/node/typescript/example.cjs/tsconfig.json')
115117
}
116118
},
117119
{
118120
files: ['examples/node/typescript/example.mjs/src/*.ts'],
119121
parserOptions: {
120-
project: './examples/node/typescript/example.mjs/tsconfig.json'
122+
project: path.join(__dirname, '/examples/node/typescript/example.mjs/tsconfig.json')
121123
}
122124
},
123125
{

.github/workflows/nodejs.yml

+34-14
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
# cache: "npm"
7676
# cache-dependency-path: "**/package-lock.json"
7777
- name: setup project
78-
run: npm i --ignore-scripts --include=optional --loglevel=silly
78+
run: npm i --ignore-scripts --include=optional --loglevel=silly
7979
- name: test
8080
run: npm run test:lint
8181

@@ -95,13 +95,16 @@ jobs:
9595
# cache: "npm"
9696
# cache-dependency-path: "**/package-lock.json"
9797
- name: setup project
98-
run: npm i --ignore-scripts --include=optional --loglevel=silly
98+
run: >
99+
npm i
100+
--ignore-scripts --loglevel=silly
101+
-w tools/code-style --include-workspace-root
99102
- name: make reports dir
100103
run: mkdir -p "$REPORTS_DIR"
101104
- name: test
102105
run: >
103106
npm run --
104-
test:standard
107+
test:standard --
105108
--format checkstyle
106109
--output-file "$REPORTS_DIR/eslint.xml"
107110
- name: Publish Checkstyle report
@@ -157,28 +160,39 @@ jobs:
157160
run: |
158161
set -ex
159162
dep_constraints=''
160-
dev_requirements='c8 mocha npm-run-all fast-glob'
163+
dev_requirements=' c8 mocha npm-run-all2 fast-glob '
161164
# as long as npm cannot auto-resolve engine-constraints, we need to help here
162165
case "$NODE_VERSION" in
163166
'16')
164-
# for some stupid reason, NPM tries to resolve dev-packages, event hey are to be omitted.
165-
# this is frustrating when NPM is not resolving to compatible versions ...so drop them here
166-
npm uninstall --save-dev eslint-plugin-jsdoc
167+
dev_requirements="${dev_requirements/ c8 / c8@^9 }"
168+
;;
169+
'14')
170+
dev_requirements="${dev_requirements/ c8 / c8@^9 }"
171+
dev_requirements="${dev_requirements/ npm-run-all2 / npm-run-all2@^5 }"
167172
;;
168173
'14.0.0')
169-
dev_requirements='c8@^8 mocha npm-run-all fast-glob'
174+
dev_requirements="${dev_requirements/ c8 / c8@^8 }"
175+
dev_requirements="${dev_requirements/ npm-run-all2 / npm-run-all2@^5 }"
170176
;;
171177
esac
178+
echo "::group::install dep_constraints"
172179
## !! dont install all the dev-packages, especially since some are not runnable on node 14.0.0
173180
if [[ -n "$dep_constraints" ]]
174181
then
175-
npm add --ignore-scripts --omit=dev --only=prod --production --loglevel=silly --save $dep_constraints
182+
npm add --workspaces=false --ignore-scripts --omit=dev --only=prod --production --loglevel=silly --save $dep_constraints
176183
fi
177-
npm i --ignore-scripts --include=optional --omit=dev --only=prod --production --loglevel=silly
184+
echo "::endgroup::"
185+
echo "::group::install deps"
186+
npm i --workspaces=false --ignore-scripts --include=optional --omit=dev --only=prod --production --loglevel=silly
187+
echo "::endgroup::"
188+
echo "::group::install libxmljs2 "
178189
## rebuild deps for which scripts were ignored, or partially installed - since "ignore-scripts" was used
179190
npm rebuild --loglevel=silly libxmljs2 || npm uninstall --no-save libxmljs2
191+
echo "::endgroup::"
192+
echo "::group::install dev_requirements"
180193
## install the needed dev-deps
181-
npm i --ignore-scripts --loglevel=silly --no-save $dev_requirements
194+
npm i --workspaces=false --ignore-scripts --loglevel=silly --no-save $dev_requirements
195+
echo "::endgroup::"
182196
- name: fetch build artifact
183197
# see https://github.com/actions/download-artifact
184198
uses: actions/download-artifact@v4
@@ -225,7 +239,7 @@ jobs:
225239
## dont install all the dev-packages, especially since some are not runnable on node 14.0.0
226240
npm i --ignore-scripts --omit=optional --omit=dev --loglevel=silly
227241
## install the needed dev-deps
228-
npm i --ignore-scripts --omit=optional --no-save --loglevel=silly mocha c8 npm-run-all fast-glob
242+
npm i --ignore-scripts --omit=optional --no-save --loglevel=silly mocha c8 npm-run-all2 fast-glob
229243
- name: fetch build artifact
230244
# see https://github.com/actions/download-artifact
231245
uses: actions/download-artifact@v4
@@ -281,6 +295,7 @@ jobs:
281295
bash <(curl -Ls https://raw.githubusercontent.com/codacy/codacy-coverage-reporter/master/get.sh) report $auth $reports --partial -l Javascript &&\
282296
bash <(curl -Ls https://raw.githubusercontent.com/codacy/codacy-coverage-reporter/master/get.sh) final $auth
283297
298+
284299
examples-JS:
285300
needs: [ 'build' ]
286301
name: example JS ${{ matrix.js-type }}
@@ -440,6 +455,11 @@ jobs:
440455
# cache: "npm"
441456
# cache-dependency-path: "**/package-lock.json"
442457
- name: setup project
443-
run: npm i --ignore-scripts --loglevel=silly
458+
run: >
459+
npm install
460+
--ignore-scripts --loglevel=silly
461+
-w tools/docs-gen --include-workspace-root
444462
- name: api-doc ${{ matrix.target }}
445-
run: npm run api-doc:${{ matrix.target }}
463+
run: >
464+
npm run -w tools/docs-gen
465+
api-doc:${{ matrix.target }}

.github/workflows/release.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ jobs:
9999
with:
100100
node-version: ${{ env.NODE_ACTIVE_LTS }}
101101
- name: install build tools
102-
run: npm i --ignore-scripts --include=optional --loglevel=silly
102+
run: >
103+
npm install
104+
--ignore-scripts --include=optional --loglevel=silly
105+
-w tools/code-style --include-workspace-root
103106
# no explicit npm build. if a build is required, it should be configured as prepublish/prepublishOnly script of npm.
104107
- name: login to registries
105108
run: |

.npmrc

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
; see the docs: https://docs.npmjs.com/cli/v9/using-npm/config
22

3-
engine-strict=true
43
package-lock=false

.readthedocs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ build:
1515
# golang: "1.20"
1616
jobs:
1717
pre_build:
18-
- npm i --ignore-scripts --include=optional
18+
- npm i --ignore-scripts --loglevel=silly -w tools/docs-gen --include-workspace-root
1919
- npm run api-doc
2020

2121
# Build documentation in the docs/ directory with Sphinx

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ it requires node>=18 on dev-time.
1313
Install dependencies:
1414

1515
```shell
16-
npm install
16+
npm install --workspaces --include-workspace-root
1717
```
1818

1919
The setup will also build the project.

package.json

+11-23
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,13 @@
9494
"@types/mocha": "^10",
9595
"@types/node": "ts5.4",
9696
"@types/spdx-expression-parse": "^3",
97-
"@typescript-eslint/eslint-plugin": "6.21.0",
98-
"@typescript-eslint/parser": "6.21.0",
99-
"c8": "^8||^9",
97+
"c8": "^8||^9||^10",
10098
"deepmerge": "^4.2.2",
101-
"eslint": "8.57.0",
102-
"eslint-config-love": "43.1.0",
103-
"eslint-config-standard": "17.1.0",
104-
"eslint-plugin-editorconfig": "4.0.3",
105-
"eslint-plugin-header": "3.1.1",
106-
"eslint-plugin-import": "2.29.1",
107-
"eslint-plugin-jsdoc": "48.2.8",
108-
"eslint-plugin-n": "16.6.2",
109-
"eslint-plugin-promise": "6.2.0",
110-
"eslint-plugin-simple-import-sort": "12.1.0",
111-
"eslint-plugin-tsdoc": "0.3.0",
11299
"fast-glob": "^3.3.1",
113100
"mocha": "10.5.2",
114-
"npm-run-all2": "^6.1.2",
101+
"npm-run-all2": "^5||^6",
115102
"rimraf": "^5.0.7",
116103
"ts-loader": "9.5.1",
117-
"typedoc": "^0.25.0",
118-
"typedoc-plugin-missing-exports": "^2.0.1",
119104
"typescript": "5.4.5",
120105
"webpack": "5.92.1",
121106
"webpack-cli": "5.1.4",
@@ -179,25 +164,28 @@
179164
"test": "./tests",
180165
"example": "./examples"
181166
},
167+
"workspaces": [
168+
"tools/schema-downloader",
169+
"tools/docs-gen",
170+
"tools/code-style"
171+
],
182172
"scripts": {
173+
"dev-setup": "npm install --workspaces --include-workspace-root",
183174
"prepublish": "npm run build",
184175
"prepublishOnly": "run-s -lc build test",
185-
"lint": "tsc --noEmit",
186176
"build": "run-p --aggregate-output -l build:*",
187177
"prebuild:node": "rimraf dist.node",
188178
"build:node": "tsc -b ./tsconfig.node.json",
189179
"prebuild:web": "rimraf dist.web",
190180
"build:web": "webpack build",
191181
"prebuild:d": "rimraf dist.d",
192182
"build:d": "tsc -b ./tsconfig.d.json",
193-
"cs-fix": "eslint --fix .",
183+
"cs-fix": "npm run-script -w tools/code-style cs-fix",
194184
"test": "run-p --aggregate-output -lc test:*",
195185
"test:node": "c8 mocha -p",
196186
"test:web": "node -e 'console.log(\"TODO: write web test\")'",
197187
"test:lint": "tsc --noEmit",
198-
"test:standard": "eslint .",
199-
"api-doc": "run-p --aggregate-output -lc api-doc:*",
200-
"api-doc:node": "typedoc --options typedoc.node.json",
201-
"api-doc:web": "typedoc --options typedoc.web.json"
188+
"test:standard": "npm run-script -w tools/code-style test",
189+
"api-doc": "npm run-script -w tools/docs-gen api-doc"
202190
}
203191
}

tools/code-style/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*
2+
!/.gitignore
3+
!/package.json
4+
!/.npmrc

tools/code-style/.npmrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
; see the docs: https://docs.npmjs.com/cli/v9/using-npm/config
2+
3+
package-lock=false

tools/code-style/package.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"private": true,
3+
"name": "@cyclonedx/cyclonedx-library-code-style",
4+
"license": "Apache-2.0",
5+
"engines": {
6+
"node": ">=25"
7+
},
8+
"dependencies": {
9+
"@typescript-eslint/eslint-plugin": "6.21.0",
10+
"@typescript-eslint/parser": "6.21.0",
11+
"eslint": "8.57.0",
12+
"eslint-config-love": "43.1.0",
13+
"eslint-config-standard": "17.1.0",
14+
"eslint-plugin-editorconfig": "4.0.3",
15+
"eslint-plugin-header": "3.1.1",
16+
"eslint-plugin-import": "2.29.1",
17+
"eslint-plugin-jsdoc": "48.2.8",
18+
"eslint-plugin-n": "16.6.2",
19+
"eslint-plugin-promise": "6.2.0",
20+
"eslint-plugin-simple-import-sort": "12.1.0",
21+
"eslint-plugin-tsdoc": "0.3.0",
22+
"@cyclonedx/cyclonedx-library-docs-gen": "file:../docs-gen"
23+
},
24+
"scripts": {
25+
"test": "cd ../..; eslint .",
26+
"cs-fix": "cd ../..; eslint --fix ."
27+
},
28+
"workspaces": []
29+
}

tools/docs-gen/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*
2+
!/.gitignore
3+
!/package.json
4+
!/.npmrc

tools/docs-gen/.npmrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
; see the docs: https://docs.npmjs.com/cli/v9/using-npm/config
2+
3+
package-lock=false

tools/docs-gen/package.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"private": true,
3+
"name": "@cyclonedx/cyclonedx-library-docs-gen",
4+
"license": "Apache-2.0",
5+
"engines": {
6+
"node": ">=20"
7+
},
8+
"dependencies": {
9+
"@cyclonedx/cyclonedx-library-docs-gen": "file:",
10+
"npm-run-all2": "^6.1.2",
11+
"typedoc": "^0.25.0",
12+
"typedoc-plugin-missing-exports": "^2.0.1"
13+
},
14+
"scripts": {
15+
"api-doc": "run-p --aggregate-output -lc api-doc:*",
16+
"api-doc:node": "typedoc --options ../../typedoc.node.json",
17+
"api-doc:web": "typedoc --options ../../typedoc.web.json"
18+
},
19+
"workspaces": []
20+
}

tools/schema-downloader/.npmrc

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
; see the docs: https://docs.npmjs.com/cli/v9/using-npm/config
22

3-
engine-strict=true
43
package-lock=false

tools/schema-downloader/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
},
1010
"engines": {
1111
"node": ">=18"
12-
}
12+
},
13+
"workspaces": []
1314
}

0 commit comments

Comments
 (0)