update_api.sh 835 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. export VSCODE_QUALITY="stable"
  3. while getopts ":ilp" opt; do
  4. case "$opt" in
  5. i)
  6. export VSCODE_QUALITY="insider"
  7. ;;
  8. esac
  9. done
  10. URL=`curl -s "https://update.code.visualstudio.com/api/update/win32-x64-archive/${VSCODE_QUALITY}/VERSION" | jq -c '.url' | sed -E 's/.*"([^"]+)".*/\1/'`
  11. # echo "url: ${URL}"
  12. FILE=`echo "${URL}" | sed -E 's|.*/([^/]+\.zip)$|\1|'`
  13. # echo "file: ${FILE}"
  14. DIRECTORY=`echo "${URL}" | sed -E 's|.*/([^/]+)\.zip$|\1|'`
  15. # echo "directory: ${DIRECTORY}"
  16. if [[ ! -f "${FILE}" ]]; then
  17. wget "${URL}"
  18. fi
  19. if [[ ! -d "${DIRECTORY}" ]]; then
  20. unzip "${FILE}" -d "${DIRECTORY}"
  21. fi
  22. APIS=`cat ${DIRECTORY}/resources/app/product.json | jq -r '.extensionEnabledApiProposals'`
  23. cat <<< $(jq --argjson v "${APIS}" 'setpath(["extensionEnabledApiProposals"]; $v)' product.json) > product.json