diff --git a/migrations/user/1781158082.sh b/migrations/user/1781158082.sh new file mode 100644 index 00000000..47fc2017 --- /dev/null +++ b/migrations/user/1781158082.sh @@ -0,0 +1,17 @@ +echo "Relink Neovim theme to Omarchy current state" + +theme_link="$HOME/.config/nvim/lua/plugins/theme.lua" +legacy_absolute_target="$HOME/.config/omarchy/current/theme/neovim.lua" +legacy_relative_target="../../../omarchy/current/theme/neovim.lua" +legacy_home_target="~/.config/omarchy/current/theme/neovim.lua" +current_relative_target="../../../../.local/state/omarchy/current/theme/neovim.lua" + +[[ -L $theme_link ]] || exit 0 + +target=$(readlink "$theme_link") || exit 0 + +case "$target" in + "$legacy_absolute_target"|"$legacy_relative_target"|"$legacy_home_target") + ln -sfn "$current_relative_target" "$theme_link" + ;; +esac diff --git a/test/cli b/test/cli index b9268d80..73c67be0 100755 --- a/test/cli +++ b/test/cli @@ -378,21 +378,51 @@ MIGRATION_TMPDIR=$(mktemp -d) mkdir -p \ "$MIGRATION_TMPDIR/.config/omarchy/current/theme" \ "$MIGRATION_TMPDIR/.config/alacritty" \ + "$MIGRATION_TMPDIR/.config/hypr" \ "$MIGRATION_TMPDIR/.config/hyprland-preview-share-picker" \ "$MIGRATION_TMPDIR/.config/btop/themes" printf 'tokyo-night\n' >"$MIGRATION_TMPDIR/.config/omarchy/current/theme.name" printf 'x\n' >"$MIGRATION_TMPDIR/.config/omarchy/current/theme/colors.toml" printf 'general.import = [ "~/.config/omarchy/current/theme/alacritty.toml" ]\n' >"$MIGRATION_TMPDIR/.config/alacritty/alacritty.toml" printf 'stylesheets: ["../omarchy/current/theme/hyprland-preview-share-picker.css"]\n' >"$MIGRATION_TMPDIR/.config/hyprland-preview-share-picker/config.yaml" +cat >"$MIGRATION_TMPDIR/.config/hypr/hyprland.lua" <<'LUA' +package.path = os.getenv("HOME") + .. "/.config/?.lua;" + .. (os.getenv("OMARCHY_PATH") or "/usr/share/omarchy") + .. "/?.lua;" + .. package.path +LUA ln -s "$MIGRATION_TMPDIR/.config/omarchy/current/theme/btop.theme" "$MIGRATION_TMPDIR/.config/btop/themes/current.theme" HOME="$MIGRATION_TMPDIR" bash -euo pipefail "$ROOT/migrations/user/1781043107.sh" >/dev/null [[ -f $MIGRATION_TMPDIR/.local/state/omarchy/current/theme.name ]] || fail "current theme migration moves theme name" [[ ! -e $MIGRATION_TMPDIR/.config/omarchy/current ]] || fail "current theme migration removes legacy config state" grep -Fq '~/.local/state/omarchy/current/theme/alacritty.toml' "$MIGRATION_TMPDIR/.config/alacritty/alacritty.toml" || fail "current theme migration updates alacritty import" grep -Fq '../../.local/state/omarchy/current/theme/hyprland-preview-share-picker.css' "$MIGRATION_TMPDIR/.config/hyprland-preview-share-picker/config.yaml" || fail "current theme migration updates relative stylesheet" +grep -Fq '/.local/state/?.lua;' "$MIGRATION_TMPDIR/.config/hypr/hyprland.lua" || fail "current theme migration keeps Hyprland theme modules discoverable" [[ $(readlink "$MIGRATION_TMPDIR/.config/btop/themes/current.theme") == "$MIGRATION_TMPDIR/.local/state/omarchy/current/theme/btop.theme" ]] || fail "current theme migration updates btop symlink" pass "current theme migration moves state and rewrites shipped references" +NVIM_MIGRATION_TMPDIR=$(mktemp -d) +nvim_theme_link="$NVIM_MIGRATION_TMPDIR/.config/nvim/lua/plugins/theme.lua" +nvim_expected_target="../../../../.local/state/omarchy/current/theme/neovim.lua" +nvim_expected_resolved_target="$NVIM_MIGRATION_TMPDIR/.local/state/omarchy/current/theme/neovim.lua" +mkdir -p \ + "$(dirname "$nvim_theme_link")" \ + "$NVIM_MIGRATION_TMPDIR/.config/omarchy/current/theme" \ + "$NVIM_MIGRATION_TMPDIR/.local/state/omarchy/current/theme" +touch "$NVIM_MIGRATION_TMPDIR/.local/state/omarchy/current/theme/neovim.lua" +for nvim_legacy_target in \ + "../../../omarchy/current/theme/neovim.lua" \ + "$NVIM_MIGRATION_TMPDIR/.config/omarchy/current/theme/neovim.lua"; do + ln -sfn "$nvim_legacy_target" "$nvim_theme_link" + HOME="$NVIM_MIGRATION_TMPDIR" bash -euo pipefail "$ROOT/migrations/user/1781158082.sh" >/dev/null + nvim_actual_target=$(readlink "$nvim_theme_link") + nvim_resolved_target=$(readlink -f "$nvim_theme_link") + [[ $nvim_actual_target == $nvim_expected_target ]] || fail "nvim theme migration updates theme symlink" + [[ $nvim_resolved_target == $nvim_expected_resolved_target ]] || fail "nvim theme migration points to current theme" +done +pass "nvim theme migration relinks current theme" + cp "$NEXT_THEME/colors.toml" "$CURRENT_THEME/colors.toml" cp "$NEXT_THEME/vscode-theme.json" "$CURRENT_THEME/vscode-theme.json"