|
1 | | -# Boolean Flags in vite-plus |
| 1 | +# Boolean Flags in Vite Task |
2 | 2 |
|
3 | | -This document describes how boolean flags work in vite-plus commands. |
4 | | - |
5 | | -## Negation Pattern |
6 | | - |
7 | | -All boolean flags in vite-plus support a negation pattern using the `--no-` prefix. When a `--no-*` flag is used, it explicitly sets the corresponding boolean option to `false`. |
| 3 | +This document describes how boolean flags work in `vp` commands. |
8 | 4 |
|
9 | 5 | ## Available Boolean Flags |
10 | 6 |
|
11 | | -### Global Flags |
12 | | - |
13 | | -- `--debug` / `--no-debug` - Enable or disable cache debugging output |
14 | | - - Short form: `-d` (only for positive form) |
15 | | - |
16 | 7 | ### Run Command Flags |
17 | 8 |
|
18 | | -- `--recursive` / `--no-recursive` - Enable or disable recursive task execution across all packages |
19 | | - - Short form: `-r` (only for positive form) |
20 | | - |
21 | | -- `--parallel` / `--no-parallel` - Enable or disable parallel task execution |
22 | | - - Short form: `-p` (only for positive form) |
| 9 | +- `--recursive` / `-r` — Run task in all packages in the workspace |
| 10 | +- `--transitive` / `-t` — Run task in the current package and its transitive dependencies |
| 11 | +- `--workspace-root` / `-w` — Run task in the workspace root package |
| 12 | +- `--ignore-depends-on` — Skip explicit `dependsOn` dependencies |
| 13 | +- `--verbose` / `-v` — Show full detailed summary after execution |
| 14 | +- `--cache` / `--no-cache` — Force caching on or off for all tasks and scripts |
23 | 15 |
|
24 | | -- `--sequential` / `--no-sequential` - Enable or disable sequential task execution |
25 | | - - Short form: `-s` (only for positive form) |
| 16 | +### Negation Pattern |
26 | 17 |
|
27 | | -- `--topological` / `--no-topological` - Enable or disable topological ordering based on package dependencies |
28 | | - - Short form: `-t` (only for positive form) |
29 | | - |
30 | | -## Behavior |
31 | | - |
32 | | -### Conflicts |
33 | | - |
34 | | -The positive and negative forms of a flag are mutually exclusive. You cannot use both `--flag` and `--no-flag` in the same command: |
| 18 | +The `--cache` flag supports a `--no-cache` negation form. When `--no-cache` is used, caching is explicitly disabled for all tasks in that run: |
35 | 19 |
|
36 | 20 | ```bash |
37 | | -# This will result in an error |
38 | | -vp run --recursive --no-recursive build |
39 | | -``` |
| 21 | +# Force caching off |
| 22 | +vp run build --no-cache |
40 | 23 |
|
41 | | -### Precedence |
42 | | - |
43 | | -When only the negative form is used, it takes precedence and explicitly sets the value to `false`: |
44 | | - |
45 | | -```bash |
46 | | -# Explicitly disable topological ordering |
47 | | -vp run build -r --no-topological |
| 24 | +# Force caching on (even for scripts that default to uncached) |
| 25 | +vp run build --cache |
48 | 26 | ``` |
49 | 27 |
|
50 | | -### Default Values |
51 | | - |
52 | | -The negative flags are particularly useful for overriding default behaviors: |
53 | | - |
54 | | -- `--recursive` with `--no-topological`: By default, recursive runs enable topological ordering. Use `--no-topological` to disable it: |
55 | | - ```bash |
56 | | - # Recursive run WITHOUT topological ordering |
57 | | - vp run build -r --no-topological |
58 | | - ``` |
| 28 | +The positive and negative forms are mutually exclusive — you cannot use both `--cache` and `--no-cache` in the same command. |
59 | 29 |
|
60 | 30 | ## Examples |
61 | 31 |
|
62 | 32 | ```bash |
63 | | -# Run with debugging disabled (useful if debug is enabled by default in config) |
64 | | -vp --no-debug build |
| 33 | +# Recursive build (all packages in dependency order) |
| 34 | +vp run build -r |
| 35 | + |
| 36 | +# Current package + transitive dependencies |
| 37 | +vp run build -t |
65 | 38 |
|
66 | | -# Recursive build without topological ordering |
67 | | -vp run build --recursive --no-topological |
| 39 | +# Run in workspace root |
| 40 | +vp run build -w |
68 | 41 |
|
69 | | -# Explicitly disable parallel execution |
70 | | -vp run build --no-parallel |
| 42 | +# Skip explicit dependsOn edges |
| 43 | +vp run build --ignore-depends-on |
71 | 44 |
|
72 | | -# Run tests sequentially, not in parallel |
73 | | -vp run test --no-parallel |
| 45 | +# Verbose output |
| 46 | +vp run build -v |
| 47 | + |
| 48 | +# Force caching off for this run |
| 49 | +vp run build --no-cache |
74 | 50 | ``` |
75 | 51 |
|
76 | 52 | ## Implementation Details |
77 | 53 |
|
78 | | -The `--no-*` flags use clap's `conflicts_with` attribute to ensure they cannot be used together with their positive counterparts. When processing flags, vite-plus uses a `resolve_bool_flag` function that gives precedence to the negative form when present. |
79 | | - |
80 | | -This pattern provides a consistent and intuitive way to explicitly disable features that might be enabled by default or through configuration files. |
| 54 | +The flags use clap's argument parsing. The `--cache`/`--no-cache` pair uses clap's `conflicts_with` attribute to ensure they cannot be used together. |
0 commit comments