From 6923ba0da93fb1701204d6f08335dac2dcddecea Mon Sep 17 00:00:00 2001 From: Eric Ribeiro Date: Tue, 15 Mar 2022 08:00:00 -0700 Subject: [PATCH] fix(migrate): add the template's lint rules to the migration script and dependencies check (#129) * add the yamllint from the template to migration script * patch: add check for yq and gracefully exit if not found * add check for jq --- migrate.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/migrate.sh b/migrate.sh index 9be599d1..c8da0278 100644 --- a/migrate.sh +++ b/migrate.sh @@ -8,6 +8,20 @@ verify_run() { echo "This does not appear to be the root of a CircleCI project" exit 1 fi + + # Ensure jq is installed + if ! command -v jq >/dev/null 2>&1; then + echo "Looks like you don't have \"jq\" installed" + echo "Please install it and run the script again: https://stedolan.github.io/jq/download/." + exit 1 + fi + + # Ensure yq is installed + if ! command -v yq >/dev/null 2>&1; then + echo "Looks like you don't have \"yq\" installed" + echo "Please install it and run the script again: https://github.com/mikefarah/yq#install." + exit 1 + fi } backup_contents() { @@ -30,6 +44,10 @@ download_template() { curl -Ls "$ORB_TEMPLATE_DOWNLOAD_URL" -o "$ORB_TEMP_DIR/orb-template.tar.gz" tar -xzf "$ORB_TEMP_DIR/orb-template.tar.gz" -C "$ORB_TEMP_DIR" --strip-components 1 cp -r "${ORB_TEMP_DIR}/.circleci/." .circleci/ + + if [[ ! -e .yamllint ]]; then + cp "${ORB_TEMP_DIR}/.yamllint" .yamllint + fi } copy_custom_components() {