📦➔🦋 Store and retrieve files on the Atmosphere
35
fork

Configure Feed

Select the types of activity you want to include in your feed.

release: add built-in shellcheck

Ducky f8e032fc b77483b0

+50 -7
+50 -7
src/commands/release.sh
··· 13 13 14 14 atfile.util.check_prog "git" 15 15 atfile.util.check_prog "md5sum" 16 + atfile.util.check_prog "shellcheck" 16 17 17 18 id="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13; echo)" 18 19 commit_author="$(git config user.name) <$(git config user.email)>" 19 20 commit_hash="$(git rev-parse HEAD)" 20 - commit_date="$(git show --no-patch --format=%ci $commit_hash)" 21 + commit_date="$(git show --no-patch --format=%ci "$commit_hash")" 22 + # shellcheck disable=SC2154 21 23 dist_file="$(echo "$_prog" | cut -d "." -f 1)-${_version}.sh" 24 + # shellcheck disable=SC2154 22 25 dist_dir="$_prog_dir/bin" 23 26 dist_path="$dist_dir/$dist_file" 24 27 dist_path_relative="$(realpath --relative-to="$(pwd)" "$dist_path")" 25 28 parsed_version="$(atfile.util.parse_version "$_version")" 26 29 version_record_id="atfile-$parsed_version" 27 30 28 - atfile.say "Building ATFile $_version ($id)..." 31 + atfile.say "Building..." 29 32 30 33 mkdir -p "$dist_dir" 31 34 32 - echo "↳ Creating '$dist_file'..." 35 + echo "↳ Compiling '$dist_file'..." 33 36 echo "#!/usr/bin/env bash" > "$dist_path" 34 37 35 38 echo -e "\n# ATFile <https://tangled.sh/@zio.sh/atfile> ··· 40 43 # Build: $id ($(hostname):$(atfile.util.get_os)) 41 44 # --- 42 45 # Psst! You can \`source atfile\` in your own Bash scripts! 43 - " >> $dist_path 46 + " >> "$dist_path" 44 47 45 48 for s in "${ATFILE_DEVEL_SOURCES[@]}" 46 49 do 47 50 if [[ "$s" != *"/src/commands/release.sh" ]]; then 48 51 if [[ -f "$s" ]]; then 49 - echo "↳ Compiling: $s" 52 + echo " ↳ Adding: $s" 50 53 51 54 while IFS="" read -r line 52 55 do ··· 74 77 75 78 checksum="$(atfile.util.get_md5 "$dist_path")" 76 79 80 + echo "$dist_path" 81 + 82 + echo "Testing..." 83 + shellcheck_output="$(shellcheck --format=json "$dist_path" 2>&1)" 84 + 85 + test_error_count=0 86 + test_info_count=0 87 + test_style_count=0 88 + test_warning_count=0 89 + 90 + while read -r item; do 91 + code="$(echo "$item" | jq -r '.code')" 92 + col="$(echo "$item" | jq -r '.column')" 93 + line="$(echo "$item" | jq -r '.line')" 94 + level="$(echo "$item" | jq -r '.level')" 95 + message="$(echo "$item" | jq -r '.message')" 96 + 97 + case "$level" in 98 + "error") level="🛑 Error"; (( test_error_count++ )) ;; 99 + "info") level="ℹ️ Info"; (( test_info_count++ )) ;; 100 + "style") level="🎨 Style"; (( test_style_count++ )) ;; 101 + "warning") level="⚠️ Warning"; (( test_warning_count++ )) ;; 102 + esac 103 + 104 + echo "↳ $level ($line:$col): [$code] $message" 105 + done <<< "$(echo "$shellcheck_output" | jq -c '.[]')" 106 + 107 + test_total_count=$(( test_error_count + test_info_count + test_style_count + test_warning_count )) 108 + 77 109 echo -e "Built: $_version 78 110 ↳ Path: ./$dist_path_relative 79 111 ↳ Check: $checksum 80 - ↳ Size: "$(atfile.util.get_file_size_pretty "$(stat -c %s "$dist_path")")" 112 + ↳ Size: $(atfile.util.get_file_size_pretty "$(stat -c %s "$dist_path")") 81 113 ↳ Lines: $(atfile.util.fmt_int "$(cat "$dist_path" | wc -l)") 114 + ↳ Issues: $(atfile.util.fmt_int "$test_total_count") 115 + ↳ Error: $(atfile.util.fmt_int "$test_error_count") 116 + ↳ Warn: $(atfile.util.fmt_int "$test_warning_count") 117 + ↳ Info: $(atfile.util.fmt_int "$test_info_count") 118 + ↳ Style: $(atfile.util.fmt_int "$test_error_count") 82 119 ↳ ID: $id" 83 120 84 121 chmod +x "$dist_path" 85 122 123 + # shellcheck disable=SC2154 86 124 if [[ $_devel_publish == 1 ]]; then 125 + if [[ $test_error_count -gt 0 ]]; then 126 + atfile.die "Unable to publish ($test_error_count errors detected)" 127 + fi 128 + 87 129 echo "---" 88 130 atfile.auth "$_dist_username" "$_dist_password" 89 131 [[ $_version == *"+"* ]] && atfile.die "Cannot publish a Git version ($_version)" ··· 95 137 96 138 latest_release_record="{ 97 139 \"version\": \"$_version\", 98 - \"releasedAt\": \"$(atfile.util.get_date "$_commit_date")\", 140 + \"releasedAt\": \"$(atfile.util.get_date "$commit_date")\", 99 141 \"commit\": \"$commit_hash\", 100 142 \"id\": \"$id\", 101 143 \"checksum\": \"$checksum\" 102 144 }" 103 145 104 146 atfile.say "Updating latest record to $_version..." 147 + # shellcheck disable=SC2154 105 148 atfile.invoke.manage_record put "at://$_username/self.atfile.latest/self" "$latest_release_record" &> /dev/null 106 149 fi 107 150 }