Skip to content

Commit

Permalink
Use jq to extract npm version from package.json (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr authored Apr 2, 2023
1 parent 9f8497a commit 013bcf1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 23 deletions.
34 changes: 27 additions & 7 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,32 @@ CMD="$1"
NAME="polkadot-js-tools"
REPO="jacogr"

if ! jq --help 2>&1 1>/dev/null
then
echo ""
echo "FATAL: 'jq' was not found in your PATH. Please install it."
echo ""
echo " This script uses the 'jq' binary to extract the latest"
echo " published npm version and then installs that version to"
echo " build the docker image"
echo ""
exit 1
fi

if ! docker --help 2>&1 1>/dev/null
then
echo ""
echo "FATAL: 'docker' was not found in your PATH. Please install it."
echo ""
echo " This script builds images using the 'docker' binary and as"
echo " such it requires the binary for any image build and publish"
echo " operations"
echo ""
exit 1
fi

# extract the current npm version from package.json
VERSION=$(cat package.json \
| grep npm \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| sed 's/ //g')
VERSION=$(cat package.json | jq .versions.npm --raw-output)

# helper function for the build logic
function build () {
Expand Down Expand Up @@ -53,10 +72,11 @@ function publish () {

# helper function for the usage logic
function usage () {
echo ""
echo "This builds a docker image for the latest npm published version."
echo "For maintainers publishing functionality is also provided."
echo ""
echo "Usage: docker.sh <build|publish>"
echo "Usage: build.sh <build|publish>"
echo "Commands:"
echo " build: builds a $NAME docker image"
echo " publish: publishes a built image to dockerhub"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"test": "yarn run:api --help && yarn run:json --help && yarn run:metadata --help && yarn run:monitor --help && yarn run:signer --help && yarn run:vanity --help"
},
"devDependencies": {
"@polkadot/dev": "^0.72.29",
"@polkadot/dev": "^0.72.32",
"@types/node": "^18.15.11",
"@types/yargs": "^17.0.24"
},
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -453,34 +453,34 @@ __metadata:
languageName: node
linkType: hard

"@polkadot/dev-test@npm:^0.72.29":
version: 0.72.29
resolution: "@polkadot/dev-test@npm:0.72.29"
"@polkadot/dev-test@npm:^0.72.32":
version: 0.72.32
resolution: "@polkadot/dev-test@npm:0.72.32"
dependencies:
jsdom: ^21.1.1
tslib: ^2.5.0
checksum: f82b2be6539dc359b9d6574f9694266ebd6b63cd686630a9049b9bf88d86d13f96b8763b514a074007bfa5cfec27d3fc58db4e002c022237ad54416752d76d17
checksum: 81f6649827db6f43efdf6ea7f7b13b83e9ca9be9058c588cde62e695836e26c135dba26804c4832288c2690ed174a24dfd11d574c49053dfedd5bb30e913a801
languageName: node
linkType: hard

"@polkadot/dev-ts@npm:^0.72.29":
version: 0.72.29
resolution: "@polkadot/dev-ts@npm:0.72.29"
"@polkadot/dev-ts@npm:^0.72.32":
version: 0.72.32
resolution: "@polkadot/dev-ts@npm:0.72.32"
dependencies:
json5: ^2.2.3
tslib: ^2.5.0
typescript: ^5.0.3
checksum: 97af0e678ed25d5538d435f8e091564f462411d79b024e3ccc45eba55f3c05e4e476cc402039d6bb9dc2542a585b082833f484e71bc49a9ce3d2ead07971c5d1
checksum: 4d9783e83cde12ba1677273cbb89e56223d0b6d4b75452f14dd0ab612f264e40a888d79b081044f447815f7aaf584ccd5f299dce0291e9a0443135a9b070b546
languageName: node
linkType: hard

"@polkadot/dev@npm:^0.72.29":
version: 0.72.29
resolution: "@polkadot/dev@npm:0.72.29"
"@polkadot/dev@npm:^0.72.32":
version: 0.72.32
resolution: "@polkadot/dev@npm:0.72.32"
dependencies:
"@eslint/js": ^8.37.0
"@polkadot/dev-test": ^0.72.29
"@polkadot/dev-ts": ^0.72.29
"@polkadot/dev-test": ^0.72.32
"@polkadot/dev-ts": ^0.72.32
"@rollup/plugin-alias": ^4.0.3
"@rollup/plugin-commonjs": ^24.0.1
"@rollup/plugin-dynamic-import-vars": ^2.0.3
Expand Down Expand Up @@ -541,7 +541,7 @@ __metadata:
polkadot-exec-rollup: scripts/polkadot-exec-rollup.mjs
polkadot-exec-tsc: scripts/polkadot-exec-tsc.mjs
polkadot-exec-webpack: scripts/polkadot-exec-webpack.mjs
checksum: d7b62ff4405b35626f07b9b9a4401b3a45db5cb3cc5f2bbccba583c1ffbb24e8327e757cf98894fc47f9176fbc95d859e1ea286d1e9fd6805994f739f98698ab
checksum: f4ab710a54a211bf5b99e88eaae73945312952213c0d405590348fd14576887d401a44546659773b0801ae77204973808f5b0eb8cf39cad1a910520a1b8b506f
languageName: node
linkType: hard

Expand Down Expand Up @@ -7658,7 +7658,7 @@ fsevents@~2.3.2:
version: 0.0.0-use.local
resolution: "root-workspace-0b6124@workspace:."
dependencies:
"@polkadot/dev": ^0.72.29
"@polkadot/dev": ^0.72.32
"@types/node": ^18.15.11
"@types/yargs": ^17.0.24
languageName: unknown
Expand Down

0 comments on commit 013bcf1

Please sign in to comment.