skillwatch 0.1.7 → 0.1.9
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 +21 -15
- package/dist/cli.js +1 -1
- package/package.json +1 -1
package/dist/checker.js
CHANGED
|
@@ -79,15 +79,13 @@ const fetchGitHubJson = async (url, token) => {
|
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
+
const fetchTreeForBranch = async (ownerRepo, branch, token) => await fetchGitHubJson(`https://api.github.com/repos/${ownerRepo}/git/trees/${branch}?recursive=1`, token);
|
|
82
83
|
const fetchRepoTree = async (ownerRepo, token) => {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const uniqueBranches = [...new Set(branches)];
|
|
89
|
-
for (const branch of uniqueBranches) {
|
|
90
|
-
const treeData = await fetchGitHubJson(`https://api.github.com/repos/${ownerRepo}/git/trees/${branch}?recursive=1`, token);
|
|
84
|
+
const mainTree = await fetchTreeForBranch(ownerRepo, "main", token);
|
|
85
|
+
if (mainTree) return mainTree;
|
|
86
|
+
const fallbacks = [(await fetchGitHubJson(`https://api.github.com/repos/${ownerRepo}`, token))?.default_branch, "master"].filter((b) => typeof b === "string" && b !== "main");
|
|
87
|
+
for (const branch of fallbacks) {
|
|
88
|
+
const treeData = await fetchTreeForBranch(ownerRepo, branch, token);
|
|
91
89
|
if (treeData) return treeData;
|
|
92
90
|
}
|
|
93
91
|
return null;
|
|
@@ -149,17 +147,25 @@ const findUpdates = async () => {
|
|
|
149
147
|
const token = getGitHubToken();
|
|
150
148
|
const updates = [];
|
|
151
149
|
const errors = [];
|
|
152
|
-
const
|
|
150
|
+
const repoIds = [...new Set(trackedSkills.map((s) => s.repoId))];
|
|
151
|
+
const treeEntries = await Promise.all(repoIds.map(async (repoId) => {
|
|
152
|
+
return [repoId, await fetchRepoTree(repoId, token)];
|
|
153
|
+
}));
|
|
154
|
+
const treeCache = new Map(treeEntries);
|
|
153
155
|
for (const tracked of trackedSkills) {
|
|
154
|
-
|
|
155
|
-
if (treeData
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
const treeData = treeCache.get(tracked.repoId) ?? null;
|
|
157
|
+
if (!treeData) {
|
|
158
|
+
errors.push({
|
|
159
|
+
reason: "Could not fetch repo tree",
|
|
160
|
+
repoId: tracked.repoId,
|
|
161
|
+
skillName: tracked.skillName
|
|
162
|
+
});
|
|
163
|
+
continue;
|
|
158
164
|
}
|
|
159
|
-
const remoteHash =
|
|
165
|
+
const remoteHash = findFolderHashInTree(treeData, tracked.skillPath);
|
|
160
166
|
if (!remoteHash) {
|
|
161
167
|
errors.push({
|
|
162
|
-
reason: "
|
|
168
|
+
reason: "Skill folder not found in repo tree",
|
|
163
169
|
repoId: tracked.repoId,
|
|
164
170
|
skillName: tracked.skillName
|
|
165
171
|
});
|
package/dist/cli.js
CHANGED
|
@@ -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.9";
|
|
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");
|