Skip to content

Commit be569cb

Browse files
authored
feat(npx): switch from npm to npx to isolate dependencies (#321)
1 parent 2b4b3bd commit be569cb

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ updates:
2424
default-days: 7
2525
commit-message:
2626
prefix: build(deps)
27+
- package-ecosystem: "npm"
28+
directory: "/xml"
29+
schedule:
30+
interval: "daily"
31+
cooldown:
32+
default-days: 7
33+
commit-message:
34+
prefix: build(deps)
2735
- package-ecosystem: "github-actions"
2836
directory: "/"
2937
schedule:

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ To know more command-line options of `xmllint`:
6666
docker run --rm --net=none leplusorg/xml xmllint --help
6767
```
6868

69+
## NPM Packages
70+
71+
Use the `npx` command to run command-line tools coming from npm
72+
packages. This ensures isolation between the different packages
73+
(including potentially conflicting dependencies).
74+
6975
## Software Bill of Materials (SBOM)
7076

7177
To get the SBOM for the latest image (in SPDX JSON format), use the

xml/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ RUN apk upgrade --no-cache \
2525
git=2.49.1-r0 \
2626
grep=3.12-r0 \
2727
html-xml-utils=8.7-r0 \
28+
jq=1.8.0-r0 \
2829
libxml2-utils=2.13.9-r0 \
2930
libxslt=1.1.43-r3 \
3031
maven=3.9.9-r0 \
@@ -48,9 +49,11 @@ RUN pipx ensurepath --global \
4849
&& xargs -a /tmp/requirements.txt -n 1 pipx install --global \
4950
&& rm -f /tmp/requirements.txt
5051

51-
RUN npm install -g \
52-
53-
52+
COPY package.json /tmp/package.json
53+
54+
RUN jq -r '.dependencies | to_entries[] | "\(.key)@\(.value)"' /tmp/package.json \
55+
| xargs -n 1 npm install -g \
56+
&& rm -f /tmp/package.json
5457

5558
RUN mkdir -p /opt/saxon
5659

xml/docker-compose.test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ services:
2020
grep --version # grep
2121
java --version # openjdk21-jre-headless
2222
jf -v # jsonfmt
23+
jq --version # jq
2324
mvn --version # maven
2425
pandoc --version # pandoc
2526
pip --version # py3-pip
2627
pipx --version # pipx
27-
prettier --version # prettier
28+
npx prettier --version # prettier
2829
python --version # python3
2930
remarshal --version # remarshal
31+
npx v8r --version # v8r
3032
xmlindent -v # xmlindent
3133
xmllint --version # libxml2-utils
3234
xmlsec1 --version # xmlsec

xml/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "docker-xml",
3+
"version": "1.0.0",
4+
"description": "XML processing tools",
5+
"dependencies": {
6+
"prettier": "3.6.2",
7+
"v8r": "5.1.0"
8+
}
9+
}

0 commit comments

Comments
 (0)