@grampro/kit 2.7.1 → 2.7.2
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/.gbs/skills/gbs-components/SKILL.md +4 -2
- package/.gbs/skills/gbs-components/references/install.md +28 -2
- package/CHANGELOG.md +63 -0
- package/README.md +2 -1
- package/index.cjs +148 -21
- package/package.json +1 -1
- package/source/components/accordion/passport.json +1 -1
- package/source/components/alert/passport.json +1 -1
- package/source/components/avatar/passport.json +1 -1
- package/source/components/badge/passport.json +1 -1
- package/source/components/breadcrumb/passport.json +1 -1
- package/source/components/button/passport.json +1 -1
- package/source/components/card/passport.json +1 -1
- package/source/components/checkbox/passport.json +1 -1
- package/source/components/combobox/passport.json +1 -1
- package/source/components/data-grid/passport.json +1 -1
- package/source/components/date-picker/passport.json +1 -1
- package/source/components/dialog/passport.json +1 -1
- package/source/components/file-uploader/passport.json +1 -1
- package/source/components/input/passport.json +1 -1
- package/source/components/menu/passport.json +1 -1
- package/source/components/modal/passport.json +1 -1
- package/source/components/number-input/passport.json +1 -1
- package/source/components/popover/passport.json +1 -1
- package/source/components/progress/passport.json +1 -1
- package/source/components/radio-group/passport.json +1 -1
- package/source/components/skeleton/passport.json +1 -1
- package/source/components/spinner/passport.json +1 -1
- package/source/components/switch/passport.json +1 -1
- package/source/components/tabs/passport.json +1 -1
- package/source/components/textarea/passport.json +1 -1
- package/source/components/toaster/passport.json +1 -1
- package/source/components/tooltip/passport.json +1 -1
- package/tools/doctor/baseline.cjs +227 -0
- package/tools/doctor/contract.cjs +252 -0
- package/tools/doctor/format.cjs +160 -0
- package/tools/doctor/index.cjs +246 -0
- package/tools/doctor/usage.cjs +95 -0
- package/tools/jsx-tags.cjs +120 -0
- package/tools/mcp/server.cjs +47 -40
- package/tools/passport/extract.cjs +47 -20
- package/tools/passport/hash.cjs +39 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The content hash a passport records as `source.sourceHash`.
|
|
3
|
+
*
|
|
4
|
+
* Kept on its own, with no TypeScript and no extractor behind it, because two
|
|
5
|
+
* very different callers need the identical function: the passport generator,
|
|
6
|
+
* which writes the hash, and the installer, which has to recompute it inside a
|
|
7
|
+
* user's project to tell an untouched component from an edited one. If those
|
|
8
|
+
* two ever disagreed by a byte, every installed component would read as
|
|
9
|
+
* edited, and `add` would refuse to update any of them.
|
|
10
|
+
*
|
|
11
|
+
* Entries are hashed by label, not by where the file sits on disk. The
|
|
12
|
+
* generator labels a file by its path inside this repository
|
|
13
|
+
* (`source/components/button/react/Button.tsx`); the installer reads the same
|
|
14
|
+
* file from `component-lib/button/react/Button.tsx` and labels it the same
|
|
15
|
+
* way. Sorting by that label — rather than by absolute path, as this used to —
|
|
16
|
+
* also makes the order independent of whether the OS separator is `/` or `\`.
|
|
17
|
+
*/
|
|
18
|
+
const fs = require("fs");
|
|
19
|
+
const crypto = require("crypto");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {{ label: string, file: string }[]} entries
|
|
23
|
+
* @returns {string} "sha256:<hex>"
|
|
24
|
+
*/
|
|
25
|
+
function hashEntries(entries) {
|
|
26
|
+
const h = crypto.createHash("sha256");
|
|
27
|
+
const sorted = [...entries].sort((a, b) => (a.label < b.label ? -1 : a.label > b.label ? 1 : 0));
|
|
28
|
+
for (const { label, file } of sorted) {
|
|
29
|
+
h.update(label);
|
|
30
|
+
h.update("\0");
|
|
31
|
+
// Line endings normalised: the same file is CRLF on a Windows checkout
|
|
32
|
+
// and LF on CI, and a content hash must not depend on how it was checked out.
|
|
33
|
+
h.update(fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n"));
|
|
34
|
+
h.update("\0");
|
|
35
|
+
}
|
|
36
|
+
return `sha256:${h.digest("hex")}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = { hashEntries };
|