@henryqw/pi-deps 0.3.1 → 0.3.3
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 +5 -0
- package/extensions/deps.ts +4 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Prepare locked Node and uv dependencies whenever Git creates a new worktree for an opted-in repository.
|
|
4
4
|
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
- **Created for**: Installing locked dependencies whenever Git creates a new worktree in an opted-in repository.
|
|
8
|
+
- **Advantage**: Prepares each checkout regardless of which tool created it, without paying install cost at every Pi startup.
|
|
9
|
+
|
|
5
10
|
## Install
|
|
6
11
|
|
|
7
12
|
```bash
|
package/extensions/deps.ts
CHANGED
|
@@ -71,8 +71,8 @@ const waitTimeoutMs = 10 * 60_000;
|
|
|
71
71
|
const spinnerIntervalMs = 100;
|
|
72
72
|
const spinnerFrames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
73
73
|
|
|
74
|
-
function formatElapsed(startedAt: number
|
|
75
|
-
const seconds = Math.max(0, Math.floor((now - startedAt) / 1_000));
|
|
74
|
+
function formatElapsed(startedAt: number): string {
|
|
75
|
+
const seconds = Math.max(0, Math.floor((Date.now() - startedAt) / 1_000));
|
|
76
76
|
const minutes = Math.floor(seconds / 60);
|
|
77
77
|
return minutes ? `${minutes}m ${seconds % 60}s` : `${seconds}s`;
|
|
78
78
|
}
|
|
@@ -93,7 +93,6 @@ export interface InstallWatchContext {
|
|
|
93
93
|
export async function watchDependencyInstallation(
|
|
94
94
|
exec: ExtensionAPI["exec"],
|
|
95
95
|
ctx: InstallWatchContext,
|
|
96
|
-
timing: { pollMs?: number; successTtlMs?: number } = {},
|
|
97
96
|
): Promise<void> {
|
|
98
97
|
if (ctx.mode && ctx.mode !== "tui") return;
|
|
99
98
|
const git = await exec("git", ["rev-parse", "--path-format=absolute", "--git-dir"], { cwd: ctx.cwd });
|
|
@@ -137,7 +136,7 @@ export async function watchDependencyInstallation(
|
|
|
137
136
|
}
|
|
138
137
|
const deadline = Date.now() + waitTimeoutMs;
|
|
139
138
|
while (status.state === "running" && Date.now() < deadline) {
|
|
140
|
-
await new Promise((resolveSleep) => setTimeout(resolveSleep,
|
|
139
|
+
await new Promise((resolveSleep) => setTimeout(resolveSleep, pollMs));
|
|
141
140
|
status = await readStatus();
|
|
142
141
|
if (!status) {
|
|
143
142
|
ctx.ui.setWidget(widgetKey, undefined);
|
|
@@ -147,7 +146,7 @@ export async function watchDependencyInstallation(
|
|
|
147
146
|
await rm(statusPath, { force: true }); // consume so later sessions do not replay a stale outcome
|
|
148
147
|
if (status.state === "ok") {
|
|
149
148
|
ctx.ui.setWidget(widgetKey, ["pi-deps: dependencies installed"]);
|
|
150
|
-
setTimeout(() => ctx.ui.setWidget(widgetKey, undefined),
|
|
149
|
+
setTimeout(() => ctx.ui.setWidget(widgetKey, undefined), successTtlMs);
|
|
151
150
|
} else if (status.state === "error") {
|
|
152
151
|
ctx.ui.setWidget(widgetKey, [
|
|
153
152
|
`pi-deps: install failed: ${status.message ?? "unknown error"}`,
|