skillwatch 0.1.6 → 0.1.7
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/dist/checker.js +17 -9
- package/dist/cli.js +3 -5
- package/package.json +1 -1
package/dist/checker.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as R, c as Wt, d as __toESM, i as Nt, l as be, n as Gt, o as Rt, r as Me, t as require_picocolors, u as Ct } from "./picocolors-hRUfkPbe.js";
|
|
3
|
-
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { dirname, join, resolve } from "node:path";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { promisify } from "node:util";
|
|
10
11
|
//#region src/checker.ts
|
|
11
12
|
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
12
13
|
const log = (message) => {
|
|
@@ -114,7 +115,7 @@ const buildNotificationBody = (grouped) => {
|
|
|
114
115
|
if (grouped.length > 3) preview.push(`+${grouped.length - 3} more`);
|
|
115
116
|
return preview.join(", ");
|
|
116
117
|
};
|
|
117
|
-
const buildSignature = (
|
|
118
|
+
const buildSignature = (updates) => createHash("sha256").update(JSON.stringify(updates)).digest("hex");
|
|
118
119
|
const escapeAppleScript = (value) => value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
|
|
119
120
|
const sendNotification = (title, body) => {
|
|
120
121
|
execFileSync("/usr/bin/osascript", ["-e", `display notification "${escapeAppleScript(body)}" with title "${escapeAppleScript(title)}"`], { stdio: "ignore" });
|
|
@@ -189,7 +190,7 @@ const promptAndUpdate = async (signature, grouped) => {
|
|
|
189
190
|
const updateSpinner = be();
|
|
190
191
|
updateSpinner.start("Updating skills...");
|
|
191
192
|
try {
|
|
192
|
-
|
|
193
|
+
await promisify(execFile)("npx", ["skills", "update"]);
|
|
193
194
|
updateSpinner.stop("Skills updated successfully");
|
|
194
195
|
} catch {
|
|
195
196
|
updateSpinner.stop("Update failed");
|
|
@@ -232,22 +233,29 @@ const main = async () => {
|
|
|
232
233
|
return;
|
|
233
234
|
}
|
|
234
235
|
for (const repo of grouped) info(`Update available: ${import_picocolors.default.bold(repo.repoId)} ${import_picocolors.default.dim("->")} ${repo.skillNames.join(", ")}`);
|
|
235
|
-
const signature = buildSignature(
|
|
236
|
+
const signature = buildSignature(updates);
|
|
236
237
|
if (tty) {
|
|
237
238
|
await promptAndUpdate(signature, grouped);
|
|
238
239
|
return;
|
|
239
240
|
}
|
|
240
241
|
if ((await readJson(STATE_PATH, {})).lastNotifiedSignature === signature) {
|
|
241
|
-
log("
|
|
242
|
+
log("Already handled. Skipping.");
|
|
242
243
|
await writeState(signature, grouped);
|
|
243
244
|
process.exitCode = 0;
|
|
244
245
|
return;
|
|
245
246
|
}
|
|
246
247
|
const body = buildNotificationBody(grouped);
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
try {
|
|
249
|
+
await promisify(execFile)("npx", ["skills", "update"]);
|
|
250
|
+
sendNotification("Skills updated", body);
|
|
251
|
+
log(`Updated: ${body}`);
|
|
252
|
+
await writeState(null);
|
|
253
|
+
} catch {
|
|
254
|
+
sendNotification("Skill update failed", body);
|
|
255
|
+
log(`Update failed: ${body}`);
|
|
256
|
+
log("To update manually, run: npx skills update");
|
|
257
|
+
await writeState(null, grouped);
|
|
258
|
+
}
|
|
251
259
|
};
|
|
252
260
|
const isExecutedDirectly = () => {
|
|
253
261
|
const [, entryArg] = process.argv;
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { c as Wt, d as __toESM, i as Nt, n as Gt, s as Vt, t as require_picocolors } from "./picocolors-hRUfkPbe.js";
|
|
3
3
|
import { execFileSync } from "node:child_process";
|
|
4
|
-
import {
|
|
4
|
+
import { realpathSync } from "node:fs";
|
|
5
5
|
import { copyFile, mkdir, readdir, rm, writeFile } from "node:fs/promises";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -9,7 +9,7 @@ import { fileURLToPath } from "node:url";
|
|
|
9
9
|
//#region src/cli.ts
|
|
10
10
|
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
11
11
|
const PACKAGE_NAME = "skillwatch";
|
|
12
|
-
const PACKAGE_VERSION = "0.1.
|
|
12
|
+
const PACKAGE_VERSION = "0.1.7";
|
|
13
13
|
const ENTRYPOINT_PATH = fileURLToPath(import.meta.url);
|
|
14
14
|
const PACKAGE_DIR = dirname(ENTRYPOINT_PATH);
|
|
15
15
|
const CHECKER_SOURCE_PATH = join(PACKAGE_DIR, "checker.js");
|
|
@@ -199,9 +199,7 @@ const uninstallCommand = async () => {
|
|
|
199
199
|
};
|
|
200
200
|
const checkNowCommand = () => {
|
|
201
201
|
assertMacOS();
|
|
202
|
-
|
|
203
|
-
const checkerPath = existsSync(installedChecker) ? installedChecker : CHECKER_SOURCE_PATH;
|
|
204
|
-
execFileSync(process.execPath, [checkerPath], {
|
|
202
|
+
execFileSync(process.execPath, [CHECKER_SOURCE_PATH], {
|
|
205
203
|
env: process.env,
|
|
206
204
|
stdio: "inherit"
|
|
207
205
|
});
|