#!/bin/bash

set -ex

read -r -a PLUGINS_LIST_ARR <<< "$PLUGINS_LIST"
rm -rf $(printf 'gems/plugins/%s ' "${PLUGINS_LIST_ARR[@]}")

export DISABLE_POSTINSTALL=1
yarn install --ignore-optional || yarn install --ignore-optional --network-concurrency 1

if ! git diff --exit-code yarn.lock; then
  message="yarn.lock changes need to be checked in. Make sure you run 'yarn install' without private canvas-lms plugins installed."
  gergich comment "{\"path\":\"yarn.lock\",\"position\":1,\"severity\":\"error\",\"message\":\"$message\"}"
else
  yarn dedupe-yarn

  if ! git diff --exit-code yarn.lock; then
    message="yarn.lock changes need to be de-duplicated. Make sure you run 'yarn dedupe-yarn'."
    gergich comment "{\"path\":\"yarn.lock\",\"position\":1,\"severity\":\"error\",\"message\":\"$message\"}"
  fi
fi

gergich status
echo "YARN_LOCK OK!"

#!/bin/bash

set -ex

if [ -z "$SKIP_YARN" ]; then
  read -r -a PLUGINS_LIST_ARR <<< "$PLUGINS_LIST"
  rm -rf $(printf 'gems/plugins/%s ' "${PLUGINS_LIST_ARR[@]}")

  export DISABLE_POSTINSTALL=1
  yarn install --ignore-optional || yarn install --ignore-optional --network-concurrency 1
fi

if ! git diff --exit-code yarn.lock; then
  #
  # Put yarn.lock diff into the build output
  #
  git --no-pager diff yarn.lock

  #
  # Put yarn.lock diff into the Gergich message
  #
  diff="$(git diff yarn.lock)"
  diff="\n\n\`\`\`\n$diff\n\`\`\`"
  diff=${diff//$'\n'/'\n'}
  diff=${diff//$'"'/'\"'}

  message="yarn.lock changes need to be checked in. Make sure you run 'yarn install' without private canvas-lms plugins installed."
  gergich comment "{\"path\":\"yarn.lock\",\"position\":1,\"severity\":\"error\",\"message\":\"$message$diff\"}"
else
  yarn dedupe-yarn

  if ! git diff --exit-code yarn.lock; then
    message="yarn.lock changes need to be de-duplicated. Make sure you run 'yarn dedupe-yarn'."
    gergich comment "{\"path\":\"yarn.lock\",\"position\":1,\"severity\":\"error\",\"message\":\"$message\"}"
  fi
fi

gergich status
echo "YARN_LOCK OK!"

Make Gergich give better information about yarn.lock differences
Make Gergich give better information about yarn.lock differences

Thought it might be helpful for Gergich to provide diffs on the
yarn.lock file so we can have a better idea what we have installed
that doesn't belong in "vanilla" Canvas.

flag=none
test plan
 none, but see the lint-review -2 comment on g/287836
 for an example of what the output looks like

Change-Id: I238cb3d7b1b14262313037bdb49a574b4c1f5df4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/286910
Tested-by: Service Cloud Jenkins <9144042a601061f88f1e1d7a1753ea3e2972119d@instructure.com>
Reviewed-by: James Butters <4c5a489c9bb72d41f20b3b22aaf4c9b864e32f20@instructure.com>
Reviewed-by: Gonzalo Penaranda <8c432dde3e94facf86654413d4aff3fa9eced8f8@instructure.com>
Product-Review: Jon Scheiding <9af6aa5061dd5eef0e85122953253a66930fcf3e@instructure.com>
QA-Review: Gonzalo Penaranda <8c432dde3e94facf86654413d4aff3fa9eced8f8@instructure.com>
