Skip to content

Instantly share code, notes, and snippets.

@shesek
Last active September 16, 2017 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shesek/029fbf279b826005095dad50697c0e27 to your computer and use it in GitHub Desktop.
Save shesek/029fbf279b826005095dad50697c0e27 to your computer and use it in GitHub Desktop.
Lock-down bower.json to the currently installed package versions (semi shrinkwrap)

This script will:

  • Expand the bower.json file to include all installed dependencies, including indirect ones.

  • Configure the dependencies field to use exact revision hashes of the currently installed versions.

  • Configure the resolutions field to the currently installed versions, too.

Requires jq (available on the Ubuntu repos via apt install jq).

cp bower.json bower.json.old
cat bower.json.old | \
jq "$(cat bower_components/*/.bower.json | \
jq -r '".dependencies[\"" + .name + "\"]=\"" + (._source+"#"+._resolution.commit) + "\"|.resolutions[\"" + .name + "\"]=\"" + ._resolution.commit + "\""' |paste -d'|' -s -)" \
> bower.json
@shesek
Copy link
Author

shesek commented Aug 28, 2017

You can see the effects of running this script here:

cobit-wallet/cobit@3197cf2#diff-0a08a7565aba4405282251491979bb6b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment