sigs.k8s.io/prow@v0.0.0-20240503223140-c5e374dc7eb1/hack/make-rules/update/ts-rollup.sh (about) 1 #!/usr/bin/env bash 2 # Copyright 2022 The Kubernetes Authors. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -o nounset 17 set -o errexit 18 set -o pipefail 19 20 REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd -P)" 21 cd $REPO_ROOT 22 23 TS_PACKAGES_FILE="${1:-}" 24 if [[ -z "$TS_PACKAGES_FILE" ]]; then 25 echo "ERROR: TS_PACKAGES_FILE must provided" 26 exit 1 27 fi 28 29 ROLLUP_ENTRYPOINTS=() 30 while IFS= read -r rollup_entrypoint; do 31 ROLLUP_ENTRYPOINTS+=("${rollup_entrypoint}") 32 done < "${TS_PACKAGES_FILE}" 33 34 for rollup_entrypoint_info in ${ROLLUP_ENTRYPOINTS[@]}; do 35 if [[ -z "${rollup_entrypoint_info}" || ${rollup_entrypoint_info} =~ \#.* ]]; then 36 continue 37 fi 38 parts=(${rollup_entrypoint_info//->/ }) 39 rollup_entrypoint="${parts[0]}" 40 dst_js="${parts[1]}" 41 rollup_entrypoint_dir="$(dirname ${rollup_entrypoint})" 42 rollup_entrypoint_file="$(basename -s '.ts' ${rollup_entrypoint})" 43 export OUT="${rollup_entrypoint_dir}/${dst_js}" 44 if [[ "${CLEAN:-}" == "true" ]]; then 45 echo "Clean up ${OUT}" 46 if [[ -f $OUT ]]; then 47 rm $OUT 48 fi 49 else 50 echo "Rollup ${rollup_entrypoint}" 51 ./hack/rollup-js.sh "${rollup_entrypoint_dir}" "${rollup_entrypoint_file}" 52 fi 53 done