Skip to content
Open
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
14 changes: 12 additions & 2 deletions crates/vp_cli_help/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use std::{borrow::Cow, fmt::Write as _, io::Write as _};

use clap::{Arg, Command};
use console::style;
use console::StyledObject;
use terminal_size::{Width, terminal_size_of};

const HELP_RIGHT_MARGIN: usize = 4;
Expand Down Expand Up @@ -157,7 +157,17 @@ pub fn accent_command(command: &str) -> String {
}

pub fn should_style_help() -> bool {
console::colors_enabled()
if vp_shared::output::user_output_to_stderr() {
console::colors_enabled_stderr()
} else {
console::colors_enabled()
}
}

// Self-setup captures stdout for shell assignments and routes its diagnostics to stderr.
fn style<D>(value: D) -> StyledObject<D> {
let styled = console::style(value);
if vp_shared::output::user_output_to_stderr() { styled.for_stderr() } else { styled }
}

fn terminal_content_width() -> usize {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,18 @@ steps = [{ argv = ["node", "install.mjs", "interactive", "failure"], interaction
name = "installation_progress_non_tty"
vp = "global"
skip-platforms = ["windows"]
steps = [{ argv = ["node", "install.mjs"], tty = false }]
steps = [{ argv = ["node", "install.mjs"], tty = false, formatted-snapshot = true }]

[[case]]
name = "installation_progress_ci"
vp = "global"
skip-platforms = ["windows"]
steps = [{ argv = ["node", "install.mjs"], envs = [["CI", "1"]] }]
# The installer captures stdout while setup diagnostics retain the terminal on stderr.
steps = [{ argv = ["node", "install.mjs"], envs = [["CI", "1"]], formatted-snapshot = true }]

[[case]]
name = "installation_progress_no_color"
vp = "global"
skip-platforms = ["windows"]
env = { CI = "1", NO_COLOR = "1" }
steps = [{ argv = ["node", "install.mjs"], formatted-snapshot = true }]
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

```
Before installation: preserve this output.
info: installing vite-plus@<version>...
info: Preparing Node.js and pnpm...
info: Installing dependencies...
✓ Dependencies installed.
Setup:
\x1b[94;1minfo: installing vite-plus@<version>...
\x1b[94;1minfo: Preparing Node.js and pnpm...
\x1b[94;1minfo: Installing dependencies...
\x1b[32m\xe2\x9c\x93 Dependencies installed.
\x1b[94;1mSetup:
Preparing vite-plus environment.

Created Shims:
\x1b[94;1mCreated Shims:
<workspace>/home/fallback-bin/node
<workspace>/home/bin/npm
<workspace>/home/bin/npx
Expand All @@ -26,14 +26,14 @@ Created Shims:
<workspace>/home/bin/vpx
<workspace>/home/bin/vpr

Next Steps:
\x1b[94;1mNext Steps:
Activate Vite+ in this terminal:
. "<workspace>/home/env"
. \"<workspace>/home/env\"

Add the command to your .zshrc file to activate future Zsh terminals.

Restart an already-running IDE to load its environment. Run `vp env doctor` to verify.
✓ Vite+ setup complete.
Restart an already-running IDE to load its environment. Run `\x1b[94mvp env doctor` to verify.
\x1b[32m\xe2\x9c\x93 Vite+ setup complete.
Bootstrap stdout contains only shell assignments.
After installation.
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# installation_progress_no_color

## `node install.mjs`

```
Before installation: preserve this output.
info: installing vite-plus@<version>...
info: Preparing Node.js and pnpm...
info: Installing dependencies...
\xe2\x9c\x93 Dependencies installed.
Setup:
Preparing vite-plus environment.

Created Shims:
<workspace>/home/fallback-bin/node
<workspace>/home/bin/npm
<workspace>/home/bin/npx
<workspace>/home/bin/pnpm
<workspace>/home/bin/pnpx
<workspace>/home/bin/pn
<workspace>/home/bin/pnx
<workspace>/home/bin/yarn
<workspace>/home/bin/yarnpkg
<workspace>/home/bin/bun
<workspace>/home/bin/bunx
<workspace>/home/bin/vpx
<workspace>/home/bin/vpr

Next Steps:
Activate Vite+ in this terminal:
. \"<workspace>/home/env\"

Add the command to your .zshrc file to activate future Zsh terminals.

Restart an already-running IDE to load its environment. Run `vp env doctor` to verify.
\xe2\x9c\x93 Vite+ setup complete.
Bootstrap stdout contains only shell assignments.
After installation.
```
Loading