๐Ÿ“ฆโž”๐Ÿฆ‹ Store and retrieve files on the ATmosphere

Compare changes

Choose any two refs to compare.

+283 -206
+8
.tangled/workflows/build.yaml
··· 14 dependencies: 15 nixpkgs: 16 - bash 17 - shellcheck 18 19 environment:
··· 14 dependencies: 15 nixpkgs: 16 - bash 17 + - coreutils 18 + - curl 19 + - file 20 + - git 21 + - gnugrep 22 + - gnused 23 + - hostname 24 + - jq 25 - shellcheck 26 27 environment:
+4 -2
README.md
··· 102 103 Various environment variables can be exported to control various aspects of the development version. These are as follows: 104 105 * `ATFILE_DEVEL_ENABLE_PIPING` <em>&lt;int&gt; (default: `0`)</em><br />Allow piping (useful to test installation) _(e.g. `cat ./atfile.sh | bash`)_ 106 * `ATFILE_DEVEL_ENABLE_PUBLISH` <em>&lt;int&gt; (default: `0`)</em><br />Publish build to ATProto repository (to allow for updating) as the last step when running `release`. Several requirements must be fulfilled to succeed: 107 - * `ATFILE_DEVEL_DIST_USERNAME` must be set<br />By default, this is set to `$did` in `atfile.sh` (see **๐Ÿ—๏ธ Building โž” Meta**). Ideally, you should not set this variable as updates in the built version will not be fetched from the correct place 108 * `ATFILE_DEVEL_DIST_PASSWORD` must be set 109 * No tests should return an **Error** (**Warning** is acceptable) 110 * Git commit must be <a href="https://git-scm.com/docs/git-tag">tagged</a> ··· 119 120 ### Meta 121 122 - Various meta variables can be set to be available in the final compiled build (usually found in `help`). These are found in `atfile.sh` under `# Meta`. These variables are as follows: 123 124 * `author` <em>&lt;string&gt;</em><br />Copyright author 125 * `did` <em>&lt;did&gt;</em><br />DID of copyright author. Also used as the source for published builds, unless `ATFILE_DEVEL_DIST_USERNAME` is set (see **๐Ÿ—๏ธ Building โž” Environment variables**)
··· 102 103 Various environment variables can be exported to control various aspects of the development version. These are as follows: 104 105 + * `ATFILE_DEVEL_DIST_USERNAME` <em>&lt;string&gt;</em><br />_(Todo)_. During runtime, this is set to `$did` in `atfile.sh` (see **๐Ÿ—๏ธ Building โž” Meta**). Ideally, you should not set this variable as updates in the built version will not be fetched from the correct place 106 + * `ATFILE_DEVEL_DIST_PASSWORD` <em>&lt;string&gt;</em><br />_(Todo)_ 107 * `ATFILE_DEVEL_ENABLE_PIPING` <em>&lt;int&gt; (default: `0`)</em><br />Allow piping (useful to test installation) _(e.g. `cat ./atfile.sh | bash`)_ 108 * `ATFILE_DEVEL_ENABLE_PUBLISH` <em>&lt;int&gt; (default: `0`)</em><br />Publish build to ATProto repository (to allow for updating) as the last step when running `release`. Several requirements must be fulfilled to succeed: 109 + * `ATFILE_DEVEL_DIST_USERNAME` must be set 110 * `ATFILE_DEVEL_DIST_PASSWORD` must be set 111 * No tests should return an **Error** (**Warning** is acceptable) 112 * Git commit must be <a href="https://git-scm.com/docs/git-tag">tagged</a> ··· 121 122 ### Meta 123 124 + Various meta variables can be set to be available in the final compiled build (usually found in `help`). These are found in `atfile.sh` under `# Meta`. These are as follows: 125 126 * `author` <em>&lt;string&gt;</em><br />Copyright author 127 * `did` <em>&lt;did&gt;</em><br />DID of copyright author. Also used as the source for published builds, unless `ATFILE_DEVEL_DIST_USERNAME` is set (see **๐Ÿ—๏ธ Building โž” Environment variables**)
+1 -1
atfile.sh
··· 36 author="zio" 37 did="did:web:zio.sh" 38 repo="https://tangled.sh/@zio.sh/atfile" 39 - version="0.12.2" 40 year="$(date +%Y)" 41 42 # Entry
··· 36 author="zio" 37 did="did:web:zio.sh" 38 repo="https://tangled.sh/@zio.sh/atfile" 39 + version="0.12.8" 40 year="$(date +%Y)" 41 42 # Entry
+1 -1
src/commands/auth.sh
··· 31 # NOTE: Speeds things up a little if the command doesn't need actor resolving 32 if [[ -z $_command ]] ||\ 33 [[ $_command == "ai" ]] ||\ 34 [[ $_command == "handle" ]] ||\ 35 [[ $_command == "help" ]] ||\ 36 [[ $_command == "now" ]] ||\ 37 - [[ $_command == "release" ]] ||\ 38 [[ $_command == "resolve" ]] ||\ 39 [[ $_command == "scrape" ]] ||\ 40 [[ $_command == "something-broke" ]] ||\
··· 31 # NOTE: Speeds things up a little if the command doesn't need actor resolving 32 if [[ -z $_command ]] ||\ 33 [[ $_command == "ai" ]] ||\ 34 + [[ $_command == "build" ]] ||\ 35 [[ $_command == "handle" ]] ||\ 36 [[ $_command == "help" ]] ||\ 37 [[ $_command == "now" ]] ||\ 38 [[ $_command == "resolve" ]] ||\ 39 [[ $_command == "scrape" ]] ||\ 40 [[ $_command == "something-broke" ]] ||\
+192
src/commands/build.sh
···
··· 1 + #!/usr/bin/env bash 2 + # atfile-devel=ignore-build 3 + 4 + function atfile.build() { 5 + # shellcheck disable=SC2154 6 + [[ $_os != "linux" ]] && atfile.die "Only available on Linux (GNU)\nโ†ณ Detected OS: $_os" 7 + 8 + function atfile.build.get_devel_value() { 9 + local file="$1" 10 + local value="$2" 11 + local found_line 12 + 13 + found_line="$(grep '^# atfile-devel=' "$file" | head -n1)" 14 + if [[ -n "$found_line" ]]; then 15 + local devel_values="${found_line#*=}" 16 + IFS=',' read -ra arr <<< "$devel_values" 17 + for v in "${arr[@]}"; do 18 + if [[ "$v" == "$value" ]]; then 19 + echo 1 20 + fi 21 + done 22 + fi 23 + } 24 + 25 + function atfile.build.replace_template_var() { 26 + string="$1" 27 + key="$2" 28 + value="$3" 29 + 30 + sed -s "s|{:$key:}|$value|g" <<< "$string" 31 + } 32 + 33 + atfile.util.check_prog "git" 34 + atfile.util.check_prog "grep" 35 + atfile.util.check_prog "hostname" 36 + atfile.util.check_prog "md5sum" 37 + atfile.util.check_prog "sed" 38 + atfile.util.check_prog "shellcheck" 39 + 40 + id="$(atfile.util.get_random 13)" 41 + commit_author="$(git config user.name) <$(git config user.email)>" 42 + commit_hash="$(git rev-parse HEAD)" 43 + commit_date="$(git show --no-patch --format=%ci "$commit_hash")" 44 + # shellcheck disable=SC2154 45 + dist_file="$(echo "$_prog" | cut -d "." -f 1)-${_version}.sh" 46 + # shellcheck disable=SC2154 47 + dist_dir="$_prog_dir/bin" 48 + dist_path="$dist_dir/$dist_file" 49 + dist_path_relative="$(realpath --relative-to="$(pwd)" "$dist_path")" 50 + parsed_version="$(atfile.util.parse_version "$_version")" 51 + version_record_id="atfile-$parsed_version" 52 + 53 + test_error_count=0 54 + test_info_count=0 55 + test_style_count=0 56 + test_warning_count=0 57 + test_ignore_count=0 58 + 59 + atfile.say "โš’๏ธ Building..." 60 + 61 + echo "โ†ณ Creating '$dist_file'..." 62 + mkdir -p "$dist_dir" 63 + echo "#!/usr/bin/env bash" > "$dist_path" 64 + 65 + echo "โ†ณ Generating header..." 66 + echo -e "\n# ATFile <${ATFILE_FORCE_META_REPO}> 67 + # --- 68 + # Version: $_version 69 + # Commit: $commit_hash 70 + # Author: $commit_author 71 + # Build: $id ($(hostname):$(atfile.util.get_os)) 72 + # --- 73 + # Psst! You can \`source atfile\` in your own Bash scripts! 74 + " >> "$dist_path" 75 + 76 + for s in "${ATFILE_DEVEL_INCLUDES[@]}" 77 + do 78 + if [[ -f "$s" ]]; then 79 + if [[ $(atfile.build.get_devel_value "$s" "ignore-build" == 1 ) ]]; then 80 + echo "โ†ณ Ignoring: $s" 81 + else 82 + echo "โ†ณ Compiling: $s" 83 + 84 + while IFS="" read -r line 85 + do 86 + include_line=1 87 + 88 + if [[ $line == "#"* ]] ||\ 89 + [[ $line == *" #"* ]] ||\ 90 + [[ $line == " " ]] ||\ 91 + [[ $line == "" ]]; then 92 + include_line=0 93 + fi 94 + 95 + if [[ $line == *"# shellcheck disable"* ]]; then 96 + if [[ $line == *"=SC2154"* ]]; then 97 + include_line=0 98 + else 99 + include_line=1 100 + (( test_ignore_count++ )) 101 + fi 102 + fi 103 + 104 + if [[ $include_line == 1 ]]; then 105 + if [[ $line == *"{:"* && $line == *":}"* ]]; then 106 + # NOTE: Not using atfile.util.get_envvar() here, as confusion can arise from config file 107 + line="$(atfile.build.replace_template_var "$line" "meta_author" "$ATFILE_FORCE_META_AUTHOR")" 108 + line="$(atfile.build.replace_template_var "$line" "meta_did" "$ATFILE_FORCE_META_DID")" 109 + line="$(atfile.build.replace_template_var "$line" "meta_repo" "$ATFILE_FORCE_META_REPO")" 110 + line="$(atfile.build.replace_template_var "$line" "meta_year" "$ATFILE_FORCE_META_YEAR")" 111 + line="$(atfile.build.replace_template_var "$line" "version" "$ATFILE_FORCE_VERSION")" 112 + fi 113 + 114 + echo "$line" >> "$dist_path" 115 + fi 116 + done < "$s" 117 + fi 118 + fi 119 + done 120 + 121 + echo -e "\n# \"Four million lines of BASIC\"\n# - Kif Kroker (3003)" >> "$dist_path" 122 + 123 + checksum="$(atfile.util.get_md5 "$dist_path" | cut -d "|" -f 1)" 124 + 125 + echo "๐Ÿงช Testing..." 126 + shellcheck_output="$(shellcheck --format=json "$dist_path" 2>&1)" 127 + 128 + while read -r item; do 129 + code="$(echo "$item" | jq -r '.code')" 130 + col="$(echo "$item" | jq -r '.column')" 131 + line="$(echo "$item" | jq -r '.line')" 132 + level="$(echo "$item" | jq -r '.level')" 133 + message="$(echo "$item" | jq -r '.message')" 134 + 135 + case "$level" in 136 + "error") level="๐Ÿ›‘ Error"; (( test_error_count++ )) ;; 137 + "info") level="โ„น๏ธ Info"; (( test_info_count++ )) ;; 138 + "style") level="๐ŸŽจ Style"; (( test_style_count++ )) ;; 139 + "warning") level="โš ๏ธ Warning"; (( test_warning_count++ )) ;; 140 + esac 141 + 142 + echo "โ†ณ $level ($line:$col): [SC$code] $message" 143 + done <<< "$(echo "$shellcheck_output" | jq -c '.[]')" 144 + 145 + test_total_count=$(( test_error_count + test_info_count + test_style_count + test_warning_count )) 146 + 147 + if [[ $test_error_count -gt 0 ]]; then 148 + atfile.say "---" 149 + atfile.say "โ›” Build failed" "" 31 31 1 150 + rm -f "$dist_path" 151 + exit 255 152 + fi 153 + 154 + echo -e "---\nโœ… Built: $_version 155 + โ†ณ Path: ./$dist_path_relative 156 + โ†ณ Check: $checksum 157 + โ†ณ Size: $(atfile.util.get_file_size_pretty "$(stat -c %s "$dist_path")") 158 + โ†ณ Lines: $(atfile.util.fmt_int "$(wc -l < "$dist_path")") 159 + โ†ณ Issues: $(atfile.util.fmt_int "$test_total_count") 160 + โ†ณ Error: $(atfile.util.fmt_int "$test_error_count") 161 + โ†ณ Warning: $(atfile.util.fmt_int "$test_warning_count") 162 + โ†ณ Info: $(atfile.util.fmt_int "$test_info_count") 163 + โ†ณ Style: $(atfile.util.fmt_int "$test_style_count") 164 + โ†ณ Ignored: $(atfile.util.fmt_int "$test_ignore_count") 165 + โ†ณ ID: $id" 166 + 167 + chmod +x "$dist_path" 168 + 169 + # shellcheck disable=SC2154 170 + if [[ $_devel_enable_publish == 1 ]]; then 171 + atfile.say "---\nโœจ Updating..." 172 + atfile.auth "$_devel_dist_username" "$_devel_dist_password" 173 + [[ $_version == *"+"* ]] && atfile.die "Cannot publish a Git version ($_version)" 174 + 175 + atfile.say "โ†ณ Uploading '$dist_path'..." 176 + atfile.invoke.upload "$dist_path" "" "$version_record_id" 177 + # shellcheck disable=SC2181 178 + [[ $? != 0 ]] && atfile.die "Unable to upload '$dist_path'" 179 + 180 + latest_release_record="{ 181 + \"version\": \"$_version\", 182 + \"releasedAt\": \"$(atfile.util.get_date "$commit_date")\", 183 + \"commit\": \"$commit_hash\", 184 + \"id\": \"$id\", 185 + \"checksum\": \"$checksum\" 186 + }" 187 + 188 + atfile.say "---\nโฌ†๏ธ Bumping..." 189 + # shellcheck disable=SC2154 190 + atfile.record update "at://$_devel_dist_username/self.atfile.latest/self" "$latest_release_record" 191 + fi 192 + }
+3 -2
src/commands/help.sh
··· 162 Disable periodic update checking when command finishes 163 ${_envvar_prefix}_DISABLE_UPDATE_COMMAND <boolยน> (default: $_disable_update_command_default) 164 Disable \`update\` command\n 165 - ${_envvar_prefix}_DEBUG <boolยน> (default: 0) 166 Print debug outputs 167 โš ๏ธ When output is JSON (${_envvar_prefix}_OUTPUT_JSON=1), sets to 0\n 168 ยน A bool in Bash is 1 (true) or 0 (false) 169 - ยฒ These servers are ran by @$handle. You can trust us!" 170 171 usage_paths="Paths 172 $_path_envvar
··· 162 Disable periodic update checking when command finishes 163 ${_envvar_prefix}_DISABLE_UPDATE_COMMAND <boolยน> (default: $_disable_update_command_default) 164 Disable \`update\` command\n 165 + ${_envvar_prefix}_DEBUGยณ <boolยน> (default: 0) 166 Print debug outputs 167 โš ๏ธ When output is JSON (${_envvar_prefix}_OUTPUT_JSON=1), sets to 0\n 168 ยน A bool in Bash is 1 (true) or 0 (false) 169 + ยฒ These servers are ran by @$handle. You can trust us! 170 + ยณ Cannot be set by config file" 171 172 usage_paths="Paths 173 $_path_envvar
+10 -2
src/commands/install.sh
··· 25 fi 26 27 case $_os in 28 "haiku") 29 install_dir="/boot/system/non-packaged/bin" 30 ;; ··· 39 esac 40 41 if [[ $# -gt 0 ]]; then 42 - atfile.say.debug "Overriden variables\nโ†ณ Path: $override_path\nโ†ณ Version: $override_version\nโ†ณ DID: $override_did" 43 fi 44 45 atfile.say.debug "Setting up..." 46 47 [[ -n "$override_path" ]] && install_dir="$override_path" 48 mkdir -p "$conf_dir" 49 # shellcheck disable=SC2154 50 touch "$conf_dir/$_file_envvar" ··· 94 95 atfile.say.debug "Found latest version\nโ†ณ Version: $found_version ($parsed_found_version)\nโ†ณ Source: $source_did\nโ†ณ Blob: $found_version_blob" 96 97 - atfile.say.debug "Download '$blob_url'..." 98 99 curl -s -o "${install_dir}/$install_file" "$blob_url" 100 [[ $? != 0 ]] && atfile.die "Unable to download" 101 102 atfile.say.debug "Installing...\nโ†ณ OS: $_os\nโ†ณ Install: $install_dir/$install_file\nโ†ณ Config: $conf_dir/$_file_envvar"
··· 25 fi 26 27 case $_os in 28 + "linux-termux") 29 + # NOTE: The correct path of '$PREFIX/local/bin' would be more correct, 30 + # however, '$PREFIX/local' doesn't exist by default on Termux (and thus, 31 + # not in $PATH), so we'll install it in '$PREFIX/bin' instead 32 + install_dir="$PREFIX/bin" 33 + ;; 34 "haiku") 35 install_dir="/boot/system/non-packaged/bin" 36 ;; ··· 45 esac 46 47 if [[ $# -gt 0 ]]; then 48 + atfile.say.debug "Overridden variables\nโ†ณ Path: $override_path\nโ†ณ Version: $override_version\nโ†ณ DID: $override_did" 49 fi 50 51 atfile.say.debug "Setting up..." 52 53 [[ -n "$override_path" ]] && install_dir="$override_path" 54 + mkdir -p "$install_dir" 55 mkdir -p "$conf_dir" 56 # shellcheck disable=SC2154 57 touch "$conf_dir/$_file_envvar" ··· 101 102 atfile.say.debug "Found latest version\nโ†ณ Version: $found_version ($parsed_found_version)\nโ†ณ Source: $source_did\nโ†ณ Blob: $found_version_blob" 103 104 + atfile.say.debug "Downloading...\nโ†ณ Source: $blob_url\nโ†ณ Dest.: ${install_dir}/$install_file" 105 106 curl -s -o "${install_dir}/$install_file" "$blob_url" 107 + # shellcheck disable=SC2181 108 [[ $? != 0 ]] && atfile.die "Unable to download" 109 110 atfile.say.debug "Installing...\nโ†ณ OS: $_os\nโ†ณ Install: $install_dir/$install_file\nโ†ณ Config: $conf_dir/$_file_envvar"
+2
src/commands/record.sh
··· 48 at_collection="$(atfile.util.parse_at_uri "$at_uri" "collection")" 49 at_rkey="$(atfile.util.parse_at_uri "$at_uri" "rkey")" 50 51 case "$sub_command" in 52 "create") 53 if [[ -z "$at_rkey" ]]; then
··· 48 at_collection="$(atfile.util.parse_at_uri "$at_uri" "collection")" 49 at_rkey="$(atfile.util.parse_at_uri "$at_uri" "rkey")" 50 51 + atfile.say.debug "Resolved AT URI\nโ†ณ Actor: $at_actor\nโ†ณ Collection: $at_collection\nโ†ณ RKey: $at_rkey" 52 + 53 case "$sub_command" in 54 "create") 55 if [[ -z "$at_rkey" ]]; then
-186
src/commands/release.sh
··· 1 - #!/usr/bin/env bash 2 - # atfile-devel=ignore-build 3 - 4 - function atfile.release() { 5 - # shellcheck disable=SC2154 6 - [[ $_os != "linux" ]] && atfile.die "Only available on Linux (GNU)\nโ†ณ Detected OS: $_os" 7 - 8 - function atfile.release.get_devel_value() { 9 - local file="$1" 10 - local value="$2" 11 - local found_line 12 - 13 - found_line="$(grep '^# atfile-devel=' "$file" | head -n1)" 14 - if [[ -n "$found_line" ]]; then 15 - local devel_values="${found_line#*=}" 16 - IFS=',' read -ra arr <<< "$devel_values" 17 - for v in "${arr[@]}"; do 18 - if [[ "$v" == "$value" ]]; then 19 - echo 1 20 - fi 21 - done 22 - fi 23 - } 24 - 25 - function atfile.release.replace_template_var() { 26 - string="$1" 27 - key="$2" 28 - value="$3" 29 - 30 - sed -s "s|{:$key:}|$value|g" <<< "$string" 31 - } 32 - 33 - atfile.util.check_prog "git" 34 - atfile.util.check_prog "md5sum" 35 - atfile.util.check_prog "shellcheck" 36 - 37 - id="$(atfile.util.get_random 13)" 38 - commit_author="$(git config user.name) <$(git config user.email)>" 39 - commit_hash="$(git rev-parse HEAD)" 40 - commit_date="$(git show --no-patch --format=%ci "$commit_hash")" 41 - # shellcheck disable=SC2154 42 - dist_file="$(echo "$_prog" | cut -d "." -f 1)-${_version}.sh" 43 - # shellcheck disable=SC2154 44 - dist_dir="$_prog_dir/bin" 45 - dist_path="$dist_dir/$dist_file" 46 - dist_path_relative="$(realpath --relative-to="$(pwd)" "$dist_path")" 47 - parsed_version="$(atfile.util.parse_version "$_version")" 48 - version_record_id="atfile-$parsed_version" 49 - 50 - test_error_count=0 51 - test_info_count=0 52 - test_style_count=0 53 - test_warning_count=0 54 - test_ignore_count=0 55 - 56 - atfile.say "โš’๏ธ Building..." 57 - 58 - echo "โ†ณ Creating '$dist_file'..." 59 - mkdir -p "$dist_dir" 60 - echo "#!/usr/bin/env bash" > "$dist_path" 61 - 62 - echo "โ†ณ Generating header..." 63 - echo -e "\n# ATFile <${ATFILE_FORCE_META_REPO}> 64 - # --- 65 - # Version: $_version 66 - # Commit: $commit_hash 67 - # Author: $commit_author 68 - # Build: $id ($(hostname):$(atfile.util.get_os)) 69 - # --- 70 - # Psst! You can \`source atfile\` in your own Bash scripts! 71 - " >> "$dist_path" 72 - 73 - for s in "${ATFILE_DEVEL_INCLUDES[@]}" 74 - do 75 - if [[ -f "$s" ]]; then 76 - if [[ $(atfile.release.get_devel_value "$s" "ignore-build" == 1 ) ]]; then 77 - echo "โ†ณ Ignoring: $s" 78 - else 79 - echo "โ†ณ Compiling: $s" 80 - 81 - while IFS="" read -r line 82 - do 83 - include_line=1 84 - 85 - if [[ $line == "#"* ]] ||\ 86 - [[ $line == *" #"* ]] ||\ 87 - [[ $line == " " ]] ||\ 88 - [[ $line == "" ]]; then 89 - include_line=0 90 - fi 91 - 92 - if [[ $line == *"# shellcheck disable"* ]]; then 93 - if [[ $line == *"=SC2154"* ]]; then 94 - include_line=0 95 - else 96 - include_line=1 97 - (( test_ignore_count++ )) 98 - fi 99 - fi 100 - 101 - if [[ $include_line == 1 ]]; then 102 - if [[ $line == *"{:"* && $line == *":}"* ]]; then 103 - # NOTE: Not using atfile.util.get_envvar() here, as confusion can arise from config file 104 - line="$(atfile.release.replace_template_var "$line" "meta_author" "$ATFILE_FORCE_META_AUTHOR")" 105 - line="$(atfile.release.replace_template_var "$line" "meta_did" "$ATFILE_FORCE_META_DID")" 106 - line="$(atfile.release.replace_template_var "$line" "meta_repo" "$ATFILE_FORCE_META_REPO")" 107 - line="$(atfile.release.replace_template_var "$line" "meta_year" "$ATFILE_FORCE_META_YEAR")" 108 - line="$(atfile.release.replace_template_var "$line" "version" "$ATFILE_FORCE_VERSION")" 109 - fi 110 - 111 - echo "$line" >> "$dist_path" 112 - fi 113 - done < "$s" 114 - fi 115 - fi 116 - done 117 - 118 - echo -e "\n# \"Four million lines of BASIC\"\n# - Kif Kroker (3003)" >> "$dist_path" 119 - 120 - checksum="$(atfile.util.get_md5 "$dist_path" | cut -d "|" -f 1)" 121 - 122 - echo "๐Ÿงช Testing..." 123 - shellcheck_output="$(shellcheck --format=json "$dist_path" 2>&1)" 124 - 125 - while read -r item; do 126 - code="$(echo "$item" | jq -r '.code')" 127 - col="$(echo "$item" | jq -r '.column')" 128 - line="$(echo "$item" | jq -r '.line')" 129 - level="$(echo "$item" | jq -r '.level')" 130 - message="$(echo "$item" | jq -r '.message')" 131 - 132 - case "$level" in 133 - "error") level="๐Ÿ›‘ Error"; (( test_error_count++ )) ;; 134 - "info") level="โ„น๏ธ Info"; (( test_info_count++ )) ;; 135 - "style") level="๐ŸŽจ Style"; (( test_style_count++ )) ;; 136 - "warning") level="โš ๏ธ Warning"; (( test_warning_count++ )) ;; 137 - esac 138 - 139 - echo "โ†ณ $level ($line:$col): [SC$code] $message" 140 - done <<< "$(echo "$shellcheck_output" | jq -c '.[]')" 141 - 142 - test_total_count=$(( test_error_count + test_info_count + test_style_count + test_warning_count )) 143 - 144 - echo -e "---\nโœ… Built: $_version 145 - โ†ณ Path: ./$dist_path_relative 146 - โ†ณ Check: $checksum 147 - โ†ณ Size: $(atfile.util.get_file_size_pretty "$(stat -c %s "$dist_path")") 148 - โ†ณ Lines: $(atfile.util.fmt_int "$(wc -l < "$dist_path")") 149 - โ†ณ Issues: $(atfile.util.fmt_int "$test_total_count") 150 - โ†ณ Error: $(atfile.util.fmt_int "$test_error_count") 151 - โ†ณ Warning: $(atfile.util.fmt_int "$test_warning_count") 152 - โ†ณ Info: $(atfile.util.fmt_int "$test_info_count") 153 - โ†ณ Style: $(atfile.util.fmt_int "$test_style_count") 154 - โ†ณ Ignored: $(atfile.util.fmt_int "$test_ignore_count") 155 - โ†ณ ID: $id" 156 - 157 - chmod +x "$dist_path" 158 - 159 - # shellcheck disable=SC2154 160 - if [[ $_devel_enable_publish == 1 ]]; then 161 - if [[ $test_error_count -gt 0 ]]; then 162 - atfile.die "Unable to publish ($test_error_count errors detected)" 163 - fi 164 - 165 - atfile.say "---\nโœจ Updating..." 166 - atfile.auth "$_devel_dist_username" "$_devel_dist_password" 167 - [[ $_version == *"+"* ]] && atfile.die "Cannot publish a Git version ($_version)" 168 - 169 - atfile.say "โ†ณ Uploading '$dist_path'..." 170 - atfile.invoke.upload "$dist_path" "" "$version_record_id" 171 - # shellcheck disable=SC2181 172 - [[ $? != 0 ]] && atfile.die "Unable to upload '$dist_path'" 173 - 174 - latest_release_record="{ 175 - \"version\": \"$_version\", 176 - \"releasedAt\": \"$(atfile.util.get_date "$commit_date")\", 177 - \"commit\": \"$commit_hash\", 178 - \"id\": \"$id\", 179 - \"checksum\": \"$checksum\" 180 - }" 181 - 182 - atfile.say "โ†ณ Bumping current version..." 183 - # shellcheck disable=SC2154 184 - atfile.invoke.manage_record put "at://$_devel_dist_username/self.atfile.latest/self" "$latest_release_record" &> /dev/null 185 - fi 186 - }
···
+3
src/commands/something_broke.sh
··· 103 $(atfile.something_broke.print_envvar "MAX_LIST" "$_max_list_default") 104 $(atfile.something_broke.print_envvar "OUTPUT_JSON" "$_output_json_default") 105 $(atfile.something_broke.print_envvar "PATH_CONF" "$_path_envvar") 106 โ†ณ ${_envvar_prefix}_PASSWORD: $([[ -n $(atfile.util.get_envvar "${_envvar_prefix}_PASSWORD") ]] && echo "(Set)") 107 $(atfile.something_broke.print_envvar "USERNAME") 108 Paths
··· 103 $(atfile.something_broke.print_envvar "MAX_LIST" "$_max_list_default") 104 $(atfile.something_broke.print_envvar "OUTPUT_JSON" "$_output_json_default") 105 $(atfile.something_broke.print_envvar "PATH_CONF" "$_path_envvar") 106 + $(atfile.something_broke.print_envvar "PATH_HOOK_POST_START") 107 + $(atfile.something_broke.print_envvar "PATH_HOOK_PRE_EXIT") 108 + $(atfile.something_broke.print_envvar "PATH_HOOK_PRE_START") 109 โ†ณ ${_envvar_prefix}_PASSWORD: $([[ -n $(atfile.util.get_envvar "${_envvar_prefix}_PASSWORD") ]] && echo "(Set)") 110 $(atfile.something_broke.print_envvar "USERNAME") 111 Paths
+19 -3
src/entry.sh
··· 13 14 ### Combination 15 16 _command="$1" 17 _command_args=("${@:2}") 18 _os="$(atfile.util.get_os)" ··· 24 _meta_repo="{:meta_repo:}" 25 _meta_year="{:meta_year:}" 26 _now="$(atfile.util.get_date)" 27 _version="{:version:}" 28 29 ## "Hello, world!" 30 31 atfile.say.debug "Reticulating splines..." 32 33 ## Paths 34 ··· 50 _path_envvar="$_path_home/config/settings" 51 ;; 52 "linux-termux") 53 - _path_blobs_tmp="/data/data/com.termux/files/tmp" 54 ;; 55 "macos") 56 _path_envvar="$_path_home/Library/Application Support" ··· 80 _os_supported=1 81 fi 82 83 ## Pipe detection 84 85 if [ -p /dev/stdin ] ||\ ··· 108 109 if [[ $_is_piped == 1 ]] ||\ 110 [[ "$1" == "install" ]]; then 111 if [[ "$1" == "install" ]]; then 112 atfile.install "$2" "$3" "$4" 113 install_exit="$?" ··· 116 install_exit="$?" 117 fi 118 119 atfile.util.print_seconds_since_start_debug 120 exit $install_exit 121 fi 122 ··· 291 previous_command="$_command" 292 293 case "$_command" in 294 "open"|"print"|"c") _command="cat" ;; 295 "rm") _command="delete" ;; 296 "download"|"f"|"d") _command="fetch" ;; ··· 299 "--help"|"-h") _command="help" ;; 300 "get"|"i") _command="info" ;; 301 "ls") _command="list" ;; 302 - "build") _command="release" ;; 303 "did") _command="resolve" ;; 304 "sb") _command="something-broke" ;; 305 "js") _command="stream" ;; 306 "ul"|"u") _command="upload" ;; 307 "ub") _command="upload-blob" ;; 308 "uc") _command="upload-crypt" ;; 309 - "--update"|"-U") _command="update" ;; 310 "get-url"|"b") _command="url" ;; 311 "--version"|"-V") _command="version" ;; 312 esac ··· 328 329 ## Invoke 330 331 if [[ $_is_sourced == 0 ]]; then 332 atfile.auth 333 atfile.invoke "$_command" "${_command_args[@]}" 334 fi 335 336 atfile.util.print_seconds_since_start_debug
··· 13 14 ### Combination 15 16 + _ci="$(atfile.util.get_ci)" 17 _command="$1" 18 _command_args=("${@:2}") 19 _os="$(atfile.util.get_os)" ··· 25 _meta_repo="{:meta_repo:}" 26 _meta_year="{:meta_year:}" 27 _now="$(atfile.util.get_date)" 28 + _path_hook_post_start="$(atfile.util.get_envvar "${_envvar_prefix}_PATH_HOOK_POST_START")" 29 + _path_hook_pre_exit="$(atfile.util.get_envvar "${_envvar_prefix}_PATH_HOOK_PRE_EXIT")" 30 + _path_hook_pre_start="$(atfile.util.get_envvar "${_envvar_prefix}_PATH_HOOK_PRE_START")" 31 _version="{:version:}" 32 33 ## "Hello, world!" 34 35 atfile.say.debug "Reticulating splines..." 36 + atfile.util.source_hook "$_path_hook_pre_start" 37 38 ## Paths 39 ··· 55 _path_envvar="$_path_home/config/settings" 56 ;; 57 "linux-termux") 58 + _path_blobs_tmp="$PREFIX/tmp" 59 ;; 60 "macos") 61 _path_envvar="$_path_home/Library/Application Support" ··· 85 _os_supported=1 86 fi 87 88 + ## CI detection 89 + 90 + [[ -n "$_ci" ]] && atfile.say.debug "Detected CI: $_ci" 91 + 92 ## Pipe detection 93 94 if [ -p /dev/stdin ] ||\ ··· 117 118 if [[ $_is_piped == 1 ]] ||\ 119 [[ "$1" == "install" ]]; then 120 + atfile.util.source_hook "$_path_hook_post_start" 121 + 122 if [[ "$1" == "install" ]]; then 123 atfile.install "$2" "$3" "$4" 124 install_exit="$?" ··· 127 install_exit="$?" 128 fi 129 130 + atfile.util.source_hook "$_path_hook_pre_exit" 131 atfile.util.print_seconds_since_start_debug 132 + 133 exit $install_exit 134 fi 135 ··· 304 previous_command="$_command" 305 306 case "$_command" in 307 + "release") _command="build" ;; 308 "open"|"print"|"c") _command="cat" ;; 309 "rm") _command="delete" ;; 310 "download"|"f"|"d") _command="fetch" ;; ··· 313 "--help"|"-h") _command="help" ;; 314 "get"|"i") _command="info" ;; 315 "ls") _command="list" ;; 316 "did") _command="resolve" ;; 317 "sb") _command="something-broke" ;; 318 "js") _command="stream" ;; 319 "ul"|"u") _command="upload" ;; 320 + "--update"|"-U") _command="update" ;; 321 "ub") _command="upload-blob" ;; 322 "uc") _command="upload-crypt" ;; 323 "get-url"|"b") _command="url" ;; 324 "--version"|"-V") _command="version" ;; 325 esac ··· 341 342 ## Invoke 343 344 + atfile.util.source_hook "$_path_hook_post_start" 345 + 346 if [[ $_is_sourced == 0 ]]; then 347 atfile.auth 348 atfile.invoke "$_command" "${_command_args[@]}" 349 fi 350 351 + atfile.util.source_hook "$_path_hook_pre_exit" 352 atfile.util.print_seconds_since_start_debug
+3 -1
src/shared/die.sh
··· 3 function atfile.die() { 4 message="$1" 5 6 if [[ $_output_json != 1 ]]; then 7 atfile.say.die "$message" 8 else 9 echo -e "{ \"error\": \"$1\" }" | jq 10 fi 11 12 [[ $_is_sourced == 0 ]] && exit 255 13 } 14 ··· 50 51 function atfile.die.unknown_command() { 52 command="$1" 53 - atfile.die "Unknown command '$1'" 54 }
··· 3 function atfile.die() { 4 message="$1" 5 6 + # shellcheck disable=SC2154 7 if [[ $_output_json != 1 ]]; then 8 atfile.say.die "$message" 9 else 10 echo -e "{ \"error\": \"$1\" }" | jq 11 fi 12 13 + # shellcheck disable=SC2154 14 [[ $_is_sourced == 0 ]] && exit 255 15 } 16 ··· 52 53 function atfile.die.unknown_command() { 54 command="$1" 55 + atfile.die "Unknown command '$command'" 56 }
+8 -7
src/shared/invoke.sh
··· 5 shift 6 args=("$@") 7 8 if [[ $_is_sourced == 0 ]] && [[ $ATFILE_DEVEL_NO_INVOKE != 1 ]]; then 9 atfile.say.debug "Invoking '$command'...\nโ†ณ Arguments: ${args[*]}" 10 ··· 25 atfile.bsky_profile "$_username" 26 else 27 atfile.bsky_profile "${args[0]}" 28 fi 29 ;; 30 "cat") ··· 128 "rm"|"delete"|"d") atfile.record "delete" "${args[1]}" ;; 129 *) atfile.die.unknown_command "$(echo "$command ${args[0]}" | xargs)" ;; 130 esac 131 - ;; 132 - "release") 133 - if [[ $ATFILE_DEVEL == 1 ]]; then 134 - atfile.release 135 - else 136 - atfile.die.unknown_command "$command" 137 - fi 138 ;; 139 "resolve") 140 atfile.resolve "${args[0]}"
··· 5 shift 6 args=("$@") 7 8 + # shellcheck disable=SC2154 9 if [[ $_is_sourced == 0 ]] && [[ $ATFILE_DEVEL_NO_INVOKE != 1 ]]; then 10 atfile.say.debug "Invoking '$command'...\nโ†ณ Arguments: ${args[*]}" 11 ··· 26 atfile.bsky_profile "$_username" 27 else 28 atfile.bsky_profile "${args[0]}" 29 + fi 30 + ;; 31 + "build") 32 + if [[ $ATFILE_DEVEL == 1 ]]; then 33 + atfile.build 34 + else 35 + atfile.die.unknown_command "$command" 36 fi 37 ;; 38 "cat") ··· 136 "rm"|"delete"|"d") atfile.record "delete" "${args[1]}" ;; 137 *) atfile.die.unknown_command "$(echo "$command ${args[0]}" | xargs)" ;; 138 esac 139 ;; 140 "resolve") 141 atfile.resolve "${args[0]}"
+11 -1
src/shared/say.sh
··· 10 11 prefix_length=0 12 13 # shellcheck disable=SC2154 14 if [[ $_os == "haiku" ]]; then 15 message="${message//โ†ณ/>}" ··· 42 fi 43 44 message="${message//\\n/\\n$(atfile.util.repeat_char " " "$prefix_length")}" 45 46 - echo -n -e "${prefix}${color_message}$message\033[0m${suffix}" 47 } 48 49 function atfile.say.debug() { ··· 52 53 [[ -z "$prefix" ]] && prefix="Debug" 54 55 if [[ $_debug == 1 ]]; then 56 atfile.say "$message" "$prefix" 35 >&2 57 fi
··· 10 11 prefix_length=0 12 13 + if [[ -n $_ci ]]; then 14 + unset color_prefix 15 + unset color_message 16 + unset color_prefix_message 17 + fi 18 + 19 # shellcheck disable=SC2154 20 if [[ $_os == "haiku" ]]; then 21 message="${message//โ†ณ/>}" ··· 48 fi 49 50 message="${message//\\n/\\n$(atfile.util.repeat_char " " "$prefix_length")}" 51 + message="${prefix}${color_message}$message\033[0m${suffix}" 52 + 53 + [[ -n "$_ci" ]] && message="${message//\\033[0m/}" 54 55 + echo -n -e "$message" 56 } 57 58 function atfile.say.debug() { ··· 61 62 [[ -z "$prefix" ]] && prefix="Debug" 63 64 + # shellcheck disable=SC2154 65 if [[ $_debug == 1 ]]; then 66 atfile.say "$message" "$prefix" 35 >&2 67 fi
+18
src/shared/util.sh
··· 199 echo "$cdn_uri" 200 } 201 202 # TODO: Support BusyBox's shit `date` command 203 # `date -u +"$format" -s "1996-08-11 01:23:34"` 204 function atfile.util.get_date() { ··· 1121 else 1122 echo "$error" 1123 exit 255 1124 fi 1125 } 1126
··· 199 echo "$cdn_uri" 200 } 201 202 + function atfile.util.get_ci() { 203 + [[ -d "/tangled/workspace" ]] && echo "tangled" 204 + } 205 + 206 # TODO: Support BusyBox's shit `date` command 207 # `date -u +"$format" -s "1996-08-11 01:23:34"` 208 function atfile.util.get_date() { ··· 1125 else 1126 echo "$error" 1127 exit 255 1128 + fi 1129 + } 1130 + 1131 + function atfile.util.source_hook() { 1132 + file="$1" 1133 + 1134 + if [[ -n "$file" ]]; then 1135 + atfile.say.debug "Sourcing: $file" 1136 + if [[ -f "$file" ]]; then 1137 + # shellcheck disable=SC1090 1138 + . "$file" 1139 + else 1140 + atfile.die "Unable to source '$file'" 1141 + fi 1142 fi 1143 } 1144