Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
"terminal.integrated.cursorBlinking": true,
"telemetry.editStats.enabled": false,
"bashIde.explainshellEndpoint": "http://127.0.0.1:5000",
"bashIde.shfmt.simplifyCode": true,
"bashIde.includeAllWorkspaceSymbols": true,
"shellcheck.useWorkspaceRootAsCwd": true,
"shellcheck.disableVersionCheck": true,
"shellcheck.enableQuickFix": false
}
}
Expand Down
44 changes: 44 additions & 0 deletions .devcontainer/scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
BASHRC="$HOME/.bashrc"
ALIASES="$HOME/.bash_aliases"
INPUTRC="$HOME/.inputrc"
HELIX_CONFIG="$HOME/.config/helix/config.toml"

log "Creating $ALIASES file..."
cat <<'EOF' >"$ALIASES"
Expand Down Expand Up @@ -149,3 +150,46 @@ source <(fzf --bash)
FZF_COMPLETION_AUTO_COMMON_PREFIX=true
FZF_COMPLETION_AUTO_COMMON_PREFIX_PART=true
EOF

log "Creating helix config..."
mkdir -p "$(dirname "$HELIX_CONFIG")"
cat <<'EOF' >"$HELIX_CONFIG"
theme = "catppuccin-mocha"

[editor]
editor-config = true
line-number = "absolute"
mouse = true
shell = ["bash", "-c"]
auto-completion = true
auto-format = true
preview-completion-insert = true
completion-replace = false
true-color = true
text-width = 120
default-line-ending = "lf"
insert-final-newline = true
indent-heuristic = "hybrid"
undercurl = true
trim-final-newlines = false
clipboard-provider = "wayland"
auto-pairs = true
popup-border = "menu"
rulers = [80,120]
trim-trailing-whitespace = true
path-completion = true
end-of-line-diagnostics = "hint"

[editor.inline-diagnostics]
cursor-line = "warning"

[editor.indent-guides]
render = true
character = "⸽" # Some characters that work well: "▏", "┆", "┊", "⸽", "╎"
skip-levels = 1

[editor.cursor-shape]
insert = "bar"
normal = "block"
select = "underline"
EOF
3 changes: 1 addition & 2 deletions .devcontainer/scripts/update-content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ set -euo pipefail
SCRIPTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=.devcontainer/scripts/utils.sh
source "${SCRIPTS_DIR}/utils.sh"
# shellcheck source=.devcontainer/scripts/config.sh
source "${SCRIPTS_DIR}/config.sh"

log "This script is run after on-create.sh"

Expand All @@ -32,6 +30,7 @@ download_and_install_deb "bat" "0.25.0" "https://github.com/sharkdp/bat/releases
download_and_install_deb "delta" "0.18.2" "https://github.com/dandavison/delta/releases/download/0.18.2/git-delta_0.18.2_amd64.deb"
download_and_install_deb "helix" "25.7.1-1" "https://github.com/helix-editor/helix/releases/download/25.07.1/helix_25.7.1-1_amd64.deb"

ensure_apt_packages "lynx"
ensure_apt_packages "ruby" "ruby-dev" "build-essential" "rpm"
ensure_gem_installed "fpm"

Expand Down
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Default code owner for the repository
* @mihailfox
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
SHELL := /usr/bin/env bash

SHELLCHECK_FILES := src/helix-url-handler.sh $(wildcard src/lib/*.sh) scripts/release/build-artifacts.sh scripts/release/prepare-matrix.sh
SHELLCHECK_FILES := src/helix-url-handler.sh $(wildcard src/lib/*.sh) scripts/release/common.sh scripts/release/build-artifacts.sh scripts/release/prepare-matrix.sh
DIST_FORMATS := tgz deb rpm

.PHONY: check lint test devcontainer dist $(addprefix dist-,$(DIST_FORMATS))
.PHONY: check lint test devcontainer dist FORCE

check: lint test

Expand All @@ -23,10 +23,12 @@ define REQUIRE_VERSION
fi
endef

dist:
dist: FORCE
$(REQUIRE_VERSION)
@scripts/release/build-artifacts.sh "$(VERSION)" all

dist-%:
dist-%: FORCE
$(REQUIRE_VERSION)
@scripts/release/build-artifacts.sh "$(VERSION)" "$*"

FORCE:
100 changes: 97 additions & 3 deletions code-dev-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,95 @@ if ! command -v code >/dev/null 2>&1; then
exit 1
fi

detect_terminal_command() {
local candidates=()
if [[ -n "${TERMINAL:-}" ]]; then
candidates+=("$TERMINAL")
fi
candidates+=(
"x-terminal-emulator"
"sensible-terminal"
"kitty"
"alacritty"
"wezterm"
"gnome-terminal"
"konsole"
"xfce4-terminal"
"tilix"
"mate-terminal"
"terminator"
"lxterminal"
"xterm"
"urxvt"
"foot"
"footclient"
)

for term in "${candidates[@]}"; do
if command -v "$term" >/dev/null 2>&1; then
echo "$term"
return 0
fi
done

return 1
}

launch_in_terminal() {
local terminal="$1"
shift
local command=("$@")

local cmd_string=""
printf -v cmd_string '%q ' "${command[@]}"
cmd_string="${cmd_string% }"

case "$(basename "$terminal")" in
kitty)
"$terminal" --detach -- bash -lc "$cmd_string"
;;
wezterm)
"$terminal" start -- bash -lc "$cmd_string"
;;
alacritty)
"$terminal" -e bash -lc "$cmd_string"
;;
gnome-terminal|gnome-terminal-*)
"$terminal" -- bash -lc "$cmd_string"
;;
konsole)
"$terminal" --noclose -e bash -lc "$cmd_string"
;;
xfce4-terminal)
"$terminal" --hold -e bash -lc "$cmd_string"
;;
mate-terminal)
"$terminal" -- bash -lc "$cmd_string"
;;
tilix)
"$terminal" -e bash -lc "$cmd_string"
;;
sensible-terminal)
"$terminal" -x bash -lc "$cmd_string"
;;
terminator)
"$terminal" -x bash -lc "$cmd_string"
;;
foot|footclient)
"$terminal" -e bash -lc "$cmd_string"
;;
*)
"$terminal" -e bash -lc "$cmd_string"
;;
esac
}

dir="$(pwd)"
hex="$(printf '%s' "$dir" | od -A n -t x1 | tr -d ' \t\n')"
base="$(basename "$dir")"

if ! code --folder-uri="vscode-remote://dev-container%2B${hex}/workspaces/${base}"; then
echo "VSCode and/or devcontainer failed to init!"
echo "[ ERROR ] VSCode and/or devcontainer failed to init!"
exit 1
fi

Expand All @@ -25,9 +108,20 @@ sleep $wait_time
dev_container_id="$(docker ps --format="{{.ID}}\t{{.Image}}" | grep "$base" | awk '{ print $1 }')"

if [[ -z $dev_container_id ]]; then
echo "The $dev_container_id was not found!"
echo "[ ERROR ] The dev container id was not found!"
exit 2
fi

echo "Attaching shell to devcontainer..."
docker exec -it --user node "$dev_container_id" bash
docker_command=(docker exec -it --user node -w "/workspaces/$base" "$dev_container_id" bash)

if terminal_cmd="$(detect_terminal_command)"; then
echo "Launching shell via ${terminal_cmd}..."
if ! launch_in_terminal "$terminal_cmd" "${docker_command[@]}"; then
echo "[ WARN ] Failed to launch ${terminal_cmd}; using current shell instead."
"${docker_command[@]}"
fi
else
echo "[ INFO ] No terminal launcher detected; using current shell."
"${docker_command[@]}"
fi
27 changes: 21 additions & 6 deletions scripts/release/build-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

set -euo pipefail

: "${LOG_LEVEL:=error}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/release/common.sh
source "${SCRIPT_DIR}/common.sh"
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
VERSION_RAW="${1:-}"

Expand Down Expand Up @@ -50,7 +54,7 @@ else
fi
;;
*)
echo "Unknown format: $1" >&2
err "Unknown format: $1"
usage
;;
esac
Expand All @@ -59,10 +63,12 @@ else
fi

if [[ ${#FORMATS[@]} -eq 0 ]]; then
echo "No package formats selected." >&2
err "No package formats selected."
exit 1
fi

log "Preparing ${PKG_NAME} ${VERSION} for formats: ${FORMATS[*]}"

need_tgz=false
need_package_stage=false
for format in "${FORMATS[@]}"; do
Expand All @@ -73,10 +79,11 @@ for format in "${FORMATS[@]}"; do
done

if [[ "$need_package_stage" == true ]] && ! command -v fpm >/dev/null 2>&1; then
echo "fpm is required to build deb or rpm packages." >&2
err "fpm is required to build deb or rpm packages."
exit 1
fi

log "Resetting dist directory at ${DIST_DIR}"
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"

Expand All @@ -89,6 +96,7 @@ copy_payload() {

if [[ "$need_package_stage" == true ]]; then
mkdir -p "$APP_ROOT" "$BIN_ROOT"
log "Staging package payload under ${APP_ROOT}"
copy_payload "$APP_ROOT"
cat > "${BIN_ROOT}/${PKG_NAME}" <<'SCRIPT'
#!/usr/bin/env bash
Expand All @@ -98,11 +106,13 @@ SCRIPT
fi

if [[ "$need_tgz" == true ]]; then
log "Preparing portable archive directory ${PORTABLE_DIR}"
copy_payload "$PORTABLE_DIR"
fi

declare -a ARTIFACTS=()
readonly -a COMMON_FPM_ARGS=(
--log "$LOG_LEVEL"
-s dir
-C "$STAGE_DIR"
-n "$PKG_NAME"
Expand All @@ -119,29 +129,31 @@ build_tgz() {
local archive="${DIST_DIR}/${PORTABLE_BASENAME}.tar.gz"
tar -C "${DIST_DIR}" -czf "$archive" "${PORTABLE_BASENAME}"
ARTIFACTS+=("$archive")
echo "Created ${archive}"
log "Created ${archive}"
}

build_deb() {
local package="${DIST_DIR}/${PKG_NAME}_${VERSION}_all.deb"
fpm "${COMMON_FPM_ARGS[@]}" \
-t deb \
--architecture all \
--package "$package" \
usr/lib/${PKG_NAME} \
usr/bin/${PKG_NAME}
ARTIFACTS+=("$package")
echo "Created ${package}"
log "Created ${package}"
}

build_rpm() {
local package="${DIST_DIR}/${PKG_NAME}-${VERSION}-1.noarch.rpm"
fpm "${COMMON_FPM_ARGS[@]}" \
-t rpm \
--architecture noarch \
--package "$package" \
usr/lib/${PKG_NAME} \
usr/bin/${PKG_NAME}
ARTIFACTS+=("$package")
echo "Created ${package}"
log "Created ${package}"
}

for format in "${FORMATS[@]}"; do
Expand All @@ -154,16 +166,19 @@ done

pushd "$DIST_DIR" >/dev/null
: > SHASUMS256.txt
log "Calculating SHA256 checksums in ${DIST_DIR}/SHASUMS256.txt"
for artifact in "${ARTIFACTS[@]}"; do
file="$(basename "$artifact")"
sha256sum "$file" >> SHASUMS256.txt
done
popd >/dev/null

if [[ "$need_tgz" == true ]]; then
log "Removing portable staging directory ${PORTABLE_DIR}"
rm -rf "$PORTABLE_DIR"
fi

if [[ "$need_package_stage" == true ]]; then
log "Cleaning staging directory ${STAGE_DIR}"
rm -rf "$STAGE_DIR"
fi
Loading