@simon_he/pi 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -4
- package/dist/index.cjs +899 -149
- package/dist/index.mjs +901 -152
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
- [Language Settings](#-language)
|
|
19
19
|
- [Installation](#-installation)
|
|
20
20
|
- [Usage](#-usage)
|
|
21
|
+
- [Workspace Tool Selection](#-workspace-tool-selection)
|
|
21
22
|
- [Supported Features](#-features)
|
|
22
23
|
- [Special Features](#-feature)
|
|
23
24
|
- [Custom Configuration](#-custom-configuration)
|
|
@@ -96,6 +97,20 @@ export PI_Lang=en
|
|
|
96
97
|
# According to the environment of the current directory to analyze which package manager to use,go、rust、pnpm、yarn、npm
|
|
97
98
|
# Install dependencies
|
|
98
99
|
pi xxx
|
|
100
|
+
# Re-pick the package manager used by the current workspace
|
|
101
|
+
pi --choose-tool
|
|
102
|
+
# Pick the tool directly without opening the selector
|
|
103
|
+
pi --choose-tool bun
|
|
104
|
+
# Clear the saved package manager choice for the current workspace
|
|
105
|
+
pi --forget-tool
|
|
106
|
+
# Show which package manager the current workspace will use
|
|
107
|
+
pi --show-tool
|
|
108
|
+
# Show the current workspace tool as JSON
|
|
109
|
+
pi --show-tool --json
|
|
110
|
+
# List all detected package-manager candidates
|
|
111
|
+
pi --list-tools
|
|
112
|
+
# List candidates as JSON
|
|
113
|
+
pi --list-tools --json
|
|
99
114
|
# Uninstall dependencies
|
|
100
115
|
pui xxx
|
|
101
116
|
# Execute command
|
|
@@ -114,6 +129,45 @@ export PI_Lang=en
|
|
|
114
129
|
|
|
115
130
|
```
|
|
116
131
|
|
|
132
|
+
## :triangular_ruler: Workspace Tool Selection
|
|
133
|
+
|
|
134
|
+
When a workspace contains multiple package-manager indicators, for example `bun.lock` and `pnpm-lock.yaml`, `pi`, `pil`, and `pci` will ask once which tool to use and remember that choice for the current workspace.
|
|
135
|
+
|
|
136
|
+
- The saved choice is stored locally in your config directory, for example `~/.config/pi/workspace-tools.json`.
|
|
137
|
+
- The record is local to your machine and should not be committed into the repository.
|
|
138
|
+
- If the remembered tool no longer exists in that workspace, PI ignores the old value and removes the stale record automatically.
|
|
139
|
+
- Use `pi --choose-tool` or `pil --choose-tool` to switch the remembered tool.
|
|
140
|
+
- You can also choose directly with `pi --choose-tool bun` or `pil --choose-tool pnpm`.
|
|
141
|
+
- Use `pi --forget-tool` or `pil --forget-tool` to clear the remembered tool.
|
|
142
|
+
- Use `pi --show-tool` or `pil --show-tool` to inspect the current tool and where that decision came from.
|
|
143
|
+
- Add `--json` to `--show-tool` when you want script-friendly output.
|
|
144
|
+
- Use `pi --list-tools` or `pil --list-tools` to inspect all detected candidates, roots, and lockfile indicators.
|
|
145
|
+
- `pci --choose-tool` and `pci --forget-tool` follow the same behavior.
|
|
146
|
+
- `pci --show-tool` follows the same behavior too.
|
|
147
|
+
- `pci --list-tools` follows the same behavior too.
|
|
148
|
+
- `pui` and `pio` will also reuse the same remembered tool when they resolve the package manager.
|
|
149
|
+
|
|
150
|
+
Examples:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
pi react --choose-tool
|
|
154
|
+
pi --choose-tool bun
|
|
155
|
+
pil --choose-tool
|
|
156
|
+
pil --choose-tool pnpm
|
|
157
|
+
pi --forget-tool
|
|
158
|
+
pil --forget-tool
|
|
159
|
+
pi --show-tool
|
|
160
|
+
pil --show-tool
|
|
161
|
+
pi --show-tool --json
|
|
162
|
+
pi --list-tools
|
|
163
|
+
pi --list-tools --json
|
|
164
|
+
pci --choose-tool
|
|
165
|
+
pci --forget-tool
|
|
166
|
+
pci --show-tool
|
|
167
|
+
pci --show-tool --json
|
|
168
|
+
pci --list-tools
|
|
169
|
+
```
|
|
170
|
+
|
|
117
171
|
## Shell Integration (prun)
|
|
118
172
|
|
|
119
173
|
```
|
|
@@ -125,15 +179,21 @@ eval "$(prun --init bash)"
|
|
|
125
179
|
|
|
126
180
|
# fish
|
|
127
181
|
eval (prun --init fish)
|
|
182
|
+
|
|
183
|
+
# Windows PowerShell
|
|
184
|
+
prun --init powershell | Out-String | Invoke-Expression
|
|
185
|
+
|
|
186
|
+
# PowerShell 7+
|
|
187
|
+
prun --init pwsh | Out-String | Invoke-Expression
|
|
128
188
|
```
|
|
129
189
|
|
|
130
|
-
> Note: This lets the command selected by prun be available immediately in your shell history (press ↑ to recall).
|
|
190
|
+
> Note: This lets the command selected by `prun` or `pfind` be available immediately in your shell history (press ↑ to recall).
|
|
131
191
|
|
|
132
192
|
Auto integration (built-in):
|
|
133
193
|
|
|
134
|
-
- In interactive shells, the first `prun` run will append the right line to your shell rc (zsh: `~/.zshrc`, bash: `~/.bashrc`, fish: `~/.config/fish/config.fish`).
|
|
194
|
+
- In interactive shells, the first `prun` run will append the right line to your shell rc/profile (zsh: `~/.zshrc`, bash: `~/.bashrc`, fish: `~/.config/fish/config.fish`, PowerShell: `$PROFILE`).
|
|
135
195
|
- Disable with `PI_NO_AUTO_INIT=1` (or set `PI_AUTO_INIT=0`).
|
|
136
|
-
- Open a new terminal (or source the rc
|
|
196
|
+
- Open a new terminal (or source the rc/profile) after the first run.
|
|
137
197
|
|
|
138
198
|
Make it persistent:
|
|
139
199
|
|
|
@@ -146,6 +206,12 @@ echo 'eval "$(prun --init bash)"' >> ~/.bashrc
|
|
|
146
206
|
|
|
147
207
|
# fish
|
|
148
208
|
echo 'prun --init fish | source' >> ~/.config/fish/config.fish
|
|
209
|
+
|
|
210
|
+
# Windows PowerShell
|
|
211
|
+
Add-Content -Path $PROFILE -Value 'prun --init powershell | Out-String | Invoke-Expression'
|
|
212
|
+
|
|
213
|
+
# PowerShell 7+
|
|
214
|
+
Add-Content -Path $PROFILE -Value 'prun --init pwsh | Out-String | Invoke-Expression'
|
|
149
215
|
```
|
|
150
216
|
|
|
151
217
|
Reload your shell config (or open a new terminal) after adding the line.
|
|
@@ -187,7 +253,7 @@ You can configure the loading style in .zshrc, as follows:
|
|
|
187
253
|
```
|
|
188
254
|
export PI_COLOR=red # loadingstyle color
|
|
189
255
|
export PI_SPINNER=star # loadingstyle
|
|
190
|
-
export PI_DEFAULT=pnpm #
|
|
256
|
+
export PI_DEFAULT=pnpm # Used as the fallback tool when PI cannot infer a better choice for the current workspace
|
|
191
257
|
```
|
|
192
258
|
|
|
193
259
|
- 70+ types of styles, from [cli-spinners](https://jsfiddle.net/sindresorhus/2eLtsbey/embedded/result/),You can choose to fill in the name in PI_SPINNER.
|