Skip to content

Commit 09c6607

Browse files
committed
feat(npx): switch from npm to npx to isolate dependencies
1 parent a40d99f commit 09c6607

File tree

5 files changed

+39
-14
lines changed

5 files changed

+39
-14
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ updates:
1515
default-days: 7
1616
commit-message:
1717
prefix: build(deps)
18+
- package-ecosystem: "npm"
19+
directory: "/json"
20+
schedule:
21+
interval: "daily"
22+
cooldown:
23+
default-days: 7
24+
commit-message:
25+
prefix: build(deps)
1826
- package-ecosystem: "github-actions"
1927
directory: "/"
2028
schedule:

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ To know more command-line options of `jq`:
5858
docker run --rm --net=none leplusorg/json jq -h
5959
```
6060

61+
## NPM Packages
62+
63+
Use the `npx` command to run command-line tools coming from npm
64+
packages. This ensures isolation between the different packages
65+
(including potentially conflicting dependencies).
66+
6167
## Software Bill of Materials (SBOM)
6268

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

json/Dockerfile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,11 @@ RUN pipx ensurepath --global \
3939
&& xargs -a /tmp/requirements.txt -n 1 pipx install --global \
4040
&& rm -f /tmp/requirements.txt
4141

42-
RUN npm install -g \
43-
44-
45-
46-
47-
48-
49-
42+
COPY package.json /tmp/package.json
43+
44+
RUN jq -r '.dependencies | to_entries[] | "\(.key)@\(.value)"' /tmp/package.json \
45+
| xargs -n 1 npm install -g \
46+
&& rm -f /tmp/package.json
5047

5148
RUN adduser \
5249
--home "${USER_HOME}" \

json/docker-compose.test.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,24 @@ services:
1616
csvsql --version # csvkit
1717
curl --version # curl
1818
dasel --version # dasel
19-
echo | prettyjson # prettyjson
19+
echo | npx prettyjson # prettyjson
2020
git --version # git
2121
grep --version # grep
2222
jf -v # jsonfmt
2323
jp --version # jp
24-
jsonpath-plus <(echo '{}') / # jsonpath-plus
24+
npx jsonpath-plus <(echo '{}') / # jsonpath-plus
2525
jq --version # jq
26-
jslint --version # jsonlint
27-
jsonlint --help # jsonlint
26+
npx jslint --version # jslint
27+
npx jsonlint --help # jsonlint
28+
echo 'eyJhbGciOiJub25lIn0.e30.' | npx jwt-cli # checkov:skip=CKV_SECRET_9: [JSON Web Token]: not a real secret # jwt-cli
2829
mlr --version # miller
2930
npm --version # npm
3031
openssl --version # openssl
3132
pandoc --version # pandoc
3233
pip --version # py3-pip
3334
pipx --version # pipx
34-
prettier --version # prettier
35+
npx prettier --version # prettier
3536
python --version # python3
3637
remarshal --version # remarshal
37-
v8r --version # v8r
38+
npx v8r --version # v8r
3839
'

json/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "docker-json",
3+
"version": "0.0.0",
4+
"dependencies": {
5+
"jslint": "0.12.1",
6+
"jsonlint": "1.6.3",
7+
"jsonpath-plus": "10.3.0",
8+
"jwt-cli": "2.0.0",
9+
"prettier": "3.6.2",
10+
"prettyjson": "1.2.5",
11+
"v8r": "5.1.0"
12+
}
13+
}

0 commit comments

Comments
 (0)