···102102103103Various environment variables can be exported to control various aspects of the development version. These are as follows:
104104105105+* `ATFILE_DEVEL_DIST_USERNAME` <em><string></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
106106+* `ATFILE_DEVEL_DIST_PASSWORD` <em><string></em><br />_(Todo)_
105107* `ATFILE_DEVEL_ENABLE_PIPING` <em><int> (default: `0`)</em><br />Allow piping (useful to test installation) _(e.g. `cat ./atfile.sh | bash`)_
106108* `ATFILE_DEVEL_ENABLE_PUBLISH` <em><int> (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:
107107- * `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
109109+ * `ATFILE_DEVEL_DIST_USERNAME` must be set
108110 * `ATFILE_DEVEL_DIST_PASSWORD` must be set
109111 * No tests should return an **Error** (**Warning** is acceptable)
110112 * Git commit must be <a href="https://git-scm.com/docs/git-tag">tagged</a>
···119121120122### Meta
121123122122-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:
124124+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:
123125124126* `author` <em><string></em><br />Copyright author
125127* `did` <em><did></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**)
···162162 Disable periodic update checking when command finishes
163163 ${_envvar_prefix}_DISABLE_UPDATE_COMMAND <boolยน> (default: $_disable_update_command_default)
164164 Disable \`update\` command\n
165165- ${_envvar_prefix}_DEBUG <boolยน> (default: 0)
165165+ ${_envvar_prefix}_DEBUGยณ <boolยน> (default: 0)
166166 Print debug outputs
167167 โ ๏ธ When output is JSON (${_envvar_prefix}_OUTPUT_JSON=1), sets to 0\n
168168 ยน A bool in Bash is 1 (true) or 0 (false)
169169- ยฒ These servers are ran by @$handle. You can trust us!"
169169+ ยฒ These servers are ran by @$handle. You can trust us!
170170+ ยณ Cannot be set by config file"
170171171172 usage_paths="Paths
172173 $_path_envvar
+10-2
src/commands/install.sh
···2525 fi
26262727 case $_os in
2828+ "linux-termux")
2929+ # NOTE: The correct path of '$PREFIX/local/bin' would be more correct,
3030+ # however, '$PREFIX/local' doesn't exist by default on Termux (and thus,
3131+ # not in $PATH), so we'll install it in '$PREFIX/bin' instead
3232+ install_dir="$PREFIX/bin"
3333+ ;;
2834 "haiku")
2935 install_dir="/boot/system/non-packaged/bin"
3036 ;;
···3945 esac
40464147 if [[ $# -gt 0 ]]; then
4242- atfile.say.debug "Overriden variables\nโณ Path: $override_path\nโณ Version: $override_version\nโณ DID: $override_did"
4848+ atfile.say.debug "Overridden variables\nโณ Path: $override_path\nโณ Version: $override_version\nโณ DID: $override_did"
4349 fi
44504551 atfile.say.debug "Setting up..."
46524753 [[ -n "$override_path" ]] && install_dir="$override_path"
5454+ mkdir -p "$install_dir"
4855 mkdir -p "$conf_dir"
4956 # shellcheck disable=SC2154
5057 touch "$conf_dir/$_file_envvar"
···9410195102 atfile.say.debug "Found latest version\nโณ Version: $found_version ($parsed_found_version)\nโณ Source: $source_did\nโณ Blob: $found_version_blob"
961039797- atfile.say.debug "Download '$blob_url'..."
104104+ atfile.say.debug "Downloading...\nโณ Source: $blob_url\nโณ Dest.: ${install_dir}/$install_file"
9810599106 curl -s -o "${install_dir}/$install_file" "$blob_url"
107107+ # shellcheck disable=SC2181
100108 [[ $? != 0 ]] && atfile.die "Unable to download"
101109102110 atfile.say.debug "Installing...\nโณ OS: $_os\nโณ Install: $install_dir/$install_file\nโณ Config: $conf_dir/$_file_envvar"
+2
src/commands/record.sh
···4848 at_collection="$(atfile.util.parse_at_uri "$at_uri" "collection")"
4949 at_rkey="$(atfile.util.parse_at_uri "$at_uri" "rkey")"
50505151+ atfile.say.debug "Resolved AT URI\nโณ Actor: $at_actor\nโณ Collection: $at_collection\nโณ RKey: $at_rkey"
5252+5153 case "$sub_command" in
5254 "create")
5355 if [[ -z "$at_rkey" ]]; then
-186
src/commands/release.sh
···11-#!/usr/bin/env bash
22-# atfile-devel=ignore-build
33-44-function atfile.release() {
55- # shellcheck disable=SC2154
66- [[ $_os != "linux" ]] && atfile.die "Only available on Linux (GNU)\nโณ Detected OS: $_os"
77-88- function atfile.release.get_devel_value() {
99- local file="$1"
1010- local value="$2"
1111- local found_line
1212-1313- found_line="$(grep '^# atfile-devel=' "$file" | head -n1)"
1414- if [[ -n "$found_line" ]]; then
1515- local devel_values="${found_line#*=}"
1616- IFS=',' read -ra arr <<< "$devel_values"
1717- for v in "${arr[@]}"; do
1818- if [[ "$v" == "$value" ]]; then
1919- echo 1
2020- fi
2121- done
2222- fi
2323- }
2424-2525- function atfile.release.replace_template_var() {
2626- string="$1"
2727- key="$2"
2828- value="$3"
2929-3030- sed -s "s|{:$key:}|$value|g" <<< "$string"
3131- }
3232-3333- atfile.util.check_prog "git"
3434- atfile.util.check_prog "md5sum"
3535- atfile.util.check_prog "shellcheck"
3636-3737- id="$(atfile.util.get_random 13)"
3838- commit_author="$(git config user.name) <$(git config user.email)>"
3939- commit_hash="$(git rev-parse HEAD)"
4040- commit_date="$(git show --no-patch --format=%ci "$commit_hash")"
4141- # shellcheck disable=SC2154
4242- dist_file="$(echo "$_prog" | cut -d "." -f 1)-${_version}.sh"
4343- # shellcheck disable=SC2154
4444- dist_dir="$_prog_dir/bin"
4545- dist_path="$dist_dir/$dist_file"
4646- dist_path_relative="$(realpath --relative-to="$(pwd)" "$dist_path")"
4747- parsed_version="$(atfile.util.parse_version "$_version")"
4848- version_record_id="atfile-$parsed_version"
4949-5050- test_error_count=0
5151- test_info_count=0
5252- test_style_count=0
5353- test_warning_count=0
5454- test_ignore_count=0
5555-5656- atfile.say "โ๏ธ Building..."
5757-5858- echo "โณ Creating '$dist_file'..."
5959- mkdir -p "$dist_dir"
6060- echo "#!/usr/bin/env bash" > "$dist_path"
6161-6262- echo "โณ Generating header..."
6363- echo -e "\n# ATFile <${ATFILE_FORCE_META_REPO}>
6464-# ---
6565-# Version: $_version
6666-# Commit: $commit_hash
6767-# Author: $commit_author
6868-# Build: $id ($(hostname):$(atfile.util.get_os))
6969-# ---
7070-# Psst! You can \`source atfile\` in your own Bash scripts!
7171-" >> "$dist_path"
7272-7373- for s in "${ATFILE_DEVEL_INCLUDES[@]}"
7474- do
7575- if [[ -f "$s" ]]; then
7676- if [[ $(atfile.release.get_devel_value "$s" "ignore-build" == 1 ) ]]; then
7777- echo "โณ Ignoring: $s"
7878- else
7979- echo "โณ Compiling: $s"
8080-8181- while IFS="" read -r line
8282- do
8383- include_line=1
8484-8585- if [[ $line == "#"* ]] ||\
8686- [[ $line == *" #"* ]] ||\
8787- [[ $line == " " ]] ||\
8888- [[ $line == "" ]]; then
8989- include_line=0
9090- fi
9191-9292- if [[ $line == *"# shellcheck disable"* ]]; then
9393- if [[ $line == *"=SC2154"* ]]; then
9494- include_line=0
9595- else
9696- include_line=1
9797- (( test_ignore_count++ ))
9898- fi
9999- fi
100100-101101- if [[ $include_line == 1 ]]; then
102102- if [[ $line == *"{:"* && $line == *":}"* ]]; then
103103- # NOTE: Not using atfile.util.get_envvar() here, as confusion can arise from config file
104104- line="$(atfile.release.replace_template_var "$line" "meta_author" "$ATFILE_FORCE_META_AUTHOR")"
105105- line="$(atfile.release.replace_template_var "$line" "meta_did" "$ATFILE_FORCE_META_DID")"
106106- line="$(atfile.release.replace_template_var "$line" "meta_repo" "$ATFILE_FORCE_META_REPO")"
107107- line="$(atfile.release.replace_template_var "$line" "meta_year" "$ATFILE_FORCE_META_YEAR")"
108108- line="$(atfile.release.replace_template_var "$line" "version" "$ATFILE_FORCE_VERSION")"
109109- fi
110110-111111- echo "$line" >> "$dist_path"
112112- fi
113113- done < "$s"
114114- fi
115115- fi
116116- done
117117-118118- echo -e "\n# \"Four million lines of BASIC\"\n# - Kif Kroker (3003)" >> "$dist_path"
119119-120120- checksum="$(atfile.util.get_md5 "$dist_path" | cut -d "|" -f 1)"
121121-122122- echo "๐งช Testing..."
123123- shellcheck_output="$(shellcheck --format=json "$dist_path" 2>&1)"
124124-125125- while read -r item; do
126126- code="$(echo "$item" | jq -r '.code')"
127127- col="$(echo "$item" | jq -r '.column')"
128128- line="$(echo "$item" | jq -r '.line')"
129129- level="$(echo "$item" | jq -r '.level')"
130130- message="$(echo "$item" | jq -r '.message')"
131131-132132- case "$level" in
133133- "error") level="๐ Error"; (( test_error_count++ )) ;;
134134- "info") level="โน๏ธ Info"; (( test_info_count++ )) ;;
135135- "style") level="๐จ Style"; (( test_style_count++ )) ;;
136136- "warning") level="โ ๏ธ Warning"; (( test_warning_count++ )) ;;
137137- esac
138138-139139- echo "โณ $level ($line:$col): [SC$code] $message"
140140- done <<< "$(echo "$shellcheck_output" | jq -c '.[]')"
141141-142142- test_total_count=$(( test_error_count + test_info_count + test_style_count + test_warning_count ))
143143-144144- echo -e "---\nโ Built: $_version
145145-โณ Path: ./$dist_path_relative
146146- โณ Check: $checksum
147147- โณ Size: $(atfile.util.get_file_size_pretty "$(stat -c %s "$dist_path")")
148148- โณ Lines: $(atfile.util.fmt_int "$(wc -l < "$dist_path")")
149149-โณ Issues: $(atfile.util.fmt_int "$test_total_count")
150150- โณ Error: $(atfile.util.fmt_int "$test_error_count")
151151- โณ Warning: $(atfile.util.fmt_int "$test_warning_count")
152152- โณ Info: $(atfile.util.fmt_int "$test_info_count")
153153- โณ Style: $(atfile.util.fmt_int "$test_style_count")
154154- โณ Ignored: $(atfile.util.fmt_int "$test_ignore_count")
155155-โณ ID: $id"
156156-157157- chmod +x "$dist_path"
158158-159159- # shellcheck disable=SC2154
160160- if [[ $_devel_enable_publish == 1 ]]; then
161161- if [[ $test_error_count -gt 0 ]]; then
162162- atfile.die "Unable to publish ($test_error_count errors detected)"
163163- fi
164164-165165- atfile.say "---\nโจ Updating..."
166166- atfile.auth "$_devel_dist_username" "$_devel_dist_password"
167167- [[ $_version == *"+"* ]] && atfile.die "Cannot publish a Git version ($_version)"
168168-169169- atfile.say "โณ Uploading '$dist_path'..."
170170- atfile.invoke.upload "$dist_path" "" "$version_record_id"
171171- # shellcheck disable=SC2181
172172- [[ $? != 0 ]] && atfile.die "Unable to upload '$dist_path'"
173173-174174- latest_release_record="{
175175- \"version\": \"$_version\",
176176- \"releasedAt\": \"$(atfile.util.get_date "$commit_date")\",
177177- \"commit\": \"$commit_hash\",
178178- \"id\": \"$id\",
179179- \"checksum\": \"$checksum\"
180180-}"
181181-182182- atfile.say "โณ Bumping current version..."
183183- # shellcheck disable=SC2154
184184- atfile.invoke.manage_record put "at://$_devel_dist_username/self.atfile.latest/self" "$latest_release_record" &> /dev/null
185185- fi
186186-}