@preapexis/pi-kit 1.0.10 → 1.0.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/extensions/update.ts +13 -14
- package/package.json +1 -1
package/extensions/update.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// cSpell:words
|
|
1
|
+
// cSpell:words preapexis npm PowerShell
|
|
2
2
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
|
|
4
4
|
type EventContext = Parameters<Parameters<ExtensionAPI["on"]>[1]>[1];
|
|
@@ -31,11 +31,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
31
31
|
label: "Update installed Pi packages/extensions",
|
|
32
32
|
shell: "pi update --extensions"
|
|
33
33
|
},
|
|
34
|
-
{
|
|
35
|
-
id: "kit-local",
|
|
36
|
-
label: "Re-link this local PreApeXis kit",
|
|
37
|
-
shell: "pi install -l ."
|
|
38
|
-
},
|
|
39
34
|
{
|
|
40
35
|
id: "kit-npm",
|
|
41
36
|
label: "Update PreApeXis Pi Kit from npm",
|
|
@@ -63,18 +58,19 @@ export default function (pi: ExtensionAPI): void {
|
|
|
63
58
|
}
|
|
64
59
|
|
|
65
60
|
function startUpdateStatus(ctx: EventContext, label: string): () => void {
|
|
61
|
+
const frames = ["◐", "◓", "◑", "◒"];
|
|
66
62
|
let seconds = 0;
|
|
67
|
-
let
|
|
63
|
+
let frame = 0;
|
|
68
64
|
|
|
69
|
-
ctx.ui.setStatus(UPDATE_STATUS_KEY, `
|
|
65
|
+
ctx.ui.setStatus(UPDATE_STATUS_KEY, `updating: ${label} ${frames[0]} 0s`);
|
|
70
66
|
|
|
71
67
|
const timer = setInterval(() => {
|
|
72
68
|
seconds += 1;
|
|
73
|
-
|
|
69
|
+
frame = (frame + 1) % frames.length;
|
|
74
70
|
|
|
75
71
|
ctx.ui.setStatus(
|
|
76
72
|
UPDATE_STATUS_KEY,
|
|
77
|
-
`
|
|
73
|
+
`updating: ${label} ${frames[frame]} ${seconds}s`
|
|
78
74
|
);
|
|
79
75
|
}, 1000);
|
|
80
76
|
|
|
@@ -176,15 +172,13 @@ export default function (pi: ExtensionAPI): void {
|
|
|
176
172
|
const shell = shellCommand(option.shell);
|
|
177
173
|
const stopStatus = startUpdateStatus(ctx, option.label);
|
|
178
174
|
|
|
179
|
-
let result: Awaited<ReturnType<typeof pi.exec
|
|
175
|
+
let result: Awaited<ReturnType<typeof pi.exec>> | undefined;
|
|
180
176
|
|
|
181
177
|
try {
|
|
182
178
|
result = await pi.exec(shell.command, shell.args, {
|
|
183
179
|
cwd: ctx.cwd
|
|
184
180
|
});
|
|
185
181
|
} catch (error) {
|
|
186
|
-
stopStatus();
|
|
187
|
-
|
|
188
182
|
ctx.ui.notify(
|
|
189
183
|
[
|
|
190
184
|
`Update failed: ${option.label}`,
|
|
@@ -197,9 +191,14 @@ export default function (pi: ExtensionAPI): void {
|
|
|
197
191
|
);
|
|
198
192
|
|
|
199
193
|
return false;
|
|
194
|
+
} finally {
|
|
195
|
+
stopStatus();
|
|
200
196
|
}
|
|
201
197
|
|
|
202
|
-
|
|
198
|
+
if (!result) {
|
|
199
|
+
ctx.ui.notify(`Update failed: ${option.label}`, "error");
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
203
202
|
|
|
204
203
|
const stdout = result.stdout?.trim() ?? "";
|
|
205
204
|
const stderr = result.stderr?.trim() ?? "";
|