depot/third_party/nixpkgs/pkgs/tools/package-management/yarn-lock-converter/update.sh
Default email 94427deb9d Project import generated by Copybara.
GitOrigin-RevId: f91ee3065de91a3531329a674a45ddcb3467a650
2023-05-24 16:37:59 +03:00

25 lines
645 B
Bash
Executable file

#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nodejs libarchive prefetch-npm-deps moreutils
# shellcheck shell=bash
set -exuo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
TMPDIR="$(mktemp -d)"
trap 'rm -r -- "$TMPDIR"' EXIT
pushd -- "$TMPDIR"
npm pack "@vht/yarn-lock-converter" --json | jq '.[0] | { version, integrity, filename }' > source.json
bsdtar -x -f "$(jq -r .filename source.json)"
pushd package
npm install --package-lock-only
popd
DEPS="$(prefetch-npm-deps package/package-lock.json)"
jq ".deps = \"$DEPS\"" source.json | sponge source.json
popd
cp -t . -- "$TMPDIR/source.json" "$TMPDIR/package/package-lock.json"