Skip to content

Commit 349a72b

Browse files
authored
fix(cli): support GitLab setup-vp legacy layout (#2520)
Older GitLab setup-vp templates add `~/.vite-plus/bin` to PATH after the installer exits. The installer now selects the legacy layout for these templates. A template can set `VP_VPDIRS_AWARE=1` to select the new layout. The standalone installer workflow now tests the GitHub and GitLab compatibility paths.
1 parent 044ac4c commit 349a72b

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

.github/workflows/test-standalone-install.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ jobs:
233233
cat "$OUTPUT"
234234
grep -F "Set VP_BIN_DIR, VP_DATA_DIR, and VP_CACHE_DIR together" "$OUTPUT"
235235
236-
- name: Existing setup-vp uses legacy layout
236+
- name: Existing GitHub setup-vp uses legacy layout
237237
run: |
238238
set -euo pipefail
239239
LEGACY=$(mktemp -d)
@@ -252,6 +252,27 @@ jobs:
252252
test "$(readlink "$LEGACY/.vite-plus/bin/vp")" = "$LEGACY/.vite-plus/current/bin/vp"
253253
"$LEGACY/.vite-plus/bin/vp" --version
254254
255+
- name: Existing GitLab setup-vp uses legacy layout
256+
run: |
257+
set -euo pipefail
258+
LEGACY=$(mktemp -d)
259+
FAKE_TGZ=$(mktemp)
260+
export HOME="$LEGACY"
261+
export USERPROFILE="$LEGACY"
262+
unset GITHUB_ACTION_REPOSITORY
263+
export GITLAB_CI=true
264+
export SETUP_VP_SETUP_REF=v1.15.0
265+
unset VP_VPDIRS_AWARE
266+
unset VP_HOME VP_BIN_DIR VP_DATA_DIR VP_CACHE_DIR
267+
unset XDG_DATA_HOME XDG_CACHE_HOME XDG_CONFIG_HOME XDG_STATE_HOME
268+
VP_LOCAL_TGZ="$FAKE_TGZ" VP_VERSION=local-setup-vp-gitlab-legacy bash packages/cli/install.sh
269+
270+
test -e "$LEGACY/.vite-plus/current"
271+
test -e "$LEGACY/.vite-plus/bin/vp"
272+
test ! -d "$LEGACY/.local/share/vite-plus"
273+
test "$(readlink "$LEGACY/.vite-plus/bin/vp")" = "$LEGACY/.vite-plus/current/bin/vp"
274+
"$LEGACY/.vite-plus/bin/vp" --version
275+
255276
- name: Fresh home uses split layout
256277
run: |
257278
set -euo pipefail

packages/cli/install.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,14 @@ resolution_home_dir() {
176176
fi
177177
}
178178

179-
# Released setup-vp versions add ~/.vite-plus/bin to the GitHub Actions PATH.
180-
# They do this after the installer exits. Use the monolithic layout until
181-
# setup-vp declares support for VP_DUMP_DIRS.
179+
# Released setup-vp versions add ~/.vite-plus/bin to the GitHub Actions or
180+
# GitLab CI/CD PATH. They do this after the installer exits. Use the monolithic
181+
# layout until setup-vp declares support for VP_DUMP_DIRS.
182182
enable_setup_vp_legacy_compatibility() {
183-
[ "${GITHUB_ACTION_REPOSITORY:-}" = "voidzero-dev/setup-vp" ] || return 0
183+
if [ "${GITHUB_ACTION_REPOSITORY:-}" != "voidzero-dev/setup-vp" ]; then
184+
[ "${GITLAB_CI:-}" = "true" ] || return 0
185+
[ -n "${SETUP_VP_SETUP_REF:-}" ] || return 0
186+
fi
184187
[ "${VP_VPDIRS_AWARE:-}" != "1" ] || return 0
185188
[ -z "${VP_HOME:-}" ] || return 0
186189
[ -z "${VP_BIN_DIR:-}" ] || return 0

0 commit comments

Comments
 (0)