diff --git a/ci/ci b/ci/ci new file mode 100755 index 0000000..4b2f049 Binary files /dev/null and b/ci/ci differ diff --git a/post.go b/post.go index 64afc5d..045fc2d 100644 --- a/post.go +++ b/post.go @@ -245,8 +245,13 @@ func ensureNodeLTS() { } fmt.Println("[NVM] Enabling corepack and installing latest pnpm ...") - if !runShell(`bash -c 'source ~/.nvm/nvm.sh && corepack enable && corepack prepare pnpm@latest --activate && pnpm config set global-bin-dir "$HOME/.local/share/pnpm/bin"'`, CmdOpts{}).OK() { + if !runShell(`bash -c 'source ~/.nvm/nvm.sh && corepack enable && corepack prepare pnpm@latest --activate'`, CmdOpts{}).OK() { errLog("Failed to enable corepack and prepare pnpm") + return + } + fmt.Println("[pnpm] Running pnpm setup to configure PATH ...") + if !runShell(`bash -c 'source ~/.nvm/nvm.sh && pnpm setup'`, CmdOpts{}).OK() { + errLog("pnpm setup failed") } } @@ -489,16 +494,12 @@ func installPlaywright() { } ensureNodeLTS() fmt.Println(" Installing playwright via pnpm ...") - if !runShell(`bash -c "source ~/.nvm/nvm.sh && pnpm add -g playwright"`, CmdOpts{}).OK() { + if !runShell(`bash -c "source ~/.nvm/nvm.sh && source ~/.bashrc 2>/dev/null; pnpm add -g playwright"`, CmdOpts{}).OK() { errLog("playwright installation failed") return } - pnpmBin := filepath.Join(home, ".local/share/pnpm/bin") - if !strings.Contains(os.Getenv("PATH"), pnpmBin) { - appendProfileLine("pnpm", `export PATH="$HOME/.local/share/pnpm/bin:$PATH"`) - } fmt.Println(" Installing Playwright browsers with dependencies ...") - if !runShell(fmt.Sprintf(`bash -c "source ~/.nvm/nvm.sh && PATH=%s:$PATH pnpx playwright install --with-deps"`, pnpmBin), CmdOpts{}).OK() { + if !runShell(`bash -c "source ~/.nvm/nvm.sh && source ~/.bashrc 2>/dev/null; pnpx playwright install --with-deps"`, CmdOpts{}).OK() { errLog("playwright browser installation failed") } } diff --git a/post_test.go b/post_test.go index f02edc7..a9b6258 100644 --- a/post_test.go +++ b/post_test.go @@ -350,14 +350,21 @@ func TestEnsurePythonAndNode(t *testing.T) { } ensureNodeLTS() hasInstall := false + hasPnpmSetup := false for _, cmd := range runShellCmds { if strings.Contains(cmd, "nvm install --lts") { hasInstall = true } + if strings.Contains(cmd, "pnpm setup") { + hasPnpmSetup = true + } } if !hasInstall { t.Errorf("expected nvm install --lts, got: %v", runShellCmds) } + if !hasPnpmSetup { + t.Errorf("expected pnpm setup, got: %v", runShellCmds) + } } func TestInstallPipEdgeCases(t *testing.T) {