Commit e68c72b0 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

fix(generated-releaserc): use strict yaml to avoid unexpected syntax error

parent 4446f3a1
Loading
Loading
Loading
Loading
+38 −35
Original line number Diff line number Diff line
@@ -226,19 +226,18 @@ stages:
        {
          echo "debug: ${debug}"
          echo ""
          echo "tagFormat: \"${SEMREL_TAG_FORMAT}\""
          echo "tagFormat: '${SEMREL_TAG_FORMAT}'"
          echo ""
          echo "plugins: ["
          echo "  \"@semantic-release/commit-analyzer\","
          echo "  \"@semantic-release/release-notes-generator\","
          echo "  \"@semantic-release/gitlab\","
          echo "plugins: "
          echo "  - '@semantic-release/commit-analyzer'"
          echo "  - '@semantic-release/release-notes-generator'"
          echo "  - '@semantic-release/gitlab'"
          echo "${changelogPluginConfig}"
          echo "${execPluginConfig}"
          echo "${gitPluginConfig}"
          echo "]"
          echo ""
          echo "branches:"
          echo "  - \"master\""
          echo "  - 'master'"
        } > "${semrelConfigFile}"
        cat "${semrelConfigFile}"
      fi
@@ -259,19 +258,15 @@ stages:
    if [[ -n "${SEMREL_CHANGELOG_ENABLED}" ]]; then
      if [[ -n "${SEMREL_CHANGELOG_FILE}" ]] || [[ -n "${SEMREL_CHANGELOG_TITLE}" ]]; then
        if [[ -n "${SEMREL_CHANGELOG_FILE}" ]]; then
          changeLogConfig="      \"changelogFile\": \"${SEMREL_CHANGELOG_FILE}\""
          changeLogConfig="changelogFile: '${SEMREL_CHANGELOG_FILE}'"
        fi
        if [[ -n "${SEMREL_CHANGELOG_TITLE}" ]]; then
          changeLogConfig=$(echo -e "${changeLogConfig}${changeLogConfig+,}\n      \"changelogTitle\": \"${SEMREL_CHANGELOG_TITLE}\"")
          changeLogConfig=$(echo -e "${changeLogConfig:+${changeLogConfig}\n      }changelogTitle: '${SEMREL_CHANGELOG_TITLE}'")
        fi
        echo "  ["
        echo "    \"@semantic-release/changelog\","
        echo "    {"
        echo "${changeLogConfig}"
        echo "    }"
        echo "  ],"
        echo "  - - '@semantic-release/changelog'"
        echo "    - ${changeLogConfig}"
      else
        echo "  \"@semantic-release/changelog\","
        echo "  - '@semantic-release/changelog'"
      fi
    else
      echo ""
@@ -283,52 +278,60 @@ stages:
    # git plugin has default changelog file as asset by default so 
    # we need to add it explicitly if the user configured a custom changelogFile
    if [[ -n "${SEMREL_CHANGELOG_ENABLED}" ]] && [[ -n "${SEMREL_CHANGELOG_FILE}" ]]; then
      echo "  ["
      echo "    \"@semantic-release/git\","
      echo "    {"
      echo "      \"assets\": [ \"${SEMREL_CHANGELOG_FILE}\", 'package.json', 'package-lock.json', 'npm-shrinkwrap.json' ]"
      echo "    }"
      echo "  ],"
      echo "  - - '@semantic-release/git'"
      echo "    - assets:"
      echo "      - '${SEMREL_CHANGELOG_FILE}'"
      echo "      - 'package.json'"
      echo "      - 'package-lock.json'"
      echo "      - 'npm-shrinkwrap.json'"
    else
      echo "  \"@semantic-release/git\","
      echo "  - '@semantic-release/git'"
    fi
  }

  # this script console output is inserted in generated file: DO NOT ADD LOGS
  function generate_exec_plugin_conf() {
    scriptsConfig=""
    tabs="      "
    tabs="    - "
    scriptPath=${SEMREL_HOOKS_DIR}/${SEMREL_VERIFY_CONDITIONS_CMD}
    if [[ -f "${scriptPath}" ]]; then
      scriptsConfig="${tabs}\"verifyConditionsCmd\": \"${scriptPath}\","
      chmod +x "${scriptPath}"
      scriptsConfig="${tabs}verifyConditionsCmd: '${scriptPath}'"
      tabs="      "
    fi
    scriptPath=${SEMREL_HOOKS_DIR}/${SEMREL_VERIFY_RELEASE_CMD}
    if [[ -f "${scriptPath}" ]]; then
      scriptsConfig=$(echo -e "${scriptsConfig}\n${tabs}\"verifyReleaseCmd\": \"\\\"${scriptPath}\\\" \\\"\${lastRelease.version}\\\" \\\"\${nextRelease.version}\\\" \\\"\${nextRelease.type}\\\"\",")
      chmod +x "${scriptPath}"
      scriptsConfig=$(echo -e "${scriptsConfig}\n${tabs}verifyReleaseCmd: '\"${scriptPath}\" \"\${lastRelease.version}\" \"\${nextRelease.version}\" \"\${nextRelease.type}\"'")
      tabs="      "
    fi
    scriptPath=${SEMREL_HOOKS_DIR}/${SEMREL_PREPARE_CMD}
    if [[ -f "${scriptPath}" ]]; then
      scriptsConfig=$(echo -e "${scriptsConfig}\n${tabs}\"prepareCmd\": \"\\\"${scriptPath}\\\" \\\"\${lastRelease.version}\\\" \\\"\${nextRelease.version}\\\" \\\"\${nextRelease.type}\\\"\",")
      chmod +x "${scriptPath}"
      scriptsConfig=$(echo -e "${scriptsConfig}\n${tabs}prepareCmd: '\"${scriptPath}\" \"\${lastRelease.version}\" \"\${nextRelease.version}\" \"\${nextRelease.type}\"'")
      tabs="      "
    fi
    scriptPath=${SEMREL_HOOKS_DIR}/${SEMREL_PUBLISH_CMD}
    if [[ -f "${scriptPath}" ]]; then
      scriptsConfig=$(echo -e "${scriptsConfig}\n${tabs}\"publishCmd\": \"\\\"${scriptPath}\\\" \\\"\${nextRelease.version}\\\" \\\"\${options.branch}\\\" \\\"\${commits.length}\\\" \\\"\${Date.now()}\\\"\",")
      chmod +x "${scriptPath}"
      scriptsConfig=$(echo -e "${scriptsConfig}\n${tabs}publishCmd: '\"${scriptPath}\" \"\${nextRelease.version}\" \"\${options.branch}\" \"\${commits.length}\" \"\${Date.now()}\"'")
      tabs="      "
    fi
    scriptPath=${SEMREL_HOOKS_DIR}/${SEMREL_SUCCESS_CMD}
    if [[ -f "${scriptPath}" ]]; then
      scriptsConfig=$(echo -e "${scriptsConfig}\n${tabs}\"successCmd\": \"\\\"${scriptPath}\\\" \\\"\${lastRelease.version}\\\" \\\"\${nextRelease.version}\\\"\",")
      chmod +x "${scriptPath}"
      scriptsConfig=$(echo -e "${scriptsConfig}\n${tabs}successCmd: '\"${scriptPath}\" \"\${lastRelease.version}\" \"\${nextRelease.version}\"'")
      tabs="      "
    fi
    scriptPath=${SEMREL_HOOKS_DIR}/${SEMREL_FAIL_CMD}
    if [[ -f "${scriptPath}" ]]; then
      scriptsConfig=$(echo -e "${scriptsConfig}\n${tabs}\"failCmd\": \"\\\"${scriptPath}\\\" \\\"\${lastRelease.version}\\\" \\\"\${nextRelease.version}\\\"\",")
      chmod +x "${scriptPath}"
      scriptsConfig=$(echo -e "${scriptsConfig}\n${tabs}failCmd: '\"${scriptPath}\" \"\${lastRelease.version}\" \"\${nextRelease.version}\"'")
      tabs="      "
    fi
    if [[ -n "${scriptsConfig}" ]]; then
      echo "  ["
      echo "    \"@semantic-release/exec\","
      echo "    {"
      echo "  - - '@semantic-release/exec'"
      echo "${scriptsConfig}"
      echo "    }"
      echo "  ],"
    else
      echo ""
    fi