@henryqw/pi-deps 0.3.2 → 0.3.4
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/extensions/deps.ts +5 -5
- package/package.json +1 -1
package/extensions/deps.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
1
2
|
import { randomUUID } from "node:crypto";
|
|
2
3
|
import { link, mkdir, readFile, rename, rm, writeFile, chmod } from "node:fs/promises";
|
|
3
4
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -71,8 +72,8 @@ const waitTimeoutMs = 10 * 60_000;
|
|
|
71
72
|
const spinnerIntervalMs = 100;
|
|
72
73
|
const spinnerFrames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
73
74
|
|
|
74
|
-
function formatElapsed(startedAt: number
|
|
75
|
-
const seconds = Math.max(0, Math.floor((now - startedAt) / 1_000));
|
|
75
|
+
function formatElapsed(startedAt: number): string {
|
|
76
|
+
const seconds = Math.max(0, Math.floor((Date.now() - startedAt) / 1_000));
|
|
76
77
|
const minutes = Math.floor(seconds / 60);
|
|
77
78
|
return minutes ? `${minutes}m ${seconds % 60}s` : `${seconds}s`;
|
|
78
79
|
}
|
|
@@ -93,7 +94,6 @@ export interface InstallWatchContext {
|
|
|
93
94
|
export async function watchDependencyInstallation(
|
|
94
95
|
exec: ExtensionAPI["exec"],
|
|
95
96
|
ctx: InstallWatchContext,
|
|
96
|
-
timing: { pollMs?: number; successTtlMs?: number } = {},
|
|
97
97
|
): Promise<void> {
|
|
98
98
|
if (ctx.mode && ctx.mode !== "tui") return;
|
|
99
99
|
const git = await exec("git", ["rev-parse", "--path-format=absolute", "--git-dir"], { cwd: ctx.cwd });
|
|
@@ -137,7 +137,7 @@ export async function watchDependencyInstallation(
|
|
|
137
137
|
}
|
|
138
138
|
const deadline = Date.now() + waitTimeoutMs;
|
|
139
139
|
while (status.state === "running" && Date.now() < deadline) {
|
|
140
|
-
await
|
|
140
|
+
await delay(pollMs);
|
|
141
141
|
status = await readStatus();
|
|
142
142
|
if (!status) {
|
|
143
143
|
ctx.ui.setWidget(widgetKey, undefined);
|
|
@@ -147,7 +147,7 @@ export async function watchDependencyInstallation(
|
|
|
147
147
|
await rm(statusPath, { force: true }); // consume so later sessions do not replay a stale outcome
|
|
148
148
|
if (status.state === "ok") {
|
|
149
149
|
ctx.ui.setWidget(widgetKey, ["pi-deps: dependencies installed"]);
|
|
150
|
-
setTimeout(() => ctx.ui.setWidget(widgetKey, undefined),
|
|
150
|
+
setTimeout(() => ctx.ui.setWidget(widgetKey, undefined), successTtlMs);
|
|
151
151
|
} else if (status.state === "error") {
|
|
152
152
|
ctx.ui.setWidget(widgetKey, [
|
|
153
153
|
`pi-deps: install failed: ${status.message ?? "unknown error"}`,
|